package com.zcxk.charge.web.service;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zcxk.charge.core.dao.DeviceSceneMapper;
import com.zcxk.charge.core.entity.DeviceSceneEntity;
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-12-23 09:57
 */
@Service
public class DeviceSceneService extends ServiceImpl<DeviceSceneMapper, DeviceSceneEntity> {

    @Resource
    private DeviceSceneMapper deviceSceneMapper;

    /**
     * 查列表
     */
    public List<DeviceSceneEntity> findList(DeviceSceneEntity deviceSceneEntity) {
        return deviceSceneMapper.findList(deviceSceneEntity);
    }

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

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

    /**
     * 保存
     */
    public boolean addDeviceScene(DeviceSceneEntity deviceScene) {
        if (this.save(deviceScene)) {
            return true;
        }
        return false;
    }

    /**
     * 修改根居ID
     */
    public boolean updateDeviceSceneById(DeviceSceneEntity deviceScene) {
        if (this.updateById(deviceScene)) {
            return true;
        }
        return false;
    }

    /**
     * 根居ID获取对象
     */
    public DeviceSceneEntity findDeviceSceneById(Long id) {
        return deviceSceneMapper.findDeviceSceneById(id);
    }
}
