Browse Source

新增教师、导入教师添加默认组件

tags/正式3.14.2
王宁 2 weeks ago
parent
commit
e7bb5c2e37

+ 12
- 0
suser/src/main/java/com/xhkjedu/suser/mapper/system/UserComponentMapper.java View File

1
+package com.xhkjedu.suser.mapper.system;
2
+
3
+import com.xhkjedu.base.TkMapper;
4
+import com.xhkjedu.suser.model.system.TUserComponent;
5
+
6
+/**
7
+ * @Description:用户组件
8
+ * @Author: WN
9
+ * @Date: 2024/7/19 14:44:39
10
+ **/
11
+public interface UserComponentMapper extends TkMapper<TUserComponent> {
12
+}

+ 36
- 0
suser/src/main/java/com/xhkjedu/suser/model/system/TUserComponent.java View File

1
+package com.xhkjedu.suser.model.system;
2
+
3
+import lombok.Data;
4
+
5
+import javax.persistence.Id;
6
+import javax.persistence.Table;
7
+
8
+/**
9
+ * @Description:用户组件表
10
+ * @Author: WN
11
+ * @Date: 2024/7/19 14:39:09
12
+ **/
13
+@Table(name = "t_user_component")
14
+@Data
15
+public class TUserComponent {
16
+    @Id
17
+    private Integer ucid;
18
+
19
+    //用户id
20
+    private Integer userid;
21
+
22
+    //组件code
23
+    private String ccode;
24
+
25
+    //组件宽(份数)
26
+    private Integer cwidth;
27
+
28
+    //组件高(份数)
29
+    private Integer cheight;
30
+
31
+    //组件排序
32
+    private Integer corder;
33
+
34
+    //创建时间
35
+    private Integer createtime;
36
+}

+ 42
- 9
suser/src/main/java/com/xhkjedu/suser/service/system/UserService.java View File

6
 import com.xhkjedu.suser.mapper.gradeclass.ClassMapper;
6
 import com.xhkjedu.suser.mapper.gradeclass.ClassMapper;
7
 import com.xhkjedu.suser.mapper.gradeclass.ClassTeacherMapper;
7
 import com.xhkjedu.suser.mapper.gradeclass.ClassTeacherMapper;
8
 import com.xhkjedu.suser.mapper.gradeclass.SchoolMapper;
8
 import com.xhkjedu.suser.mapper.gradeclass.SchoolMapper;
9
-import com.xhkjedu.suser.mapper.subjectbook.TeacherPowersbMapper;
10
 import com.xhkjedu.suser.mapper.system.MsgMapper;
9
 import com.xhkjedu.suser.mapper.system.MsgMapper;
11
-import com.xhkjedu.suser.mapper.system.UserLogMapper;
10
+import com.xhkjedu.suser.mapper.system.UserComponentMapper;
12
 import com.xhkjedu.suser.mapper.system.UserMapper;
11
 import com.xhkjedu.suser.mapper.system.UserMapper;
13
 import com.xhkjedu.suser.mapper.system.UserUsecretMapper;
12
 import com.xhkjedu.suser.mapper.system.UserUsecretMapper;
14
 import com.xhkjedu.suser.model.gradeclass.TClassTeacher;
13
 import com.xhkjedu.suser.model.gradeclass.TClassTeacher;
15
 import com.xhkjedu.suser.model.system.TMsg;
14
 import com.xhkjedu.suser.model.system.TMsg;
16
 import com.xhkjedu.suser.model.system.TUser;
15
 import com.xhkjedu.suser.model.system.TUser;
16
+import com.xhkjedu.suser.model.system.TUserComponent;
17
 import com.xhkjedu.suser.model.system.TUserUsecret;
17
 import com.xhkjedu.suser.model.system.TUserUsecret;
18
 import com.xhkjedu.suser.utils.PoiUtils;
18
 import com.xhkjedu.suser.utils.PoiUtils;
19
 import com.xhkjedu.suser.utils.SMSSender;
19
 import com.xhkjedu.suser.utils.SMSSender;
62
     @Resource
62
     @Resource
63
     private UserUsecretMapper userUsecretMapper;
63
     private UserUsecretMapper userUsecretMapper;
64
     @Resource
64
     @Resource
65
-    private TeacherPowersbMapper teacherPowersbMapper;
66
-    @Resource
67
-    private UserLogMapper userLogMapper;
65
+    private UserComponentMapper userComponentMapper;
68
 
66
 
69
     /**
67
     /**
70
      * 添加用户信息
68
      * 添加用户信息
74
      * @Author ywx
72
      * @Author ywx
75
      * @Date 2020/6/2 9:45
73
      * @Date 2020/6/2 9:45
76
      **/
74
      **/
75
+    @Transactional(rollbackFor = Exception.class)
77
     public ResultVo save(TUser user) {
76
     public ResultVo save(TUser user) {
78
         Integer schoolid = user.getSchoolid();
77
         Integer schoolid = user.getSchoolid();
79
         Integer usernum = schoolMapper.getUserNumById(schoolid);
78
         Integer usernum = schoolMapper.getUserNumById(schoolid);
108
         user.setErrornum(0);
107
         user.setErrornum(0);
109
         user.setLoginname(N_Utils.strTrim(user.getLoginname()));
108
         user.setLoginname(N_Utils.strTrim(user.getLoginname()));
110
         userMapper.insertUseGeneratedKeys(user);
109
         userMapper.insertUseGeneratedKeys(user);
111
-        return new ResultVo(0, "保存成功", user.getId());
110
+        Integer userid = user.getId();
111
+        if(user.getUsertype() == 1){
112
+            List<TUserComponent> initComponents = UserUtil.listInitComponents();
113
+            List<TUserComponent> saveComponents = new ArrayList<>();
114
+            Integer timestamp = N_Utils.getSecondTimestamp();
115
+            for (TUserComponent userComponent : initComponents) {
116
+                TUserComponent sc = new TUserComponent();
117
+                sc.setUserid(userid);
118
+                sc.setCcode(userComponent.getCcode());
119
+                sc.setCwidth(userComponent.getCwidth());
120
+                sc.setCheight(userComponent.getCheight());
121
+                sc.setCorder(userComponent.getCorder());
122
+                sc.setCreatetime(timestamp);
123
+                saveComponents.add(sc);
124
+            }
125
+            userComponentMapper.insertList(saveComponents);
126
+        }
127
+
128
+        return new ResultVo(0, "保存成功", userid);
112
     }
129
     }
113
 
130
 
114
     /**
131
     /**
435
             user.setUserlock(0);
452
             user.setUserlock(0);
436
             user.setErrornum(0);
453
             user.setErrornum(0);
437
             userMapper.insertUseGeneratedKeys(user);
454
             userMapper.insertUseGeneratedKeys(user);
438
-            //teacherList.add(user);
455
+            int timestamp = N_Utils.getSecondTimestamp();
456
+            userid = user.getId();
457
+
458
+            //初始化首页组件
459
+            List<TUserComponent> initComponents = UserUtil.listInitComponents();
460
+            List<TUserComponent> saveComponents = new ArrayList<>();
461
+            for(TUserComponent userComponent : initComponents){
462
+                TUserComponent sc = new TUserComponent();
463
+                sc.setUserid(userid);
464
+                sc.setCcode(userComponent.getCcode());
465
+                sc.setCwidth(userComponent.getCwidth());
466
+                sc.setCheight(userComponent.getCheight());
467
+                sc.setCorder(userComponent.getCorder());
468
+                sc.setCreatetime(timestamp);
469
+                saveComponents.add(sc);
470
+            }
471
+            userComponentMapper.insertList(saveComponents);
439
 
472
 
440
             //处理用户班级
473
             //处理用户班级
441
             Integer grageid = user.getGrageid();
474
             Integer grageid = user.getGrageid();
443
             List<Integer> classids = user.getClassids();
476
             List<Integer> classids = user.getClassids();
444
             if (N_Utils.isListEmpty(classids)) return new AsyncResult<>(true);
477
             if (N_Utils.isListEmpty(classids)) return new AsyncResult<>(true);
445
 
478
 
446
-            userid = user.getId();
447
-            int timestamp = N_Utils.getSecondTimestamp();
479
+
448
             for (Integer classid : classids) {
480
             for (Integer classid : classids) {
449
                 TClassTeacher ct = new TClassTeacher();
481
                 TClassTeacher ct = new TClassTeacher();
450
                 ct.setTeacherid(userid);
482
                 ct.setTeacherid(userid);
454
                 ct.setCreatetime(timestamp);
486
                 ct.setCreatetime(timestamp);
455
                 ctlst.add(ct);
487
                 ctlst.add(ct);
456
             }
488
             }
489
+
457
         } else {
490
         } else {
458
             if (schoolid != u.getSchoolid()) {
491
             if (schoolid != u.getSchoolid()) {
459
                 usersExisted.add(u);
492
                 usersExisted.add(u);

+ 49
- 0
suser/src/main/java/com/xhkjedu/suser/utils/UserUtil.java View File

1
 package com.xhkjedu.suser.utils;
1
 package com.xhkjedu.suser.utils;
2
 
2
 
3
+import com.xhkjedu.suser.model.system.TUserComponent;
3
 import com.xhkjedu.utils.N_Utils;
4
 import com.xhkjedu.utils.N_Utils;
4
 import com.xhkjedu.vo.ResultVo;
5
 import com.xhkjedu.vo.ResultVo;
5
 import lombok.extern.slf4j.Slf4j;
6
 import lombok.extern.slf4j.Slf4j;
81
             }
82
             }
82
         }
83
         }
83
     }
84
     }
85
+
86
+    /*
87
+     * @Description 初始化组件
88
+     * @Date 2024/12/9 16:23:01
89
+     * @Author WN
90
+     * @Param []
91
+     * @Return java.util.List<com.xhkjedu.suser.model.system.TUserComponent>
92
+     **/
93
+    public static List<TUserComponent> listInitComponents(){
94
+        List<TUserComponent> initComponents = new ArrayList<>();
95
+        TUserComponent uc1 = new TUserComponent();
96
+        uc1.setCcode("HomeWorkNoticeResearch");
97
+        uc1.setCwidth(1);
98
+        uc1.setCheight(1);
99
+        uc1.setCorder(1);
100
+        initComponents.add(uc1);
101
+
102
+        TUserComponent uc2 = new TUserComponent();
103
+        uc2.setCcode("MySpace");
104
+        uc2.setCwidth(1);
105
+        uc2.setCheight(1);
106
+        uc2.setCorder(2);
107
+        initComponents.add(uc2);
108
+
109
+        TUserComponent uc3 = new TUserComponent();
110
+        uc3.setCcode("CommonUse");
111
+        uc3.setCwidth(1);
112
+        uc3.setCheight(1);
113
+        uc3.setCorder(2);
114
+        initComponents.add(uc3);
115
+
116
+        TUserComponent uc4 = new TUserComponent();
117
+        uc4.setCcode("PreviewHomeworkRecite");
118
+        uc4.setCwidth(2);
119
+        uc4.setCheight(1);
120
+        uc4.setCorder(4);
121
+        initComponents.add(uc4);
122
+
123
+        TUserComponent uc5 = new TUserComponent();
124
+        uc5.setCcode("SchoolResourceLibrary");
125
+        uc5.setCwidth(1);
126
+        uc5.setCheight(1);
127
+        uc5.setCorder(5);
128
+        initComponents.add(uc5);
129
+
130
+        return initComponents;
131
+
132
+    }
84
 }
133
 }

Loading…
Cancel
Save