package cn.stylefeng.guns.modular.zsx.bs.equipment.service.impl;
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.zsx.bs.equipment.entity.EquipmentInfo;
import cn.stylefeng.guns.modular.zsx.bs.equipment.mapper.EquipmentInfoMapper;
import cn.stylefeng.guns.modular.zsx.bs.equipment.model.params.EquipmentInfoParam;
import cn.stylefeng.guns.modular.zsx.bs.equipment.model.result.EquipmentInfoResult;
import cn.stylefeng.guns.modular.zsx.bs.equipment.service.EquipmentInfoService;
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 ruimin
* @since 2023-09-18
*/
@Service
public class EquipmentInfoServiceImpl extends ServiceImpl implements EquipmentInfoService {
@Override
public void add(EquipmentInfoParam param){
EquipmentInfo entity = getEntity(param);
this.save(entity);
}
@Override
public void delete(EquipmentInfoParam param){
this.removeById(getKey(param));
}
@Override
public void update(EquipmentInfoParam param){
EquipmentInfo oldEntity = getOldEntity(param);
EquipmentInfo newEntity = getEntity(param);
ToolUtil.copyProperties(newEntity, oldEntity);
this.updateById(newEntity);
}
@Override
public EquipmentInfoResult findBySpec(EquipmentInfoParam param){
return null;
}
@Override
public List findListBySpec(EquipmentInfoParam param){
return null;
}
@Override
public LayuiPageInfo findPageBySpec(EquipmentInfoParam param){
Page pageContext = getPageContext();
IPage page = this.baseMapper.customPageList(pageContext, param);
return LayuiPageFactory.createPageInfo(page);
}
private Serializable getKey(EquipmentInfoParam param){
return param.getId();
}
private Page getPageContext() {
return LayuiPageFactory.defaultPage();
}
private EquipmentInfo getOldEntity(EquipmentInfoParam param) {
return this.getById(getKey(param));
}
private EquipmentInfo getEntity(EquipmentInfoParam param) {
EquipmentInfo entity = new EquipmentInfo();
ToolUtil.copyProperties(param, entity);
return entity;
}
}