Browse Source

教师、学生添加、导入功能完善

tags/正式3.3.0
雍文秀 2 years ago
parent
commit
908c9cca71

+ 2
- 2
suser/src/main/java/com/xhkjedu/suser/controller/gradeclass/ClassStudentController.java View File

@@ -60,8 +60,8 @@ public class ClassStudentController {
60 60
         Integer classid = tClassStudent.getClassid();
61 61
         N_Utils.validation(new Object[]{classid,"班级id",1});
62 62
         try {
63
-            classStudentService.save(tClassStudent);
64
-            return new ResultVo(0, "保存成功");
63
+            Integer delStuId = classStudentService.save(tClassStudent);
64
+            return new ResultVo(0, "保存成功", delStuId);
65 65
         } catch (Exception e) {
66 66
             return new ResultVo(1,e.getMessage());
67 67
         }

+ 16
- 0
suser/src/main/java/com/xhkjedu/suser/controller/system/UserController.java View File

@@ -605,4 +605,20 @@ public class UserController {
605 605
         userService.batchUpdateTime(usertime, userids);
606 606
         return new ResultVo(0, "批量修有效期成功");
607 607
     }
608
+
609
+    @PostMapping("/activate")
610
+    public ResultVo activate(@RequestBody TUser user) {
611
+        Integer userid = user.getUserid();
612
+        N_Utils.validation(new Object[]{userid, "用户id", 1});
613
+        userService.updateState(userid, 1);
614
+        return new ResultVo(0, "激活成功");
615
+    }
616
+
617
+    @PostMapping("/batch_activate")
618
+    public ResultVo batchActivate(@RequestBody Map map) {
619
+        List<Integer> userids = (List<Integer>) map.get("userids");
620
+        if (N_Utils.isListEmpty(userids)) return new ResultVo(1, "用户id集合不能为空");
621
+        userService.batchActivate(userids);
622
+        return new ResultVo(0, "批量激活成功");
623
+    }
608 624
 }

+ 4
- 1
suser/src/main/java/com/xhkjedu/suser/mapper/system/UserMapper.java View File

@@ -87,7 +87,7 @@ public interface UserMapper extends TkMapper<TUser> {
87 87
      * @Author ywx
88 88
      * @Date 2020/6/2 10:44
89 89
      **/
90
-    Integer checkLoginName(@Param("loginname") String loginname);
90
+    Map checkLoginName(@Param("loginname") String loginname);
91 91
 
92 92
     /**
93 93
      * 根据登录账号获取用户详情
@@ -249,4 +249,7 @@ public interface UserMapper extends TkMapper<TUser> {
249 249
 
250 250
     //根据手机号获取用户基本信息
251 251
     UserVo getUserByUserPhone(String userphone);
252
+
253
+    //批量更新用户状态
254
+    void batchUpdateUserState(@Param("userstate") Integer userstate, @Param("userids") List<Integer> userids);
252 255
 }

+ 4
- 0
suser/src/main/java/com/xhkjedu/suser/model/gradeclass/TClassTeacher.java View File

@@ -60,4 +60,8 @@ public class TClassTeacher extends BaseBean {
60 60
     @Transient
61 61
     //是否锁定0未锁定1已锁定
62 62
     private Integer userlock;
63
+
64
+    @Transient
65
+    //用户状态1正常2删除
66
+    private Integer userstate;
63 67
 }

+ 30
- 16
suser/src/main/java/com/xhkjedu/suser/service/gradeclass/ClassStudentService.java View File

@@ -74,7 +74,7 @@ public class ClassStudentService {
74 74
                 //全体分组
75 75
                 ImportStudentVo stu = getNumById(classid, studentid, year);
76 76
                 if (classVo.getClasstype() == 1 && stu.getXznum() != 0) {
77
-                    throw new Exception("学生已在行政班");
77
+                    throw new Exception("学生已在行政班");
78 78
                 }
79 79
                 Integer num = stu.getClassnum();//班级学生数量
80 80
                 if (num == 0) {//学生不在该班级
@@ -192,7 +192,8 @@ public class ClassStudentService {
192 192
 
193 193
     //添加
194 194
     @Transactional(rollbackFor = Exception.class)
195
-    public void save(TClassStudent model) throws Exception {
195
+    public Integer save(TClassStudent model) throws Exception {
196
+        Integer delStuId = 0;//已删除学生id
196 197
         try {
197 198
             model.setCreatetime(N_Utils.getSecondTimestamp());
198 199
             Integer schoolid = model.getSchoolid();
@@ -218,8 +219,8 @@ public class ClassStudentService {
218 219
                             stu.setHeadtime(N_Utils.getSecondTimestamp());
219 220
                         }
220 221
                     }
221
-                    if (1 != user.getUserstate()) {//已删除用户改为正常用户
222
-                        stu.setUserstate(1);
222
+                    if (1 != user.getUserstate()) {//已删除用户
223
+                        delStuId = userid;
223 224
                     }
224 225
                     userMapper.updateByPrimaryKeySelective(stu);
225 226
                 }
@@ -231,7 +232,7 @@ public class ClassStudentService {
231 232
             ClassVo classVo = classMapper.getById(model.getClassid());
232 233
             ImportStudentVo student = getNumById(model.getClassid(), model.getStudentid(), classVo.getYear());
233 234
             if (classVo.getClasstype() == 1 && student.getXznum() != 0) {
234
-                throw new Exception("学生已在行政班");
235
+                throw new Exception("学生已在行政班");
235 236
             }
236 237
             Integer num = student.getClassnum();//班级学生数量
237 238
             if (num == 0) {//学生不在该班级
@@ -272,6 +273,7 @@ public class ClassStudentService {
272 273
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
273 274
             throw new MissingParametersException(e.getMessage());
274 275
         }
276
+        return delStuId;
275 277
     }
276 278
 
277 279
     /**
@@ -372,7 +374,7 @@ public class ClassStudentService {
372 374
     public ResultVo update(TClassStudent model) {
373 375
         TUser u = userMapper.getObjByLoginName(model.getStudentno());
374 376
         if (u != null && !model.getStudentid().equals(u.getUserid())) {
375
-            return new ResultVo(1, "账号已被【" + u.getUsername() + "】占用");
377
+            return new ResultVo(1, "账号已被【" + u.getUsername() + "】占用");
376 378
         }
377 379
         //修改学生信息
378 380
         TUser user = new TUser();
@@ -446,8 +448,10 @@ public class ClassStudentService {
446 448
             List<Integer> changeCourseidList = new ArrayList<>();//用户更新直播课中学生数量
447 449
             Map<Integer, List<Map>> courseMap = new HashMap<>();//要添加班级直播
448 450
             Map<String, List<Map>> delCourseMap = new HashMap<>();//要删除班级直播
449
-            // 以下学生信息已存在
450
-            List<TUser> usersExisted = new ArrayList<>();
451
+            List<TUser> teachersExisted = new ArrayList<>();//已存在教师列表
452
+            List<TUser> studentsExisted = new ArrayList<>();//已存在学生列表
453
+            List<TUser> usersExisted = new ArrayList<>();//已存在非本校账号列表
454
+            List<TUser> delUsers = new ArrayList<>();//已删除学生列表
451 455
             for (TUser user : students) {
452 456
                 TUser u = userMapper.getObjByLoginName(user.getLoginname());
453 457
                 if (null == u) {
@@ -461,15 +465,19 @@ public class ClassStudentService {
461 465
                     user.setUserlock(0);
462 466
                     users.add(user);
463 467
                 } else {
464
-                    Integer studentid = u.getUserid();
465
-                    Integer oldclassid = classStudentMapper.getClassIdByStuId(studentid);//获取学生行政班id
466
-                    if (2 != u.getUsertype() || schoolid != u.getSchoolid()) {//非本校学生信息
468
+                    if (schoolid != u.getSchoolid()) {
467 469
                         usersExisted.add(u);
470
+                        continue;//非本校账号处理下一条数据
471
+                    } else if (2 != u.getUsertype()) {
472
+                        teachersExisted.add(u);
473
+                        continue;//非本校学生处理下一条数据
468 474
                     } else {
475
+                        Integer studentid = u.getUserid();
476
+                        Integer oldclassid = classStudentMapper.getClassIdByStuId(studentid);//获取学生行政班id
469 477
                         Integer classid = user.getClassid();
470 478
                         if (!classid.equals(oldclassid) && 2 == u.getUsertype() && schoolid == u.getSchoolid()) {
471 479
                             if (1 != u.getUserstate()) {
472
-                                userMapper.updateState(u.getUserid(), 1);
480
+                                delUsers.add(u);
473 481
                             }
474 482
                             //要添加的班级
475 483
                             setStudents(classid, schoolid, createid, user.getGroupid(), classStudents, groupStudents, studentid);//处理班级加入学生
@@ -506,7 +514,7 @@ public class ClassStudentService {
506 514
                                 handleDelClassCourse2(delStudentList, changeCourseidList, courses2, studentid);//处理关联的直播课以及需要删除学生的直播班id
507 515
                             }
508 516
                         } else {//本班学生信息
509
-                            usersExisted.add(u);
517
+                            studentsExisted.add(u);
510 518
                         }
511 519
                     }
512 520
                 }
@@ -549,8 +557,12 @@ public class ClassStudentService {
549 557
                 String numcourseids = changeCourseidList.stream().distinct().map(String::valueOf).collect(Collectors.joining(","));
550 558
                 courseMapper.updateStuNumBatch(numcourseids);//批量修改课程学生数量
551 559
             }
560
+            map.put("teachersExisted", teachersExisted);
561
+            map.put("studentsExisted", studentsExisted);
552 562
             map.put("usersExisted", usersExisted);
553
-            if (N_Utils.isListNotEmpty(usersExisted)) {
563
+            map.put("delUsers", delUsers);
564
+            if (N_Utils.isListNotEmpty(teachersExisted) || N_Utils.isListNotEmpty(studentsExisted)
565
+                    || N_Utils.isListNotEmpty(usersExisted) || N_Utils.isListNotEmpty(delUsers)) {
554 566
                 map.put("code", 1);
555 567
             } else {
556 568
                 map.put("code", 0);
@@ -631,6 +643,7 @@ public class ClassStudentService {
631 643
             Map<Integer, List<Map>> courseMap = new HashMap<>();
632 644
             // 以下学生信息不存在
633 645
             List<TUser> usersNotExisted = new ArrayList<>();
646
+            List<TUser> delUsers = new ArrayList<>();//已删除学生列表
634 647
             for (TUser user : students) {
635 648
                 TUser u = userMapper.getObjByLoginName(user.getLoginname());
636 649
                 if (null == u) {
@@ -649,7 +662,7 @@ public class ClassStudentService {
649 662
                         usersNotExisted.add(u);
650 663
                     } else if (0 == classnum && 2 == u.getUsertype() && schoolid == u.getSchoolid()) {
651 664
                         if (1 != u.getUserstate()) {
652
-                            userMapper.updateState(u.getUserid(), 1);
665
+                            delUsers.add(u);
653 666
                         }
654 667
                         setStudents(classid, schoolid, createid, user.getGroupid(), classStudents, groupStudents, studentid);//处理班级加入学生
655 668
                         List<Map> courses = listCourseByClassId(courseMap, classid);
@@ -673,7 +686,8 @@ public class ClassStudentService {
673 686
                 courseMapper.updateStuNumBatch(numcourseids);//批量修改课程学生数量
674 687
             }
675 688
             map.put("usersNotExisted", usersNotExisted);
676
-            if (N_Utils.isListNotEmpty(usersNotExisted)) {
689
+            map.put("delUsers", delUsers);
690
+            if (N_Utils.isListNotEmpty(usersNotExisted) || N_Utils.isListNotEmpty(delUsers)) {
677 691
                 map.put("code", 1);
678 692
             } else {
679 693
                 map.put("code", 0);

+ 98
- 49
suser/src/main/java/com/xhkjedu/suser/service/system/UserService.java View File

@@ -87,7 +87,7 @@ public class UserService extends JedisUtil {
87 87
             resultVo = this.checkLoginUser(user,userVo,1);
88 88
 
89 89
         } else {
90
-            resultVo = new ResultVo(1, "账号不存在");
90
+            resultVo = new ResultVo(1, "账号不存在");
91 91
         }
92 92
 
93 93
         return getLogResultVo(user, resultVo, loginpwd, request);
@@ -98,25 +98,29 @@ public class UserService extends JedisUtil {
98 98
             //帐号密码登录
99 99
             return new ResultVo(1, "密码错误");
100 100
         } else {
101
-
102
-            if(userVo.getUsertype() == 999){
101
+            Integer usertype = userVo.getUsertype();
102
+            if (usertype == 999) {
103 103
                 return new ResultVo(0, "登录成功", userVo);
104 104
             }
105 105
             //判断学校状态
106
-            if(userVo.getSchoolstate() != 1){
107
-                return new ResultVo(1, "学校已锁定,禁止登录");
106
+            if (userVo.getSchoolstate() != 1) {
107
+                return new ResultVo(1, "学校已锁定,禁止登录");
108 108
             }
109 109
             //判断用户状态
110 110
             if (userVo.getUserstate() != 1) {
111
-                return new ResultVo(1, "该账户无权访问,请联系老师");
111
+                if (usertype == 2) {//学生
112
+                    return new ResultVo(1, "此账号无权访问,请联系老师");
113
+                } else {
114
+                    return new ResultVo(1, "此账号无权访问,请联系管理员");
115
+                }
112 116
             }
113 117
 
114 118
             if(userVo.getUserlock() == 1){
115
-                return new ResultVo(1, "该账户已被锁定,禁止登录");
119
+                return new ResultVo(1, "此账号已锁定,禁止登录");
116 120
             }
117 121
 
118 122
             //进行角色判断
119
-            if (userVo.getUsertype() == 2) {
123
+            if (usertype == 2) {
120 124
                 Integer stuweb = userVo.getStuweb();
121 125
                 if (stuweb != null && stuweb != 1) return new ResultVo(1, "学生账号无法登录");
122 126
 
@@ -139,7 +143,7 @@ public class UserService extends JedisUtil {
139 143
                 }
140 144
                 //验证用户是否有行政班
141 145
                 if (binduser.getXznum() == 0) {
142
-                    return new ResultVo(1, "账号未分配班级");
146
+                    return new ResultVo(1, "账号未分配班级");
143 147
                 }
144 148
 
145 149
                 //更新学生硬件绑定信息
@@ -171,17 +175,17 @@ public class UserService extends JedisUtil {
171 175
                 if (userVo.getUsertype() != 1) {
172 176
                     resultVo = new ResultVo(1, "禁止非教师账号登录");
173 177
                 } else if (userVo.getSchoolstate() != 1) {
174
-                    resultVo = new ResultVo(1, "用户所在学校暂无权限");
178
+                    resultVo = new ResultVo(1, "此学校已锁定,禁止登录");
175 179
                 } else {
176 180
                     if (userVo.getUserstate() != 1) {
177
-                        resultVo = new ResultVo(1, "该账户无权访问,请联系老师");
181
+                        resultVo = new ResultVo(1, "此账号无权访问,请联系管理员");
178 182
                     } else {
179 183
                         resultVo = new ResultVo(0, "登录成功", userVo);
180 184
                     }
181 185
                 }
182 186
             }
183 187
         } else {
184
-            resultVo = new ResultVo(1, "账号不存在");
188
+            resultVo = new ResultVo(1, "账号不存在");
185 189
         }
186 190
 
187 191
         return getLogResultVo(user, resultVo, loginpwd, request);
@@ -209,7 +213,7 @@ public class UserService extends JedisUtil {
209 213
             //验证学生登录系列问题
210 214
             resultVo = checkLoginStudent(user,userVo);
211 215
         } else {
212
-            resultVo = new ResultVo(1, "账号不存在");
216
+            resultVo = new ResultVo(1, "账号不存在");
213 217
         }
214 218
 
215 219
         return getLogResultVo(user, resultVo, loginpwd, request);
@@ -226,7 +230,7 @@ public class UserService extends JedisUtil {
226 230
             if (userVo.getUsertype() != 2) {
227 231
                 return new ResultVo(1, "登录失败,仅允许学生登录");
228 232
             } else if (userVo.getXznum() == 0) {
229
-                return new ResultVo(1, "账号未分配班级");
233
+                return new ResultVo(1, "账号未分配班级");
230 234
             } else if (sbindmac == 1 && N_Utils.isNotEmpty(mac)) {
231 235
                 if (N_Utils.isNotEmpty(userVo.getMac()) && !mac.equals(userVo.getMac())) {
232 236
                     return new ResultVo(1, "登录失败,该账号已与其他设备关联");
@@ -266,7 +270,7 @@ public class UserService extends JedisUtil {
266 270
 
267 271
             resultVo = checkLoginUser(user,userVo,2);
268 272
         } else {
269
-            resultVo = new ResultVo(1, "账号不存在");
273
+            resultVo = new ResultVo(1, "账号不存在");
270 274
         }
271 275
 
272 276
         return getLogResultVo(user, resultVo, user.getMsgcode() + "", request);
@@ -289,7 +293,7 @@ public class UserService extends JedisUtil {
289 293
             UserVo userVo = (UserVo) result.getObj();
290 294
             if (userVo.getUserlock() == 1) {
291 295
                 result.setCode(1);
292
-                result.setMsg("该账户已被锁定,禁止登录");
296
+                result.setMsg("此账号已锁定,禁止登录");
293 297
                 return result;
294 298
             }
295 299
             String usertime = userVo.getUsertime();
@@ -297,7 +301,11 @@ public class UserService extends JedisUtil {
297 301
                 String dayBegin = DatesUtil.getDayBegin();
298 302
                 if (usertime.compareTo(dayBegin) < 0) {
299 303
                     result.setCode(1);
300
-                    result.setMsg("账号已过有效期,请联系管理员");
304
+                    if (usertype == 2) {//学生
305
+                        result.setMsg("账号已过有效期,请联系老师");
306
+                    } else {
307
+                        result.setMsg("账号已过有效期,请联系管理员");
308
+                    }
301 309
                     return result;
302 310
                 }
303 311
             }
@@ -408,7 +416,7 @@ public class UserService extends JedisUtil {
408 416
             TUser user1 = getObjByLoginName(loginname);
409 417
             //登录账号改变并且和别的账号冲突
410 418
             if (user1 != null && !user1.getUserid().equals(user.getUserid())) {
411
-                return new ResultVo(1, "此用户已存在,请更换!");
419
+                return new ResultVo(1, "此账号已存在,请更换!");
412 420
             }
413 421
         }
414 422
         Integer bindphoned = 0;
@@ -530,9 +538,9 @@ public class UserService extends JedisUtil {
530 538
      * @Date 2020/6/2 10:44
531 539
      **/
532 540
     public ResultVo checkLoginName(String loginname) {
533
-        Integer num = userMapper.checkLoginName(loginname);
534
-        if (num != 0) {
535
-            return new ResultVo(1, "此用户已存在,请更换!");
541
+        Map num = userMapper.checkLoginName(loginname);
542
+        if (num != null) {
543
+            return new ResultVo(1, "此账号已存在,请更换", num);
536 544
         } else {
537 545
             return new ResultVo(0, "检查登录账号是否存在成功");
538 546
         }
@@ -623,8 +631,10 @@ public class UserService extends JedisUtil {
623 631
             map.remove("users");//导入成功的教师信息不返回给前端
624 632
             Integer year = schoolMapper.getYearById(schoolid);
625 633
 
626
-            // 以下教师信息已存在·
627
-            List<TUser> usersExisted = new ArrayList<>();
634
+            List<TUser> teachersExisted = new ArrayList<>();//已存在教师列表
635
+            List<TUser> studentsExisted = new ArrayList<>();//已存在学生列表
636
+            List<TUser> usersExisted = new ArrayList<>();//已存在非本校账号列表
637
+            List<TUser> delUsers = new ArrayList<>();//已删除教师列表
628 638
             List<TClassTeacher> ctlst = new ArrayList<>();//班级教师集合
629 639
             List<Integer> teacherIds = new ArrayList<>();//要导入的教师id集合
630 640
             List<TUser> teacherList = new ArrayList<>();//要导入的新教师集合
@@ -656,11 +666,18 @@ public class UserService extends JedisUtil {
656 666
                     user.setUserlock(0);
657 667
                     teacherList.add(user);
658 668
                 } else {
659
-                    if (1 != u.getUsertype() || schoolid != u.getSchoolid()) {
669
+                    if (schoolid != u.getSchoolid()) {
660 670
                         usersExisted.add(u);
671
+                        continue;//非本校账号处理下一条数据
672
+                    } else if (1 != u.getUsertype()) {
673
+                        studentsExisted.add(u);
661 674
                         continue;//非本校老师处理下一条数据
662 675
                     } else {
663
-                        usersExisted.add(u);
676
+                        if (u.getUserstate() != 1) {//本校已删除教师
677
+                            delUsers.add(u);
678
+                        } else {//本校已存在教师
679
+                            teachersExisted.add(u);
680
+                        }
664 681
                         userid = u.getUserid();
665 682
                         teacherIds.add(userid);
666 683
                         //处理用户班级
@@ -685,7 +702,6 @@ public class UserService extends JedisUtil {
685 702
             }
686 703
             if (N_Utils.isListNotEmpty(teacherList)) {
687 704
                 batchSave(teacherList);//批量添加教师
688
-                System.out.println("新教师:" + JSON.toJSONString(teacherList));
689 705
                 for (TUser user : teacherList) {
690 706
                     Integer userid = user.getId();
691 707
                     teacherIds.add(userid);//把新添加的教师id添加到要导入的教师id集合
@@ -708,14 +724,21 @@ public class UserService extends JedisUtil {
708 724
                 }
709 725
             }
710 726
 
711
-            if (N_Utils.isListNotEmpty(ctlst)) {
727
+            if (N_Utils.isListNotEmpty(teacherIds)) {
712 728
                 String teacherids = teacherIds.stream().distinct().map(String::valueOf).collect(Collectors.joining(","));
713 729
                 classTeacherMapper.deleteByUserid2(teacherids, year);//删除教师任教班级
730
+            }
731
+
732
+            if (N_Utils.isListNotEmpty(ctlst)) {
714 733
                 classTeacherMapper.insertList(ctlst);//添加教师任教班级
715 734
             }
716 735
 
736
+            map.put("teachersExisted", teachersExisted);
737
+            map.put("studentsExisted", studentsExisted);
717 738
             map.put("usersExisted", usersExisted);
718
-            if (N_Utils.isListNotEmpty(usersExisted)) {
739
+            map.put("delUsers", delUsers);
740
+            if (N_Utils.isListNotEmpty(teachersExisted) || N_Utils.isListNotEmpty(studentsExisted)
741
+                    || N_Utils.isListNotEmpty(usersExisted) || N_Utils.isListNotEmpty(delUsers)) {
719 742
                 map.put("code", 1);
720 743
             } else {
721 744
                 map.put("code", 0);
@@ -840,7 +863,7 @@ public class UserService extends JedisUtil {
840 863
         if ("yhzc".equals(templateCode)) {//用户注册验证码
841 864
             msgtxt += "验证码" + messageCode + ",您正在注册成为新用户,感谢您的支持!";
842 865
         } else if ("xgmm".equals(templateCode)) {//修改密码验证码
843
-            msgtxt += "验证码" + messageCode + ",您正在尝试修改登录密码,请妥善保管账信息。";
866
+            msgtxt += "验证码" + messageCode + ",您正在尝试修改登录密码,请妥善保管账信息。";
844 867
         } else if ("dlqr".equals(templateCode)) {//登录确认验证码
845 868
             msgtxt += "验证码" + messageCode + ",您正在登录,若非本人操作,请勿泄露。";
846 869
         } else if ("bdsj".equals(templateCode)) {//绑定手机验证码
@@ -910,26 +933,33 @@ public class UserService extends JedisUtil {
910 933
         UserVo userVo = userMapper.getUserByUserPhone(userphone);
911 934
         if (userVo == null || userVo.getBindphoned() == 0) return new ResultVo(1, "手机号码未绑定");
912 935
         //判断学校状态
913
-        if (userVo.getUsertype() != 999 && userVo.getSchoolstate() != 1) {
914
-            return new ResultVo(1, "该学校已锁定,禁止登录");
936
+        Integer usertype = userVo.getUsertype();
937
+        if (usertype != 999 && userVo.getSchoolstate() != 1) {
938
+            return new ResultVo(1, "此学校已锁定,禁止登录");
939
+        }
940
+        String roleName;
941
+        if (usertype == 2) {
942
+            roleName = "老师";
943
+        } else {
944
+            roleName = "管理员";
915 945
         }
916 946
         //判断用户状态
917 947
         if (userVo.getUserstate() != 1) {
918
-            return new ResultVo(1, "该账户无权访问,请联系老师");
948
+            return new ResultVo(1, "此账号无权访问,请联系" + roleName);
919 949
         }
920 950
         //判断用户是否锁定
921 951
         if (userVo.getUserlock() == 1) {
922
-            return new ResultVo(1, "该账户已被锁定,禁止登录");
952
+            return new ResultVo(1, "此账号已锁定,禁止登录");
923 953
         }
924 954
         //判断用户是否过期
925 955
         String usertime = userVo.getUsertime();
926 956
         String dayBegin = DatesUtil.getDayBegin();
927 957
         if (N_Utils.isNotEmpty(usertime) && usertime.compareTo(dayBegin) < 0) {
928
-            return new ResultVo(1, "账号已过有效期,请联系管理员");
958
+            return new ResultVo(1, "账号已过有效期,请联系" + roleName);
929 959
         }
930 960
 
931 961
         //进行角色判断
932
-        if (userVo.getUsertype() == 2) {
962
+        if (usertype == 2) {
933 963
             Integer stuweb = userVo.getStuweb();
934 964
             if (stuweb != null && stuweb != 1) return new ResultVo(1, "学生账号无法登录");
935 965
         }
@@ -952,36 +982,43 @@ public class UserService extends JedisUtil {
952 982
         UserVo user = userMapper.getUserSchoolByUserid(userid);
953 983
         String usertime = user.getUsertime();
954 984
         String dayBegin = DatesUtil.getDayBegin();
955
-        String msg = "用户信息正常";
985
+        String msg = "账号信息正常";
956 986
         if (!loginpwd.equals(user.getLoginpwd())) {
957 987
             needLogin = true;
958 988
             msg = "密码已修改,请重新登录";
959 989
         }
960 990
         //判断学校状态
961
-        if (!needLogin && user.getUsertype() != 999 && user.getSchoolstate() != 1) {
991
+        Integer usertype = user.getUsertype();
992
+        String roleName;
993
+        if (usertype == 2) {//学生
994
+            roleName = "老师";
995
+        } else {
996
+            roleName = "管理员";
997
+        }
998
+        if (!needLogin && usertype != 999 && user.getSchoolstate() != 1) {
962 999
             needLogin = true;
963
-            msg = "该学校已锁定,请联系管理员";
1000
+            msg = "此学校已锁定,请联系" + roleName;
964 1001
         }
965 1002
         //判断用户状态
966 1003
         if (!needLogin && user.getUserstate() != 1) {
967 1004
             needLogin = true;
968
-            msg = "该账户无权访问,请联系老师";
1005
+            msg = "此账号无权访问,请联系" + roleName;
969 1006
         }
970 1007
         if (!needLogin && N_Utils.isNotEmpty(usertime) && usertime.compareTo(dayBegin) < 0) {
971 1008
             needLogin = true;
972
-            msg = "账号已过有效期,请联系管理员";
1009
+            msg = "账号已过有效期,请联系" + roleName;
973 1010
         }
974 1011
         if (!needLogin && user.getUserlock() == 1) {
975 1012
             needLogin = true;
976
-            msg = "该用户已被锁定,请联系管理员";
1013
+            msg = "此账号已锁定,请联系" + roleName;
977 1014
         }
978
-        if (user.getUsertype() == 2) {
1015
+        if (usertype == 2) {
979 1016
             needPhone = userMapper.checkUserPhone(userid);
980 1017
             if (!needLogin && needPhone) msg = "未绑定手机号";
981 1018
 
982
-            if(device != null && "pad".equals(device)){
1019
+            if (device != null && "pad".equals(device)) {
983 1020
                 //当是设备不为空并且是pad时,进行验证
984
-                if(user.getSbindmac() == 1 && user.getBindmac() != 1){
1021
+                if (user.getSbindmac() == 1 && user.getBindmac() != 1) {
985 1022
                     needLogin = true;
986 1023
                     msg = "未绑定设备";
987 1024
                 }
@@ -1013,16 +1050,16 @@ public class UserService extends JedisUtil {
1013 1050
             } else if (userVo.getUsertype() == 2) {
1014 1051
                 resultVo = new ResultVo(1, "禁止学生登录");
1015 1052
             } else if (userVo.getSchoolstate() != 1) {
1016
-                resultVo = new ResultVo(1, "用户所在学校暂无权限");
1053
+                resultVo = new ResultVo(1, "账号所在学校暂无权限");
1017 1054
             } else {
1018 1055
                 if (userVo.getUserstate() != 1) {
1019
-                    resultVo = new ResultVo(1, "该账户无权访问,请联系老师");
1056
+                    resultVo = new ResultVo(1, "此账号无权访问,请联系管理员");
1020 1057
                 } else {
1021 1058
                     resultVo = new ResultVo(0, "登录成功", userVo);
1022 1059
                 }
1023 1060
             }
1024 1061
         } else {
1025
-            resultVo = new ResultVo(1, "账号不存在");
1062
+            resultVo = new ResultVo(1, "账号不存在");
1026 1063
         }
1027 1064
 
1028 1065
         return getLogResultVo(user, resultVo, "", request);
@@ -1087,11 +1124,11 @@ public class UserService extends JedisUtil {
1087 1124
     public ResultVo checkUser(String loginname, String username) {
1088 1125
         Map map = userMapper.getBindByName(loginname);
1089 1126
         if (N_Utils.isEmpty(map)) {
1090
-            return new ResultVo(1, "账号不存在");
1127
+            return new ResultVo(1, "账号不存在");
1091 1128
         }
1092 1129
         String username1 = map.get("username").toString();
1093 1130
         if (!username.equals(username1)) {
1094
-            return new ResultVo(1, "账号和姓名不匹配");
1131
+            return new ResultVo(1, "账号和姓名不匹配");
1095 1132
         }
1096 1133
         return new ResultVo(0, "验证身份成功", map);
1097 1134
     }
@@ -1237,4 +1274,16 @@ public class UserService extends JedisUtil {
1237 1274
     public void batchUpdateTime(String usertime, List<Integer> userids) {
1238 1275
         userMapper.batchUpdateTime(usertime, userids);
1239 1276
     }
1277
+
1278
+    /**
1279
+     * 批量激活
1280
+     *
1281
+     * @return void
1282
+     * @Param [userids]
1283
+     * @Author ywx
1284
+     * @Date 2022/6/8 17:10
1285
+     **/
1286
+    public void batchActivate(List<Integer> userids) {
1287
+        userMapper.batchUpdateUserState(1, userids);
1288
+    }
1240 1289
 }

+ 4
- 1
suser/src/main/resources/mapper/gradeclass/ClassTeacherMapper.xml View File

@@ -17,7 +17,10 @@
17 17
             left join t_teacher_powersb tp on tp.teacherid=u.userid
18 18
             left join t_subject_book sb on sb.lsbid=tp.lsbid
19 19
         </if>
20
-        where u.schoolid=#{teacher.schoolid} and u.usertype in(0,1) and u.userstate=1
20
+        where u.schoolid=#{teacher.schoolid} and u.usertype in(0,1)
21
+        <if test="teacher.userstate!=null and teacher.userstate!=0">
22
+            and u.userstate=#{teacher.userstate}
23
+        </if>
21 24
         <if test="teacher.userlock!=null and teacher.userlock!=0">
22 25
             and u.userlock=#{teacher.userlock}
23 26
         </if>

+ 10
- 3
suser/src/main/resources/mapper/system/UserMapper.xml View File

@@ -82,8 +82,8 @@
82 82
         update t_user set headpic=#{user.headpic},headtime=UNIX_TIMESTAMP() where userid=#{user.userid}
83 83
     </update>
84 84
     <!--检查登录账号是否存在-->
85
-    <select id="checkLoginName" resultType="java.lang.Integer">
86
-        select count(*) from t_user u where binary u.loginname=#{loginname}
85
+    <select id="checkLoginName" resultType="java.util.Map">
86
+        select u.userid,u.userstate,u.usertype,u.schoolid from t_user u where binary u.loginname=#{loginname}
87 87
     </select>
88 88
     <!--根据登录账号获取用户详情-->
89 89
     <select id="getObjByLoginName" resultType="com.xhkjedu.suser.model.system.TUser">
@@ -92,7 +92,7 @@
92 92
     </select>
93 93
     <!--修改用户状态-->
94 94
     <update id="updateState">
95
-        update t_user set userstate=#{userstate} where userid=#{userid}
95
+        update t_user set userstate=#{userstate},createtime=UNIX_TIMESTAMP() where userid=#{userid}
96 96
     </update>
97 97
 
98 98
     <!-- 用户设置操作密码 -->
@@ -261,6 +261,13 @@
261 261
             ${userid}
262 262
         </foreach>
263 263
     </update>
264
+    <!--批量更新用户状态-->
265
+    <update id="batchUpdateUserState">
266
+        update t_user set userstate=#{userstate},createtime=UNIX_TIMESTAMP() where userid in
267
+        <foreach collection="userids" item="userid" index="index" open="(" separator="," close=")">
268
+            ${userid}
269
+        </foreach>
270
+    </update>
264 271
 
265 272
     <!--根据用户id获取用户详细信息,学校基本信息-->
266 273
     <select id="getUserSchoolByUserid" resultType="com.xhkjedu.suser.vo.system.UserVo">

Loading…
Cancel
Save