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