package cn.stylefeng.guns.modular.em.equipmentMaintainContentTask.service.impl;
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.em.equipmentMaintainContentTask.entity.EquipmentMaintainContentTask;
import cn.stylefeng.guns.modular.em.equipmentMaintainContentTask.mapper.EquipmentMaintainContentTaskMapper;
import cn.stylefeng.guns.modular.em.equipmentMaintainContentTask.model.params.EquipmentMaintainContentTaskParam;
import cn.stylefeng.guns.modular.em.equipmentMaintainContentTask.model.result.EquipmentMaintainContentTaskResult;
import cn.stylefeng.guns.modular.em.equipmentMaintainContentTask.service.EquipmentMaintainContentTaskService;
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-02-21
*/
@Service
public class EquipmentMaintainContentTaskServiceImpl extends ServiceImpl implements EquipmentMaintainContentTaskService {
@Override
public void add(EquipmentMaintainContentTaskParam param){
EquipmentMaintainContentTask entity = getEntity(param);
this.save(entity);
}
@Override
public void delete(EquipmentMaintainContentTaskParam param){
this.removeById(getKey(param));
}
@Override
public void update(EquipmentMaintainContentTaskParam param){
EquipmentMaintainContentTask oldEntity = getOldEntity(param);
EquipmentMaintainContentTask newEntity = getEntity(param);
ToolUtil.copyProperties(newEntity, oldEntity);
this.updateById(newEntity);
}
@Override
public EquipmentMaintainContentTaskResult findBySpec(EquipmentMaintainContentTaskParam param){
return null;
}
@Override
public List findListBySpec(EquipmentMaintainContentTaskParam param){
return null;
}
@Override
public LayuiPageInfo findPageBySpec(EquipmentMaintainContentTaskParam param){
Page pageContext = getPageContext();
IPage page = this.baseMapper.customPageList(pageContext, param);
return LayuiPageFactory.createPageInfo(page);
}
private Serializable getKey(EquipmentMaintainContentTaskParam param){
return param.getId();
}
private Page getPageContext() {
return LayuiPageFactory.defaultPage();
}
private EquipmentMaintainContentTask getOldEntity(EquipmentMaintainContentTaskParam param) {
return this.getById(getKey(param));
}
private EquipmentMaintainContentTask getEntity(EquipmentMaintainContentTaskParam param) {
EquipmentMaintainContentTask entity = new EquipmentMaintainContentTask();
ToolUtil.copyProperties(param, entity);
return entity;
}
}