Browse Source

预习未选分组判断,登录优化

tags/正式3.3.0
王宁 2 years ago
parent
commit
51231974b5

+ 4
- 4
sstudy/src/main/java/com/xhkjedu/sstudy/controller/resource/GuideController.java View File

@@ -11,6 +11,7 @@ import com.xhkjedu.vo.ResultVo;
11 11
 import com.xhkjedu.sstudy.vo.paper.AnalyzeSearchVo;
12 12
 import com.xhkjedu.sstudy.vo.resource.GuideAnalyzeVo;
13 13
 import com.xhkjedu.sstudy.vo.resource.GuideVo;
14
+import lombok.extern.slf4j.Slf4j;
14 15
 import org.springframework.beans.factory.annotation.Autowired;
15 16
 import org.springframework.util.CollectionUtils;
16 17
 import org.springframework.web.bind.annotation.PostMapping;
@@ -29,6 +30,7 @@ import java.util.Map;
29 30
  **/
30 31
 @RequestMapping("/guide")
31 32
 @RestController
33
+@Slf4j
32 34
 public class GuideController {
33 35
     @Autowired
34 36
     private GuideService guideService;
@@ -106,8 +108,7 @@ public class GuideController {
106 108
         String lsbid = guide.getLsbid();
107 109
         N_Utils.validation(new Object[]{createid,"教师id",1,subjectid,"科目",2,lsbid,"教材",2});
108 110
 
109
-        guideService.save(guide);
110
-        return new ResultVo(0, "保存成功");
111
+        return guideService.save(guide);
111 112
     }
112 113
 
113 114
     //分享预习
@@ -122,8 +123,7 @@ public class GuideController {
122 123
         String lsbid = guide.getLsbid();
123 124
         N_Utils.validation(new Object[]{resourceid,"资源",2,createid,"教师id",1,subjectid,"科目",2,lsbid,"教材",2});
124 125
 
125
-        guideService.shareGuide(guide);
126
-        return new ResultVo(0, "分享成功");
126
+        return guideService.shareGuide(guide);
127 127
     }
128 128
 
129 129
     //删除预习

+ 101
- 74
sstudy/src/main/java/com/xhkjedu/sstudy/service/resource/GuideService.java View File

@@ -14,10 +14,13 @@ import com.xhkjedu.sstudy.vo.paper.AnalyzeSearchVo;
14 14
 import com.xhkjedu.sstudy.vo.resource.GuideAnalyzeVo;
15 15
 import com.xhkjedu.sstudy.vo.resource.GuideVo;
16 16
 import com.xhkjedu.utils.N_Utils;
17
+import com.xhkjedu.vo.ResultVo;
18
+import lombok.extern.slf4j.Slf4j;
17 19
 import org.apache.commons.lang3.StringUtils;
18 20
 import org.springframework.beans.factory.annotation.Autowired;
19 21
 import org.springframework.stereotype.Service;
20 22
 import org.springframework.transaction.annotation.Transactional;
23
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
21 24
 
22 25
 import javax.annotation.Resource;
23 26
 import java.util.*;
@@ -30,6 +33,7 @@ import java.util.stream.Collectors;
30 33
  * Date 2021/10/20 10:37
31 34
  **/
32 35
 @Service
36
+@Slf4j
33 37
 public class GuideService {
34 38
     @Resource
35 39
     private GuideMapper guideMapper;
@@ -90,76 +94,93 @@ public class GuideService {
90 94
     }
91 95
 
92 96
     //保存学生预习
93
-    @Transactional
94
-    public Integer save(TGuide guide){
95
-        Integer timestamp = N_Utils.getSecondTimestamp();
96
-        guide.setCreatetime(timestamp);
97
-        guideMapper.insertUseGeneratedKeys(guide);
98
-        Integer guideid = guide.getId();//预习id
99
-        guide.setGuideid(guideid);
100
-
101
-        //保存资源
102
-        List<TResource> resources = guide.getResources();
103
-        for(TResource r : resources) {
104
-            r.setCreateid(guide.getCreateid());
105
-            r.setCreatetime(guide.getCreatetime());
106
-            r.setLevel(3);
107
-            r.setResourcestate(1);
108
-            r.setResourcetype(10);
109
-            r.setBelong(4);
110
-            r.setSchoolid(guide.getSchoolid());
111
-            r.setSubjectid(guide.getSubjectid());
112
-
113
-            String resourceid = StudyUtil.getId();//资源id
114
-            r.setResourceid(resourceid);
115
-            Integer resourceclass = r.getResourceclass();
116
-            if (resourceclass == 3 || resourceclass == 4 || resourceclass == 6) {
117
-                r.setConverted(1);
118
-            } else if (resourceclass == 5 && (r.getSuffix().equals("flv") || r.getMp4code().equals("h264"))) {
119
-                r.setConverted(1);
97
+    @Transactional(rollbackFor = Exception.class)
98
+    public ResultVo save(TGuide guide){
99
+
100
+        try {
101
+            Integer timestamp = N_Utils.getSecondTimestamp();
102
+            guide.setCreatetime(timestamp);
103
+            guideMapper.insertUseGeneratedKeys(guide);
104
+            Integer guideid = guide.getId();//预习id
105
+            guide.setGuideid(guideid);
106
+
107
+            //保存资源
108
+            List<TResource> resources = guide.getResources();
109
+            for(TResource r : resources) {
110
+                r.setCreateid(guide.getCreateid());
111
+                r.setCreatetime(guide.getCreatetime());
112
+                r.setLevel(3);
113
+                r.setResourcestate(1);
114
+                r.setResourcetype(10);
115
+                r.setBelong(4);
116
+                r.setSchoolid(guide.getSchoolid());
117
+                r.setSubjectid(guide.getSubjectid());
118
+
119
+                String resourceid = StudyUtil.getId();//资源id
120
+                r.setResourceid(resourceid);
121
+                Integer resourceclass = r.getResourceclass();
122
+                if (resourceclass == 3 || resourceclass == 4 || resourceclass == 6) {
123
+                    r.setConverted(1);
124
+                } else if (resourceclass == 5 && (r.getSuffix().equals("flv") || r.getMp4code().equals("h264"))) {
125
+                    r.setConverted(1);
126
+                }
127
+                //保存资源信息
128
+                resourceMapper.insertSelective(r);
129
+                //保存预习资源关联关系
130
+                TGuideResource gr = new TGuideResource();
131
+                gr.setGuideid(guideid);
132
+                gr.setResourceid(resourceid);
133
+                gr.setCreateid(guide.getCreateid());
134
+                gr.setCreatetime(guide.getCreatetime());
135
+                guideResourceMapper.insertUseGeneratedKeys(gr);
136
+
137
+                convertUtil.convertResource(r);//资源转换(word或ppt转为pdf,视频非h264编码转码,压缩包解压)
120 138
             }
121
-            //保存资源信息
122
-            resourceMapper.insertSelective(r);
123
-            //保存预习资源关联关系
124
-            TGuideResource gr = new TGuideResource();
125
-            gr.setGuideid(guideid);
126
-            gr.setResourceid(resourceid);
127
-            gr.setCreateid(guide.getCreateid());
128
-            gr.setCreatetime(guide.getCreatetime());
129
-            guideResourceMapper.insertUseGeneratedKeys(gr);
130
-
131
-            convertUtil.convertResource(r);//资源转换(word或ppt转为pdf,视频非h264编码转码,压缩包解压)
139
+
140
+            //保存预习学生关联信息
141
+            batchSaveGuideStudent(guide);
142
+            return new ResultVo(0,"保存成功");
143
+        }catch (Exception e){
144
+            log.error("保存预习失败:" + e.getMessage());
145
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
146
+            return new ResultVo(1,"保存失败");
132 147
         }
133 148
 
134
-        //保存预习学生关联信息
135
-        batchSaveGuideStudent(guide);
136
-        return guideid;
137 149
     }
138 150
 
139 151
     //个人空间分享到学生预习
140
-    @Transactional
141
-    public void shareGuide(TGuide guide) {
142
-        String resourceid = guide.getResourceid();
143
-        Integer timestamp = N_Utils.getSecondTimestamp();
144
-        guide.setCreatetime(timestamp);
145
-        guideMapper.insertUseGeneratedKeys(guide);
146
-        Integer guideid = guide.getId();//预习id
147
-
148
-        //保存预习资源
149
-        TGuideResource guideResource = new TGuideResource();
150
-        guideResource.setGuideid(guideid);
151
-        guideResource.setResourceid(resourceid);
152
-        guideResource.setCreateid(guide.getCreateid());
153
-        guideResource.setCreatetime(timestamp);
154
-        guideResourceMapper.insert(guideResource);
155
-        guide.setGuideid(guideid);
156
-
157
-        //保存预习学生关联信息
158
-        batchSaveGuideStudent(guide);
152
+    @Transactional(rollbackFor = Exception.class)
153
+    public ResultVo shareGuide(TGuide guide){
154
+
155
+        try {
156
+            String resourceid = guide.getResourceid();
157
+            Integer timestamp = N_Utils.getSecondTimestamp();
158
+            guide.setCreatetime(timestamp);
159
+            guideMapper.insertUseGeneratedKeys(guide);
160
+            Integer guideid = guide.getId();//预习id
161
+
162
+            //保存预习资源
163
+            TGuideResource guideResource = new TGuideResource();
164
+            guideResource.setGuideid(guideid);
165
+            guideResource.setResourceid(resourceid);
166
+            guideResource.setCreateid(guide.getCreateid());
167
+            guideResource.setCreatetime(timestamp);
168
+            guideResourceMapper.insert(guideResource);
169
+            guide.setGuideid(guideid);
170
+
171
+            //保存预习学生关联信息
172
+            batchSaveGuideStudent(guide);
173
+            return new ResultVo(0,"分享成功");
174
+        }catch (Exception e){
175
+            log.error("分享预习失败:" + e.getMessage());
176
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
177
+            return new ResultVo(1,"分享失败");
178
+        }
179
+
159 180
     }
160 181
 
161 182
     //批量维护预习班级和学生信息
162
-    private void batchSaveGuideStudent(TGuide guide) {
183
+    private void batchSaveGuideStudent(TGuide guide) throws Exception {
163 184
         List<TGuideGroup> guideGroups = guide.getGuideGroups().stream().distinct().collect(Collectors.toList());
164 185
         List<TGuideGroup> savegroup = new ArrayList<>();
165 186
         List<TGuideGroupStudent> savestus = new ArrayList<>();
@@ -172,23 +193,29 @@ public class GuideService {
172 193
             g.setCreatetime(guide.getCreatetime());
173 194
             savegroup.add(g);
174 195
 
175
-            //页面选择的学生预习学生集合
176
-            String groupids = StringUtils.join(gg.getGroups(),",");
177
-
178
-            //获取选中班级分组下所有学生
179
-            List<Integer> stus = classMapper.listStudentidsByGroupids(groupids);
180
-            for (Integer studentid : stus) {
181
-                TGuideGroupStudent ggs = new TGuideGroupStudent();
182
-                ggs.setGuideid(guide.getGuideid());
183
-                ggs.setClassid(classid);
184
-                ggs.setStudentid(studentid);
185
-                ggs.setCosttime(0);
186
-                ggs.setCreatetime(N_Utils.getSecondTimestamp());
187
-                savestus.add(ggs);
196
+            if(gg.getGroups() != null && gg.getGroups().size() > 0){
197
+                //页面选择的学生预习学生集合
198
+                String groupids = StringUtils.join(gg.getGroups(),",");
199
+
200
+                //获取选中班级分组下所有学生
201
+                List<Integer> stus = classMapper.listStudentidsByGroupids(groupids);
202
+                for (Integer studentid : stus) {
203
+                    TGuideGroupStudent ggs = new TGuideGroupStudent();
204
+                    ggs.setGuideid(guide.getGuideid());
205
+                    ggs.setClassid(classid);
206
+                    ggs.setStudentid(studentid);
207
+                    ggs.setCosttime(0);
208
+                    ggs.setCreatetime(N_Utils.getSecondTimestamp());
209
+                    savestus.add(ggs);
188 210
 
211
+                }
189 212
             }
190 213
         }
191 214
 
215
+        if(savestus == null || savestus.size() == 0){
216
+            throw new Exception("未选择学生");
217
+        }
218
+
192 219
         //保存预习班级、预习学生信息
193 220
         guideGroupMapper.insertList(savegroup);
194 221
         guideGroupStudentMapper.insertList(savestus);

+ 1
- 1
sstudy/src/main/resources/application.properties View File

@@ -107,4 +107,4 @@ file.showurl=http://schoolstatictest.xhkjedu.com/static/
107 107
 dbname=xhkjedu_school_test
108 108
 
109 109
 #版本号
110
-versionname=Test_v3.2.6
110
+versionname=Test_v3.2.7

+ 35
- 4
suser/src/main/java/com/xhkjedu/suser/service/system/UserService.java View File

@@ -115,10 +115,24 @@ public class UserService extends JedisUtil {
115 115
                 }
116 116
             }
117 117
 
118
+            //判断用户状态
118 119
             if(userVo.getUserlock() == 1){
119 120
                 return new ResultVo(1, "此账号已锁定,禁止登录");
120 121
             }
121 122
 
123
+            //判断用户有效期
124
+            String usertime = userVo.getUsertime();
125
+            if (N_Utils.isNotEmpty(usertime)) {
126
+                String dayBegin = DatesUtil.getDayBegin();
127
+                if (usertime.compareTo(dayBegin) < 0) {
128
+                    if (usertype == 2) {//学生
129
+                        return new ResultVo(1, "账号已过有效期,请联系老师");
130
+                    } else {
131
+                        return new ResultVo(1, "账号已过有效期,请联系管理员");
132
+                    }
133
+                }
134
+            }
135
+
122 136
             //进行角色判断
123 137
             if (usertype == 2) {
124 138
                 Integer stuweb = userVo.getStuweb();
@@ -169,7 +183,12 @@ public class UserService extends JedisUtil {
169 183
             user.setUserid(userVo.getUserid());
170 184
             user.setUsername(userVo.getUsername());
171 185
             user.setSchoolid(userVo.getSchoolid());
172
-            if (!userVo.getLoginpwd().equals(user.getLoginpwd())) {
186
+            user.setUsertype(userVo.getUsertype());
187
+
188
+            //验证用户信息
189
+            resultVo = this.checkLoginUser(user,userVo,1);
190
+
191
+            /*if (!userVo.getLoginpwd().equals(user.getLoginpwd())) {
173 192
                 resultVo = new ResultVo(1, "密码错误");
174 193
             } else {
175 194
                 if (userVo.getUsertype() != 1) {
@@ -183,7 +202,7 @@ public class UserService extends JedisUtil {
183 202
                         resultVo = new ResultVo(0, "登录成功", userVo);
184 203
                     }
185 204
                 }
186
-            }
205
+            }*/
187 206
         } else {
188 207
             resultVo = new ResultVo(1, "此账号不存在");
189 208
         }
@@ -210,6 +229,7 @@ public class UserService extends JedisUtil {
210 229
             user.setUserid(userVo.getUserid());
211 230
             user.setUsername(userVo.getUsername());
212 231
             user.setSchoolid(userVo.getSchoolid());
232
+            user.setUsertype(userVo.getUsertype());
213 233
             //验证学生登录系列问题
214 234
             resultVo = checkLoginStudent(user,userVo);
215 235
         } else {
@@ -226,6 +246,7 @@ public class UserService extends JedisUtil {
226 246
         } else {
227 247
             Integer sbindmac = userVo.getSbindmac();//学校是否绑定设备0未绑定1绑定
228 248
             String mac = user.getMac();
249
+            String usertime = userVo.getUsertime();
229 250
 
230 251
             if (userVo.getUsertype() != 2) {
231 252
                 return new ResultVo(1, "登录失败,仅允许学生登录");
@@ -240,7 +261,15 @@ public class UserService extends JedisUtil {
240 261
                         return new ResultVo(1, "登录失败,该设备已与其他账号关联");
241 262
                     }
242 263
                 }
264
+            } else if (N_Utils.isNotEmpty(usertime)){
265
+                String dayBegin = DatesUtil.getDayBegin();
266
+                if (usertime.compareTo(dayBegin) < 0) {
267
+                    return new ResultVo(1, "账号已过有效期,请联系老师");
268
+                }
269
+            } else if (userVo.getUserlock() == 1) {
270
+                return new ResultVo(1, "此账号已锁定,禁止登录");
243 271
             }
272
+
244 273
             //更新学生硬件绑定信息
245 274
             userVo.setMac(mac);
246 275
             userVo.setBindmac(sbindmac);
@@ -267,6 +296,7 @@ public class UserService extends JedisUtil {
267 296
             user.setUsername(userVo.getUsername());
268 297
             user.setSchoolid(userVo.getSchoolid());
269 298
             user.setLoginname(userVo.getLoginname());
299
+            user.setUsertype(userVo.getUsertype());
270 300
 
271 301
             resultVo = checkLoginUser(user,userVo,2);
272 302
         } else {
@@ -291,7 +321,8 @@ public class UserService extends JedisUtil {
291 321
         Integer usertype = user.getUsertype();
292 322
         if (result.getCode() == 0) {
293 323
             UserVo userVo = (UserVo) result.getObj();
294
-            if (userVo.getUserlock() == 1) {
324
+            //以下代码登录的时候进行判断
325
+            /*if (userVo.getUserlock() == 1) {
295 326
                 result.setCode(1);
296 327
                 result.setMsg("此账号已锁定,禁止登录");
297 328
                 return result;
@@ -308,7 +339,7 @@ public class UserService extends JedisUtil {
308 339
                     }
309 340
                     return result;
310 341
                 }
311
-            }
342
+            }*/
312 343
 
313 344
             //redis
314 345
             String ticketKey = UUID.randomUUID().toString().replace("-", "");

+ 1
- 1
suser/src/main/resources/application.properties View File

@@ -57,4 +57,4 @@ signName=【河南星火燎原】
57 57
 #郑州管城大数据SSO认证鉴权接口
58 58
 ssourl=http://gcdsj.zzgcjy.cn/portal/sso/api/agent
59 59
 #版本号
60
-versionname=Test_v3.2.10
60
+versionname=Test_v3.2.11

Loading…
Cancel
Save