package cn.stylefeng.guns.modular.zsx.bs.job.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.job.entity.SysJob;
import cn.stylefeng.guns.modular.zsx.bs.job.mapper.SysJobMapper;
import cn.stylefeng.guns.modular.zsx.bs.job.model.params.SysJobParam;
import cn.stylefeng.guns.modular.zsx.bs.job.model.result.SysJobResult;
import cn.stylefeng.guns.modular.zsx.bs.job.service.SysJobService;
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-08-17
*/
@Service
public class SysJobServiceImpl extends ServiceImpl implements SysJobService {
@Override
public void add(SysJobParam param){
SysJob entity = getEntity(param);
this.save(entity);
}
@Override
public void delete(SysJobParam param){
this.removeById(getKey(param));
}
@Override
public void update(SysJobParam param){
SysJob oldEntity = getOldEntity(param);
SysJob newEntity = getEntity(param);
ToolUtil.copyProperties(newEntity, oldEntity);
this.updateById(newEntity);
}
@Override
public SysJobResult findBySpec(SysJobParam param){
return null;
}
@Override
public List findListBySpec(SysJobParam param){
return null;
}
@Override
public LayuiPageInfo findPageBySpec(SysJobParam param){
Page pageContext = getPageContext();
IPage page = this.baseMapper.customPageList(pageContext, param);
return LayuiPageFactory.createPageInfo(page);
}
private Serializable getKey(SysJobParam param){
return param.getId();
}
private Page getPageContext() {
return LayuiPageFactory.defaultPage();
}
private SysJob getOldEntity(SysJobParam param) {
return this.getById(getKey(param));
}
private SysJob getEntity(SysJobParam param) {
SysJob entity = new SysJob();
ToolUtil.copyProperties(param, entity);
return entity;
}
}