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
         Integer classid = tClassStudent.getClassid();
60
         Integer classid = tClassStudent.getClassid();
61
         N_Utils.validation(new Object[]{classid,"班级id",1});
61
         N_Utils.validation(new Object[]{classid,"班级id",1});
62
         try {
62
         try {
63
-            classStudentService.save(tClassStudent);
64
-            return new ResultVo(0, "保存成功");
63
+            Integer delStuId = classStudentService.save(tClassStudent);
64
+            return new ResultVo(0, "保存成功", delStuId);
65
         } catch (Exception e) {
65
         } catch (Exception e) {
66
             return new ResultVo(1,e.getMessage());
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
         userService.batchUpdateTime(usertime, userids);
605
         userService.batchUpdateTime(usertime, userids);
606
         return new ResultVo(0, "批量修有效期成功");
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
      * @Author ywx
87
      * @Author ywx
88
      * @Date 2020/6/2 10:44
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
 
249
 
250
     //根据手机号获取用户基本信息
250
     //根据手机号获取用户基本信息
251
     UserVo getUserByUserPhone(String userphone);
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
     @Transient
60
     @Transient
61
     //是否锁定0未锁定1已锁定
61
     //是否锁定0未锁定1已锁定
62
     private Integer userlock;
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
                 //全体分组
74
                 //全体分组
75
                 ImportStudentVo stu = getNumById(classid, studentid, year);
75
                 ImportStudentVo stu = getNumById(classid, studentid, year);
76
                 if (classVo.getClasstype() == 1 && stu.getXznum() != 0) {
76
                 if (classVo.getClasstype() == 1 && stu.getXznum() != 0) {
77
-                    throw new Exception("学生已在行政班");
77
+                    throw new Exception("学生已在行政班");
78
                 }
78
                 }
79
                 Integer num = stu.getClassnum();//班级学生数量
79
                 Integer num = stu.getClassnum();//班级学生数量
80
                 if (num == 0) {//学生不在该班级
80
                 if (num == 0) {//学生不在该班级
192
 
192
 
193
     //添加
193
     //添加
194
     @Transactional(rollbackFor = Exception.class)
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
         try {
197
         try {
197
             model.setCreatetime(N_Utils.getSecondTimestamp());
198
             model.setCreatetime(N_Utils.getSecondTimestamp());
198
             Integer schoolid = model.getSchoolid();
199
             Integer schoolid = model.getSchoolid();
218
                             stu.setHeadtime(N_Utils.getSecondTimestamp());
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
                     userMapper.updateByPrimaryKeySelective(stu);
225
                     userMapper.updateByPrimaryKeySelective(stu);
225
                 }
226
                 }
231
             ClassVo classVo = classMapper.getById(model.getClassid());
232
             ClassVo classVo = classMapper.getById(model.getClassid());
232
             ImportStudentVo student = getNumById(model.getClassid(), model.getStudentid(), classVo.getYear());
233
             ImportStudentVo student = getNumById(model.getClassid(), model.getStudentid(), classVo.getYear());
233
             if (classVo.getClasstype() == 1 && student.getXznum() != 0) {
234
             if (classVo.getClasstype() == 1 && student.getXznum() != 0) {
234
-                throw new Exception("学生已在行政班");
235
+                throw new Exception("学生已在行政班");
235
             }
236
             }
236
             Integer num = student.getClassnum();//班级学生数量
237
             Integer num = student.getClassnum();//班级学生数量
237
             if (num == 0) {//学生不在该班级
238
             if (num == 0) {//学生不在该班级
272
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
273
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
273
             throw new MissingParametersException(e.getMessage());
274
             throw new MissingParametersException(e.getMessage());
274
         }
275
         }
276
+        return delStuId;
275
     }
277
     }
276
 
278
 
277
     /**
279
     /**
372
     public ResultVo update(TClassStudent model) {
374
     public ResultVo update(TClassStudent model) {
373
         TUser u = userMapper.getObjByLoginName(model.getStudentno());
375
         TUser u = userMapper.getObjByLoginName(model.getStudentno());
374
         if (u != null && !model.getStudentid().equals(u.getUserid())) {
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
         TUser user = new TUser();
380
         TUser user = new TUser();
446
             List<Integer> changeCourseidList = new ArrayList<>();//用户更新直播课中学生数量
448
             List<Integer> changeCourseidList = new ArrayList<>();//用户更新直播课中学生数量
447
             Map<Integer, List<Map>> courseMap = new HashMap<>();//要添加班级直播
449
             Map<Integer, List<Map>> courseMap = new HashMap<>();//要添加班级直播
448
             Map<String, List<Map>> delCourseMap = new HashMap<>();//要删除班级直播
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
             for (TUser user : students) {
455
             for (TUser user : students) {
452
                 TUser u = userMapper.getObjByLoginName(user.getLoginname());
456
                 TUser u = userMapper.getObjByLoginName(user.getLoginname());
453
                 if (null == u) {
457
                 if (null == u) {
461
                     user.setUserlock(0);
465
                     user.setUserlock(0);
462
                     users.add(user);
466
                     users.add(user);
463
                 } else {
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
                         usersExisted.add(u);
469
                         usersExisted.add(u);
470
+                        continue;//非本校账号处理下一条数据
471
+                    } else if (2 != u.getUsertype()) {
472
+                        teachersExisted.add(u);
473
+                        continue;//非本校学生处理下一条数据
468
                     } else {
474
                     } else {
475
+                        Integer studentid = u.getUserid();
476
+                        Integer oldclassid = classStudentMapper.getClassIdByStuId(studentid);//获取学生行政班id
469
                         Integer classid = user.getClassid();
477
                         Integer classid = user.getClassid();
470
                         if (!classid.equals(oldclassid) && 2 == u.getUsertype() && schoolid == u.getSchoolid()) {
478
                         if (!classid.equals(oldclassid) && 2 == u.getUsertype() && schoolid == u.getSchoolid()) {
471
                             if (1 != u.getUserstate()) {
479
                             if (1 != u.getUserstate()) {
472
-                                userMapper.updateState(u.getUserid(), 1);
480
+                                delUsers.add(u);
473
                             }
481
                             }
474
                             //要添加的班级
482
                             //要添加的班级
475
                             setStudents(classid, schoolid, createid, user.getGroupid(), classStudents, groupStudents, studentid);//处理班级加入学生
483
                             setStudents(classid, schoolid, createid, user.getGroupid(), classStudents, groupStudents, studentid);//处理班级加入学生
506
                                 handleDelClassCourse2(delStudentList, changeCourseidList, courses2, studentid);//处理关联的直播课以及需要删除学生的直播班id
514
                                 handleDelClassCourse2(delStudentList, changeCourseidList, courses2, studentid);//处理关联的直播课以及需要删除学生的直播班id
507
                             }
515
                             }
508
                         } else {//本班学生信息
516
                         } else {//本班学生信息
509
-                            usersExisted.add(u);
517
+                            studentsExisted.add(u);
510
                         }
518
                         }
511
                     }
519
                     }
512
                 }
520
                 }
549
                 String numcourseids = changeCourseidList.stream().distinct().map(String::valueOf).collect(Collectors.joining(","));
557
                 String numcourseids = changeCourseidList.stream().distinct().map(String::valueOf).collect(Collectors.joining(","));
550
                 courseMapper.updateStuNumBatch(numcourseids);//批量修改课程学生数量
558
                 courseMapper.updateStuNumBatch(numcourseids);//批量修改课程学生数量
551
             }
559
             }
560
+            map.put("teachersExisted", teachersExisted);
561
+            map.put("studentsExisted", studentsExisted);
552
             map.put("usersExisted", usersExisted);
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
                 map.put("code", 1);
566
                 map.put("code", 1);
555
             } else {
567
             } else {
556
                 map.put("code", 0);
568
                 map.put("code", 0);
631
             Map<Integer, List<Map>> courseMap = new HashMap<>();
643
             Map<Integer, List<Map>> courseMap = new HashMap<>();
632
             // 以下学生信息不存在
644
             // 以下学生信息不存在
633
             List<TUser> usersNotExisted = new ArrayList<>();
645
             List<TUser> usersNotExisted = new ArrayList<>();
646
+            List<TUser> delUsers = new ArrayList<>();//已删除学生列表
634
             for (TUser user : students) {
647
             for (TUser user : students) {
635
                 TUser u = userMapper.getObjByLoginName(user.getLoginname());
648
                 TUser u = userMapper.getObjByLoginName(user.getLoginname());
636
                 if (null == u) {
649
                 if (null == u) {
649
                         usersNotExisted.add(u);
662
                         usersNotExisted.add(u);
650
                     } else if (0 == classnum && 2 == u.getUsertype() && schoolid == u.getSchoolid()) {
663
                     } else if (0 == classnum && 2 == u.getUsertype() && schoolid == u.getSchoolid()) {
651
                         if (1 != u.getUserstate()) {
664
                         if (1 != u.getUserstate()) {
652
-                            userMapper.updateState(u.getUserid(), 1);
665
+                            delUsers.add(u);
653
                         }
666
                         }
654
                         setStudents(classid, schoolid, createid, user.getGroupid(), classStudents, groupStudents, studentid);//处理班级加入学生
667
                         setStudents(classid, schoolid, createid, user.getGroupid(), classStudents, groupStudents, studentid);//处理班级加入学生
655
                         List<Map> courses = listCourseByClassId(courseMap, classid);
668
                         List<Map> courses = listCourseByClassId(courseMap, classid);
673
                 courseMapper.updateStuNumBatch(numcourseids);//批量修改课程学生数量
686
                 courseMapper.updateStuNumBatch(numcourseids);//批量修改课程学生数量
674
             }
687
             }
675
             map.put("usersNotExisted", usersNotExisted);
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
                 map.put("code", 1);
691
                 map.put("code", 1);
678
             } else {
692
             } else {
679
                 map.put("code", 0);
693
                 map.put("code", 0);

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

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

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

82
         update t_user set headpic=#{user.headpic},headtime=UNIX_TIMESTAMP() where userid=#{user.userid}
82
         update t_user set headpic=#{user.headpic},headtime=UNIX_TIMESTAMP() where userid=#{user.userid}
83
     </update>
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
     </select>
87
     </select>
88
     <!--根据登录账号获取用户详情-->
88
     <!--根据登录账号获取用户详情-->
89
     <select id="getObjByLoginName" resultType="com.xhkjedu.suser.model.system.TUser">
89
     <select id="getObjByLoginName" resultType="com.xhkjedu.suser.model.system.TUser">
92
     </select>
92
     </select>
93
     <!--修改用户状态-->
93
     <!--修改用户状态-->
94
     <update id="updateState">
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
     </update>
96
     </update>
97
 
97
 
98
     <!-- 用户设置操作密码 -->
98
     <!-- 用户设置操作密码 -->
261
             ${userid}
261
             ${userid}
262
         </foreach>
262
         </foreach>
263
     </update>
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
     <!--根据用户id获取用户详细信息,学校基本信息-->
272
     <!--根据用户id获取用户详细信息,学校基本信息-->
266
     <select id="getUserSchoolByUserid" resultType="com.xhkjedu.suser.vo.system.UserVo">
273
     <select id="getUserSchoolByUserid" resultType="com.xhkjedu.suser.vo.system.UserVo">

Loading…
Cancel
Save