AdaKing88
2023-08-23 ae35159387a55199e8ab150ebb97d89d68a235bd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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<JianbjSelfMapper, JianbjSelf>  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<JianbjSelf> paginQuery(JianbjSelf jianbjSelf, long current, long size){
        //1. 构建动态查询条件
        LambdaQueryWrapper<JianbjSelf> 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<JianbjSelf> pagin = new Page<>(current , size , true);
        IPage<JianbjSelf> 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<JianbjSelf> queryByHeadId(String headId) {
        //return jianbjRdMapper.queryByHeadId(headId) ;
        QueryWrapper<JianbjSelf> q = new QueryWrapper<>();
        q.eq("head_id",headId);
        return jianbjSelfMapper.selectList(q);
    }
 
 
 
}