Преглед изворни кода

* 商品详情接口bug修复

libo пре 4 година
родитељ
комит
03c0481843
21 измењених фајлова са 1210 додато и 92 уклоњено
  1. 23 4
      src/main/java/com/tdba/cxb/ares/api/controller/UserController.java
  2. 9 46
      src/main/java/com/tdba/cxb/ares/api/model/BaseUser.java
  3. 79 0
      src/main/java/com/tdba/cxb/ares/api/model/DataListResp.java
  4. 67 0
      src/main/java/com/tdba/cxb/ares/api/model/DataTotalResp.java
  5. 43 0
      src/main/java/com/tdba/cxb/ares/api/model/DetailListResp.java
  6. 135 0
      src/main/java/com/tdba/cxb/ares/api/model/UserBind.java
  7. 61 0
      src/main/java/com/tdba/cxb/ares/api/model/UserLoginResp.java
  8. 120 11
      src/main/java/com/tdba/cxb/ares/api/model/UserRelate.java
  9. 133 0
      src/main/java/com/tdba/cxb/ares/api/model/UserVo.java
  10. 25 0
      src/main/java/com/tdba/cxb/ares/api/repository/UserBindMapper.java
  11. 9 0
      src/main/java/com/tdba/cxb/ares/api/repository/UserMapper.java
  12. 3 0
      src/main/java/com/tdba/cxb/ares/api/repository/UserRelateMapper.java
  13. 107 5
      src/main/java/com/tdba/cxb/ares/api/service/UserService.java
  14. 15 18
      src/main/java/com/tdba/cxb/ares/api/util/BaseUserArgumentResolver.java
  15. 80 0
      src/main/java/com/tdba/cxb/ares/api/util/JwtUtil.java
  16. 22 0
      src/main/java/com/tdba/cxb/ares/api/util/Sensitive.java
  17. 61 0
      src/main/java/com/tdba/cxb/ares/api/util/SensitiveSerializer.java
  18. 2 0
      src/main/java/module-info.java
  19. 74 0
      src/main/resources/mapper/UserBindMapper.xml
  20. 68 0
      src/main/resources/mapper/UserMapper.xml
  21. 74 8
      src/main/resources/mapper/UserRelateMapper.xml

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

@@ -1,5 +1,6 @@
1 1
 package com.tdba.cxb.ares.api.controller;
2 2
 
3
+import com.github.pagehelper.PageInfo;
3 4
 import com.tdba.cxb.ares.api.model.BaseUser;
4 5
 import com.tdba.cxb.ares.api.model.BindUserAdd;
5 6
 import com.tdba.cxb.ares.api.model.OperatorLoginReq;
@@ -14,12 +15,15 @@ import org.springframework.web.bind.annotation.RequestBody;
14 15
 import org.springframework.web.bind.annotation.RequestParam;
15 16
 
16 17
 import javax.annotation.Resource;
18
+import javax.validation.constraints.NotNull;
17 19
 
18 20
 import java.time.LocalDate;
19 21
 import java.time.LocalDateTime;
20 22
 import java.time.ZoneOffset;
21 23
 import java.time.ZonedDateTime;
24
+import java.util.Objects;
22 25
 
26
+import static com.tdba.cxb.ares.api.config.PageEntityBuilder.buildByPageInfo;
23 27
 import static com.tdba.cxb.ares.api.model.TDBAResponseBuilder.buildSuccess;
24 28
 
25 29
 /**
@@ -28,6 +32,7 @@ import static com.tdba.cxb.ares.api.model.TDBAResponseBuilder.buildSuccess;
28 32
  * @author: libo
29 33
  * @create: 2022-06-06 17:48:41
30 34
  */
35
+@Validated
31 36
 @TDBAController("/api/v1/operate")
32 37
 public class UserController {
33 38
 
@@ -55,7 +60,7 @@ public class UserController {
55 60
      */
56 61
     @PostMapping("login")
57 62
     public TDBAResponse login(@RequestBody @Validated OperatorLoginReq param){
58
-        return buildSuccess("");
63
+        return buildSuccess(userService.login(param));
59 64
     }
60 65
 
61 66
     /**
@@ -65,7 +70,8 @@ public class UserController {
65 70
      */
66 71
     @GetMapping("bind_list")
67 72
     public TDBAResponse bind_list(BaseUser baseUser){
68
-        return buildSuccess("");
73
+        Objects.requireNonNull(baseUser, "请登录后操作");
74
+        return buildSuccess(buildByPageInfo(new PageInfo(userService.teamList(baseUser.getId()))));
69 75
     }
70 76
 
71 77
     /**
@@ -75,10 +81,23 @@ public class UserController {
75 81
      */
76 82
     @PostMapping("bind_add")
77 83
     public TDBAResponse bind_add(@RequestBody @Validated BindUserAdd param, BaseUser baseUser){
84
+        Objects.requireNonNull(baseUser, "请登录后操作");
85
+        userService.teamAdd(param, baseUser);
86
+        return buildSuccess("");
87
+    }
88
+
89
+    @GetMapping("data_total")
90
+    public TDBAResponse data_total(BaseUser baseUser){
78 91
         return buildSuccess("");
79 92
     }
80 93
 
81
-    public static void main(String[] args) {
82
-        System.out.println(LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8)));
94
+    @GetMapping("data_list")
95
+    public TDBAResponse data_list(@RequestParam(name = "type", required = false) @NotNull(message = "类型不能为空") Integer type, BaseUser baseUser){
96
+        return buildSuccess("");
97
+    }
98
+
99
+    @GetMapping("detail_list")
100
+    public TDBAResponse detail_list(@RequestParam(name = "userId", required = false) Integer userId, BaseUser baseUser){
101
+        return buildSuccess("");
83 102
     }
84 103
 }

+ 9 - 46
src/main/java/com/tdba/cxb/ares/api/model/BaseUser.java

@@ -6,44 +6,19 @@ package com.tdba.cxb.ares.api.model;
6 6
  */
7 7
 public class BaseUser {
8 8
 
9
-    /** 登录用户ID*/
10
-    private Integer loginId;
11
-
12
-
13
-    /** 企业ID*/
14
-    private Integer companyId;
15
-
16 9
     /** 用户ID*/
17
-    private Integer userId;
18
-
19
-    public Integer getLoginId() {
20
-        return loginId;
21
-    }
22
-
23
-    public void setLoginId(Integer loginId) {
24
-        this.loginId = loginId;
25
-    }
26
-
27
-    public Integer getCompanyId() {
28
-        return companyId;
29
-    }
10
+    private Integer id;
30 11
 
31
-    public void setCompanyId(Integer companyId) {
32
-        this.companyId = companyId;
12
+    public Integer getId() {
13
+        return id;
33 14
     }
34 15
 
35
-    public Integer getUserId() {
36
-        return userId;
37
-    }
38
-
39
-    public void setUserId(Integer userId) {
40
-        this.userId = userId;
16
+    public void setId(Integer id) {
17
+        this.id = id;
41 18
     }
42 19
 
43 20
     public static final class BaseUserBuilder {
44
-        private Integer loginId;
45
-        private Integer companyId;
46
-        private Integer userId;
21
+        private Integer id;
47 22
 
48 23
         private BaseUserBuilder() {
49 24
         }
@@ -52,26 +27,14 @@ public class BaseUser {
52 27
             return new BaseUserBuilder();
53 28
         }
54 29
 
55
-        public BaseUserBuilder withLoginId(Integer loginId) {
56
-            this.loginId = loginId;
57
-            return this;
58
-        }
59
-
60
-        public BaseUserBuilder withCompanyId(Integer companyId) {
61
-            this.companyId = companyId;
62
-            return this;
63
-        }
64
-
65
-        public BaseUserBuilder withUserId(Integer userId) {
66
-            this.userId = userId;
30
+        public BaseUserBuilder withId(Integer id) {
31
+            this.id = id;
67 32
             return this;
68 33
         }
69 34
 
70 35
         public BaseUser build() {
71 36
             BaseUser baseUser = new BaseUser();
72
-            baseUser.setLoginId(loginId);
73
-            baseUser.setCompanyId(companyId);
74
-            baseUser.setUserId(userId);
37
+            baseUser.setId(id);
75 38
             return baseUser;
76 39
         }
77 40
     }

+ 79 - 0
src/main/java/com/tdba/cxb/ares/api/model/DataListResp.java

@@ -0,0 +1,79 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+import java.time.LocalDate;
4
+import java.time.LocalDateTime;
5
+
6
+/**
7
+ * @program: order-web
8
+ * @description:
9
+ * @author: libo
10
+ * @create: 2022-06-09 11:03:34
11
+ */
12
+public class DataListResp {
13
+
14
+    /** 普通用户数量*/
15
+    private Integer user_count = 0;
16
+
17
+    /** 大仓会员数量*/
18
+    private Integer warehouse_count = 0;
19
+
20
+    /** 商户数量*/
21
+    private Integer merchant_count = 0;
22
+
23
+    /** 渠道商数量*/
24
+    private Integer channel_count = 0;
25
+
26
+    /** 代理商数量*/
27
+    private Integer agent_count = 0;
28
+
29
+    /** 创建时间*/
30
+    private LocalDate date;
31
+
32
+    public Integer getUser_count() {
33
+        return user_count;
34
+    }
35
+
36
+    public void setUser_count(Integer user_count) {
37
+        this.user_count = user_count;
38
+    }
39
+
40
+    public Integer getWarehouse_count() {
41
+        return warehouse_count;
42
+    }
43
+
44
+    public void setWarehouse_count(Integer warehouse_count) {
45
+        this.warehouse_count = warehouse_count;
46
+    }
47
+
48
+    public Integer getMerchant_count() {
49
+        return merchant_count;
50
+    }
51
+
52
+    public void setMerchant_count(Integer merchant_count) {
53
+        this.merchant_count = merchant_count;
54
+    }
55
+
56
+    public Integer getChannel_count() {
57
+        return channel_count;
58
+    }
59
+
60
+    public void setChannel_count(Integer channel_count) {
61
+        this.channel_count = channel_count;
62
+    }
63
+
64
+    public Integer getAgent_count() {
65
+        return agent_count;
66
+    }
67
+
68
+    public void setAgent_count(Integer agent_count) {
69
+        this.agent_count = agent_count;
70
+    }
71
+
72
+    public LocalDate getDate() {
73
+        return date;
74
+    }
75
+
76
+    public void setDate(LocalDate date) {
77
+        this.date = date;
78
+    }
79
+}

+ 67 - 0
src/main/java/com/tdba/cxb/ares/api/model/DataTotalResp.java

@@ -0,0 +1,67 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+import java.time.LocalDateTime;
4
+
5
+/**
6
+ * @program: order-web
7
+ * @description:
8
+ * @author: libo
9
+ * @create: 2022-06-09 11:00:00
10
+ */
11
+public class DataTotalResp {
12
+
13
+    /** 普通用户数量*/
14
+    private Integer user_count = 0;
15
+
16
+    /** 大仓会员数量*/
17
+    private Integer warehouse_count = 0;
18
+
19
+    /** 商户数量*/
20
+    private Integer merchant_count = 0;
21
+
22
+    /** 渠道商数量*/
23
+    private Integer channel_count = 0;
24
+
25
+    /** 代理商数量*/
26
+    private Integer agent_count = 0;
27
+
28
+    public Integer getUser_count() {
29
+        return user_count;
30
+    }
31
+
32
+    public void setUser_count(Integer user_count) {
33
+        this.user_count = user_count;
34
+    }
35
+
36
+    public Integer getWarehouse_count() {
37
+        return warehouse_count;
38
+    }
39
+
40
+    public void setWarehouse_count(Integer warehouse_count) {
41
+        this.warehouse_count = warehouse_count;
42
+    }
43
+
44
+    public Integer getMerchant_count() {
45
+        return merchant_count;
46
+    }
47
+
48
+    public void setMerchant_count(Integer merchant_count) {
49
+        this.merchant_count = merchant_count;
50
+    }
51
+
52
+    public Integer getChannel_count() {
53
+        return channel_count;
54
+    }
55
+
56
+    public void setChannel_count(Integer channel_count) {
57
+        this.channel_count = channel_count;
58
+    }
59
+
60
+    public Integer getAgent_count() {
61
+        return agent_count;
62
+    }
63
+
64
+    public void setAgent_count(Integer agent_count) {
65
+        this.agent_count = agent_count;
66
+    }
67
+}

+ 43 - 0
src/main/java/com/tdba/cxb/ares/api/model/DetailListResp.java

@@ -0,0 +1,43 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+/**
4
+ * @program: order-web
5
+ * @description:
6
+ * @author: libo
7
+ * @create: 2022-06-09 11:05:00
8
+ */
9
+public class DetailListResp {
10
+
11
+    /** 主键ID*/
12
+    private Integer id;
13
+
14
+    /** 用户名称*/
15
+    private String name;
16
+
17
+    /** 手机号*/
18
+    private String mobile;
19
+
20
+    public Integer getId() {
21
+        return id;
22
+    }
23
+
24
+    public void setId(Integer id) {
25
+        this.id = id;
26
+    }
27
+
28
+    public String getName() {
29
+        return name;
30
+    }
31
+
32
+    public void setName(String name) {
33
+        this.name = name;
34
+    }
35
+
36
+    public String getMobile() {
37
+        return mobile;
38
+    }
39
+
40
+    public void setMobile(String mobile) {
41
+        this.mobile = mobile;
42
+    }
43
+}

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

@@ -0,0 +1,135 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+import java.time.LocalDateTime;
4
+
5
+/**
6
+ * @program: order-web
7
+ * @description: 运营商绑定的团队信息
8
+ * @author: libo
9
+ * @create: 2022-06-09 10:30:42
10
+ */
11
+public class UserBind {
12
+
13
+    /** 主键ID*/
14
+    private Integer id;
15
+
16
+    /** 用户ID*/
17
+    private Integer uid;
18
+
19
+    /** 添加时间*/
20
+    private LocalDateTime createTime;
21
+
22
+    /** 删除标记:0否1是*/
23
+    private Integer delFlag;
24
+
25
+    /** 运营商用户ID(sys_user)*/
26
+    private Integer bindUid;
27
+
28
+    /** 类型:0正常统计1统计时过滤*/
29
+    private Integer type;
30
+
31
+    public Integer getId() {
32
+        return id;
33
+    }
34
+
35
+    public void setId(Integer id) {
36
+        this.id = id;
37
+    }
38
+
39
+    public Integer getUid() {
40
+        return uid;
41
+    }
42
+
43
+    public void setUid(Integer uid) {
44
+        this.uid = uid;
45
+    }
46
+
47
+    public LocalDateTime getCreateTime() {
48
+        return createTime;
49
+    }
50
+
51
+    public void setCreateTime(LocalDateTime createTime) {
52
+        this.createTime = createTime;
53
+    }
54
+
55
+    public Integer getDelFlag() {
56
+        return delFlag;
57
+    }
58
+
59
+    public void setDelFlag(Integer delFlag) {
60
+        this.delFlag = delFlag;
61
+    }
62
+
63
+    public Integer getBindUid() {
64
+        return bindUid;
65
+    }
66
+
67
+    public void setBindUid(Integer bindUid) {
68
+        this.bindUid = bindUid;
69
+    }
70
+
71
+    public Integer getType() {
72
+        return type;
73
+    }
74
+
75
+    public void setType(Integer type) {
76
+        this.type = type;
77
+    }
78
+
79
+    public static final class UserBindBuilder {
80
+        private Integer id;
81
+        private Integer uid;
82
+        private LocalDateTime createTime;
83
+        private Integer delFlag;
84
+        private Integer bindUid;
85
+        private Integer type;
86
+
87
+        private UserBindBuilder() {
88
+        }
89
+
90
+        public static UserBindBuilder anUserBind() {
91
+            return new UserBindBuilder();
92
+        }
93
+
94
+        public UserBindBuilder withId(Integer id) {
95
+            this.id = id;
96
+            return this;
97
+        }
98
+
99
+        public UserBindBuilder withUid(Integer uid) {
100
+            this.uid = uid;
101
+            return this;
102
+        }
103
+
104
+        public UserBindBuilder withCreateTime(LocalDateTime createTime) {
105
+            this.createTime = createTime;
106
+            return this;
107
+        }
108
+
109
+        public UserBindBuilder withDelFlag(Integer delFlag) {
110
+            this.delFlag = delFlag;
111
+            return this;
112
+        }
113
+
114
+        public UserBindBuilder withBindUid(Integer bindUid) {
115
+            this.bindUid = bindUid;
116
+            return this;
117
+        }
118
+
119
+        public UserBindBuilder withType(Integer type) {
120
+            this.type = type;
121
+            return this;
122
+        }
123
+
124
+        public UserBind build() {
125
+            UserBind userBind = new UserBind();
126
+            userBind.setId(id);
127
+            userBind.setUid(uid);
128
+            userBind.setCreateTime(createTime);
129
+            userBind.setDelFlag(delFlag);
130
+            userBind.setBindUid(bindUid);
131
+            userBind.setType(type);
132
+            return userBind;
133
+        }
134
+    }
135
+}

+ 61 - 0
src/main/java/com/tdba/cxb/ares/api/model/UserLoginResp.java

@@ -0,0 +1,61 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+/**
4
+ * @program: order-web
5
+ * @description: 登录返回信息
6
+ * @author: libo
7
+ * @create: 2022-06-08 17:31:41
8
+ */
9
+public class UserLoginResp {
10
+
11
+    /** 令牌*/
12
+    private String token;
13
+
14
+    /** 用户信息*/
15
+    private UserVo user;
16
+
17
+    public String getToken() {
18
+        return token;
19
+    }
20
+
21
+    public void setToken(String token) {
22
+        this.token = token;
23
+    }
24
+
25
+    public UserVo getUser() {
26
+        return user;
27
+    }
28
+
29
+    public void setUser(UserVo user) {
30
+        this.user = user;
31
+    }
32
+
33
+    public static final class UserLoginRespBuilder {
34
+        private String token;
35
+        private UserVo user;
36
+
37
+        private UserLoginRespBuilder() {
38
+        }
39
+
40
+        public static UserLoginRespBuilder anUserLoginResp() {
41
+            return new UserLoginRespBuilder();
42
+        }
43
+
44
+        public UserLoginRespBuilder withToken(String token) {
45
+            this.token = token;
46
+            return this;
47
+        }
48
+
49
+        public UserLoginRespBuilder withUser(UserVo user) {
50
+            this.user = user;
51
+            return this;
52
+        }
53
+
54
+        public UserLoginResp build() {
55
+            UserLoginResp userLoginResp = new UserLoginResp();
56
+            userLoginResp.setToken(token);
57
+            userLoginResp.setUser(user);
58
+            return userLoginResp;
59
+        }
60
+    }
61
+}

+ 120 - 11
src/main/java/com/tdba/cxb/ares/api/model/UserRelate.java

@@ -1,5 +1,6 @@
1 1
 package com.tdba.cxb.ares.api.model;
2 2
 
3
+import java.time.LocalDate;
3 4
 import java.time.LocalDateTime;
4 5
 
5 6
 /**
@@ -10,14 +11,40 @@ import java.time.LocalDateTime;
10 11
  */
11 12
 public class UserRelate {
12 13
 
14
+    /** 主键ID*/
15
+    private Integer id;
16
+
13 17
     /** 用户ID*/
14 18
     private Integer uid;
15 19
 
16
-    /** 关联用户ID*/
20
+    /** 关联用户ID*/
17 21
     private Integer pid;
18 22
 
19
-    /** 创建时间*/
20
-    private LocalDateTime create_time;
23
+    /** 删除标记:0否1是*/
24
+    private Integer delFlag;
25
+
26
+    /** 大仓会员:0否1是*/
27
+    private Integer isDacang;
28
+
29
+    /** 商家:0否1是*/
30
+    private Integer isMerchant;
31
+
32
+    /** 渠道商:0否1是*/
33
+    private Integer isChannel;
34
+
35
+    /** 代理商:0否1是*/
36
+    private Integer isAgent;
37
+
38
+    /** 日期*/
39
+    private LocalDate date;
40
+
41
+    public Integer getId() {
42
+        return id;
43
+    }
44
+
45
+    public void setId(Integer id) {
46
+        this.id = id;
47
+    }
21 48
 
22 49
     public Integer getUid() {
23 50
         return uid;
@@ -35,18 +62,64 @@ public class UserRelate {
35 62
         this.pid = pid;
36 63
     }
37 64
 
38
-    public LocalDateTime getCreate_time() {
39
-        return create_time;
65
+    public Integer getDelFlag() {
66
+        return delFlag;
67
+    }
68
+
69
+    public void setDelFlag(Integer delFlag) {
70
+        this.delFlag = delFlag;
71
+    }
72
+
73
+    public Integer getIsDacang() {
74
+        return isDacang;
75
+    }
76
+
77
+    public void setIsDacang(Integer isDacang) {
78
+        this.isDacang = isDacang;
79
+    }
80
+
81
+    public Integer getIsMerchant() {
82
+        return isMerchant;
83
+    }
84
+
85
+    public void setIsMerchant(Integer isMerchant) {
86
+        this.isMerchant = isMerchant;
87
+    }
88
+
89
+    public Integer getIsChannel() {
90
+        return isChannel;
91
+    }
92
+
93
+    public void setIsChannel(Integer isChannel) {
94
+        this.isChannel = isChannel;
40 95
     }
41 96
 
42
-    public void setCreate_time(LocalDateTime create_time) {
43
-        this.create_time = create_time;
97
+    public Integer getIsAgent() {
98
+        return isAgent;
99
+    }
100
+
101
+    public void setIsAgent(Integer isAgent) {
102
+        this.isAgent = isAgent;
103
+    }
104
+
105
+    public LocalDate getDate() {
106
+        return date;
107
+    }
108
+
109
+    public void setDate(LocalDate date) {
110
+        this.date = date;
44 111
     }
45 112
 
46 113
     public static final class UserRelateBuilder {
114
+        private Integer id;
47 115
         private Integer uid;
48 116
         private Integer pid;
49
-        private LocalDateTime create_time;
117
+        private Integer delFlag;
118
+        private Integer isDacang;
119
+        private Integer isMerchant;
120
+        private Integer isChannel;
121
+        private Integer isAgent;
122
+        private LocalDate date;
50 123
 
51 124
         private UserRelateBuilder() {
52 125
         }
@@ -55,6 +128,11 @@ public class UserRelate {
55 128
             return new UserRelateBuilder();
56 129
         }
57 130
 
131
+        public UserRelateBuilder withId(Integer id) {
132
+            this.id = id;
133
+            return this;
134
+        }
135
+
58 136
         public UserRelateBuilder withUid(Integer uid) {
59 137
             this.uid = uid;
60 138
             return this;
@@ -65,16 +143,47 @@ public class UserRelate {
65 143
             return this;
66 144
         }
67 145
 
68
-        public UserRelateBuilder withCreate_time(LocalDateTime create_time) {
69
-            this.create_time = create_time;
146
+        public UserRelateBuilder withDelFlag(Integer delFlag) {
147
+            this.delFlag = delFlag;
148
+            return this;
149
+        }
150
+
151
+        public UserRelateBuilder withIsDacang(Integer isDacang) {
152
+            this.isDacang = isDacang;
153
+            return this;
154
+        }
155
+
156
+        public UserRelateBuilder withIsMerchant(Integer isMerchant) {
157
+            this.isMerchant = isMerchant;
158
+            return this;
159
+        }
160
+
161
+        public UserRelateBuilder withIsChannel(Integer isChannel) {
162
+            this.isChannel = isChannel;
163
+            return this;
164
+        }
165
+
166
+        public UserRelateBuilder withIsAgent(Integer isAgent) {
167
+            this.isAgent = isAgent;
168
+            return this;
169
+        }
170
+
171
+        public UserRelateBuilder withDate(LocalDate date) {
172
+            this.date = date;
70 173
             return this;
71 174
         }
72 175
 
73 176
         public UserRelate build() {
74 177
             UserRelate userRelate = new UserRelate();
178
+            userRelate.setId(id);
75 179
             userRelate.setUid(uid);
76 180
             userRelate.setPid(pid);
77
-            userRelate.setCreate_time(create_time);
181
+            userRelate.setDelFlag(delFlag);
182
+            userRelate.setIsDacang(isDacang);
183
+            userRelate.setIsMerchant(isMerchant);
184
+            userRelate.setIsChannel(isChannel);
185
+            userRelate.setIsAgent(isAgent);
186
+            userRelate.setDate(date);
78 187
             return userRelate;
79 188
         }
80 189
     }

+ 133 - 0
src/main/java/com/tdba/cxb/ares/api/model/UserVo.java

@@ -0,0 +1,133 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+/**
4
+ * @program: order-web
5
+ * @description: 登录用户
6
+ * @author: libo
7
+ * @create: 2022-06-08 17:32:49
8
+ */
9
+public class UserVo {
10
+
11
+    /** 主键ID*/
12
+    private Integer id;
13
+
14
+    /** 用户名称*/
15
+    private String name;
16
+
17
+    /** 手机号*/
18
+    private String mobile;
19
+
20
+    /** 用户头像*/
21
+    private String avatar;
22
+
23
+    /** 状态*/
24
+    private Integer status;
25
+
26
+    /** 团队名称*/
27
+    private String teamName;
28
+
29
+    public Integer getId() {
30
+        return id;
31
+    }
32
+
33
+    public void setId(Integer id) {
34
+        this.id = id;
35
+    }
36
+
37
+    public String getName() {
38
+        return name;
39
+    }
40
+
41
+    public void setName(String name) {
42
+        this.name = name;
43
+    }
44
+
45
+    public String getMobile() {
46
+        return mobile;
47
+    }
48
+
49
+    public void setMobile(String mobile) {
50
+        this.mobile = mobile;
51
+    }
52
+
53
+    public String getAvatar() {
54
+        return avatar;
55
+    }
56
+
57
+    public void setAvatar(String avatar) {
58
+        this.avatar = avatar;
59
+    }
60
+
61
+    public Integer getStatus() {
62
+        return status;
63
+    }
64
+
65
+    public void setStatus(Integer status) {
66
+        this.status = status;
67
+    }
68
+
69
+    public String getTeamName() {
70
+        return teamName;
71
+    }
72
+
73
+    public void setTeamName(String teamName) {
74
+        this.teamName = teamName;
75
+    }
76
+
77
+    public static final class UserVoBuilder {
78
+        private Integer id;
79
+        private String name;
80
+        private String mobile;
81
+        private String avatar;
82
+        private Integer status;
83
+        private String teamName;
84
+
85
+        private UserVoBuilder() {
86
+        }
87
+
88
+        public static UserVoBuilder anUserVo() {
89
+            return new UserVoBuilder();
90
+        }
91
+
92
+        public UserVoBuilder withId(Integer id) {
93
+            this.id = id;
94
+            return this;
95
+        }
96
+
97
+        public UserVoBuilder withName(String name) {
98
+            this.name = name;
99
+            return this;
100
+        }
101
+
102
+        public UserVoBuilder withMobile(String mobile) {
103
+            this.mobile = mobile;
104
+            return this;
105
+        }
106
+
107
+        public UserVoBuilder withAvatar(String avatar) {
108
+            this.avatar = avatar;
109
+            return this;
110
+        }
111
+
112
+        public UserVoBuilder withStatus(Integer status) {
113
+            this.status = status;
114
+            return this;
115
+        }
116
+
117
+        public UserVoBuilder withTeamName(String teamName) {
118
+            this.teamName = teamName;
119
+            return this;
120
+        }
121
+
122
+        public UserVo build() {
123
+            UserVo userVo = new UserVo();
124
+            userVo.setId(id);
125
+            userVo.setName(name);
126
+            userVo.setMobile(mobile);
127
+            userVo.setAvatar(avatar);
128
+            userVo.setStatus(status);
129
+            userVo.setTeamName(teamName);
130
+            return userVo;
131
+        }
132
+    }
133
+}

+ 25 - 0
src/main/java/com/tdba/cxb/ares/api/repository/UserBindMapper.java

@@ -0,0 +1,25 @@
1
+package com.tdba.cxb.ares.api.repository;
2
+
3
+import com.tdba.cxb.ares.api.model.UserBind;
4
+import org.apache.ibatis.annotations.Mapper;
5
+import org.apache.ibatis.annotations.Param;
6
+
7
+import java.util.List;
8
+
9
+/**
10
+ * @program: order-web
11
+ * @description:
12
+ * @author: libo
13
+ * @create: 2022-06-09 10:32:52
14
+ */
15
+@Mapper
16
+public interface UserBindMapper {
17
+
18
+    int insertSelective(UserBind record);
19
+
20
+    int updateByPrimaryKeySelective(UserBind record);
21
+
22
+    UserBind selectByUid(@Param("uid") Integer uid);
23
+
24
+    List<Integer> selectUid(@Param("bindUid") Integer bindUid);
25
+}

+ 9 - 0
src/main/java/com/tdba/cxb/ares/api/repository/UserMapper.java

@@ -1,6 +1,7 @@
1 1
 package com.tdba.cxb.ares.api.repository;
2 2
 
3 3
 import com.tdba.cxb.ares.api.model.UserDto;
4
+import com.tdba.cxb.ares.api.model.UserVo;
4 5
 import org.apache.ibatis.annotations.Mapper;
5 6
 import org.apache.ibatis.annotations.Param;
6 7
 
@@ -36,4 +37,12 @@ public interface UserMapper {
36 37
 
37 38
     List<UserDto> selectAgent(@Param("beginTime")Long beginTime,
38 39
                                @Param("endTime")Long endTime);
40
+
41
+    UserVo selectByAccount(@Param("mobile") String mobile);
42
+
43
+    UserVo selectByUid(@Param("uid") Integer uid);
44
+
45
+    List<UserVo> selectByBindUid(@Param("bindUid") Integer bindUid);
46
+
47
+    UserVo selectByAccountForSimple(@Param("mobile") String mobile);
39 48
 }

+ 3 - 0
src/main/java/com/tdba/cxb/ares/api/repository/UserRelateMapper.java

@@ -30,4 +30,7 @@ public interface UserRelateMapper {
30 30
 
31 31
     Integer updateByUid(@Param("userType") Integer userType,
32 32
                         @Param("uid") Integer uid);
33
+
34
+    Integer countByUid(@Param("uid") Integer uid,
35
+                       @Param("pidList") List<Integer> pidList);
33 36
 }

+ 107 - 5
src/main/java/com/tdba/cxb/ares/api/service/UserService.java

@@ -1,16 +1,17 @@
1 1
 package com.tdba.cxb.ares.api.service;
2 2
 
3
-import com.tdba.cxb.ares.api.model.UserCount;
4
-import com.tdba.cxb.ares.api.model.UserDto;
5
-import com.tdba.cxb.ares.api.model.UserRelate;
6
-import com.tdba.cxb.ares.api.model.UserTypeEnum;
3
+import com.tdba.cxb.ares.api.model.*;
4
+import com.tdba.cxb.ares.api.repository.UserBindMapper;
7 5
 import com.tdba.cxb.ares.api.repository.UserCountMapper;
8 6
 import com.tdba.cxb.ares.api.repository.UserMapper;
9 7
 import com.tdba.cxb.ares.api.repository.UserRelateMapper;
8
+import com.tdba.cxb.ares.api.util.JwtUtil;
10 9
 import com.tdba.cxb.ares.api.util.TDBAException;
11 10
 import org.slf4j.Logger;
12 11
 import org.slf4j.LoggerFactory;
12
+import org.springframework.data.redis.core.RedisTemplate;
13 13
 import org.springframework.stereotype.Service;
14
+import org.springframework.transaction.annotation.Transactional;
14 15
 import org.springframework.util.CollectionUtils;
15 16
 
16 17
 import javax.annotation.Resource;
@@ -20,6 +21,7 @@ import java.time.LocalTime;
20 21
 import java.time.ZoneOffset;
21 22
 import java.util.ArrayList;
22 23
 import java.util.List;
24
+import java.util.Objects;
23 25
 
24 26
 /**
25 27
  * @program: order-web
@@ -41,6 +43,9 @@ public class UserService {
41 43
     @Resource
42 44
     private UserRelateMapper userRelateMapper;
43 45
 
46
+    @Resource
47
+    private UserBindMapper userBindMapper;
48
+
44 49
     public void createSpreadInfo(LocalDate localDate){
45 50
 
46 51
         LocalDateTime currentTime = LocalDateTime.now();
@@ -63,11 +68,13 @@ public class UserService {
63 68
                     relateList.add(UserRelate.UserRelateBuilder.anUserRelate()
64 69
                             .withUid(currentId)
65 70
                             .withPid(row.getUid())
71
+                            .withDate(localDate)
66 72
                             .build());
67 73
                     for(int j = i + 1; j < idlist.size(); j++){
68 74
                         relateList.add(UserRelate.UserRelateBuilder.anUserRelate()
69 75
                                 .withUid(idlist.get(j))
70 76
                                 .withPid(currentId)
77
+                                .withDate(localDate)
71 78
                                 .build());
72 79
                     }
73 80
                 }
@@ -79,6 +86,7 @@ public class UserService {
79 86
                 relateList.add(UserRelate.UserRelateBuilder.anUserRelate()
80 87
                         .withUid(row.getUid())
81 88
                         .withPid(row.getSpread_uid())
89
+                        .withDate(localDate)
82 90
                         .build());
83 91
                 //推荐人
84 92
                 resultList.add(UserCount.UserCountBuilder.anUserCount()
@@ -297,4 +305,98 @@ public class UserService {
297 305
         }
298 306
         return result;
299 307
     }
300
-}
308
+
309
+
310
+    @Resource
311
+    private RedisTemplate redisTemplate;
312
+
313
+    /**
314
+     * 登录
315
+     * @param param
316
+     * @return
317
+     */
318
+    public UserLoginResp login(OperatorLoginReq param){
319
+        if(!param.getCode().equals(redisTemplate.opsForValue().get("api.auth.sms." + param.getMobile()))){
320
+            throw new TDBAException("短信验证码有误");
321
+        }
322
+        redisTemplate.delete("api.auth.sms." + param.getMobile());
323
+
324
+        UserVo userVo = userMapper.selectByAccount(param.getMobile());
325
+        Objects.requireNonNull(userVo, "用户信息不存在");
326
+
327
+        return UserLoginResp.UserLoginRespBuilder.anUserLoginResp()
328
+                .withUser(userVo)
329
+                .withToken(JwtUtil.create(userVo.getId())).build();
330
+    }
331
+
332
+    /**
333
+     * 用户详情
334
+     * @param id
335
+     * @return
336
+     */
337
+    public UserVo info(Integer id){
338
+        UserVo userVo = userMapper.selectByUid(id);
339
+        Objects.requireNonNull(userVo, "用户信息不存在");
340
+        return userVo;
341
+    }
342
+
343
+    /**
344
+     * 团队列表
345
+     * @param id
346
+     * @return
347
+     */
348
+    public List<UserVo> teamList(Integer id){
349
+        List<UserVo> result = userMapper.selectByBindUid(id);
350
+        if(result.size() < 20){
351
+            int length = 20 - result.size();
352
+            for(int i = 0; i < length; i++){
353
+                result.add(UserVo.UserVoBuilder.anUserVo()
354
+                        .withAvatar("")
355
+                        .withId(0)
356
+                        .withMobile("")
357
+                        .withStatus(0)
358
+                        .withTeamName("")
359
+                        .build());
360
+            }
361
+        }
362
+        return result;
363
+    }
364
+
365
+    /**
366
+     * 新增团队信息
367
+     * @param param
368
+     * @param baseUser
369
+     */
370
+    @Transactional
371
+    public void teamAdd(BindUserAdd param, BaseUser baseUser){
372
+        if(!param.getCode().equals(redisTemplate.opsForValue().get("api.auth.sms." + param.getMobile()))){
373
+            throw new TDBAException("短信验证码有误");
374
+        }
375
+        redisTemplate.delete("api.auth.sms." + param.getMobile());
376
+
377
+        UserVo userVo = userMapper.selectByAccountForSimple(param.getMobile());
378
+        Objects.requireNonNull(userVo, "该手机号未在【储蓄宝App】内注册,请先注册后再绑定");
379
+
380
+        if(userVo.getId() == baseUser.getId()){
381
+            throw new TDBAException("运营商不可添加自身为团队成员");
382
+        }
383
+
384
+        UserBind oldUserBind = userBindMapper.selectByUid(userVo.getId());
385
+        if(oldUserBind != null){
386
+            throw new TDBAException((oldUserBind.getBindUid() == baseUser.getId())? "手机号已添加,请勿重复操作": "该手机号已被其他运营商绑定");
387
+        }
388
+
389
+        List<Integer> oldUidList = userBindMapper.selectUid(baseUser.getId());
390
+        boolean isFilter = false;
391
+        if(!oldUidList.isEmpty()){
392
+            if(0 < userRelateMapper.countByUid(userVo.getId(), oldUidList)){
393
+                isFilter = true;
394
+            }
395
+        }
396
+        userBindMapper.insertSelective(UserBind.UserBindBuilder.anUserBind()
397
+                .withBindUid(baseUser.getId())
398
+                .withUid(userVo.getId())
399
+                .withCreateTime(LocalDateTime.now())
400
+                .withType(isFilter? 1: 0).build());
401
+    }
402
+}

+ 15 - 18
src/main/java/com/tdba/cxb/ares/api/util/BaseUserArgumentResolver.java

@@ -9,6 +9,7 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolver;
9 9
 import org.springframework.web.method.support.ModelAndViewContainer;
10 10
 
11 11
 import javax.servlet.http.HttpServletRequest;
12
+import java.util.List;
12 13
 
13 14
 /**
14 15
  * 注入当前登录的用户信息
@@ -30,24 +31,20 @@ public class BaseUserArgumentResolver implements HandlerMethodArgumentResolver {
30 31
                                   ModelAndViewContainer mavContainer,
31 32
                                   NativeWebRequest webRequest,
32 33
                                   WebDataBinderFactory binderFactory)  {
33
-
34
-//        if((null != parameter) && parameter.getParameterType().equals(BaseUser.class)){
35
-//            String token = webRequest.getNativeRequest(HttpServletRequest.class).getHeader(BHConstant.HEADER_TOKEN);
36
-//            if (StringUtils.hasLength(token)) {
37
-//                return BaseUser.BaseUserBuilder.aBaseUser()
38
-//                        .loginId(JwtUtil.getClaimOfInt(token, BaseConstant.ACCOUNT))
39
-//                        .companyType(CompanyTypeEnum.values()[resolveNull(JwtUtil.getClaimOfInt(token, BaseConstant.COMPANY_TYPE))])
40
-//                        .companyId(JwtUtil.getClaimOfInt(token, BaseConstant.COMPANY_ID))
41
-//                        .userId(JwtUtil.getClaimOfInt(token, BaseConstant.USER_ID))
42
-//                        .userType(UserTypeEnum.values()[resolveNull(JwtUtil.getClaimOfInt(token, BaseConstant.USER_TYPE))])
43
-//                        .build();
44
-//            }
45
-//        }
46
-
34
+        if((null != parameter) && parameter.getParameterType().equals(BaseUser.class)){
35
+            String token = webRequest.getNativeRequest(HttpServletRequest.class).getHeader("X-Token");
36
+            BaseUser baseuser = null;
37
+            if (StringUtils.hasLength(token)) {
38
+                baseuser = BaseUser.BaseUserBuilder.aBaseUser()
39
+                        .withId(JwtUtil.resolveUserId(token))
40
+                        .build();
41
+            }
42
+
43
+            if(null == baseuser){
44
+                throw new TDBAException("请登录");
45
+            }
46
+            return baseuser;
47
+        }
47 48
         return null;
48 49
     }
49
-
50
-    private int resolveNull(Integer src){
51
-        return (null == src)? 0: src.intValue();
52
-    }
53 50
 }

+ 80 - 0
src/main/java/com/tdba/cxb/ares/api/util/JwtUtil.java

@@ -0,0 +1,80 @@
1
+package com.tdba.cxb.ares.api.util;
2
+
3
+import com.alibaba.fastjson2.JSONArray;
4
+import com.alibaba.fastjson2.JSONObject;
5
+import com.auth0.jwt.JWT;
6
+import com.auth0.jwt.algorithms.Algorithm;
7
+import com.auth0.jwt.exceptions.TokenExpiredException;
8
+import com.auth0.jwt.interfaces.DecodedJWT;
9
+import org.slf4j.Logger;
10
+import org.slf4j.LoggerFactory;
11
+import org.springframework.util.Assert;
12
+import org.springframework.util.StringUtils;
13
+
14
+import java.time.LocalDateTime;
15
+import java.time.ZoneOffset;
16
+import java.util.List;
17
+
18
+/**
19
+ * @program: admin-web
20
+ * @description: jwt工具类
21
+ * @author: libo
22
+ * @create: 2022-06-01 16:56:13
23
+ */
24
+public class JwtUtil {
25
+
26
+
27
+    private static Logger log = LoggerFactory.getLogger(JwtUtil.class);
28
+
29
+    public static Integer resolveUserId(String token){
30
+        DecodedJWT jwt = JWT.decode(token);
31
+        List list = jwt.getClaim("jti").as(List.class);
32
+        log.info("{}", list);
33
+        return Integer.valueOf(list.get(0).toString());
34
+    }
35
+
36
+    private static String SECRET_KEY = "VliwSuvne";
37
+
38
+
39
+    /** 有效期 秒,默认为7天 */
40
+    public final static int Access_Expire = 86400 * 7;
41
+
42
+    /**
43
+     * 验证 令牌是否有效
44
+     * 签名验证, 过期时间戳验证
45
+     * @param token
46
+     * @return
47
+     */
48
+    public static boolean verify(String token){
49
+
50
+        if(!StringUtils.hasLength(token)){
51
+            return false;
52
+        }
53
+
54
+        try{
55
+            return null != JWT.require(Algorithm.HMAC256(SECRET_KEY)).build().verify(token);
56
+        }catch (TokenExpiredException e){
57
+            log.debug("token过期, {}", token);
58
+            return false;
59
+        }
60
+
61
+
62
+    }
63
+
64
+    /**
65
+     * 生成 令牌
66
+     * @return
67
+     */
68
+    public static String create(Integer uid){
69
+
70
+        Long timestamp = LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8));
71
+        return JWT.create()
72
+                .withClaim("iss", "127.0.0.1")
73
+                .withClaim("aud", "127.0.0.1")
74
+                .withClaim("exp", timestamp + Access_Expire)
75
+                .withClaim("nbf", timestamp)
76
+                .withClaim("iat", timestamp)
77
+                .withClaim("jti", JSONArray.of(uid, "user"))
78
+                .sign(Algorithm.HMAC256(SECRET_KEY));
79
+    }
80
+}

+ 22 - 0
src/main/java/com/tdba/cxb/ares/api/util/Sensitive.java

@@ -0,0 +1,22 @@
1
+package com.tdba.cxb.ares.api.util;
2
+
3
+import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
4
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
5
+
6
+import java.lang.annotation.ElementType;
7
+import java.lang.annotation.Retention;
8
+import java.lang.annotation.RetentionPolicy;
9
+import java.lang.annotation.Target;
10
+
11
+/**
12
+ * @program: order-web
13
+ * @description: 脱敏
14
+ * @author: libo
15
+ * @create: 2022-06-08 17:22:04
16
+ */
17
+@Retention(RetentionPolicy.RUNTIME)
18
+@Target(ElementType.FIELD)
19
+@JacksonAnnotationsInside
20
+@JsonSerialize(using = SensitiveSerializer.class)
21
+public @interface Sensitive {
22
+}

+ 61 - 0
src/main/java/com/tdba/cxb/ares/api/util/SensitiveSerializer.java

@@ -0,0 +1,61 @@
1
+package com.tdba.cxb.ares.api.util;
2
+
3
+import com.fasterxml.jackson.core.JacksonException;
4
+import com.fasterxml.jackson.core.JsonGenerator;
5
+import com.fasterxml.jackson.core.JsonParser;
6
+import com.fasterxml.jackson.core.JsonProcessingException;
7
+import com.fasterxml.jackson.databind.*;
8
+import com.fasterxml.jackson.databind.ser.ContextualSerializer;
9
+import org.slf4j.Logger;
10
+import org.slf4j.LoggerFactory;
11
+import org.springframework.util.StringUtils;
12
+
13
+import java.io.IOException;
14
+import java.util.HashMap;
15
+import java.util.Map;
16
+import java.util.Objects;
17
+
18
+/**
19
+ * @program: order-web
20
+ * @description: 脱敏
21
+ * @author: libo
22
+ * @create: 2022-06-08 17:22:57
23
+ */
24
+public class SensitiveSerializer extends JsonSerializer<String> implements ContextualSerializer {
25
+
26
+    private static Logger log = LoggerFactory.getLogger(SensitiveSerializer.class);
27
+
28
+    @Override
29
+    public void serialize(String value, JsonGenerator jgen, SerializerProvider provider) {
30
+        try {
31
+            String result = null;
32
+            if(StringUtils.hasText(value)) {
33
+                char[] array = value.toCharArray();
34
+                array[3] = 'x';
35
+                array[4] = 'x';
36
+                array[5] = 'x';
37
+                jgen.writeString(new String(array));
38
+            }
39
+        } catch (Exception e) {
40
+            log.error("脱敏处理异常 value = {}", value, e);
41
+        }
42
+    }
43
+
44
+    @Override
45
+    public JsonSerializer<?> createContextual(SerializerProvider serializerProvider, BeanProperty beanProperty) throws JsonMappingException {
46
+
47
+        if (beanProperty != null) { //为空直接跳过
48
+            if (Objects.equals(beanProperty.getType().getRawClass(), String.class)) { //非String类直接跳过
49
+                Sensitive image = beanProperty.getAnnotation(Sensitive.class);
50
+                if (image == null) {
51
+                    image = beanProperty.getContextAnnotation(Sensitive.class);
52
+                }
53
+                if (image != null) { //如果能得到注解,就将注解的value传入ImageURLSerialize
54
+                    return new SensitiveSerializer();
55
+                }
56
+            }
57
+            return serializerProvider.findValueSerializer(beanProperty.getType(), beanProperty);
58
+        }
59
+        return serializerProvider.findNullValueSerializer(beanProperty);
60
+    }
61
+}

+ 2 - 0
src/main/java/module-info.java

@@ -23,4 +23,6 @@ open module order.web {
23 23
     requires org.mybatis;
24 24
     requires spring.aop;
25 25
     requires jdk.unsupported;
26
+    requires com.alibaba.fastjson2;
27
+    requires spring.tx;
26 28
 }

+ 74 - 0
src/main/resources/mapper/UserBindMapper.xml

@@ -0,0 +1,74 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="com.tdba.cxb.ares.api.repository.UserBindMapper">
4
+
5
+    <insert id="insertSelective">
6
+        insert into user_bind
7
+        <trim prefix="(" suffix=")" suffixOverrides=",">
8
+            <if test="null != uid">
9
+                uid,
10
+            </if>
11
+            <if test="null != createTime">
12
+                create_time,
13
+            </if>
14
+            <if test="null != delFlag">
15
+                del_flag,
16
+            </if>
17
+            <if test="null != bindUid">
18
+                bind_uid,
19
+            </if>
20
+            <if test="null != type">
21
+                type,
22
+            </if>
23
+        </trim>
24
+
25
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
26
+            <if test="null != uid">
27
+                #{ uid },
28
+            </if>
29
+            <if test="null != createTime">
30
+                #{ createTime },
31
+            </if>
32
+            <if test="null != delFlag">
33
+                #{ delFlag },
34
+            </if>
35
+            <if test="null != bindUid">
36
+                #{ bindUid },
37
+            </if>
38
+            <if test="null != type">
39
+                #{ type },
40
+            </if>
41
+        </trim>
42
+    </insert>
43
+
44
+    <update id="updateByPrimaryKeySelective">
45
+        update user_bind
46
+        <set>
47
+            <if test="null != uid">
48
+                uid = #{ uid },
49
+            </if>
50
+            <if test="null != createTime">
51
+                create_time = #{ createTime },
52
+            </if>
53
+            <if test="null != delFlag">
54
+                del_flag = #{ delFlag },
55
+            </if>
56
+            <if test="null != bindUid">
57
+                bind_uid = #{ bindUid },
58
+            </if>
59
+            <if test="null != type">
60
+                type = #{ type },
61
+            </if>
62
+        </set>
63
+        where id = #{id}
64
+    </update>
65
+
66
+    <select id="selectByUid" resultType="com.tdba.cxb.ares.api.model.UserBind">
67
+        select * from user_bind where del_flag = 0 and uid = #{uid}
68
+    </select>
69
+
70
+    <select id="selectUid" resultType="java.lang.Integer">
71
+        select uid from user_bind where del_flag = 0 and type = 0 and bind_uid = #{bindUid}
72
+    </select>
73
+
74
+</mapper>

+ 68 - 0
src/main/resources/mapper/UserMapper.xml

@@ -82,4 +82,72 @@
82 82
             and u.test_user = 0
83 83
             and u.spread_uid > 0
84 84
     </select>
85
+
86
+    <select id="selectByAccount" resultType="com.tdba.cxb.ares.api.model.UserVo">
87
+        select
88
+            u.account 'mobile',
89
+                u.uid 'id',
90
+                u.nickname 'name',
91
+                u.avatar
92
+        from
93
+            user_operator uo
94
+                left join
95
+            rrx_user u
96
+            on uo.uid = u.uid
97
+        where
98
+            uo.del_flag = 0
99
+          and u.status = 1
100
+          and  u.account = #{mobile}
101
+        limit 1
102
+    </select>
103
+
104
+    <select id="selectByUid" resultType="com.tdba.cxb.ares.api.model.UserVo">
105
+        select
106
+            u.account 'mobile',
107
+                u.uid 'id',
108
+                u.nickname 'name',
109
+                u.avatar
110
+        from
111
+            user_operator uo
112
+                left join
113
+            rrx_user u
114
+            on uo.uid = u.uid
115
+        where
116
+            uo.del_flag = 0
117
+          and u.status = 1
118
+          and  u.uid = #{uid}
119
+            limit 1
120
+    </select>
121
+
122
+    <select id="selectByBindUid" resultType="com.tdba.cxb.ares.api.model.UserVo">
123
+        select
124
+            u.account 'mobile',
125
+                u.uid 'id',
126
+                u.nickname 'name',
127
+                u.avatar,
128
+            '1' as 'status'
129
+        from
130
+            user_bind ub
131
+                left join
132
+            rrx_user u
133
+            on ub.uid = u.uid
134
+        where
135
+            ub.del_flag = 0
136
+          and u.test_user = 0
137
+          and ub.bind_uid = #{bindUid}
138
+    </select>
139
+
140
+    <select id="selectByAccountForSimple" resultType="com.tdba.cxb.ares.api.model.UserVo">
141
+        select
142
+            u.account 'mobile',
143
+                u.uid 'id',
144
+                u.nickname 'name',
145
+                u.avatar
146
+        from
147
+            rrx_user u
148
+        where
149
+            u.test_user = 0
150
+          and u.account = #{mobile}
151
+        limit 1
152
+    </select>
85 153
 </mapper>

+ 74 - 8
src/main/resources/mapper/UserRelateMapper.xml

@@ -1,7 +1,6 @@
1 1
 <?xml version="1.0" encoding="UTF-8" ?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3 3
 <mapper namespace="com.tdba.cxb.ares.api.repository.UserRelateMapper">
4
-
5 4
     <insert id="insertSelective">
6 5
         insert into user_relate
7 6
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -11,9 +10,24 @@
11 10
             <if test="null != pid">
12 11
                 pid,
13 12
             </if>
14
-            <if test="null != del_flag">
13
+            <if test="null != delFlag">
15 14
                 del_flag,
16 15
             </if>
16
+            <if test="null != isDacang">
17
+                is_dacang,
18
+            </if>
19
+            <if test="null != isMerchant">
20
+                is_merchant,
21
+            </if>
22
+            <if test="null != isChannel">
23
+                is_channel,
24
+            </if>
25
+            <if test="null != isAgent">
26
+                is_agent,
27
+            </if>
28
+            <if test="null != date">
29
+                date,
30
+            </if>
17 31
         </trim>
18 32
 
19 33
         <trim prefix="values (" suffix=")" suffixOverrides=",">
@@ -23,8 +37,23 @@
23 37
             <if test="null != pid">
24 38
                 #{ pid },
25 39
             </if>
26
-            <if test="null != del_flag">
27
-                #{del_flag},
40
+            <if test="null != delFlag">
41
+                #{ delFlag },
42
+            </if>
43
+            <if test="null != isDacang">
44
+                #{ isDacang },
45
+            </if>
46
+            <if test="null != isMerchant">
47
+                #{ isMerchant },
48
+            </if>
49
+            <if test="null != isChannel">
50
+                #{ isChannel },
51
+            </if>
52
+            <if test="null != isAgent">
53
+                #{ isAgent },
54
+            </if>
55
+            <if test="null != date">
56
+                #{ date },
28 57
             </if>
29 58
         </trim>
30 59
     </insert>
@@ -38,8 +67,23 @@
38 67
             <if test="null != pid">
39 68
                 pid = #{ pid },
40 69
             </if>
41
-            <if test="null != del_flag">
42
-                del_flag = #{del_flag},
70
+            <if test="null != delFlag">
71
+                del_flag = #{ delFlag },
72
+            </if>
73
+            <if test="null != isDacang">
74
+                is_dacang = #{ isDacang },
75
+            </if>
76
+            <if test="null != isMerchant">
77
+                is_merchant = #{ isMerchant },
78
+            </if>
79
+            <if test="null != isChannel">
80
+                is_channel = #{ isChannel },
81
+            </if>
82
+            <if test="null != isAgent">
83
+                is_agent = #{ isAgent },
84
+            </if>
85
+            <if test="null != date">
86
+                date = #{ date },
43 87
             </if>
44 88
         </set>
45 89
         where id = #{id}
@@ -49,12 +93,22 @@
49 93
         insert into user_relate
50 94
         (
51 95
         uid,
52
-        pid      )
96
+        pid,
97
+        is_dacang,
98
+        is_merchant,
99
+        is_channel,
100
+        is_agent,
101
+        date        )
53 102
         values
54 103
         <foreach collection="list" separator="," item="row">
55 104
             (
56 105
             #{row.uid },
57
-            #{row.pid }       )
106
+            #{row.pid },
107
+            #{row.isDacang },
108
+            #{row.isMerchant },
109
+            #{row.isChannel },
110
+            #{row.isAgent },
111
+            #{row.date }            )
58 112
         </foreach>
59 113
     </insert>
60 114
 
@@ -79,4 +133,16 @@
79 133
 
80 134
         where uid = #{uid}
81 135
     </select>
136
+
137
+    <select id="countByUid" resultType="java.lang.Integer">
138
+        select
139
+            count(1)
140
+        from
141
+            user_relate
142
+        where
143
+            del_flag = 0
144
+          and uid = #{uid}
145
+          and pid in
146
+        <foreach collection="pidList" item="item" open="(" separator="," close=")"></foreach>
147
+    </select>
82 148
 </mapper>