|
@@ -1,13 +1,18 @@
|
1
|
1
|
package com.yunzhi.shigongli.service.impl;
|
2
|
2
|
|
|
3
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
4
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
3
|
5
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
4
|
6
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
5
|
7
|
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
|
8
|
+import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
6
|
9
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
7
|
10
|
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
8
|
11
|
import com.yunzhi.shigongli.service.IBaseService;
|
9
|
12
|
|
10
|
13
|
import java.io.Serializable;
|
|
14
|
+import java.util.List;
|
|
15
|
+import java.util.function.Supplier;
|
11
|
16
|
|
12
|
17
|
public class BaseServiceImpl <M extends BaseMapper<T>, T> extends ServiceImpl <M, T> implements IBaseService<T> {
|
13
|
18
|
@Override
|
|
@@ -20,4 +25,27 @@ public class BaseServiceImpl <M extends BaseMapper<T>, T> extends ServiceImpl <M
|
20
|
25
|
|
21
|
26
|
return update(updateWrapper);
|
22
|
27
|
}
|
|
28
|
+
|
|
29
|
+ @Override
|
|
30
|
+ public List<T> getBy(SFunction<T, ?> column, Serializable val) {
|
|
31
|
+ LambdaQueryWrapper<T> queryWrapper = new LambdaQueryWrapper<>();
|
|
32
|
+ queryWrapper.eq(column, val);
|
|
33
|
+
|
|
34
|
+ return list(queryWrapper);
|
|
35
|
+ }
|
|
36
|
+
|
|
37
|
+ @Override
|
|
38
|
+ public boolean isExisted(SFunction<T, ?> column, Serializable val) {
|
|
39
|
+ return isExisted(column, val, (SFunction<T, ?>) null, null);
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ @Override
|
|
43
|
+ public boolean isExisted(SFunction<T, ?> column, Serializable val, SFunction<T, ?> notEq, Serializable notVal) {
|
|
44
|
+ LambdaQueryWrapper<T> queryWrapper = new LambdaQueryWrapper<>();
|
|
45
|
+ queryWrapper.eq(column, val);
|
|
46
|
+ queryWrapper.ne(null != notVal, notEq, notVal);
|
|
47
|
+
|
|
48
|
+ int cnt = count(queryWrapper);
|
|
49
|
+ return cnt > 0;
|
|
50
|
+ }
|
23
|
51
|
}
|