package org.jeecg.modules.arj.service.impl; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.jeecg.modules.arj.service.JianbjSelfService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.jeecg.modules.arj.entity.JianbjSelf; import org.jeecg.modules.arj.mapper.JianbjSelfMapper; import java.util.List; /** * 剪板机自检;(jianbj_self)表服务实现类 * @author : http://www.chiner.pro * @date : 2022-11-22 */ @Service public class JianbjSelfServiceImpl extends ServiceImpl implements JianbjSelfService { @Autowired private JianbjSelfMapper jianbjSelfMapper; /** * 通过ID查询单条数据 * * @param id 主键 * @return 实例对象 */ public JianbjSelf queryById(String id){ return jianbjSelfMapper.selectById(id); } /** * 分页查询 * * @param jianbjSelf 筛选条件 * @param current 当前页码 * @param size 每页大小 * @return */ public Page paginQuery(JianbjSelf jianbjSelf, long current, long size){ //1. 构建动态查询条件 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); if(StrUtil.isNotBlank(jianbjSelf.getCpml())){ queryWrapper.eq(JianbjSelf::getCpml, jianbjSelf.getCpml()); } if(StrUtil.isNotBlank(jianbjSelf.getZhijiaodu())){ queryWrapper.eq(JianbjSelf::getZhijiaodu, jianbjSelf.getZhijiaodu()); } if(StrUtil.isNotBlank(jianbjSelf.getGaodu())){ queryWrapper.eq(JianbjSelf::getGaodu, jianbjSelf.getGaodu()); } if(StrUtil.isNotBlank(jianbjSelf.getChangdu())){ queryWrapper.eq(JianbjSelf::getChangdu, jianbjSelf.getChangdu()); } if(StrUtil.isNotBlank(jianbjSelf.getCreatedBy())){ queryWrapper.eq(JianbjSelf::getCreatedBy, jianbjSelf.getCreatedBy()); } if(StrUtil.isNotBlank(jianbjSelf.getUpdatedBy())){ queryWrapper.eq(JianbjSelf::getUpdatedBy, jianbjSelf.getUpdatedBy()); } if(StrUtil.isNotBlank(jianbjSelf.getHeadId())){ queryWrapper.eq(JianbjSelf::getHeadId, jianbjSelf.getHeadId()); } //2. 执行分页查询 Page pagin = new Page<>(current , size , true); IPage selectResult = jianbjSelfMapper.selectByPage(pagin , queryWrapper); pagin.setPages(selectResult.getPages()); pagin.setTotal(selectResult.getTotal()); pagin.setRecords(selectResult.getRecords()); //3. 返回结果 return pagin; } /** * 新增数据 * * @param jianbjSelf 实例对象 * @return 实例对象 */ public JianbjSelf insert(JianbjSelf jianbjSelf){ jianbjSelfMapper.insert(jianbjSelf); return jianbjSelf; } /** * 更新数据 * * @param jianbjSelf 实例对象 * @return 实例对象 */ public JianbjSelf update(JianbjSelf jianbjSelf){ int k = jianbjSelfMapper.updateById(jianbjSelf); return jianbjSelf; } /** * 通过主键删除数据 * * @param id 主键 * @return 是否成功 */ public boolean deleteById(String id){ int total = jianbjSelfMapper.deleteById(id); return total > 0; } @Override public List queryByHeadId(String headId) { //return jianbjRdMapper.queryByHeadId(headId) ; QueryWrapper q = new QueryWrapper<>(); q.eq("head_id",headId); return jianbjSelfMapper.selectList(q); } }