Browse Source

Merge remote-tracking branch 'origin/wn' into ywx

tags/正式3.10.0
雍文秀 1 year ago
parent
commit
7871a82593

+ 3
- 0
suser/src/main/java/com/xhkjedu/suser/mapper/system/UserMapper.java View File

269
 
269
 
270
     //更新用户信息
270
     //更新用户信息
271
     void updateUser(@Param("u") TUser user);
271
     void updateUser(@Param("u") TUser user);
272
+
273
+    //获取当前区域码
274
+    String getCloudCode();
272
 }
275
 }

+ 14
- 2
suser/src/main/java/com/xhkjedu/suser/model/system/TUser.java View File

153
     @Transient
153
     @Transient
154
     private String qrkey;// 扫码登录时二维码唯一标识
154
     private String qrkey;// 扫码登录时二维码唯一标识
155
 
155
 
156
-    @Transient
156
+ /*   @Transient
157
     private String browser;//浏览器
157
     private String browser;//浏览器
158
 
158
 
159
     @Transient
159
     @Transient
160
-    private String os;//操作系统
160
+    private String os;//操作系统*/
161
 
161
 
162
     //重置默认头像1重置
162
     //重置默认头像1重置
163
     @Transient
163
     @Transient
164
     private Integer resethead;
164
     private Integer resethead;
165
+
166
+    //系统版本(android、鸿蒙、荣耀系统等)
167
+    @Transient
168
+    private String systemversion;
169
+
170
+    @Transient
171
+    //登录终端品牌(华为、小米、荣耀、vivo、oppo等)
172
+    private String ultypeband;
173
+
174
+    @Transient
175
+    //登录终端型号(华为mate9、小米13等)
176
+    private String ultypemodel;
165
 }
177
 }

+ 12
- 0
suser/src/main/java/com/xhkjedu/suser/model/system/TUserLog.java View File

23
     //登录名
23
     //登录名
24
     private String loginname;
24
     private String loginname;
25
 
25
 
26
+    //用户类型999超管0学校管理员1教师2学生
27
+    private Integer usertype;
28
+
26
     //登录状态1成功2失败
29
     //登录状态1成功2失败
27
     private Integer loginstate;
30
     private Integer loginstate;
28
 
31
 
38
     //登录终端设备
41
     //登录终端设备
39
     private String ultype;
42
     private String ultype;
40
 
43
 
44
+    //登录终端品牌(华为、小米、荣耀、vivo、oppo等)
45
+    private String ultypeband;
46
+
47
+    //登录终端型号(华为mate9、小米13等)
48
+    private String ultypemodel;
49
+
41
     //版本号
50
     //版本号
42
     private String versionnum;
51
     private String versionnum;
43
 
52
 
53
+    //系统版本(android、鸿蒙、荣耀系统等)
54
+    private String systemversion;
55
+
44
     //备注
56
     //备注
45
     private String logtxt;
57
     private String logtxt;
46
 
58
 

+ 28
- 50
suser/src/main/java/com/xhkjedu/suser/service/system/UserLogService.java View File

2
 
2
 
3
 import com.alibaba.fastjson.JSON;
3
 import com.alibaba.fastjson.JSON;
4
 import com.xhkjedu.suser.config.ConfigKey;
4
 import com.xhkjedu.suser.config.ConfigKey;
5
-import com.xhkjedu.suser.mapper.system.UserLogMapper;
5
+import com.xhkjedu.suser.mapper.system.UserMapper;
6
 import com.xhkjedu.suser.model.system.TUser;
6
 import com.xhkjedu.suser.model.system.TUser;
7
 import com.xhkjedu.suser.model.system.TUserLog;
7
 import com.xhkjedu.suser.model.system.TUserLog;
8
-import com.xhkjedu.suser.utils.IpRegionUtil;
9
-import com.xhkjedu.suser.utils.UserUtil;
10
 import com.xhkjedu.suser.vo.system.UserVo;
8
 import com.xhkjedu.suser.vo.system.UserVo;
11
 import com.xhkjedu.utils.N_Utils;
9
 import com.xhkjedu.utils.N_Utils;
12
 import lombok.extern.slf4j.Slf4j;
10
 import lombok.extern.slf4j.Slf4j;
14
 import org.springframework.stereotype.Service;
12
 import org.springframework.stereotype.Service;
15
 
13
 
16
 import javax.annotation.Resource;
14
 import javax.annotation.Resource;
17
-import javax.servlet.http.HttpServletRequest;
18
 import java.util.HashMap;
15
 import java.util.HashMap;
19
 import java.util.Map;
16
 import java.util.Map;
20
 
17
 
27
 @Slf4j
24
 @Slf4j
28
 public class UserLogService {
25
 public class UserLogService {
29
     @Resource
26
     @Resource
30
-    private UserLogMapper userLogMapper;
27
+    private UserMapper userMapper;
31
 
28
 
32
     //保存登录日志
29
     //保存登录日志
33
-    @Async("asyncPoolTaskExecutor")
34
-    public void saveSyncLoginLog(TUserLog userLog, TUser user, HttpServletRequest request) {
35
-        try {
36
-            userLog.setUserid(user.getUserid());
37
-            userLog.setUsername(user.getUsername());
38
-            userLog.setSchoolid(user.getSchoolid());
39
-            //获取请求ip并解析区域
40
-            String ip = UserUtil.getIpAddress(request);
41
-            String region = null;
42
-            if (N_Utils.isNotEmpty(ip)) {
43
-                IpRegionUtil ipRegionUtil = new IpRegionUtil();
44
-                region = ipRegionUtil.getIpForAddress(ip);
45
-            }
46
-            userLog.setLogip(ip);
47
-            userLog.setLogaddress(region);
48
-            Integer usertype = user.getUsertype();
49
-            String ultype = user.getUltype();
50
-            if (N_Utils.isNotEmpty(ultype) && ultype.equals("p_web") && usertype != null) {
51
-                //网页端学生和教师合并登录,前端传p_web,拼接完整的ultype
52
-                if (usertype == 2) {
53
-                    userLog.setUltype(user.getUltype() + "_s");
54
-                } else {
55
-                    userLog.setUltype(user.getUltype() + "_t");
56
-                }
57
-            } else {
58
-                userLog.setUltype(user.getUltype());
59
-            }
60
 
30
 
61
-            userLog.setVersionnum(user.getVersionnum());
62
-            int logintime = N_Utils.getSecondTimestamp();
63
-            userLog.setLogtime(logintime);
64
-            userLogMapper.insertSelective(userLog);
65
-        } catch (Exception e) {
66
-            log.error("添加登录日志失败:" + e.getMessage());
67
-        }
68
-    }
69
 
31
 
70
     //用户登录信息同步到云平台
32
     //用户登录信息同步到云平台
71
     @Async("asyncPoolTaskExecutor")
33
     @Async("asyncPoolTaskExecutor")
72
     public void saveSyncUserLogin(UserVo userVo, TUser user, TUserLog userLog) {
34
     public void saveSyncUserLogin(UserVo userVo, TUser user, TUserLog userLog) {
73
         Map<String, Object> params = new HashMap<>();
35
         Map<String, Object> params = new HashMap<>();
74
-        params.put("cloudcode", userVo.getCloudcode());
75
-        params.put("schoolname", userVo.getSchoolname());
76
-        params.put("userid", userVo.getUserid());
77
-        params.put("loginname", userVo.getLoginname());
78
-        params.put("usertype", userVo.getUsertype());
79
-        params.put("device", userLog.getUltype());
36
+        if(userVo == null){
37
+            //获取当前区域码
38
+            String cloudcode = userMapper.getCloudCode();
39
+            params.put("cloudcode", cloudcode);
40
+            params.put("schoolname", "");
41
+            params.put("userid", user.getUserid());
42
+            params.put("loginname", user.getLoginname());
43
+            params.put("username", "");
44
+
45
+        }else{
46
+            params.put("cloudcode", userVo.getCloudcode());
47
+            params.put("schoolname", userVo.getSchoolname());
48
+            params.put("userid", userVo.getUserid());
49
+            params.put("loginname", userVo.getLoginname());
50
+            params.put("username", userVo.getUsername());
51
+        }
52
+        params.put("deviceband", user.getUltypeband());
53
+        params.put("devicemodel", user.getUltypemodel());
80
         params.put("mac", user.getMac());
54
         params.put("mac", user.getMac());
81
-        params.put("loginip", userLog.getLogip());
82
-        params.put("logintime", userLog.getLogtime());
83
         params.put("versioncode", user.getVersionnum());
55
         params.put("versioncode", user.getVersionnum());
84
-        params.put("browser", user.getBrowser());
85
-        params.put("env", user.getOs());
56
+        params.put("systemversion", user.getSystemversion());
57
+        params.put("usertype", userLog.getUsertype());
58
+        params.put("device", userLog.getUltype());
59
+        params.put("logip", userLog.getLogip());
60
+        params.put("logaddress", userLog.getLogaddress());
61
+        params.put("logtime", userLog.getLogtime());
62
+        params.put("loginstate", userLog.getLoginstate());
63
+        params.put("logtxt",userLog.getLogtxt());
86
 
64
 
87
         try {
65
         try {
88
             N_Utils.sendJsonPost(ConfigKey.cloudapi + "rlinfo/save", JSON.toJSONString(params));
66
             N_Utils.sendJsonPost(ConfigKey.cloudapi + "rlinfo/save", JSON.toJSONString(params));

+ 88
- 34
suser/src/main/java/com/xhkjedu/suser/service/system/UserService.java View File

9
 import com.xhkjedu.suser.mapper.gradeclass.SchoolMapper;
9
 import com.xhkjedu.suser.mapper.gradeclass.SchoolMapper;
10
 import com.xhkjedu.suser.mapper.subjectbook.TeacherPowersbMapper;
10
 import com.xhkjedu.suser.mapper.subjectbook.TeacherPowersbMapper;
11
 import com.xhkjedu.suser.mapper.system.MsgMapper;
11
 import com.xhkjedu.suser.mapper.system.MsgMapper;
12
+import com.xhkjedu.suser.mapper.system.UserLogMapper;
12
 import com.xhkjedu.suser.mapper.system.UserMapper;
13
 import com.xhkjedu.suser.mapper.system.UserMapper;
13
 import com.xhkjedu.suser.mapper.system.UserUsecretMapper;
14
 import com.xhkjedu.suser.mapper.system.UserUsecretMapper;
14
 import com.xhkjedu.suser.model.gradeclass.TClassTeacher;
15
 import com.xhkjedu.suser.model.gradeclass.TClassTeacher;
16
 import com.xhkjedu.suser.model.system.TUser;
17
 import com.xhkjedu.suser.model.system.TUser;
17
 import com.xhkjedu.suser.model.system.TUserLog;
18
 import com.xhkjedu.suser.model.system.TUserLog;
18
 import com.xhkjedu.suser.model.system.TUserUsecret;
19
 import com.xhkjedu.suser.model.system.TUserUsecret;
20
+import com.xhkjedu.suser.utils.IpRegionUtil;
19
 import com.xhkjedu.suser.utils.PoiUtils;
21
 import com.xhkjedu.suser.utils.PoiUtils;
20
 import com.xhkjedu.suser.utils.SMSSender;
22
 import com.xhkjedu.suser.utils.SMSSender;
21
 import com.xhkjedu.suser.utils.UserUtil;
23
 import com.xhkjedu.suser.utils.UserUtil;
65
     private UserUsecretMapper userUsecretMapper;
67
     private UserUsecretMapper userUsecretMapper;
66
     @Resource
68
     @Resource
67
     private TeacherPowersbMapper teacherPowersbMapper;
69
     private TeacherPowersbMapper teacherPowersbMapper;
70
+    @Resource
71
+    private UserLogMapper userLogMapper;
68
 
72
 
69
     /**
73
     /**
70
      * 功能描述  根据登录名和密码获取用户信息
74
      * 功能描述  根据登录名和密码获取用户信息
101
     private ResultVo checkLoginUser(TUser user, UserVo userVo, Integer checkmethod) {
105
     private ResultVo checkLoginUser(TUser user, UserVo userVo, Integer checkmethod) {
102
         if (checkmethod == 1 && !userVo.getLoginpwd().equals(user.getLoginpwd())) {
106
         if (checkmethod == 1 && !userVo.getLoginpwd().equals(user.getLoginpwd())) {
103
             //帐号密码登录
107
             //帐号密码登录
104
-            return new ResultVo(1, "密码错误");
108
+            return new ResultVo(1, "密码错误", userVo);
105
         } else {
109
         } else {
106
             Integer usertype = userVo.getUsertype();
110
             Integer usertype = userVo.getUsertype();
107
             if (usertype == 999) {
111
             if (usertype == 999) {
109
             }
113
             }
110
             //判断学校状态
114
             //判断学校状态
111
             if (userVo.getSchoolstate() != 1) {
115
             if (userVo.getSchoolstate() != 1) {
112
-                return new ResultVo(1, "此学校已锁定,禁止登录");
116
+                return new ResultVo(1, "此学校已锁定,禁止登录", userVo);
113
             }
117
             }
114
             //判断用户状态
118
             //判断用户状态
115
             if (userVo.getUserstate() != 1) {
119
             if (userVo.getUserstate() != 1) {
116
                 if (usertype == 2) {//学生
120
                 if (usertype == 2) {//学生
117
-                    return new ResultVo(1, "此账号无权访问,请联系老师");
121
+                    return new ResultVo(1, "此账号无权访问,请联系老师", userVo);
118
                 } else {
122
                 } else {
119
-                    return new ResultVo(1, "此账号无权访问,请联系管理员");
123
+                    return new ResultVo(1, "此账号无权访问,请联系管理员", userVo);
120
                 }
124
                 }
121
             }
125
             }
122
 
126
 
123
             //判断用户状态
127
             //判断用户状态
124
             if (userVo.getUserlock() == 1) {
128
             if (userVo.getUserlock() == 1) {
125
-                return new ResultVo(1, "此账号已锁定,禁止登录");
129
+                return new ResultVo(1, "此账号已锁定,禁止登录", userVo);
126
             }
130
             }
127
 
131
 
128
             //判断用户有效期
132
             //判断用户有效期
131
                 String dayBegin = DatesUtil.getDayBegin();
135
                 String dayBegin = DatesUtil.getDayBegin();
132
                 if (usertime.compareTo(dayBegin) < 0) {
136
                 if (usertime.compareTo(dayBegin) < 0) {
133
                     if (usertype == 2) {//学生
137
                     if (usertype == 2) {//学生
134
-                        return new ResultVo(1, "账号已过有效期,请联系老师");
138
+                        return new ResultVo(1, "账号已过有效期,请联系老师", userVo);
135
                     } else {
139
                     } else {
136
-                        return new ResultVo(1, "账号已过有效期,请联系管理员");
140
+                        return new ResultVo(1, "账号已过有效期,请联系管理员", userVo);
137
                     }
141
                     }
138
                 }
142
                 }
139
             }
143
             }
141
             //进行角色判断
145
             //进行角色判断
142
             if (usertype == 2) {
146
             if (usertype == 2) {
143
                 Integer stuweb = userVo.getStuweb();
147
                 Integer stuweb = userVo.getStuweb();
144
-                if (stuweb != null && stuweb != 1) return new ResultVo(1, "学生账号无法登录");
148
+                if (stuweb != null && stuweb != 1) return new ResultVo(1, "学生账号无法登录", userVo);
145
 
149
 
146
                 Integer sbindmac = userVo.getSbindmac();
150
                 Integer sbindmac = userVo.getSbindmac();
147
                 String mac = user.getMac();
151
                 String mac = user.getMac();
150
                 UserVo binduser = userMapper.getStudentByuserIdMac(userVo.getUserid(), mac);
154
                 UserVo binduser = userMapper.getStudentByuserIdMac(userVo.getUserid(), mac);
151
                 if (sbindmac == 1 && N_Utils.isNotEmpty(mac)) {
155
                 if (sbindmac == 1 && N_Utils.isNotEmpty(mac)) {
152
                     if (N_Utils.isNotEmpty(binduser.getMac()) && !mac.equals(binduser.getMac())) {
156
                     if (N_Utils.isNotEmpty(binduser.getMac()) && !mac.equals(binduser.getMac())) {
153
-                        return new ResultVo(1, "登录失败,该账号已与其他设备关联");
157
+                        return new ResultVo(1, "该账号已与其他设备关联", userVo);
154
                     } else {
158
                     } else {
155
                         //20211221添加注释,sql语句修改了,不绑定的情况下会出现一个mac可以绑定多个帐号,绑定情况下没问题
159
                         //20211221添加注释,sql语句修改了,不绑定的情况下会出现一个mac可以绑定多个帐号,绑定情况下没问题
156
                         if (N_Utils.isNotEmpty(binduser.getMacname()) && !binduser.getMacname().equals(user.getLoginname())) {
160
                         if (N_Utils.isNotEmpty(binduser.getMacname()) && !binduser.getMacname().equals(user.getLoginname())) {
157
-                            return new ResultVo(1, "登录失败,该设备已与其他账号关联");
161
+                            return new ResultVo(1, "该设备已与其他账号关联", userVo);
158
                         } else {
162
                         } else {
159
                             return new ResultVo(0, "登录成功", userVo);
163
                             return new ResultVo(0, "登录成功", userVo);
160
                         }
164
                         }
162
                 }
166
                 }
163
                 //验证用户是否有行政班
167
                 //验证用户是否有行政班
164
                 if (binduser.getXznum() == 0) {
168
                 if (binduser.getXznum() == 0) {
165
-                    return new ResultVo(1, "此账号未分配班级");
169
+                    return new ResultVo(1, "此账号未分配班级", userVo);
166
                 }
170
                 }
167
 
171
 
168
                 String device = user.getDevice();//只有学生
172
                 String device = user.getDevice();//只有学生
200
             user.setSchoolid(userVo.getSchoolid());
204
             user.setSchoolid(userVo.getSchoolid());
201
             user.setUsertype(userVo.getUsertype());
205
             user.setUsertype(userVo.getUsertype());
202
             if (userVo.getUsertype() != 1) {
206
             if (userVo.getUsertype() != 1) {
203
-                resultVo = new ResultVo(1, "禁止非教师帐号登录");
207
+                resultVo = new ResultVo(1, "禁止非教师帐号登录", userVo);
204
             } else {
208
             } else {
205
                 //验证用户信息
209
                 //验证用户信息
206
                 resultVo = this.checkLoginUser(user, userVo, 1);
210
                 resultVo = this.checkLoginUser(user, userVo, 1);
207
             }
211
             }
208
-
209
         } else {
212
         } else {
210
             resultVo = new ResultVo(1, "此账号不存在");
213
             resultVo = new ResultVo(1, "此账号不存在");
211
         }
214
         }
212
-
213
-
214
-
215
         return getLogResultVo(user, resultVo, loginpwd, request);
215
         return getLogResultVo(user, resultVo, loginpwd, request);
216
     }
216
     }
217
 
217
 
247
     //验证学生登录系列问题
247
     //验证学生登录系列问题
248
     private ResultVo checkLoginStudent(TUser user, UserVo userVo) {
248
     private ResultVo checkLoginStudent(TUser user, UserVo userVo) {
249
         if (!userVo.getLoginpwd().equals(user.getLoginpwd())) {
249
         if (!userVo.getLoginpwd().equals(user.getLoginpwd())) {
250
-            return new ResultVo(1, "密码错误");
250
+            return new ResultVo(1, "密码错误", userVo);
251
         } else {
251
         } else {
252
             Integer sbindmac = userVo.getSbindmac();//学校是否绑定设备0未绑定1绑定
252
             Integer sbindmac = userVo.getSbindmac();//学校是否绑定设备0未绑定1绑定
253
             String mac = user.getMac();
253
             String mac = user.getMac();
255
 
255
 
256
             //判断学校状态
256
             //判断学校状态
257
             if (userVo.getSchoolstate() != 1) {
257
             if (userVo.getSchoolstate() != 1) {
258
-                return new ResultVo(1, "此学校已锁定,禁止登录");
258
+                return new ResultVo(1, "此学校已锁定,禁止登录", userVo);
259
             }
259
             }
260
 
260
 
261
             //判断用户状态
261
             //判断用户状态
262
             if (userVo.getUserstate() != 1) {
262
             if (userVo.getUserstate() != 1) {
263
                 if (userVo.getUsertype() == 2) {//学生
263
                 if (userVo.getUsertype() == 2) {//学生
264
-                    return new ResultVo(1, "此账号无权访问,请联系老师");
264
+                    return new ResultVo(1, "此账号无权访问,请联系老师", userVo);
265
                 }
265
                 }
266
             }
266
             }
267
 
267
 
268
             if (userVo.getUserlock() == 1) {
268
             if (userVo.getUserlock() == 1) {
269
-                return new ResultVo(1, "此账号已锁定,禁止登录");
269
+                return new ResultVo(1, "此账号已锁定,禁止登录", userVo);
270
             } else if (userVo.getUsertype() != 2) {
270
             } else if (userVo.getUsertype() != 2) {
271
-                return new ResultVo(1, "登录失败,仅允许学生登录");
271
+                return new ResultVo(1, "登录失败,仅允许学生登录", userVo);
272
             } else if (userVo.getXznum() == 0) {
272
             } else if (userVo.getXznum() == 0) {
273
-                return new ResultVo(1, "此账号未分配班级");
273
+                return new ResultVo(1, "此账号未分配班级", userVo);
274
             } else if (N_Utils.isNotEmpty(usertime)) {
274
             } else if (N_Utils.isNotEmpty(usertime)) {
275
                 String dayBegin = DatesUtil.getDayBegin();
275
                 String dayBegin = DatesUtil.getDayBegin();
276
                 if (usertime.compareTo(dayBegin) < 0) {
276
                 if (usertime.compareTo(dayBegin) < 0) {
277
-                    return new ResultVo(1, "账号已过有效期,请联系老师");
277
+                    return new ResultVo(1, "账号已过有效期,请联系老师", userVo);
278
                 }
278
                 }
279
             } else if (sbindmac == 1 && N_Utils.isNotEmpty(mac)) {
279
             } else if (sbindmac == 1 && N_Utils.isNotEmpty(mac)) {
280
                 if (N_Utils.isNotEmpty(userVo.getMac()) && !mac.equals(userVo.getMac())) {
280
                 if (N_Utils.isNotEmpty(userVo.getMac()) && !mac.equals(userVo.getMac())) {
281
-                    return new ResultVo(1, "登录失败,该账号已与其他设备关联");
281
+                    return new ResultVo(1, "登录失败,该账号已与其他设备关联", userVo);
282
                 } else {
282
                 } else {
283
                     //20211221添加注释,sql语句修改了,不绑定的情况下会出现一个mac可以绑定多个帐号,绑定情况下没问题
283
                     //20211221添加注释,sql语句修改了,不绑定的情况下会出现一个mac可以绑定多个帐号,绑定情况下没问题
284
                     if (N_Utils.isNotEmpty(userVo.getMacname()) && !userVo.getMacname().equals(user.getLoginname())) {
284
                     if (N_Utils.isNotEmpty(userVo.getMacname()) && !userVo.getMacname().equals(user.getLoginname())) {
285
-                        return new ResultVo(1, "登录失败,该设备已与其他账号关联");
285
+                        return new ResultVo(1, "登录失败,该设备已与其他账号关联", userVo);
286
                     }
286
                     }
287
                 }
287
                 }
288
             }
288
             }
312
             Integer usertype = user.getUsertype();
312
             Integer usertype = user.getUsertype();
313
             Integer utype = userVo.getUsertype();
313
             Integer utype = userVo.getUsertype();
314
             if (usertype != null && usertype == 1 && utype != 0 & utype != 1) {//教师端只能管理员、教师登录
314
             if (usertype != null && usertype == 1 && utype != 0 & utype != 1) {//教师端只能管理员、教师登录
315
-                return new ResultVo(1, "禁止非教师帐号登录");
315
+                return new ResultVo(1, "禁止非教师帐号登录", userVo);
316
             }
316
             }
317
             user.setUserid(userVo.getUserid());
317
             user.setUserid(userVo.getUserid());
318
             user.setUsername(userVo.getUsername());
318
             user.setUsername(userVo.getUsername());
389
         TUserLog userLog = new TUserLog();
389
         TUserLog userLog = new TUserLog();
390
         userLog.setLoginname(loginname);
390
         userLog.setLoginname(loginname);
391
         userLog.setMac(user.getMac());
391
         userLog.setMac(user.getMac());
392
-        Integer usertype = user.getUsertype();
393
         UserVo userVo = null;
392
         UserVo userVo = null;
394
         if (result.getCode() == 0) {
393
         if (result.getCode() == 0) {
395
             userVo = (UserVo) result.getObj();
394
             userVo = (UserVo) result.getObj();
401
             if (!redis_rtn) {
400
             if (!redis_rtn) {
402
                 result.setCode(1);
401
                 result.setCode(1);
403
                 result.setMsg("加入缓存出错!");
402
                 result.setMsg("加入缓存出错!");
404
-                return result;
403
+                userLog.setLoginstate(2);
404
+                userLog.setLogtxt("登录失败," + result.getMsg());
405
+                // return result;
405
             } else {
406
             } else {
406
                 userLog.setLoginstate(1);
407
                 userLog.setLoginstate(1);
407
                 userLog.setLogtxt("登录成功");
408
                 userLog.setLogtxt("登录成功");
410
                 result.setObj(userVo);
411
                 result.setObj(userVo);
411
             }
412
             }
412
         } else {
413
         } else {
414
+            if(N_Utils.isNotEmpty(result.getObj())){
415
+                userVo = (UserVo) result.getObj();
416
+            }
413
             userLog.setLoginstate(2);
417
             userLog.setLoginstate(2);
414
-            userLog.setLogtxt(result.getMsg() + ",密码:" + loginpwd);
418
+            if(result.getMsg().contains("密码错误")){
419
+                userLog.setLogtxt("登录失败," + result.getMsg() + ",密码:" + loginpwd);
420
+            }else{
421
+                userLog.setLogtxt("登录失败," + result.getMsg());
422
+            }
415
         }
423
         }
424
+
416
         //保存登录日志
425
         //保存登录日志
417
-        userLogService.saveSyncLoginLog(userLog,user,request);
418
-        boolean cloudsynclogin = ConfigKey.cloudsynclogin;//为true时代表同步云平台
419
-        if(cloudsynclogin && userLog.getLoginstate() !=null && userLog.getLoginstate() == 1){
420
-            userLogService.saveSyncUserLogin(userVo, user, userLog);
421
-        }
426
+        saveSyncLoginLog(userLog,user,userVo,request);
427
+
422
         return result;
428
         return result;
423
     }
429
     }
424
 
430
 
431
+    //保存登录日志
432
+    @Async("asyncPoolTaskExecutor")
433
+    public void saveSyncLoginLog(TUserLog userLog, TUser user,UserVo userVo, HttpServletRequest request) {
434
+        try {
435
+
436
+            userLog.setUserid(user.getUserid());
437
+            userLog.setUsername(user.getUsername());
438
+            userLog.setSchoolid(user.getSchoolid());
439
+            Integer usertype = user.getUsertype();
440
+            userLog.setUsertype(usertype);
441
+            String ultype = user.getUltype();
442
+            if (N_Utils.isNotEmpty(ultype) && ultype.equals("p_web") && usertype != null) {
443
+                //网页端学生和教师合并登录,前端传p_web,拼接完整的ultype
444
+                if (usertype == 2) {
445
+                    userLog.setUltype(user.getUltype() + "_s");
446
+                } else {
447
+                    userLog.setUltype(user.getUltype() + "_t");
448
+                }
449
+            } else {
450
+                userLog.setUltype(user.getUltype());
451
+            }
452
+
453
+            userLog.setVersionnum(user.getVersionnum());
454
+            int logintime = N_Utils.getSecondTimestamp();
455
+            userLog.setLogtime(logintime);
456
+
457
+            //获取请求ip并解析区域
458
+            String ip = UserUtil.getIpAddress(request);
459
+            String region = null;
460
+            if (N_Utils.isNotEmpty(ip)) {
461
+                IpRegionUtil ipRegionUtil = new IpRegionUtil();
462
+                region = ipRegionUtil.getIpForAddress(ip);
463
+            }
464
+            userLog.setLogip(ip);
465
+            userLog.setLogaddress(region);
466
+
467
+            boolean cloudsynclogin = ConfigKey.cloudsynclogin;//为true时代表同步云平台
468
+            if(cloudsynclogin && userLog.getLoginstate() !=null){
469
+                userLogService.saveSyncUserLogin(userVo, user, userLog);
470
+            }
471
+
472
+            userLogMapper.insertSelective(userLog);
473
+
474
+        } catch (Exception e) {
475
+            log.error("添加登录日志失败:" + e.getMessage());
476
+        }
477
+    }
478
+
425
     /**
479
     /**
426
      * 添加用户信息
480
      * 添加用户信息
427
      *
481
      *

+ 5
- 0
suser/src/main/resources/mapper/system/UserMapper.xml View File

340
         </if>
340
         </if>
341
         where userid=#{user.userid}
341
         where userid=#{user.userid}
342
     </update>
342
     </update>
343
+
344
+    <!--获取当前区域码-->
345
+    <select id="getCloudCode" resultType="java.lang.String">
346
+        select cloudcode from t_cloud order by cloudid limit 1;
347
+    </select>
343
 </mapper>
348
 </mapper>

Loading…
Cancel
Save