package com.zcxk.charge.web.service;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zcxk.charge.core.dao.DeviceSetupRecordMapper;
import com.zcxk.charge.core.entity.DeviceSetupRecordEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * 参数设置指令记录Service接口
 *
 * @author: WYY
 * @date 2021-05-10 14:39
 */
@Service
public class DeviceSetupRecordService extends ServiceImpl<DeviceSetupRecordMapper, DeviceSetupRecordEntity> {

    @Resource
    private DeviceSetupRecordMapper deviceSetupRecordMapper;
    /**
     * 查列表
     */
    public List<DeviceSetupRecordEntity> findList(DeviceSetupRecordEntity deviceSetupRecordEntity) {
        return deviceSetupRecordMapper.findList(deviceSetupRecordEntity);
    }

    /**
     * 批量删除
     */
    @Transactional(rollbackFor = Exception.class)
    public boolean delDeviceSetupRecordByIds(Long[] ids) {

        return this.removeByIds(Arrays.asList(ids));

    }

    /**
     * 单个删除
     */
    public boolean delDeviceSetupRecordById(Long id) {


        return this.removeById(id);

    }

    /**
     * 保存
     */
    public boolean addDeviceSetupRecord(DeviceSetupRecordEntity deviceSetupRecord) {

        if (this.save(deviceSetupRecord)) {
            return true;
        }
        return false;
    }

    /**
     * 修改根居ID
     */
    public boolean updateDeviceSetupRecordById(DeviceSetupRecordEntity deviceSetupRecord) {

        if (this.updateById(deviceSetupRecord)) {
            return true;
        }
        return false;
    }

    /**
     * 根居ID获取对象
     */
    public DeviceSetupRecordEntity findDeviceSetupRecordById(Long id) {
        return deviceSetupRecordMapper.findDeviceSetupRecordById(id);
    }

    /**
     * 查询最后一条操作记录
     * @param deviceSetupRecordEntity
     * @return
     */
    public DeviceSetupRecordEntity selectLastOne(DeviceSetupRecordEntity deviceSetupRecordEntity) {
        return deviceSetupRecordMapper.selectLastOne(deviceSetupRecordEntity);
    }
}
