package com.zcxk.charge.web.service;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zcxk.charge.core.dao.DeviceAttributeMapper;
import com.zcxk.charge.core.entity.DeviceAttributeEntity;
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 2020-11-20 20:29
 */
@Service
public class DeviceAttributeService extends ServiceImpl<DeviceAttributeMapper, DeviceAttributeEntity> {

    @Resource
    private DeviceAttributeMapper deviceAttributeMapper;

    /**
     * 查列表
     */
    public List<DeviceAttributeEntity> findList(DeviceAttributeEntity deviceAttributeEntity) {
        return deviceAttributeMapper.findList(deviceAttributeEntity);
    }

    /**
     * 批量删除
     */
    @Transactional(rollbackFor = Exception.class)
    public boolean delDeviceAttributeByIds(Long[] ids) {
        return this.removeByIds(Arrays.asList(ids));
    }

    /**
     * 单个删除
     */
    public boolean delDeviceAttributeById(Long id) {
        return this.removeById(id);
    }

    /**
     * 保存
     */
    public boolean addDeviceAttribute(DeviceAttributeEntity deviceAttribute) {
        if (this.save(deviceAttribute)) {
            return true;
        }
        return false;
    }

    /**
     * 修改根居ID
     */
    public boolean updateDeviceAttributeById(DeviceAttributeEntity deviceAttribute) {
        if (this.updateById(deviceAttribute)) {
            return true;
        }
        return false;
    }

    /**
     * 根居ID获取对象
     */
    public DeviceAttributeEntity findDeviceAttributeById(Long id) {
        return deviceAttributeMapper.findDeviceAttributeById(id);
    }
}
