Browse Source

Merge branch 'master' into wn

ywx
王宁 2 weeks ago
parent
commit
6e3694c1d9

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

@@ -0,0 +1,12 @@
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

@@ -0,0 +1,36 @@
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,14 +6,14 @@ import com.xhkjedu.suser.config.ConfigKey;
6 6
 import com.xhkjedu.suser.mapper.gradeclass.ClassMapper;
7 7
 import com.xhkjedu.suser.mapper.gradeclass.ClassTeacherMapper;
8 8
 import com.xhkjedu.suser.mapper.gradeclass.SchoolMapper;
9
-import com.xhkjedu.suser.mapper.subjectbook.TeacherPowersbMapper;
10 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 11
 import com.xhkjedu.suser.mapper.system.UserMapper;
13 12
 import com.xhkjedu.suser.mapper.system.UserUsecretMapper;
14 13
 import com.xhkjedu.suser.model.gradeclass.TClassTeacher;
15 14
 import com.xhkjedu.suser.model.system.TMsg;
16 15
 import com.xhkjedu.suser.model.system.TUser;
16
+import com.xhkjedu.suser.model.system.TUserComponent;
17 17
 import com.xhkjedu.suser.model.system.TUserUsecret;
18 18
 import com.xhkjedu.suser.utils.PoiUtils;
19 19
 import com.xhkjedu.suser.utils.SMSSender;
@@ -62,9 +62,7 @@ public class UserService extends JedisUtil {
62 62
     @Resource
63 63
     private UserUsecretMapper userUsecretMapper;
64 64
     @Resource
65
-    private TeacherPowersbMapper teacherPowersbMapper;
66
-    @Resource
67
-    private UserLogMapper userLogMapper;
65
+    private UserComponentMapper userComponentMapper;
68 66
 
69 67
     /**
70 68
      * 添加用户信息
@@ -74,6 +72,7 @@ public class UserService extends JedisUtil {
74 72
      * @Author ywx
75 73
      * @Date 2020/6/2 9:45
76 74
      **/
75
+    @Transactional(rollbackFor = Exception.class)
77 76
     public ResultVo save(TUser user) {
78 77
         Integer schoolid = user.getSchoolid();
79 78
         Integer usernum = schoolMapper.getUserNumById(schoolid);
@@ -108,7 +107,25 @@ public class UserService extends JedisUtil {
108 107
         user.setErrornum(0);
109 108
         user.setLoginname(N_Utils.strTrim(user.getLoginname()));
110 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,7 +452,23 @@ public class UserService extends JedisUtil {
435 452
             user.setUserlock(0);
436 453
             user.setErrornum(0);
437 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 474
             Integer grageid = user.getGrageid();
@@ -443,8 +476,7 @@ public class UserService extends JedisUtil {
443 476
             List<Integer> classids = user.getClassids();
444 477
             if (N_Utils.isListEmpty(classids)) return new AsyncResult<>(true);
445 478
 
446
-            userid = user.getId();
447
-            int timestamp = N_Utils.getSecondTimestamp();
479
+
448 480
             for (Integer classid : classids) {
449 481
                 TClassTeacher ct = new TClassTeacher();
450 482
                 ct.setTeacherid(userid);
@@ -454,6 +486,7 @@ public class UserService extends JedisUtil {
454 486
                 ct.setCreatetime(timestamp);
455 487
                 ctlst.add(ct);
456 488
             }
489
+
457 490
         } else {
458 491
             if (schoolid != u.getSchoolid()) {
459 492
                 usersExisted.add(u);

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

@@ -1,5 +1,6 @@
1 1
 package com.xhkjedu.suser.utils;
2 2
 
3
+import com.xhkjedu.suser.model.system.TUserComponent;
3 4
 import com.xhkjedu.utils.N_Utils;
4 5
 import com.xhkjedu.vo.ResultVo;
5 6
 import lombok.extern.slf4j.Slf4j;
@@ -81,4 +82,52 @@ public class UserUtil {
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