package cn.stylefeng.guns.opcua.service.impl;
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.opcua.entity.OpcuaConf;
import cn.stylefeng.guns.opcua.mapper.OpcuaConfMapper;
import cn.stylefeng.guns.opcua.model.params.OpcuaConfParam;
import cn.stylefeng.guns.opcua.model.result.OpcuaConfResult;
import cn.stylefeng.guns.opcua.service.OpcuaConfService;
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 yyt
* @since 2023-10-17
*/
@Service
public class OpcuaConfServiceImpl extends ServiceImpl implements OpcuaConfService {
@Override
public void add(OpcuaConfParam param){
OpcuaConf entity = getEntity(param);
this.save(entity);
}
@Override
public void delete(OpcuaConfParam param){
this.removeById(getKey(param));
}
@Override
public void update(OpcuaConfParam param){
OpcuaConf oldEntity = getOldEntity(param);
OpcuaConf newEntity = getEntity(param);
ToolUtil.copyProperties(newEntity, oldEntity);
this.updateById(newEntity);
}
@Override
public OpcuaConfResult findBySpec(OpcuaConfParam param){
return null;
}
@Override
public List findListBySpec(OpcuaConfParam param){
return null;
}
@Override
public LayuiPageInfo findPageBySpec(OpcuaConfParam param){
Page pageContext = getPageContext();
IPage page = this.baseMapper.customPageList(pageContext, param);
return LayuiPageFactory.createPageInfo(page);
}
private Serializable getKey(OpcuaConfParam param){
return param.getId();
}
private Page getPageContext() {
return LayuiPageFactory.defaultPage();
}
private OpcuaConf getOldEntity(OpcuaConfParam param) {
return this.getById(getKey(param));
}
private OpcuaConf getEntity(OpcuaConfParam param) {
OpcuaConf entity = new OpcuaConf();
ToolUtil.copyProperties(param, entity);
return entity;
}
}