王宁 2 лет назад
Родитель
Сommit
9e63d6b8d8

+ 109
- 0
slive/src/main/java/com/xhkjedu/slive/controller/xz/XzController.java Просмотреть файл

@@ -0,0 +1,109 @@
1
+package com.xhkjedu.slive.controller.xz;
2
+
3
+import com.github.pagehelper.PageHelper;
4
+import com.github.pagehelper.PageInfo;
5
+import com.xhkjedu.slive.model.xz.LXz;
6
+import com.xhkjedu.slive.service.xz.XzService;
7
+import com.xhkjedu.utils.N_Utils;
8
+import com.xhkjedu.utils.PageUtil;
9
+import com.xhkjedu.vo.PageResult;
10
+import com.xhkjedu.vo.ResultVo;
11
+import org.springframework.web.bind.annotation.PostMapping;
12
+import org.springframework.web.bind.annotation.RequestBody;
13
+import org.springframework.web.bind.annotation.RequestMapping;
14
+import org.springframework.web.bind.annotation.RestController;
15
+
16
+import javax.annotation.Resource;
17
+import java.util.List;
18
+import java.util.Map;
19
+
20
+/**
21
+ *@Description
22
+ *@Author WN
23
+ *Date 2022/3/30 12:09
24
+ **/
25
+@RestController
26
+@RequestMapping("/xz")
27
+public class XzController {
28
+
29
+    @Resource
30
+    private XzService xzService;
31
+
32
+    /** 行政直播列表
33
+     * @Description
34
+     * @Param [xz]
35
+     * @Return com.xhkjedu.vo.ResultVo
36
+     * @Author wn
37
+     * @Date 2022/3/30 13:55
38
+     **/
39
+    @PostMapping("/list")
40
+    public ResultVo list(@RequestBody LXz xz){
41
+        N_Utils.validation(new Object[]{xz.getSchoolid(),"学校id",1});
42
+        PageHelper.startPage(xz.getPage(), xz.getPageSize());
43
+        List<Map> list = xzService.listXzs(xz.getSchoolid(),xz.getXzname());
44
+        PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
45
+        return new ResultVo(0,"获取行政直播列表成功",pageResult);
46
+    }
47
+
48
+
49
+   /**
50
+    * @Description 保存行政直播
51
+    * @Param xz
52
+    * @Return com.xhkjedu.vo.ResultVo
53
+    * @Author wn
54
+    * @Date 2022/3/30 13:51
55
+    **/
56
+    @PostMapping("/save")
57
+    public ResultVo save(@RequestBody LXz xz){
58
+        N_Utils.validation(new Object[]{xz.getXzname(),"名称",2,xz.getGradeid(),"年级",1,xz.getDaynum(),"课节数量",1,
59
+        xz.getBegindate(),"开始日期",2,xz.getEnddate(),"结束日期",2,xz.getSchoolid(),"学校id",1});
60
+        if ("NaN-aN-aN".equals(xz.getBegindate()) || "NaN-aN-aN".equals(xz.getEnddate())) {
61
+            return new ResultVo(1,"日期格式不正确");
62
+        }
63
+        Integer xzid = xzService.saveXz(xz);
64
+        return new ResultVo(0, "保存成功",xzid);
65
+    }
66
+
67
+    /**
68
+     * @Description 修改行政直播
69
+     * @Param [xz]
70
+     * @Return com.xhkjedu.vo.ResultVo
71
+     * @Author wn
72
+     * @Date 2022/3/30 17:05
73
+     **/
74
+    @PostMapping("/update")
75
+    public ResultVo update(@RequestBody LXz xz){
76
+        N_Utils.validation(new Object[]{xz.getXzid(),"行政直播id",1,xz.getXzname(),"名称",2});
77
+        xzService.updateXz(xz);
78
+        return new ResultVo(0, "修改成功");
79
+    }
80
+
81
+    /**
82
+     * @Description  行政直播下进行中和已结束课数量
83
+     * @Param [xz]
84
+     * @Return com.xhkjedu.vo.ResultVo
85
+     * @Author wn
86
+     * @Date 2022/3/30 15:23
87
+     **/
88
+    @PostMapping("/snum")
89
+    public ResultVo getXzSectionKsNum(@RequestBody LXz xz){
90
+        N_Utils.validation(new Object[]{xz.getXzid(),"行政直播id",1});
91
+        Integer num = xzService.getXzSectionKsNum(xz.getXzid());
92
+        return new ResultVo(0, "成功获取直播下进行中和结束课数量",num);
93
+    }
94
+
95
+    /**
96
+     * @Description 删除行政直播
97
+     * @Param [xz]
98
+     * @Return com.xhkjedu.vo.ResultVo
99
+     * @Author wn
100
+     * @Date 2022/3/30 14:29
101
+     **/
102
+    @PostMapping("/del")
103
+    public ResultVo delete(@RequestBody LXz xz){
104
+        N_Utils.validation(new Object[]{xz.getXzid(),"行政直播id",1});
105
+        xzService.deleteXz(xz.getXzid());
106
+        return new ResultVo(0, "删除成功");
107
+    }
108
+
109
+}

+ 50
- 0
slive/src/main/java/com/xhkjedu/slive/controller/xz/XzKjController.java Просмотреть файл

@@ -0,0 +1,50 @@
1
+package com.xhkjedu.slive.controller.xz;
2
+
3
+import com.xhkjedu.slive.model.xz.LXzKj;
4
+import com.xhkjedu.slive.service.xz.XzKjService;
5
+import com.xhkjedu.utils.N_Utils;
6
+import com.xhkjedu.vo.ResultVo;
7
+import org.springframework.web.bind.annotation.PostMapping;
8
+import org.springframework.web.bind.annotation.RequestBody;
9
+import org.springframework.web.bind.annotation.RequestMapping;
10
+import org.springframework.web.bind.annotation.RestController;
11
+
12
+import javax.annotation.Resource;
13
+import java.util.List;
14
+
15
+/**
16
+ * @Description 行政直播课节详情
17
+ * @Author WN
18
+ * Date 2022/3/30 15:25
19
+ **/
20
+@RestController
21
+@RequestMapping("/xzkj")
22
+public class XzKjController {
23
+    @Resource
24
+    private XzKjService xzKjService;
25
+
26
+    /**
27
+     * @Description 保存直播课课节信息
28
+     * @Param [kj]
29
+     * @Return com.xhkjedu.vo.ResultVo
30
+     * @Author wn
31
+     * @Date 2022/3/30 16:22
32
+     **/
33
+    @PostMapping("/save")
34
+    public ResultVo save(@RequestBody LXzKj kj){
35
+        N_Utils.validation(new Object[]{kj.getXzid(),"行政直播id",1,kj.getCreateid(),"创建人",1});
36
+        return xzKjService.save(kj);
37
+    }
38
+
39
+    /**
40
+     * @Description 修改直播课节信息
41
+     * @Param [kj]
42
+     * @Return com.xhkjedu.vo.ResultVo
43
+     * @Author wn
44
+     * @Date 2022/3/30 17:53
45
+     **/
46
+    @PostMapping("/update")
47
+    public ResultVo update(@RequestBody List<LXzKj> kjs){
48
+       return xzKjService.updateBatch(kjs);
49
+    }
50
+}

+ 24
- 0
slive/src/main/java/com/xhkjedu/slive/mapper/xz/XzKjMapper.java Просмотреть файл

@@ -0,0 +1,24 @@
1
+package com.xhkjedu.slive.mapper.xz;
2
+
3
+import com.xhkjedu.slive.base.TkMapper;
4
+import com.xhkjedu.slive.model.xz.LXzKj;
5
+import org.apache.ibatis.annotations.Param;
6
+import org.springframework.stereotype.Repository;
7
+
8
+import java.util.List;
9
+import java.util.Map;
10
+
11
+/**
12
+ * @Description 直播课节详情
13
+ * @Author wn
14
+ * @Date 2022/3/30 12:06
15
+ */
16
+@Repository
17
+public interface XzKjMapper extends TkMapper<LXzKj> {
18
+
19
+    //获取行政直播课节详情
20
+    List<Map> listXzKjsByXzid(@Param("xzid") Integer xzid);
21
+
22
+    //批量修改行政直播课节详情
23
+    void updateBatchXzKj(@Param("list") List<LXzKj> list);
24
+}

+ 37
- 0
slive/src/main/java/com/xhkjedu/slive/mapper/xz/XzMapper.java Просмотреть файл

@@ -0,0 +1,37 @@
1
+package com.xhkjedu.slive.mapper.xz;
2
+
3
+import com.xhkjedu.slive.base.TkMapper;
4
+import com.xhkjedu.slive.model.xz.LXz;
5
+import org.apache.ibatis.annotations.Param;
6
+import org.springframework.stereotype.Repository;
7
+
8
+import java.util.List;
9
+import java.util.Map;
10
+
11
+/**
12
+ * @Deprecated  直播行政概要表
13
+ * @Duthor wn
14
+ * @Date 2022/3/30 12:01
15
+ */
16
+@Repository
17
+public interface XzMapper extends TkMapper<LXz> {
18
+
19
+    //行政直播列表
20
+    List<Map> listXzs(@Param("schoolid") Integer schoolid,@Param("xzname") String xzname);
21
+
22
+    //行政直播下进行中或已结束的课节数量
23
+    Integer getXzSectionKsNum(@Param("xzid") Integer xzid);
24
+
25
+    //删除行政直播下所有的直播课程和直播班级
26
+    void deleteCourseClassByXzid(@Param("xzid") Integer xzid);
27
+
28
+    //删除行政直播和课节详情
29
+    void deleteXzAndKjByXzid(@Param("xzid") Integer xzid);
30
+
31
+    //删除行政直播下未开始的直播课、班级、课节详情
32
+    void deleteCourseClassKjByXzid(@Param("xzid") Integer xzid);
33
+
34
+    //修改行政直播删除状态
35
+    void updateXzDeleted(@Param("deleted") Integer deleted,@Param("xzid") Integer xzid);
36
+
37
+}

+ 49
- 0
slive/src/main/java/com/xhkjedu/slive/model/xz/LXz.java Просмотреть файл

@@ -0,0 +1,49 @@
1
+package com.xhkjedu.slive.model.xz;
2
+import com.xhkjedu.slive.model.BaseBean;
3
+import lombok.Data;
4
+
5
+import javax.persistence.Id;
6
+import javax.persistence.Table;
7
+
8
+/**
9
+ *@Description 行政直播概要表
10
+ *@Author WN
11
+ *Date 2022/3/30 11:52
12
+ **/
13
+@Data
14
+@Table(name = "l_xz")
15
+public class LXz extends BaseBean {
16
+    //行政直播概要表
17
+    @Id
18
+    private Integer xzid;
19
+
20
+    //名称
21
+    private String xzname;
22
+
23
+    //概要
24
+    private String xzcomm;
25
+
26
+    //年级
27
+    private Integer gradeid;
28
+
29
+    //日课节数
30
+    private Integer daynum;
31
+
32
+    //开始日期
33
+    private String begindate;
34
+
35
+    //结束日期
36
+    private String enddate;
37
+
38
+    //是否删除1正常10已删除
39
+    private Integer deleted;
40
+
41
+    //创建人
42
+    private Integer createid;
43
+
44
+    //创建时间
45
+    private Integer createtime;
46
+
47
+    //学校id
48
+    private Integer schoolid;
49
+}

+ 49
- 0
slive/src/main/java/com/xhkjedu/slive/model/xz/LXzKj.java Просмотреть файл

@@ -0,0 +1,49 @@
1
+package com.xhkjedu.slive.model.xz;
2
+
3
+import com.xhkjedu.slive.model.BaseBean;
4
+import lombok.Data;
5
+
6
+import javax.persistence.Table;
7
+import java.util.List;
8
+import javax.persistence.Id;
9
+import javax.persistence.Transient;
10
+
11
+/**
12
+ *@Description 行政直播课节表
13
+ *@Author WN
14
+ *Date 2022/3/30 11:52
15
+ **/
16
+@Data
17
+@Table(name = "l_xz_kj")
18
+public class LXzKj extends BaseBean {
19
+
20
+    //行政直播课节详情表
21
+    @Id
22
+    private Integer kjid;
23
+
24
+    //行政直播概要表
25
+    private Integer xzid;
26
+
27
+    //课节名称
28
+    private String kjname;
29
+
30
+    //课节排序
31
+    private Integer kjorder;
32
+
33
+    //开始时间
34
+    private String begintime;
35
+
36
+    //结束时间
37
+    private String endtime;
38
+
39
+    //创建人
40
+    private Integer createid;
41
+
42
+    //创建时间
43
+    private Integer createtime;
44
+
45
+    //课节集合
46
+    @Transient
47
+    private List<LXzKj> xzkjs;
48
+
49
+}

+ 76
- 0
slive/src/main/java/com/xhkjedu/slive/service/xz/XzKjService.java Просмотреть файл

@@ -0,0 +1,76 @@
1
+package com.xhkjedu.slive.service.xz;
2
+
3
+import com.xhkjedu.slive.mapper.xz.XzKjMapper;
4
+import com.xhkjedu.slive.model.xz.LXzKj;
5
+import com.xhkjedu.utils.N_Utils;
6
+import com.xhkjedu.vo.ResultVo;
7
+import org.springframework.stereotype.Service;
8
+
9
+import javax.annotation.Resource;
10
+import java.util.List;
11
+import java.util.Map;
12
+
13
+/**
14
+ * @Description
15
+ * @Author WN
16
+ * Date 2022/3/30 15:26
17
+ **/
18
+@Service
19
+public class XzKjService {
20
+    @Resource
21
+    private XzKjMapper xzKjMapper;
22
+
23
+    /**
24
+     * @Description 保存课节信息
25
+     * @Param [xzKj]
26
+     * @Return com.xhkjedu.vo.ResultVo
27
+     * @Author wn
28
+     * @Date 2022/3/30 16:19
29
+     **/
30
+    public ResultVo save(LXzKj xzKj) {
31
+        Integer timestamp = N_Utils.getSecondTimestamp();
32
+        List<LXzKj> kjlst = xzKj.getXzkjs();
33
+        if (kjlst == null || kjlst.size() == 0) {
34
+            return new ResultVo(1, "未设置课节信息");
35
+        } else {
36
+            for (int i = 0; i < kjlst.size(); i++) {
37
+                LXzKj kj = kjlst.get(i);
38
+                kj.setXzid(xzKj.getXzid());
39
+                kj.setCreateid(xzKj.getCreateid());
40
+                kj.setCreatetime(timestamp);
41
+                kj.setKjorder(i + 1);
42
+            }
43
+
44
+            xzKjMapper.insertList(kjlst);
45
+            //获取保存课节信息集合
46
+            List<Map> rtnlst = xzKjMapper.listXzKjsByXzid(xzKj.getXzid());
47
+            return new ResultVo(0, "保存成功", rtnlst);
48
+        }
49
+    }
50
+
51
+    /**
52
+     * @Description 修改行政直播课节信息
53
+     * @Param [xzKjs]
54
+     * @Return com.xhkjedu.vo.ResultVo
55
+     * @Author wn
56
+     * @Date 2022/3/30 21:51
57
+     **/
58
+    public ResultVo updateBatch(List<LXzKj> xzKjs) {
59
+        for (int i = 0; i < xzKjs.size(); i++) {
60
+            boolean rtn = false;
61
+            LXzKj kj = xzKjs.get(i);
62
+            if (kj.getKjid() == null || kj.getKjid() == 0) {
63
+                rtn = true;
64
+            }
65
+            if (N_Utils.isEmpty(kj.getKjname()) || N_Utils.isEmpty(kj.getBegintime()) || N_Utils.isEmpty(kj.getEndtime())) {
66
+                rtn = true;
67
+            }
68
+            if(rtn){
69
+                return new ResultVo(1,"课节信息不完善");
70
+            }
71
+        }
72
+
73
+        xzKjMapper.updateBatchXzKj(xzKjs);
74
+        return new ResultVo(0,"修改课节信息成功");
75
+    }
76
+}

+ 91
- 0
slive/src/main/java/com/xhkjedu/slive/service/xz/XzService.java Просмотреть файл

@@ -0,0 +1,91 @@
1
+package com.xhkjedu.slive.service.xz;
2
+
3
+import com.xhkjedu.slive.mapper.xz.XzMapper;
4
+import com.xhkjedu.slive.model.xz.LXz;
5
+import com.xhkjedu.utils.N_Utils;
6
+import org.springframework.stereotype.Service;
7
+import org.springframework.transaction.annotation.Transactional;
8
+
9
+import javax.annotation.Resource;
10
+import java.util.List;
11
+import java.util.Map;
12
+
13
+/**
14
+ * @Description 行政直播概要
15
+ * @Author WN
16
+ * Date 2022/3/30 13:42
17
+ **/
18
+@Service
19
+public class XzService {
20
+    @Resource
21
+    private XzMapper xzMapper;
22
+
23
+    /**
24
+     * @Description 行政直播列表
25
+     * @Param [schoolid]
26
+     * @Return java.util.List<java.util.Map>
27
+     * @Author wn
28
+     * @Date 2022/3/30 14:03
29
+     **/
30
+    public List<Map> listXzs(Integer schoolid, String xzname) {
31
+        return xzMapper.listXzs(schoolid, xzname);
32
+    }
33
+
34
+    /**
35
+     * @Description 保存行政直播
36
+     * @Param [xz]
37
+     * @Return void
38
+     * @Author wn
39
+     * @Date 2022/3/30 14:07
40
+     **/
41
+    public Integer saveXz(LXz xz) {
42
+        xz.setCreatetime(N_Utils.getSecondTimestamp());
43
+        xz.setDeleted(1);
44
+        xzMapper.insertUseGeneratedKeys(xz);
45
+        return xz.getId();
46
+    }
47
+
48
+    /**
49
+     * @Description 修改行政直播
50
+     * @Param [xz]
51
+     * @Return void
52
+     * @Author wn
53
+     * @Date 2022/3/30 14:16
54
+     **/
55
+    public void updateXz(LXz xz) {
56
+        xzMapper.updateByPrimaryKeySelective(xz);
57
+    }
58
+
59
+    //获取行政直播课下进行中或者已结束的直播课数量
60
+    public Integer getXzSectionKsNum(Integer xzid) {
61
+        Integer num = xzMapper.getXzSectionKsNum(xzid);
62
+        if (num == null) {
63
+            num = 0;
64
+        }
65
+        return num;
66
+    }
67
+
68
+    /**
69
+     * @Description 删除行政直播
70
+     * @Param [xzid]
71
+     * @Return void
72
+     * @Author wn
73
+     * @Date 2022/3/30 15:24
74
+     **/
75
+    @Transactional
76
+    public void deleteXz(Integer xzid) {
77
+        //如果行政直播下所有的课都未开始,则可以直接删除,
78
+        //如果有直播课已经开始则进行逻辑删除,并删除所有未开始上的直播课
79
+        Integer sectionnum = xzMapper.getXzSectionKsNum(xzid);
80
+        if (sectionnum != null && sectionnum > 0) {
81
+            //说明直播下有开始或结束的课节,只能删除未开始的直播和直播班级信息
82
+            xzMapper.deleteCourseClassKjByXzid(xzid);
83
+            //修改行政直播的状态未已删除
84
+            xzMapper.updateXzDeleted(10, xzid);
85
+        } else {
86
+            //说明该行政直播课程可以直接删除
87
+            xzMapper.deleteCourseClassByXzid(xzid);
88
+            xzMapper.deleteXzAndKjByXzid(xzid);
89
+        }
90
+    }
91
+}

+ 17
- 0
slive/src/main/resources/mapper/xz/XzKjMapper.xml Просмотреть файл

@@ -0,0 +1,17 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.xhkjedu.slive.mapper.xz.XzKjMapper">
4
+
5
+    <!--获取行政直播课节详情-->
6
+    <select id="listXzKjsByXzid" resultType="java.util.Map">
7
+        select * from l_xz_kj where xzid=1 order by kjorder asc
8
+    </select>
9
+
10
+    <!--批量修改行政直播课节详情-->
11
+    <update id="updateBatchXzKj" parameterType="java.util.List">
12
+        <foreach collection="list" item="kj" index="index" separator=";">
13
+            update l_xz_kj set kjname=#{kj.kjname},begintime=#{kj.begintime},endtime=#{kj.endtime}
14
+            where kjid=#{kj.kjid}
15
+        </foreach>
16
+    </update>
17
+</mapper>

+ 60
- 0
slive/src/main/resources/mapper/xz/XzMapper.xml Просмотреть файл

@@ -0,0 +1,60 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.xhkjedu.slive.mapper.xz.XzMapper">
4
+
5
+    <!--行政直播列表-->
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,
8
+        x.createtime, u.username from l_xz x left join t_user u on x.createid=u.userid
9
+        where x.schoolid=#{schoolid} and x.deleted=1
10
+        <if test="xzname!='' and xzname!=null">
11
+            and x.xzname like '%${xzname}%'
12
+        </if>
13
+        order by x.begindate desc
14
+    </select>
15
+
16
+    <!--行政直播课对应的课节进行中或已结束数量-->
17
+    <select id="getXzSectionKsNum" resultType="java.lang.Integer">
18
+        select count(*)
19
+        from l_course_section s
20
+                 left join l_course c on c.courseid = s.courseid
21
+                 left join l_xz_kj k on c.kjid = k.kjid
22
+        where k.xzid = #{xzid}
23
+          and s.sectionstate BETWEEN 2 and 3
24
+    </select>
25
+
26
+    <!--删除行政直播下所有的直播课程和直播班级-->
27
+    <delete id="deleteCourseClassByXzid" parameterType="java.lang.Integer">
28
+        delete
29
+        c,lc from t_class as c left join l_course as lc on c.classid=lc.classid
30
+        left join l_xz_kj k on k.kjid=lc.kjid where k.xzid=
31
+        #{xzid}
32
+    </delete>
33
+    <!--删除行政直播和课节详情-->
34
+    <delete id="deleteXzAndKjByXzid">
35
+        delete
36
+        x,k from l_xz as x left join l_xz_kj as k on x.xzid=k.xzid where x.xzid=
37
+        #{xzid}
38
+    </delete>
39
+    <!--删除行政直播下未开始的直播课、班级、课节详情-->
40
+    <delete id="deleteCourseClassKjByXzid">
41
+        delete
42
+        c,lc,k from t_class as c left join l_course as lc on c.classid=lc.classid
43
+        left join l_course_section ls on ls.courseid=lc.courseid
44
+        left join l_xz_kj k on k.kjid=lc.kjid where k.xzid=
45
+        #{xzid}
46
+        and
47
+        ls
48
+        .
49
+        sectionstate
50
+        =
51
+        0
52
+    </delete>
53
+    <!--修改行政直播删除状态-->
54
+    <update id="updateXzDeleted">
55
+        update l_xz
56
+        set deleted=#{deleted}
57
+        where xzid = #{xzid}
58
+    </update>
59
+
60
+</mapper>

Загрузка…
Отмена
Сохранить