KeyInfoServiceImpl.java
2.7 KB
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
package com.ruoyi.service.impl.keyinfo;
import com.ruoyi.domain.keyInfo.KeyInfo;
import com.ruoyi.service.keyinfo.KeyInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import javax.servlet.http.HttpServletResponse;
import java.util.Collections;
import java.util.List;
@Service
public class KeyInfoServiceImpl extends ServiceImpl<com.ruoyi.mapper.keyinfo.KeyInfoMapper, KeyInfo> implements KeyInfoService {
@Autowired
private com.ruoyi.mapper.keyinfo.KeyInfoMapper KeyInfoMapper;
/**
* 分页查询
*/
@Override
public IPage<KeyInfo> pageList(Page<KeyInfo> page, KeyInfo entity) {
LambdaQueryWrapper<KeyInfo> countWrapper = new LambdaQueryWrapper<>(entity);
countWrapper.select(KeyInfo::getId);
int count = count(countWrapper);
List<KeyInfo> lists = Collections.emptyList();
if (count > 0) {
PageHelper.startPage((int) page.getCurrent(), (int) page.getSize(), false);
LambdaQueryWrapper<KeyInfo> selectWrapper = new LambdaQueryWrapper<>(entity);
lists = list(selectWrapper);
}
IPage<KeyInfo> returnPage = new Page<KeyInfo>();
returnPage.setRecords(lists);
returnPage.setPages(count % page.getSize() == 0 ? count / page.getSize() : count / page.getSize() + 1);
returnPage.setCurrent(page.getCurrent());
returnPage.setSize(page.getSize());
returnPage.setTotal(count);
return returnPage;
}
@Override
public List<KeyInfo> list(KeyInfo entity) {
return list(new LambdaQueryWrapper<>(entity));
}
@Override
public KeyInfo getOne(KeyInfo entity) {
return getOne(new LambdaQueryWrapper<>(entity));
}
@Override
public Integer countId(KeyInfo entity) {
LambdaQueryWrapper<KeyInfo> wrapper = new LambdaQueryWrapper<>(entity);
wrapper.select(KeyInfo::getId);
return count(wrapper);
}
/**
* 插入有值的列
*/
@Override
public int insertSelective(KeyInfo entity) {
return KeyInfoMapper.insertSelective(entity);
}
/**
* 插入数据
*/
@Override
public boolean insert(KeyInfo entity) {
return save(entity);
}
/**
* 根据主键修改数据
*/
@Override
public boolean updateByPrimaryKey(KeyInfo entity) {
return updateById(entity);
}
}