KeyInfoServiceImpl.java
7.33 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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package com.ruoyi.service.impl.keyinfo;
import com.ruoyi.domain.OrderEntity;
import com.ruoyi.domain.keyInfo.KeyInfo;
import com.ruoyi.service.keyinfo.KeyInfoService;
import org.apache.commons.lang3.StringUtils;
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, OrderEntity orderEntity) {
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);
orderColumn(selectWrapper, orderEntity);
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 List<KeyInfo> listOfSelect(KeyInfo entity) {
LambdaQueryWrapper<KeyInfo> wrapper = new LambdaQueryWrapper<>(entity);
wrapper.select(KeyInfo::getId, KeyInfo::getName);
return list(wrapper);
}
@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);
}
public static void orderColumn(LambdaQueryWrapper<KeyInfo> wrapper, com.ruoyi.domain.OrderEntity orderEntity) {
if (StringUtils.equals("ascending", orderEntity.getOrder())) {
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "id")) {
wrapper.orderByAsc(KeyInfo::getId);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "name")) {
wrapper.orderByAsc(KeyInfo::getName);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "status")) {
wrapper.orderByAsc(KeyInfo::getStatus);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "delFlag")) {
wrapper.orderByAsc(KeyInfo::getDelFlag);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "createBy")) {
wrapper.orderByAsc(KeyInfo::getCreateBy);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "createTime")) {
wrapper.orderByAsc(KeyInfo::getCreateTime);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "updateby")) {
wrapper.orderByAsc(KeyInfo::getUpdateby);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "updateTime")) {
wrapper.orderByAsc(KeyInfo::getUpdateTime);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "yardId")) {
wrapper.orderByAsc(KeyInfo::getYardId);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "deviceId")) {
wrapper.orderByAsc(KeyInfo::getDeviceId);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "cabinetno")) {
wrapper.orderByAsc(KeyInfo::getCabinetno);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "plateNum")) {
wrapper.orderByAsc(KeyInfo::getPlateNum);
}
} else if (StringUtils.equals("descending", orderEntity.getOrder())) {
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "id")) {
wrapper.orderByDesc(KeyInfo::getId);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "name")) {
wrapper.orderByDesc(KeyInfo::getName);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "status")) {
wrapper.orderByDesc(KeyInfo::getStatus);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "delFlag")) {
wrapper.orderByDesc(KeyInfo::getDelFlag);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "createBy")) {
wrapper.orderByDesc(KeyInfo::getCreateBy);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "createTime")) {
wrapper.orderByDesc(KeyInfo::getCreateTime);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "updateby")) {
wrapper.orderByDesc(KeyInfo::getUpdateby);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "updateTime")) {
wrapper.orderByDesc(KeyInfo::getUpdateTime);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "yardId")) {
wrapper.orderByDesc(KeyInfo::getYardId);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "deviceId")) {
wrapper.orderByDesc(KeyInfo::getDeviceId);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "cabinetno")) {
wrapper.orderByDesc(KeyInfo::getCabinetno);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "plateNum")) {
wrapper.orderByDesc(KeyInfo::getPlateNum);
}
}
}
}