libo il y a 4 ans
Parent
commit
9fee8efa2d

+ 0 - 20
src/main/java/com/tdba/cxb/ares/api/config/CorsConfig.java

@@ -1,20 +0,0 @@
1
-package com.tdba.cxb.ares.api.config;
2
-
3
-import org.springframework.web.servlet.config.annotation.CorsRegistry;
4
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
5
-
6
-/**
7
- * @program: order-web
8
- * @description:
9
- * @author: libo
10
- * @create: 2022-06-10 11:13:38
11
- */
12
-public class CorsConfig extends WebMvcConfigurerAdapter {
13
-
14
-    @Override
15
-    public void addCorsMappings(CorsRegistry registry) {
16
-        registry.addMapping("/**").allowedOrigins("*")
17
-                .allowedMethods("GET", "HEAD", "POST","PUT", "DELETE", "OPTIONS")
18
-                .allowCredentials(true).maxAge(3600);
19
-    }
20
-}

+ 0 - 41
src/main/java/com/tdba/cxb/ares/api/config/CorsFilter.java

@@ -1,41 +0,0 @@
1
-package com.tdba.cxb.ares.api.config;
2
-
3
-import org.springframework.stereotype.Component;
4
-
5
-import javax.servlet.*;
6
-import javax.servlet.annotation.WebFilter;
7
-import javax.servlet.http.HttpServletRequest;
8
-import javax.servlet.http.HttpServletResponse;
9
-import java.io.IOException;
10
-
11
-/**
12
- * @program: order-web
13
- * @description:
14
- * @author: libo
15
- * @create: 2022-06-10 11:11:28
16
- */
17
-@Component
18
-@WebFilter(urlPatterns = "/*", filterName = "CorsFilter")
19
-public class CorsFilter implements Filter {
20
-
21
-    @Override
22
-    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
23
-        HttpServletResponse response = (HttpServletResponse) res;
24
-        HttpServletRequest reqs = (HttpServletRequest) req;
25
-        String curOrigin = reqs.getHeader("Origin");
26
-        response.setHeader("Access-Control-Allow-Origin", "*");
27
-//        response.setHeader("Access-Control-Allow-Credentials", "true");
28
-        response.setHeader("Access-Control-Allow-Methods", "GET,POST,PATCH,PUT,DELETE,OPTIONS,DELETE");
29
-        response.setHeader("Access-Control-Allow-Headers", " X-Token, user-token, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-Requested-With");
30
-        chain.doFilter(req, res);
31
-    }
32
-
33
-
34
-    @Override
35
-    public void init(FilterConfig filterConfig) {
36
-    }
37
-
38
-
39
-    @Override
40
-    public void destroy() {}
41
-}

+ 1 - 0
src/main/java/com/tdba/cxb/ares/api/config/FIlterConfig.java

@@ -14,6 +14,7 @@ import java.util.List;
14 14
 /**
15 15
  * 过滤器配置
16 16
  */
17
+@Configuration
17 18
 public class FIlterConfig {
18 19
 
19 20
     private CorsConfiguration buildConfig() {

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

@@ -7,10 +7,7 @@ import com.tdba.cxb.ares.api.service.UserService;
7 7
 import com.tdba.cxb.ares.api.util.DateUtil;
8 8
 import com.tdba.cxb.ares.api.util.TDBAController;
9 9
 import org.springframework.validation.annotation.Validated;
10
-import org.springframework.web.bind.annotation.GetMapping;
11
-import org.springframework.web.bind.annotation.PostMapping;
12
-import org.springframework.web.bind.annotation.RequestBody;
13
-import org.springframework.web.bind.annotation.RequestParam;
10
+import org.springframework.web.bind.annotation.*;
14 11
 
15 12
 import javax.annotation.Resource;
16 13
 import javax.validation.constraints.NotNull;

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

@@ -28,6 +28,9 @@ public class UserBind {
28 28
     /** 类型:0正常统计1统计时过滤*/
29 29
     private Integer type;
30 30
 
31
+    /** 名称*/
32
+    private String name;
33
+
31 34
     public Integer getId() {
32 35
         return id;
33 36
     }
@@ -76,6 +79,14 @@ public class UserBind {
76 79
         this.type = type;
77 80
     }
78 81
 
82
+    public String getName() {
83
+        return name;
84
+    }
85
+
86
+    public void setName(String name) {
87
+        this.name = name;
88
+    }
89
+
79 90
     public static final class UserBindBuilder {
80 91
         private Integer id;
81 92
         private Integer uid;
@@ -83,6 +94,7 @@ public class UserBind {
83 94
         private Integer del_flag;
84 95
         private Integer bind_uid;
85 96
         private Integer type;
97
+        private String name;
86 98
 
87 99
         private UserBindBuilder() {
88 100
         }
@@ -121,6 +133,11 @@ public class UserBind {
121 133
             return this;
122 134
         }
123 135
 
136
+        public UserBindBuilder withName(String name) {
137
+            this.name = name;
138
+            return this;
139
+        }
140
+
124 141
         public UserBind build() {
125 142
             UserBind userBind = new UserBind();
126 143
             userBind.setId(id);
@@ -129,6 +146,7 @@ public class UserBind {
129 146
             userBind.setDel_flag(del_flag);
130 147
             userBind.setBind_uid(bind_uid);
131 148
             userBind.setType(type);
149
+            userBind.setName(name);
132 150
             return userBind;
133 151
         }
134 152
     }

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

@@ -14,7 +14,7 @@ public class UserVo {
14 14
     private Integer id;
15 15
 
16 16
     /** 用户名称*/
17
-    private String name;
17
+    private String nickname;
18 18
 
19 19
     /** 手机号*/
20 20
     @Sensitive
@@ -27,7 +27,7 @@ public class UserVo {
27 27
     private Integer status;
28 28
 
29 29
     /** 团队名称*/
30
-    private String teamName;
30
+    private String name;
31 31
 
32 32
     public Integer getId() {
33 33
         return id;
@@ -37,12 +37,12 @@ public class UserVo {
37 37
         this.id = id;
38 38
     }
39 39
 
40
-    public String getName() {
41
-        return name;
40
+    public String getNickname() {
41
+        return nickname;
42 42
     }
43 43
 
44
-    public void setName(String name) {
45
-        this.name = name;
44
+    public void setNickname(String nickname) {
45
+        this.nickname = nickname;
46 46
     }
47 47
 
48 48
     public String getMobile() {
@@ -69,21 +69,21 @@ public class UserVo {
69 69
         this.status = status;
70 70
     }
71 71
 
72
-    public String getTeamName() {
73
-        return teamName;
72
+    public String getName() {
73
+        return name;
74 74
     }
75 75
 
76
-    public void setTeamName(String teamName) {
77
-        this.teamName = teamName;
76
+    public void setName(String name) {
77
+        this.name = name;
78 78
     }
79 79
 
80 80
     public static final class UserVoBuilder {
81 81
         private Integer id;
82
-        private String name;
82
+        private String nickname;
83 83
         private String mobile;
84 84
         private String avatar;
85 85
         private Integer status;
86
-        private String teamName;
86
+        private String name;
87 87
 
88 88
         private UserVoBuilder() {
89 89
         }
@@ -97,8 +97,8 @@ public class UserVo {
97 97
             return this;
98 98
         }
99 99
 
100
-        public UserVoBuilder withName(String name) {
101
-            this.name = name;
100
+        public UserVoBuilder withNickname(String nickname) {
101
+            this.nickname = nickname;
102 102
             return this;
103 103
         }
104 104
 
@@ -117,19 +117,19 @@ public class UserVo {
117 117
             return this;
118 118
         }
119 119
 
120
-        public UserVoBuilder withTeamName(String teamName) {
121
-            this.teamName = teamName;
120
+        public UserVoBuilder withName(String name) {
121
+            this.name = name;
122 122
             return this;
123 123
         }
124 124
 
125 125
         public UserVo build() {
126 126
             UserVo userVo = new UserVo();
127 127
             userVo.setId(id);
128
-            userVo.setName(name);
128
+            userVo.setNickname(nickname);
129 129
             userVo.setMobile(mobile);
130 130
             userVo.setAvatar(avatar);
131 131
             userVo.setStatus(status);
132
-            userVo.setTeamName(teamName);
132
+            userVo.setName(name);
133 133
             return userVo;
134 134
         }
135 135
     }

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

@@ -166,9 +166,14 @@ public class UserService {
166 166
             }
167 167
         });
168 168
         if(!resultList.isEmpty()){
169
-            //相同用户ID,日期合并
170
-//            resultList.stream().
171
-            userCountMapper.insertSelectiveForeach(resultList);
169
+            //相同用户ID
170
+            userCountMapper.insertSelectiveForeach(resultList.stream().collect(Collectors.groupingBy(UserCount::getUid)).entrySet().stream()
171
+                    .map(row -> UserCount.UserCountBuilder.anUserCount()
172
+                            .withUid(row.getKey())
173
+                            .withUser_type(UserTypeEnum.DACANG.ordinal())
174
+                            .withDate(localDate)
175
+                            .withCreate_time(currentTime)
176
+                            .build()).toList());
172 177
         }
173 178
     }
174 179
 
@@ -404,6 +409,7 @@ public class UserService {
404 409
         userBindMapper.insertSelective(UserBind.UserBindBuilder.anUserBind()
405 410
                 .withBind_uid(baseUser.getId())
406 411
                 .withUid(userVo.getId())
412
+                .withName(param.getName())
407 413
                 .withCreate_time(LocalDateTime.now())
408 414
                 .withType(isFilter? 1: 0).build());
409 415
     }

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

@@ -20,6 +20,9 @@
20 20
             <if test="null != type">
21 21
                 type,
22 22
             </if>
23
+            <if test="null != name">
24
+                name,
25
+            </if>
23 26
         </trim>
24 27
 
25 28
         <trim prefix="values (" suffix=")" suffixOverrides=",">
@@ -38,6 +41,9 @@
38 41
             <if test="null != type">
39 42
                 #{ type },
40 43
             </if>
44
+            <if test="null != name">
45
+                #{name},
46
+            </if>
41 47
         </trim>
42 48
     </insert>
43 49
 
@@ -59,6 +65,9 @@
59 65
             <if test="null != type">
60 66
                 type = #{ type },
61 67
             </if>
68
+            <if test="null != name">
69
+                type = #{name},
70
+            </if>
62 71
         </set>
63 72
         where id = #{id}
64 73
     </update>

+ 2 - 1
src/main/resources/mapper/UserMapper.xml

@@ -122,8 +122,9 @@
122 122
         select
123 123
             u.account 'mobile',
124 124
                 u.uid 'id',
125
-                u.nickname 'name',
125
+                u.nickname,
126 126
                 u.avatar,
127
+                ub.name,
127 128
             '1' as 'status'
128 129
         from
129 130
             user_bind ub