package cn.stylefeng.guns.modular.sc.scannerConfig.service.impl;
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.sc.scannerConfig.entity.ScannerConfig;
import cn.stylefeng.guns.modular.sc.scannerConfig.mapper.ScannerConfigMapper;
import cn.stylefeng.guns.modular.sc.scannerConfig.model.params.ScannerConfigParam;
import cn.stylefeng.guns.modular.sc.scannerConfig.model.result.ScannerConfigResult;
import cn.stylefeng.guns.modular.sc.scannerConfig.service.ScannerConfigService;
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-07-11
*/
@Service
public class ScannerConfigServiceImpl extends ServiceImpl implements ScannerConfigService {
@Override
public void add(ScannerConfigParam param){
ScannerConfig entity = getEntity(param);
this.save(entity);
}
@Override
public void delete(ScannerConfigParam param){
this.removeById(getKey(param));
}
@Override
public void update(ScannerConfigParam param){
ScannerConfig oldEntity = getOldEntity(param);
ScannerConfig newEntity = getEntity(param);
ToolUtil.copyProperties(newEntity, oldEntity);
this.updateById(newEntity);
}
@Override
public ScannerConfigResult findBySpec(ScannerConfigParam param){
return null;
}
@Override
public List findListBySpec(ScannerConfigParam param){
return null;
}
@Override
public LayuiPageInfo findPageBySpec(ScannerConfigParam param){
Page pageContext = getPageContext();
IPage page = this.baseMapper.customPageList(pageContext, param);
return LayuiPageFactory.createPageInfo(page);
}
private Serializable getKey(ScannerConfigParam param){
return param.getId();
}
private Page getPageContext() {
return LayuiPageFactory.defaultPage();
}
private ScannerConfig getOldEntity(ScannerConfigParam param) {
return this.getById(getKey(param));
}
private ScannerConfig getEntity(ScannerConfigParam param) {
ScannerConfig entity = new ScannerConfig();
ToolUtil.copyProperties(param, entity);
return entity;
}
}