package cn.stylefeng.guns.modular.em.equipmentMaintainTask.service.impl;
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.em.equipmentMaintainTask.entity.EquipmentMaintainTask;
import cn.stylefeng.guns.modular.em.equipmentMaintainTask.mapper.EquipmentMaintainTaskMapper;
import cn.stylefeng.guns.modular.em.equipmentMaintainTask.model.params.EquipmentMaintainTaskParam;
import cn.stylefeng.guns.modular.em.equipmentMaintainTask.model.result.EquipmentMaintainTaskResult;
import cn.stylefeng.guns.modular.em.equipmentMaintainTask.service.EquipmentMaintainTaskService;
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 EquipmentMaintainTaskServiceImpl extends ServiceImpl implements EquipmentMaintainTaskService {
@Override
public void add(EquipmentMaintainTaskParam param){
EquipmentMaintainTask entity = getEntity(param);
this.save(entity);
}
@Override
public void delete(EquipmentMaintainTaskParam param){
this.removeById(getKey(param));
}
@Override
public void update(EquipmentMaintainTaskParam param){
EquipmentMaintainTask oldEntity = getOldEntity(param);
EquipmentMaintainTask newEntity = getEntity(param);
ToolUtil.copyProperties(newEntity, oldEntity);
this.updateById(newEntity);
}
@Override
public EquipmentMaintainTaskResult findBySpec(EquipmentMaintainTaskParam param){
return null;
}
@Override
public List findListBySpec(EquipmentMaintainTaskParam param){
return null;
}
@Override
public LayuiPageInfo findPageBySpec(EquipmentMaintainTaskParam param){
Page pageContext = getPageContext();
IPage page = this.baseMapper.customPageList(pageContext, param);
return LayuiPageFactory.createPageInfo(page);
}
private Serializable getKey(EquipmentMaintainTaskParam param){
return param.getId();
}
private Page getPageContext() {
return LayuiPageFactory.defaultPage();
}
private EquipmentMaintainTask getOldEntity(EquipmentMaintainTaskParam param) {
return this.getById(getKey(param));
}
private EquipmentMaintainTask getEntity(EquipmentMaintainTaskParam param) {
EquipmentMaintainTask entity = new EquipmentMaintainTask();
ToolUtil.copyProperties(param, entity);
return entity;
}
}