libo %!s(int64=4) %!d(string=hai) anos
pai
achega
c040645f51

+ 6 - 0
src/main/java/com/tdba/cxb/ares/api/config/RedisConfig.java

@@ -7,6 +7,7 @@ import org.springframework.context.annotation.Bean;
7 7
 import org.springframework.context.annotation.Configuration;
8 8
 import org.springframework.data.redis.connection.RedisConnectionFactory;
9 9
 import org.springframework.data.redis.core.RedisTemplate;
10
+import org.springframework.data.redis.core.StringRedisTemplate;
10 11
 import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
11 12
 import org.springframework.data.redis.serializer.StringRedisSerializer;
12 13
 import org.springframework.util.StringUtils;
@@ -59,6 +60,11 @@ public class RedisConfig {
59 60
         return redisTemplate;
60 61
     }
61 62
 
63
+    @Bean(name = "stringRedisTemplate")
64
+    public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory){
65
+        return new StringRedisTemplate(redisConnectionFactory);
66
+    }
67
+
62 68
     @Bean
63 69
     public JedisPool redisPoolFactory() {
64 70
         try {

+ 4 - 5
src/main/java/com/tdba/cxb/ares/api/controller/UserController.java

@@ -1,10 +1,8 @@
1 1
 package com.tdba.cxb.ares.api.controller;
2 2
 
3
+import com.github.pagehelper.PageHelper;
3 4
 import com.github.pagehelper.PageInfo;
4
-import com.tdba.cxb.ares.api.model.BaseUser;
5
-import com.tdba.cxb.ares.api.model.BindUserAdd;
6
-import com.tdba.cxb.ares.api.model.OperatorLoginReq;
7
-import com.tdba.cxb.ares.api.model.TDBAResponse;
5
+import com.tdba.cxb.ares.api.model.*;
8 6
 import com.tdba.cxb.ares.api.service.UserService;
9 7
 import com.tdba.cxb.ares.api.util.DateUtil;
10 8
 import com.tdba.cxb.ares.api.util.TDBAController;
@@ -69,8 +67,9 @@ public class UserController {
69 67
      * @return
70 68
      */
71 69
     @GetMapping("bind_list")
72
-    public TDBAResponse bind_list(BaseUser baseUser){
70
+    public TDBAResponse bind_list(PageParam param, BaseUser baseUser){
73 71
         Objects.requireNonNull(baseUser, "请登录后操作");
72
+        PageHelper.startPage(param.getPage(), param.getLimit());
74 73
         return buildSuccess(buildByPageInfo(new PageInfo(userService.teamList(baseUser.getId()))));
75 74
     }
76 75
 

+ 32 - 0
src/main/java/com/tdba/cxb/ares/api/model/PageParam.java

@@ -0,0 +1,32 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+/**
4
+ * @program: admin-web
5
+ * @description: 分页请求
6
+ * @author: libo
7
+ * @create: 2022-06-01 15:35:47
8
+ */
9
+public class PageParam {
10
+
11
+    /** 当期页码*/
12
+    private Integer page = 1;
13
+
14
+    /** 每页条数*/
15
+    private Integer limit = 10;
16
+
17
+    public Integer getPage() {
18
+        return page;
19
+    }
20
+
21
+    public void setPage(Integer page) {
22
+        this.page = page;
23
+    }
24
+
25
+    public Integer getLimit() {
26
+        return limit;
27
+    }
28
+
29
+    public void setLimit(Integer limit) {
30
+        this.limit = limit;
31
+    }
32
+}

+ 27 - 27
src/main/java/com/tdba/cxb/ares/api/model/UserBind.java

@@ -17,13 +17,13 @@ public class UserBind {
17 17
     private Integer uid;
18 18
 
19 19
     /** 添加时间*/
20
-    private LocalDateTime createTime;
20
+    private LocalDateTime create_time;
21 21
 
22 22
     /** 删除标记:0否1是*/
23
-    private Integer delFlag;
23
+    private Integer del_flag;
24 24
 
25 25
     /** 运营商用户ID(sys_user)*/
26
-    private Integer bindUid;
26
+    private Integer bind_uid;
27 27
 
28 28
     /** 类型:0正常统计1统计时过滤*/
29 29
     private Integer type;
@@ -44,28 +44,28 @@ public class UserBind {
44 44
         this.uid = uid;
45 45
     }
46 46
 
47
-    public LocalDateTime getCreateTime() {
48
-        return createTime;
47
+    public LocalDateTime getCreate_time() {
48
+        return create_time;
49 49
     }
50 50
 
51
-    public void setCreateTime(LocalDateTime createTime) {
52
-        this.createTime = createTime;
51
+    public void setCreate_time(LocalDateTime create_time) {
52
+        this.create_time = create_time;
53 53
     }
54 54
 
55
-    public Integer getDelFlag() {
56
-        return delFlag;
55
+    public Integer getDel_flag() {
56
+        return del_flag;
57 57
     }
58 58
 
59
-    public void setDelFlag(Integer delFlag) {
60
-        this.delFlag = delFlag;
59
+    public void setDel_flag(Integer del_flag) {
60
+        this.del_flag = del_flag;
61 61
     }
62 62
 
63
-    public Integer getBindUid() {
64
-        return bindUid;
63
+    public Integer getBind_uid() {
64
+        return bind_uid;
65 65
     }
66 66
 
67
-    public void setBindUid(Integer bindUid) {
68
-        this.bindUid = bindUid;
67
+    public void setBind_uid(Integer bind_uid) {
68
+        this.bind_uid = bind_uid;
69 69
     }
70 70
 
71 71
     public Integer getType() {
@@ -79,9 +79,9 @@ public class UserBind {
79 79
     public static final class UserBindBuilder {
80 80
         private Integer id;
81 81
         private Integer uid;
82
-        private LocalDateTime createTime;
83
-        private Integer delFlag;
84
-        private Integer bindUid;
82
+        private LocalDateTime create_time;
83
+        private Integer del_flag;
84
+        private Integer bind_uid;
85 85
         private Integer type;
86 86
 
87 87
         private UserBindBuilder() {
@@ -101,18 +101,18 @@ public class UserBind {
101 101
             return this;
102 102
         }
103 103
 
104
-        public UserBindBuilder withCreateTime(LocalDateTime createTime) {
105
-            this.createTime = createTime;
104
+        public UserBindBuilder withCreate_time(LocalDateTime create_time) {
105
+            this.create_time = create_time;
106 106
             return this;
107 107
         }
108 108
 
109
-        public UserBindBuilder withDelFlag(Integer delFlag) {
110
-            this.delFlag = delFlag;
109
+        public UserBindBuilder withDel_flag(Integer del_flag) {
110
+            this.del_flag = del_flag;
111 111
             return this;
112 112
         }
113 113
 
114
-        public UserBindBuilder withBindUid(Integer bindUid) {
115
-            this.bindUid = bindUid;
114
+        public UserBindBuilder withBind_uid(Integer bind_uid) {
115
+            this.bind_uid = bind_uid;
116 116
             return this;
117 117
         }
118 118
 
@@ -125,9 +125,9 @@ public class UserBind {
125 125
             UserBind userBind = new UserBind();
126 126
             userBind.setId(id);
127 127
             userBind.setUid(uid);
128
-            userBind.setCreateTime(createTime);
129
-            userBind.setDelFlag(delFlag);
130
-            userBind.setBindUid(bindUid);
128
+            userBind.setCreate_time(create_time);
129
+            userBind.setDel_flag(del_flag);
130
+            userBind.setBind_uid(bind_uid);
131 131
             userBind.setType(type);
132 132
             return userBind;
133 133
         }

+ 9 - 19
src/main/java/com/tdba/cxb/ares/api/service/UserService.java

@@ -10,6 +10,7 @@ import com.tdba.cxb.ares.api.util.TDBAException;
10 10
 import org.slf4j.Logger;
11 11
 import org.slf4j.LoggerFactory;
12 12
 import org.springframework.data.redis.core.RedisTemplate;
13
+import org.springframework.data.redis.core.StringRedisTemplate;
13 14
 import org.springframework.stereotype.Service;
14 15
 import org.springframework.transaction.annotation.Transactional;
15 16
 import org.springframework.util.CollectionUtils;
@@ -320,13 +321,15 @@ public class UserService {
320 321
     @Resource
321 322
     private RedisTemplate redisTemplate;
322 323
 
324
+    @Resource
325
+    private StringRedisTemplate stringRedisTemplate;
323 326
     /**
324 327
      * 登录
325 328
      * @param param
326 329
      * @return
327 330
      */
328 331
     public UserLoginResp login(OperatorLoginReq param){
329
-        if(!param.getCode().equals("" + redisTemplate.opsForValue().get("api.auth.sms." + param.getPhone()))){
332
+        if(!param.getCode().equals("" + stringRedisTemplate.opsForValue().get("api.auth.sms." + param.getPhone()))){
330 333
             throw new TDBAException("短信验证码有误");
331 334
         }
332 335
         redisTemplate.delete("api.auth.sms." + param.getPhone());
@@ -356,20 +359,7 @@ public class UserService {
356 359
      * @return
357 360
      */
358 361
     public List<UserVo> teamList(Integer id){
359
-        List<UserVo> result = userMapper.selectByBindUid(id);
360
-        if(result.size() < 20){
361
-            int length = 20 - result.size();
362
-            for(int i = 0; i < length; i++){
363
-                result.add(UserVo.UserVoBuilder.anUserVo()
364
-                        .withAvatar("")
365
-                        .withId(0)
366
-                        .withMobile("")
367
-                        .withStatus(0)
368
-                        .withTeamName("")
369
-                        .build());
370
-            }
371
-        }
372
-        return result;
362
+        return userMapper.selectByBindUid(id);
373 363
     }
374 364
 
375 365
     /**
@@ -379,7 +369,7 @@ public class UserService {
379 369
      */
380 370
     @Transactional
381 371
     public void teamAdd(BindUserAdd param, BaseUser baseUser){
382
-        if(!param.getCode().equals(redisTemplate.opsForValue().get("api.auth.sms." + param.getMobile()))){
372
+        if(!param.getCode().equals("" + stringRedisTemplate.opsForValue().get("api.auth.sms." + param.getMobile()))){
383 373
             throw new TDBAException("短信验证码有误");
384 374
         }
385 375
         redisTemplate.delete("api.auth.sms." + param.getMobile());
@@ -393,7 +383,7 @@ public class UserService {
393 383
 
394 384
         UserBind oldUserBind = userBindMapper.selectByUid(userVo.getId());
395 385
         if(oldUserBind != null){
396
-            throw new TDBAException((oldUserBind.getBindUid().equals(baseUser.getId()))? "手机号已添加,请勿重复操作": "该手机号已被其他运营商绑定");
386
+            throw new TDBAException((oldUserBind.getBind_uid().equals(baseUser.getId()))? "手机号已添加,请勿重复操作": "该手机号已被其他运营商绑定");
397 387
         }
398 388
 
399 389
         List<Integer> oldUidList = userBindMapper.selectUid(baseUser.getId());
@@ -404,9 +394,9 @@ public class UserService {
404 394
             }
405 395
         }
406 396
         userBindMapper.insertSelective(UserBind.UserBindBuilder.anUserBind()
407
-                .withBindUid(baseUser.getId())
397
+                .withBind_uid(baseUser.getId())
408 398
                 .withUid(userVo.getId())
409
-                .withCreateTime(LocalDateTime.now())
399
+                .withCreate_time(LocalDateTime.now())
410 400
                 .withType(isFilter? 1: 0).build());
411 401
     }
412 402
 

+ 3 - 0
src/main/resources/application.yml

@@ -7,6 +7,9 @@ spring:
7 7
     type: caffeine
8 8
     caffeine:
9 9
       spec: maximumSize=5000,expireAfterWrite=60s
10
+  jackson:
11
+    parser:
12
+      allow-numeric-leading-zeros: true
10 13
 
11 14
 mybatis:
12 15
 #  configuration: