package cn.stylefeng.guns.modular.em.equipmentAlarm.service.impl;
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.em.equipmentAlarm.entity.EquipmentAlarm;
import cn.stylefeng.guns.modular.em.equipmentAlarm.mapper.EquipmentAlarmMapper;
import cn.stylefeng.guns.modular.em.equipmentAlarm.model.params.EquipmentAlarmParam;
import cn.stylefeng.guns.modular.em.equipmentAlarm.model.result.EquipmentAlarmResult;
import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService;
import cn.stylefeng.roses.core.util.ToolUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.io.Serializable;
import java.util.List;
/**
*
* 设备报警 服务实现类
*
*
* @author cl
* @since 2022-10-28
*/
@Service
public class EquipmentAlarmServiceImpl extends ServiceImpl implements EquipmentAlarmService {
@Override
public void add(EquipmentAlarmParam param){
EquipmentAlarm entity = getEntity(param);
this.save(entity);
}
@Override
public void delete(EquipmentAlarmParam param){
this.removeById(getKey(param));
}
@Override
public void update(EquipmentAlarmParam param){
EquipmentAlarm oldEntity = getOldEntity(param);
EquipmentAlarm newEntity = getEntity(param);
ToolUtil.copyProperties(newEntity, oldEntity);
this.updateById(newEntity);
}
@Override
public EquipmentAlarmResult findBySpec(EquipmentAlarmParam param){
return null;
}
@Override
public List findListBySpec(EquipmentAlarmParam param){
return null;
}
@Override
public LayuiPageInfo findPageBySpec(EquipmentAlarmParam param){
Page pageContext = getPageContext();
IPage page = this.baseMapper.customPageList(pageContext, param);
return LayuiPageFactory.createPageInfo(page);
}
private Serializable getKey(EquipmentAlarmParam param){
return param.getId();
}
private Page getPageContext() {
return LayuiPageFactory.defaultPage();
}
private EquipmentAlarm getOldEntity(EquipmentAlarmParam param) {
return this.getById(getKey(param));
}
private EquipmentAlarm getEntity(EquipmentAlarmParam param) {
EquipmentAlarm entity = new EquipmentAlarm();
ToolUtil.copyProperties(param, entity);
return entity;
}
}