Bladeren bron

行政直播操作加限制保存中的禁止操作

tags/正式3.8.0
雍文秀 1 jaar geleden
bovenliggende
commit
477b10d394

+ 0
- 34
slive/src/main/java/com/xhkjedu/slive/config/CorsConfig.java Bestand weergeven

@@ -1,34 +0,0 @@
1
-package com.xhkjedu.slive.config;
2
-
3
-import org.springframework.context.annotation.Bean;
4
-import org.springframework.context.annotation.Configuration;
5
-import org.springframework.web.cors.CorsConfiguration;
6
-import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
7
-import org.springframework.web.filter.CorsFilter;
8
-
9
-/**
10
- * @ClassName CorsConfig
11
- * Description 请求跨域支持
12
- * Author WN
13
- * Date 2020/6/5 16:29
14
- **/
15
-@Configuration
16
-public class CorsConfig {
17
-    private CorsConfiguration corsConfiguration() {
18
-        CorsConfiguration corsConfiguration = new CorsConfiguration();
19
-        // 1允许任何域名使用
20
-        corsConfiguration.addAllowedOrigin("*");
21
-        // 2允许任何头
22
-        corsConfiguration.addAllowedHeader("*");
23
-        // 3允许任何方法(post、get等)
24
-        corsConfiguration.addAllowedMethod("*");
25
-        return corsConfiguration;
26
-    }
27
-
28
-    @Bean
29
-    public CorsFilter corsFilter() {
30
-        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
31
-        source.registerCorsConfiguration("/**", corsConfiguration());
32
-        return new CorsFilter(source);
33
-    }
34
-}

+ 22
- 1
slive/src/main/java/com/xhkjedu/slive/controller/xz/XzController.java Bestand weergeven

@@ -159,7 +159,8 @@ public class XzController {
159 159
      **/
160 160
     @PostMapping("/kcbd")
161 161
     public ResultVo delXzkjDyg(@RequestBody XzDateKjTeaVo kjTeaVo){
162
-        N_Utils.validation(new Object[]{kjTeaVo.getCourseid(),"课程id",1,kjTeaVo.getClassid(),"班级id",1});
162
+        N_Utils.validation(new Object[]{kjTeaVo.getCourseid(), "课程id", 1, kjTeaVo.getClassid(), "班级id", 1
163
+                , kjTeaVo.getXzid(), "行政直播id", 1});
163 164
         return xzService.delXzkjDyg(kjTeaVo);
164 165
     }
165 166
 
@@ -185,4 +186,24 @@ public class XzController {
185 186
         return xzService.importKb(file, xzid, createid);
186 187
     }
187 188
 
189
+    /**
190
+     * 获取保存状态
191
+     *
192
+     * @return com.xhkjedu.vo.ResultVo
193
+     * @Param [xz]
194
+     * @Author ywx
195
+     * @Date 2023/1/28 15:43
196
+     **/
197
+    @PostMapping("/get_savestate")
198
+    public ResultVo getSaveState(@RequestBody LXz xz) {
199
+        Integer xzid = xz.getXzid();
200
+        N_Utils.validation(new Object[]{xzid, "行政直播id", 1});
201
+        Integer savestate = xzService.getSaveStateById(xzid);
202
+        if (savestate == 1) {
203
+            return new ResultVo(1, "有课表在保存中禁止操作", savestate);
204
+        } else {
205
+            return new ResultVo(0, "获取保存状态成功", savestate);
206
+        }
207
+    }
208
+
188 209
 }

+ 11
- 3
slive/src/main/java/com/xhkjedu/slive/mapper/xz/XzMapper.java Bestand weergeven

@@ -41,14 +41,22 @@ public interface XzMapper extends TkMapper<LXz> {
41 41
     List<Map> listXzKjsAfterSaveXz(@Param("xzid") Integer xzid);
42 42
 
43 43
     //取指定课节指定日期所有班级的课程和教师
44
-    List<Map> listXzDateKjDetail(@Param("selectdate") String selectdate,@Param("xzid") Integer xzid,@Param("classid")Integer classid);
44
+    List<Map> listXzDateKjDetail(@Param("selectdate") String selectdate, @Param("xzid") Integer xzid,
45
+                                 @Param("classid") Integer classid);
45 46
 
46 47
     //获取指定课节班级对应的课程的日期
47
-    List<String> getAllDatesForKj(@Param("kjid") Integer kjid,@Param("classid") Integer classid,@Param("seldate") String seldate);
48
+    List<String> getAllDatesForKj(@Param("kjid") Integer kjid, @Param("classid") Integer classid,
49
+                                  @Param("seldate") String seldate);
48 50
 
49 51
     //根据课节id获取行政直播详情
50 52
     LXz getXzByXzkjid(@Param("kjid") Integer kjid);
51 53
 
52 54
     //修改课程表操作步骤
53
-    void updateCurstepByXzid(@Param("curstep") Integer curstep,@Param("xzid") Integer xzid);
55
+    void updateCurstepByXzid(@Param("curstep") Integer curstep, @Param("xzid") Integer xzid);
56
+
57
+    //修改保存状态
58
+    void updateSaveState(@Param("xzid") Integer xzid, @Param("savestate") int savestate);
59
+
60
+    //获取保存状态
61
+    Integer getSaveStateById(@Param("xzid") Integer xzid);
54 62
 }

+ 3
- 0
slive/src/main/java/com/xhkjedu/slive/model/xz/LXz.java Bestand weergeven

@@ -44,6 +44,9 @@ public class LXz extends BaseBean {
44 44
     //当前步骤:1基础信息2课程表3设置完成
45 45
     private Integer curstep;
46 46
 
47
+    //保存状态:1保存中
48
+    private Integer savestate;
49
+
47 50
     //创建人
48 51
     private Integer createid;
49 52
 

+ 46
- 18
slive/src/main/java/com/xhkjedu/slive/service/xz/XzService.java Bestand weergeven

@@ -96,6 +96,7 @@ public class XzService {
96 96
             xz.setCreatetime(timestamp);
97 97
             xz.setDeleted(1);
98 98
             xz.setCurstep(2);
99
+            xz.setSavestate(0);
99 100
             xzMapper.insertUseGeneratedKeys(xz);//保存行政直播信息
100 101
             Integer xzid = xz.getId();
101 102
             //保存对应的课节信息
@@ -163,6 +164,8 @@ public class XzService {
163 164
     @Transactional(rollbackFor = Exception.class)
164 165
     public void deleteXz(Integer xzid) {
165 166
         try {
167
+            Integer savestate = xzMapper.getSaveStateById(xzid);
168
+            if (savestate != 0) throw new Exception("有课表在保存中禁止操作");
166 169
             //如果行政直播下所有的课都未开始,则可以直接删除,
167 170
             //如果有直播课已经开始则进行逻辑删除,并删除所有未开始上的直播课
168 171
             Integer sectionnum = xzMapper.getXzSectionKsNum(xzid);
@@ -191,25 +194,28 @@ public class XzService {
191 194
      * @Date 2022/3/31 21:46
192 195
      **/
193 196
     public ResultVo saveXzCourse(LXz xz) {
197
+        Integer xzid = xz.getXzid();
194 198
         try {
195 199
             //保存行政直播课程表,参数层级为日期--课节--班级和教师
196 200
             //根据同一个课节下根据班级和教师确认是否是同一个直播课,保存进course,section(单课节课程)
197
-            LXz x = xzMapper.selectByPrimaryKey(xz.getXzid());//行政直播课程
201
+            LXz x = xzMapper.selectByPrimaryKey(xzid);//行政直播课程
202
+            if (x.getSavestate() != 0) return new ResultVo(1, "有课表在保存中禁止操作");
203
+            xzMapper.updateSaveState(xzid, 1);//修改保存状态
198 204
             List<XzDateVo> xzDatelst = xz.getXzdatas();
199 205
             if (xzDatelst == null || xzDatelst.size() == 0) {
200 206
                 return new ResultVo(1, "未设置课节信息");
201 207
             } else {
202 208
                 //日期转为map,先处理所有日期的数据
203
-                TreeMap<String,TreeMap<Integer,List<XzDateKjTeaVo>>> datemap = listDateKjForSave(xzDatelst, x);
204
-                Map<Integer,XzDateKjVo> kjVoMap = setKjMap(xz.getXzid());
209
+                TreeMap<String, TreeMap<Integer, List<XzDateKjTeaVo>>> datemap = listDateKjForSave(xzDatelst, x);
210
+                Map<Integer, XzDateKjVo> kjVoMap = setKjMap(xzid);
205 211
 
206 212
                 //开始保存
207
-                for(Map.Entry<String, TreeMap<Integer,List<XzDateKjTeaVo>>> entry : datemap.entrySet()){
208
-                    TreeMap<Integer,List<XzDateKjTeaVo>> kjmap = entry.getValue();
213
+                for (Map.Entry<String, TreeMap<Integer, List<XzDateKjTeaVo>>> entry : datemap.entrySet()) {
214
+                    TreeMap<Integer, List<XzDateKjTeaVo>> kjmap = entry.getValue();
209 215
                     String seldate = entry.getKey();
210 216
                     String datazhou = LiveUtil.getDateZhou(seldate);//要保存日期对应的周
211 217
 
212
-                    for(Map.Entry<Integer, List<XzDateKjTeaVo>> entrykj : kjmap.entrySet()){
218
+                    for (Map.Entry<Integer, List<XzDateKjTeaVo>> entrykj : kjmap.entrySet()) {
213 219
                         Integer kjid = entrykj.getKey();
214 220
                         XzDateKjVo kjVo = kjVoMap.get(kjid);
215 221
                         List<XzDateKjTeaVo> xjTealst = entrykj.getValue();
@@ -257,12 +263,13 @@ public class XzService {
257 263
                 }
258 264
 
259 265
                 //保存完课程表之后修改当前步骤
260
-                xzMapper.updateCurstepByXzid(3,xz.getXzid());
266
+                xzMapper.updateCurstepByXzid(3, xzid);
261 267
 
262 268
                 return new ResultVo(0, "保存成功");
263 269
             }
264 270
         } catch (Exception e) {
265 271
             log.error("保存行政直播课程表出错:" + e.getMessage());
272
+            xzMapper.updateSaveState(xzid, 0);//修改保存状态
266 273
             return new ResultVo(1,"保存失败");
267 274
         }
268 275
 
@@ -508,6 +515,8 @@ public class XzService {
508 515
      **/
509 516
     public ResultVo delXzkjDyg(XzDateKjTeaVo kjTeaVo) {
510 517
         try {
518
+            Integer savestate = xzMapper.getSaveStateById(kjTeaVo.getXzid());
519
+            if (savestate != 0) return new ResultVo(1, "有课表在保存中禁止操作");
511 520
             //判断课程的状态,如果已经开始上课则不能删除
512 521
             LCourse course = courseMapper.selectByPrimaryKey(kjTeaVo.getCourseid());
513 522
             Integer kjid = course.getKjid();
@@ -576,8 +585,11 @@ public class XzService {
576 585
      * @Date 2022/4/2 15:19
577 586
      **/
578 587
     public ResultVo saveOneXzKjDyg(XzDateKjTeaVo kjTeaVo) {
588
+        LXz xz = xzMapper.getXzByXzkjid(kjTeaVo.getKjid());
589
+        Integer xzid = xz.getXzid();
579 590
         try {
580
-            LXz xz = xzMapper.getXzByXzkjid(kjTeaVo.getKjid());
591
+            if (xz.getSavestate() != 0) return new ResultVo(1, "有课表在保存中禁止操作");
592
+            xzMapper.updateSaveState(xzid, 1);//修改保存状态
581 593
             kjTeaVo.setGradeid(xz.getGradeid());
582 594
             kjTeaVo.setSchoolid(xz.getSchoolid());
583 595
 
@@ -612,14 +624,16 @@ public class XzService {
612 624
 
613 625
                 }
614 626
             }
615
-            return new ResultVo(0, "保存成功",courseid);
627
+            return new ResultVo(0, "保存成功", courseid);
616 628
         } catch (Exception e) {
617 629
             log.error("保存课程表单个课程出错:" + e.getMessage());
618
-            if(e.getMessage().equals("所选班级无学生")){
630
+            if (e.getMessage().equals("所选班级无学生")) {
619 631
                 return new ResultVo(1, "保存失败:所选班级无学生");
620
-            }else{
632
+            } else {
621 633
                 return new ResultVo(1, "保存失败");
622 634
             }
635
+        } finally {
636
+            xzMapper.updateSaveState(xzid, 0);//修改保存状态
623 637
         }
624 638
     }
625 639
 
@@ -721,6 +735,8 @@ public class XzService {
721 735
         try {
722 736
             //获取行政直播信息
723 737
             LXz xz = xzMapper.selectByPrimaryKey(xzid);
738
+            if (xz.getSavestate() != 0) return new ResultVo(1, "有课表在保存中禁止操作");
739
+            xzMapper.updateSaveState(xzid, 1);//修改保存状态
724 740
             List<XzKjVo> kjs = xzKjMapper.listXzKjByXzId(xzid);//获取行政直播课节详情
725 741
             Integer noTimeKjNum = kjs.stream().filter(k -> k.getBegintime() == null).collect(Collectors.toList()).size();
726 742
             if (noTimeKjNum != 0) return new ResultVo(1, "请设置课节时间");
@@ -730,22 +746,28 @@ public class XzService {
730 746
             Integer schoolid = xz.getSchoolid();
731 747
             Integer year = schoolMapper.getYearById(schoolid);
732 748
             List<XzClassVo> classlst = classMapper.listClassByXzid(schoolid, gradeid);
733
-            String classids = classlst.stream().map((XzClassVo::getClassid)).map(String::valueOf).collect(Collectors.joining(","));
749
+            String classids = classlst.stream().map((XzClassVo::getClassid)).map(String::valueOf).collect(Collectors.joining(","
750
+            ));
734 751
             List<CTeacherVo> teachers = classTeacherMapper.listTeacherByClassIds(classids);//获取班级教师
735
-            if(!N_Utils.isListNotEmpty(teachers)) return new ResultVo(1,"请设置班级任教老师");
752
+            if (!N_Utils.isListNotEmpty(teachers)) return new ResultVo(1, "请设置班级任教老师");
736 753
 
737
-            String teacherids = teachers.stream().map((CTeacherVo::getTeacherid)).map(String::valueOf).collect(Collectors.joining(","));
754
+            String teacherids =
755
+                    teachers.stream().map((CTeacherVo::getTeacherid)).map(String::valueOf).collect(Collectors.joining(","));
738 756
             List<CTeacherVo> subjects = classTeacherMapper.listSubjectByTeacherIds(teacherids);//获取教师科目
739 757
             String subjectids = subjects.stream().map(CTeacherVo::getSubjectid).distinct().collect(Collectors.joining("','"));
740 758
             List<CTeacherVo> subjects2 = classTeacherMapper.listSubjectBySubjectIds(subjectids);
741
-            Map<String, String> subjectNameMap = subjects2.stream().collect(Collectors.toMap(CTeacherVo::getSubjectid, CTeacherVo::getSubjectname));
742
-            Map<Integer, String> subjectMap = subjects.stream().collect(Collectors.toMap(CTeacherVo::getTeacherid, CTeacherVo::getSubjectid));
743
-            Map<Integer, String> classMap = classlst.stream().collect(Collectors.toMap(XzClassVo::getClassid, XzClassVo::getClassname));
759
+            Map<String, String> subjectNameMap = subjects2.stream().collect(Collectors.toMap(CTeacherVo::getSubjectid,
760
+                    CTeacherVo::getSubjectname));
761
+            Map<Integer, String> subjectMap = subjects.stream().collect(Collectors.toMap(CTeacherVo::getTeacherid,
762
+                    CTeacherVo::getSubjectid));
763
+            Map<Integer, String> classMap = classlst.stream().collect(Collectors.toMap(XzClassVo::getClassid,
764
+                    XzClassVo::getClassname));
744 765
             List<CTeacherVo> users = classTeacherMapper.listTeacherBySchoolId(schoolid);//获取学校所有教师
745 766
             Set<String> userNameSet = users.stream().map(CTeacherVo::getUsername).collect(Collectors.toCollection(TreeSet::new));
746 767
             Map<String, CTeacherVo> classTeacherMap = new HashMap<>();//班级教师map
747 768
             for (CTeacherVo teacher : teachers) {
748
-                CTeacherVo vo = users.stream().filter(u -> u.getTeacherid().equals(teacher.getTeacherid())).findFirst().orElse(null);
769
+                CTeacherVo vo =
770
+                        users.stream().filter(u -> u.getTeacherid().equals(teacher.getTeacherid())).findFirst().orElse(null);
749 771
                 if (vo != null) teacher.setUsername(vo.getUsername());
750 772
                 teacher.setClassname(classMap.get(teacher.getClassid()));
751 773
                 teacher.setSubjectid(subjectMap.get(teacher.getTeacherid()));
@@ -783,6 +805,7 @@ public class XzService {
783 805
         } catch (Exception e) {
784 806
             log.error("导入课表出错:" + e.getMessage());
785 807
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
808
+            xzMapper.updateSaveState(xzid, 0);//修改保存状态
786 809
             throw new MissingParametersException(e.getMessage());
787 810
         }
788 811
     }
@@ -907,4 +930,9 @@ public class XzService {
907 930
         classStudentMapper.insertList(classStudentList);//批量保存课程班级学生
908 931
         groupStudentMapper.insertList(groupStudentList);//批量保存课程分组学生
909 932
     }
933
+
934
+    //获取保存状态
935
+    public Integer getSaveStateById(Integer xzid) {
936
+        return xzMapper.getSaveStateById(xzid);
937
+    }
910 938
 }

+ 1
- 0
slive/src/main/java/com/xhkjedu/slive/vo/xz/XzDateKjTeaVo.java Bestand weergeven

@@ -28,6 +28,7 @@ public class XzDateKjTeaVo {
28 28
     private Integer gradeid;//年级id
29 29
     private Integer createid;//操作人id
30 30
     private Integer schoolid;//学校id
31
+    private Integer xzid;//行政直播id
31 32
 
32 33
     private List<XzDateKjTeaVo> xjclass;//存放层级用于保存时使用
33 34
 }

+ 12
- 2
slive/src/main/resources/mapper/xz/XzMapper.xml Bestand weergeven

@@ -4,7 +4,7 @@
4 4
 
5 5
     <!--行政直播列表-->
6 6
     <select id="listXzs" resultType="java.util.Map">
7
-        select x.xzid,x.xzname,x.xzcomm,x.gradeid,x.daynum,x.begindate,x.enddate,x.createid,
7
+        select x.xzid,x.xzname,x.xzcomm,x.gradeid,x.daynum,x.begindate,x.enddate,x.createid,x.savestate,
8 8
         x.createtime, u.username,u.headpic from l_xz x left join t_user u on x.createid=u.userid
9 9
         where x.schoolid=#{xz.schoolid} and x.gradeid=#{xz.gradeid} and x.deleted=1
10 10
         <if test="xz.xzname!='' and xz.xzname!=null">
@@ -96,6 +96,16 @@
96 96
 
97 97
     <!--修改课程表操作步骤-->
98 98
     <update id="updateCurstepByXzid">
99
-        update l_xz set curstep=#{curstep} where xzid=#{xzid}
99
+        update l_xz set curstep=#{curstep}
100
+        <if test="curstep==3">,savestate=0</if>
101
+        where xzid=#{xzid}
100 102
     </update>
103
+    <!--修改保存状态-->
104
+    <update id="updateSaveState">
105
+        update l_xz set savestate=#{savestate} where xzid=#{xzid}
106
+    </update>
107
+    <!--获取保存状态-->
108
+    <select id="getSaveStateById" resultType="java.lang.Integer">
109
+        select savestate from l_xz where xzid=#{xzid}
110
+    </select>
101 111
 </mapper>

Laden…
Annuleren
Opslaan