package cn.stylefeng.guns.modular.am.materialShortageAlarm.service.impl;
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.am.materialShortageAlarm.entity.MaterialShortageAlarm;
import cn.stylefeng.guns.modular.am.materialShortageAlarm.mapper.MaterialShortageAlarmMapper;
import cn.stylefeng.guns.modular.am.materialShortageAlarm.model.params.MaterialShortageAlarmParam;
import cn.stylefeng.guns.modular.am.materialShortageAlarm.model.result.MaterialShortageAlarmResult;
import cn.stylefeng.guns.modular.am.materialShortageAlarm.service.MaterialShortageAlarmService;
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 zrm
* @since 2023-02-15
*/
@Service
public class MaterialShortageAlarmServiceImpl extends ServiceImpl implements MaterialShortageAlarmService {
@Override
public void add(MaterialShortageAlarmParam param){
MaterialShortageAlarm entity = getEntity(param);
this.save(entity);
}
@Override
public void delete(MaterialShortageAlarmParam param){
this.removeById(getKey(param));
}
@Override
public void update(MaterialShortageAlarmParam param){
MaterialShortageAlarm oldEntity = getOldEntity(param);
MaterialShortageAlarm newEntity = getEntity(param);
ToolUtil.copyProperties(newEntity, oldEntity);
this.updateById(newEntity);
}
@Override
public MaterialShortageAlarmResult findBySpec(MaterialShortageAlarmParam param){
return null;
}
@Override
public List findListBySpec(MaterialShortageAlarmParam param){
return null;
}
@Override
public LayuiPageInfo findPageBySpec(MaterialShortageAlarmParam param){
Page pageContext = getPageContext();
IPage page = this.baseMapper.customPageList(pageContext, param);
return LayuiPageFactory.createPageInfo(page);
}
private Serializable getKey(MaterialShortageAlarmParam param){
return param.getId();
}
private Page getPageContext() {
return LayuiPageFactory.defaultPage();
}
private MaterialShortageAlarm getOldEntity(MaterialShortageAlarmParam param) {
return this.getById(getKey(param));
}
private MaterialShortageAlarm getEntity(MaterialShortageAlarmParam param) {
MaterialShortageAlarm entity = new MaterialShortageAlarm();
ToolUtil.copyProperties(param, entity);
return entity;
}
}