package com.njzscloud.supervisory.device.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.device.mapper.DeviceInfoMapper;
import com.njzscloud.supervisory.device.pojo.entity.DeviceInfoEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 设备信息表
 */
@Slf4j
@Service
public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoEntity> implements IService<DeviceInfoEntity> {

    /**
     * 新增
     *
     * @param deviceInfoEntity 数据
     */
    public void add(DeviceInfoEntity deviceInfoEntity) {
        this.save(deviceInfoEntity);
    }

    /**
     * 修改
     *
     * @param deviceInfoEntity 数据
     */
    public void modify(DeviceInfoEntity deviceInfoEntity) {
        this.updateById(deviceInfoEntity);
    }

    /**
     * 删除
     *
     * @param ids Ids
     */
    @Transactional(rollbackFor = Exception.class)
    public void del(List<Long> ids) {
        this.removeBatchByIds(ids);
    }

    /**
     * 详情
     *
     * @param id Id
     * @return DeviceInfoEntity 结果
     */
    public DeviceInfoEntity detail(Long id) {
        return this.getById(id);
    }

    /**
     * 分页查询
     *
     * @param deviceInfoEntity 筛选条件
     * @param pageParam        分页参数
     * @return PageResult&lt;DeviceInfoEntity&gt; 分页结果
     */
    public PageResult<DeviceInfoEntity> paging(PageParam pageParam, DeviceInfoEntity deviceInfoEntity) {
        return PageResult.of(this.page(pageParam.toPage(), Wrappers.<DeviceInfoEntity>query(deviceInfoEntity)));
    }

}
