Browse Source

答题卡相关接口

ywx
王宁 2 months ago
parent
commit
b53b141111

+ 146
- 0
sapi/src/main/java/com/xhkjedu/sapi/controller/scantron/ScantronController.java View File

@@ -0,0 +1,146 @@
1
+package com.xhkjedu.sapi.controller.scantron;
2
+
3
+import com.github.pagehelper.PageHelper;
4
+import com.github.pagehelper.PageInfo;
5
+import com.xhkjedu.sapi.model.scantron.TScantron;
6
+import com.xhkjedu.sapi.service.scantron.ScantronService;
7
+import com.xhkjedu.sapi.service.system.UserService;
8
+import com.xhkjedu.utils.N_Utils;
9
+import com.xhkjedu.utils.PageUtil;
10
+import com.xhkjedu.vo.PageResult;
11
+import com.xhkjedu.vo.ResultVo;
12
+import com.xhkjedu.vo.system.UserVo;
13
+import org.springframework.web.bind.annotation.PostMapping;
14
+import org.springframework.web.bind.annotation.RequestBody;
15
+import org.springframework.web.bind.annotation.RequestMapping;
16
+import org.springframework.web.bind.annotation.RestController;
17
+
18
+import javax.annotation.Resource;
19
+import java.util.List;
20
+import java.util.Map;
21
+
22
+/**
23
+ * @Description:答题卡
24
+ * @Author: WN
25
+ * @Date: 2024/10/25 10:15:46
26
+ **/
27
+@RestController
28
+@RequestMapping("/scantron")
29
+public class ScantronController {
30
+    @Resource
31
+    private ScantronService scantronService;
32
+    @Resource
33
+    private UserService userService;
34
+
35
+    /*
36
+     * @Description 答题卡列表-我的
37
+     * @Date 2024/10/25 10:23:08
38
+     * @Author WN
39
+     * @Param [scantron]
40
+     * @Return com.xhkjedu.vo.ResultVo
41
+     **/
42
+    @PostMapping("/list_my")
43
+    public ResultVo listMy(@RequestBody TScantron scantron){
44
+        Integer page = scantron.getPage();
45
+        Integer pageSize = scantron.getPageSize();
46
+        Integer createid = scantron.getCreateid();
47
+        Integer schoolid = scantron.getSchoolid();
48
+        N_Utils.validation(new Object[]{page,"显示页码",1,pageSize,"显示条数",1,createid,"用户id",1,schoolid,"学校id",1});
49
+        PageHelper.startPage(page, pageSize);
50
+        List<Map<String,Object>> list = scantronService.listScantrons(scantron);
51
+        PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
52
+        return new ResultVo(0,"查询成功",pageResult);
53
+    }
54
+
55
+    /*
56
+     * @Description 答题卡列表-全部
57
+     * @Date 2024/10/25 10:41:09
58
+     * @Author WN
59
+     * @Param [scantron]
60
+     * @Return com.xhkjedu.vo.ResultVo
61
+     **/
62
+    @PostMapping("/list")
63
+    public ResultVo list(@RequestBody TScantron scantron){
64
+        Integer page = scantron.getPage();
65
+        Integer pageSize = scantron.getPageSize();
66
+        Integer createid = scantron.getCreateid();
67
+        Integer schoolid = scantron.getSchoolid();
68
+        N_Utils.validation(new Object[]{page,"显示页码",1,pageSize,"显示条数",1,createid,"教师id",1,schoolid,"学校id",1});
69
+
70
+        //获取用户类型
71
+        UserVo userVo = userService.getUserTypeAndSubjectid(createid);
72
+        if(userVo.getUsertype() == 1){
73
+            //设置教师科目
74
+            scantron.setSubjectid(userVo.getSubjectid());
75
+        }
76
+        if(userVo.getUsertype() == 0){
77
+            //管理员看到学校所有
78
+            scantron.setCreateid(null);
79
+        }
80
+        scantron.setPubliched(1);//全部查看公开的
81
+
82
+        PageHelper.startPage(page, pageSize);
83
+        List<Map<String,Object>> list = scantronService.listScantrons(scantron);
84
+        PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
85
+        return new ResultVo(0,"查询成功",pageResult);
86
+    }
87
+
88
+    //答题卡-新增
89
+    @PostMapping("/add")
90
+    public ResultVo add(@RequestBody TScantron scantron){
91
+        N_Utils.validation(new Object[]{scantron.getCreateid(),"创建人id",1,scantron.getSchoolid(),"学校id",1,
92
+                scantron.getSubjectid(),"科目id",1,scantron.getSname(),"答题卡名称",2});
93
+        scantronService.save(scantron);
94
+        return new ResultVo(0,"保存成功");
95
+    }
96
+
97
+    //答题卡-修改
98
+    @PostMapping("/update")
99
+    public ResultVo update(@RequestBody TScantron scantron){
100
+        N_Utils.validation(new Object[]{scantron.getSid(),"答题卡id",1});
101
+        scantronService.update(scantron);
102
+        return new ResultVo(0,"保存成功");
103
+    }
104
+
105
+    //答题卡-删除
106
+    @PostMapping("/delete")
107
+    public ResultVo delete(@RequestBody TScantron scantron){
108
+        N_Utils.validation(new Object[]{scantron.getSid(),"答题卡id",1});
109
+        scantronService.delete(scantron.getSid());
110
+        return new ResultVo(0,"删除成功");
111
+    }
112
+    //答题卡-详情
113
+    @PostMapping("/detail")
114
+    public ResultVo detail(@RequestBody TScantron scantron){
115
+        N_Utils.validation(new Object[]{scantron.getSid(),"答题卡id",1});
116
+        TScantron st = scantronService.detail(scantron.getSid());
117
+        return new ResultVo(0,"获取成功",st);
118
+    }
119
+
120
+    //答题卡-公开
121
+    @PostMapping("/pub")
122
+    public ResultVo updatePubliched(@RequestBody TScantron scantron){
123
+        N_Utils.validation(new Object[]{scantron.getSid(),"答题卡id",1});
124
+        scantronService.updateScantronPubliched(scantron.getSid(),1);
125
+        return new ResultVo(0,"设置成功");
126
+    }
127
+    //答题卡-取消公开
128
+    @PostMapping("/unpub")
129
+    public ResultVo updateUnPubliched(@RequestBody TScantron scantron){
130
+        N_Utils.validation(new Object[]{scantron.getSid(),"答题卡id",1});
131
+        scantronService.updateScantronPubliched(scantron.getSid(),2);
132
+        return new ResultVo(0,"设置成功");
133
+    }
134
+
135
+    //答题卡-复用
136
+    @PostMapping("/copy")
137
+    public ResultVo copyScantron(@RequestBody TScantron scantron){
138
+        N_Utils.validation(new Object[]{scantron.getSid(),"答题卡id",1,scantron.getCreateid(),"创建人id",1});
139
+        TScantron st = scantronService.copyScantron(scantron);
140
+        return new ResultVo(0,"复用成功",st);
141
+    }
142
+
143
+
144
+
145
+
146
+}

+ 23
- 0
sapi/src/main/java/com/xhkjedu/sapi/mapper/scantron/ScantronMapper.java View File

@@ -0,0 +1,23 @@
1
+package com.xhkjedu.sapi.mapper.scantron;
2
+
3
+import com.xhkjedu.base.TkMapper;
4
+import com.xhkjedu.sapi.model.scantron.TScantron;
5
+import org.apache.ibatis.annotations.Param;
6
+
7
+import java.util.List;
8
+import java.util.Map;
9
+
10
+/**
11
+ * @Description:答题卡
12
+ * @Author: WN
13
+ * @Date: 2024/10/25 9:50:52
14
+ **/
15
+public interface ScantronMapper extends TkMapper<TScantron> {
16
+
17
+    //答题卡列表
18
+    List<Map<String,Object>> listScantrons(@Param("s")TScantron s);
19
+
20
+    //修改答题卡公开状态
21
+    int updateScantronPubliched(@Param("sid")int sid, @Param("publiched")int publiched);
22
+
23
+}

+ 3
- 0
sapi/src/main/java/com/xhkjedu/sapi/mapper/system/UserMapper.java View File

@@ -48,4 +48,7 @@ public interface UserMapper extends TkMapper<TUser> {
48 48
 
49 49
     //获取用户信息以及学段
50 50
     UserVo getUserAndSchoolInfo(@Param("userid") Integer userid);
51
+
52
+    //获取用户类型以及科目
53
+    UserVo getUserTypeAndSubjectid(@Param("userid") Integer userid);
51 54
 }

+ 57
- 0
sapi/src/main/java/com/xhkjedu/sapi/model/scantron/TScantron.java View File

@@ -0,0 +1,57 @@
1
+package com.xhkjedu.sapi.model.scantron;
2
+
3
+import com.xhkjedu.model.BaseBean;
4
+import lombok.Data;
5
+
6
+import javax.persistence.Id;
7
+import javax.persistence.Table;
8
+
9
+/**
10
+ * @Description:答题卡
11
+ * @Author: WN
12
+ * @Date: 2024/10/25 9:34:09
13
+ **/
14
+@Table(name = "t_scantron")
15
+@Data
16
+public class TScantron extends BaseBean {
17
+
18
+    // 答题卡ID
19
+    @Id
20
+    private Integer sid;
21
+    // 答题卡名称
22
+    private String sname;
23
+    // 科目ID
24
+    private String subjectid;
25
+    // 是否公开1公开2不公开
26
+    private Integer publiched;
27
+    // pdf地址
28
+    private String pdfpath;
29
+    // 纸张类型1A3 2A4
30
+    private Integer papertype;
31
+    // 边距数组
32
+    private String marginarray;
33
+    // 题型间距
34
+    private Double typedistance;
35
+    // 布局1一栏 2二栏 3三栏
36
+    private Integer slayout;
37
+    // 颜色
38
+    private String scolor;
39
+    // 考号类型1涂卡 2条形码 3手写1 4手写2
40
+    private Integer enumtype;
41
+    // 准考证号位数
42
+    private Integer admissiondigit;
43
+    // 考试信息(姓名,班级,学校,考号)
44
+    private String stuinfo;
45
+    // 其他信息(填涂示例,考试禁填,注意事项)
46
+    private String otherinfo;
47
+    // 批阅模式1网阅2手阅
48
+    private Integer checkmode;
49
+    // 结构JSON
50
+    private String alljson;
51
+    // 创建人ID
52
+    private Integer createid;
53
+    // 创建时间
54
+    private Integer createtime;
55
+    // 学校ID
56
+    private Integer schoolid;
57
+}

+ 71
- 0
sapi/src/main/java/com/xhkjedu/sapi/service/scantron/ScantronService.java View File

@@ -0,0 +1,71 @@
1
+package com.xhkjedu.sapi.service.scantron;
2
+
3
+import com.xhkjedu.sapi.mapper.scantron.ScantronMapper;
4
+import com.xhkjedu.sapi.model.scantron.TScantron;
5
+import com.xhkjedu.utils.N_Utils;
6
+import org.springframework.stereotype.Service;
7
+
8
+import javax.annotation.Resource;
9
+import java.util.List;
10
+import java.util.Map;
11
+
12
+/**
13
+ * @Description:答题卡
14
+ * @Author: WN
15
+ * @Date: 2024/10/25 9:52:16
16
+ **/
17
+@Service
18
+public class ScantronService {
19
+    @Resource
20
+    private ScantronMapper scantronMapper;
21
+
22
+    /*
23
+     * @Description 答题卡列表
24
+     * @Date 2024/10/25 10:15:03
25
+     * @Author WN
26
+     * @Param [tScantron]
27
+     * @Return java.util.List<com.xhkjedu.sapi.model.scantron.TScantron>
28
+     **/
29
+    public List<Map<String,Object>> listScantrons(TScantron tScantron){
30
+        return scantronMapper.listScantrons(tScantron);
31
+    }
32
+
33
+    //答题卡-保存
34
+    public void save(TScantron tScantron){
35
+        tScantron.setCreatetime(N_Utils.getSecondTimestamp());
36
+        scantronMapper.insertSelective(tScantron);
37
+    }
38
+    //答题卡-修改
39
+    public void update(TScantron tScantron){
40
+        scantronMapper.updateByPrimaryKeySelective(tScantron);
41
+    }
42
+
43
+    //答题卡-删除
44
+    public Integer delete(Integer sid){
45
+        return scantronMapper.deleteByPrimaryKey(sid);
46
+    }
47
+
48
+    //答题卡-详情
49
+    public TScantron detail(Integer sid){
50
+        return scantronMapper.selectByPrimaryKey(sid);
51
+    }
52
+
53
+    //答题卡-修改公开状态
54
+    public void updateScantronPubliched(Integer sid, Integer published){
55
+        scantronMapper.updateScantronPubliched(sid,published);
56
+    }
57
+
58
+    //答题卡-复用
59
+    public TScantron copyScantron(TScantron scantron){
60
+        //获取答题卡信息
61
+        TScantron originScantron = scantronMapper.selectByPrimaryKey(scantron.getSid());
62
+        originScantron.setSid(null);
63
+        originScantron.setCreateid(scantron.getCreateid());
64
+        originScantron.setCreatetime(N_Utils.getSecondTimestamp());
65
+        originScantron.setPubliched(2);
66
+        scantronMapper.insertUseGeneratedKeys(originScantron);
67
+        originScantron.setSid(originScantron.getId());
68
+        return originScantron;
69
+    }
70
+
71
+}

+ 29
- 0
sapi/src/main/java/com/xhkjedu/sapi/service/system/UserService.java View File

@@ -0,0 +1,29 @@
1
+package com.xhkjedu.sapi.service.system;
2
+
3
+import com.xhkjedu.sapi.mapper.system.UserMapper;
4
+import com.xhkjedu.vo.system.UserVo;
5
+import org.springframework.stereotype.Service;
6
+
7
+import javax.annotation.Resource;
8
+
9
+/**
10
+ * @Description:用户信息
11
+ * @Author: WN
12
+ * @Date: 2024/10/25 10:28:55
13
+ **/
14
+@Service
15
+public class UserService {
16
+    @Resource
17
+    private UserMapper userMapper;
18
+
19
+    /*
20
+     * @Description 获取用户类型及科目
21
+     * @Date 2024/10/25 10:29:43
22
+     * @Author WN
23
+     * @Param [userid]
24
+     * @Return java.lang.Integer
25
+     **/
26
+    public UserVo getUserTypeAndSubjectid(Integer userid){
27
+        return userMapper.getUserTypeAndSubjectid(userid);
28
+    }
29
+}

+ 30
- 0
sapi/src/main/resources/mapper/scantron/ScantronMapper.xml View File

@@ -0,0 +1,30 @@
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.sapi.mapper.scantron.ScantronMapper">
4
+    <!--答题卡列表-->
5
+    <select id="listScantrons" resultType="java.util.Map">
6
+        select s.sid,s.sname,s.subjectid,s.publiched,s.pdfpath,s.createid,
7
+        s.createtime,u.username as createname,st.subjectname
8
+        from t_scantron s left join t_user u on s.createid=u.userid
9
+        left join t_subject st on s.subjectid=st.subjectid
10
+        where s.schoolid=#{s.schoolid}
11
+        <if test="s.createid!=null and s.createid!=0">
12
+            and s.createid=#{s.createid}
13
+        </if>
14
+        <if test="s.subjectid!=null and s.subjectid!=''">
15
+            and s.subjectid=#{s.subjectid}
16
+        </if>
17
+        <if test="s.publiched!=null and s.publiched!=0">
18
+            and s.publiched=#{s.publiched}
19
+        </if>
20
+        <if test="s.sname!=null and s.sname!=''">
21
+            and s.sname like concat('%',#{s.sname},'%')
22
+        </if>
23
+        order by s.createtime desc,s.sid desc
24
+    </select>
25
+
26
+    <!--修改答题卡公开状态-->
27
+    <update id="updateScantronPubliched">
28
+        update t_scantron set publiched=#{publiched} where sid=#{sid}
29
+    </update>
30
+</mapper>

+ 6
- 0
sapi/src/main/resources/mapper/system/UserMapper.xml View File

@@ -59,4 +59,10 @@
59 59
         left join t_school s on u.schoolid=s.schoolid where u.userid=#{userid}
60 60
     </select>
61 61
 
62
+    <!--获取用户类型以及科目-->
63
+    <select id="getUserTypeAndSubjectid" resultType="com.xhkjedu.vo.system.UserVo">
64
+        select DISTINCT u.userid, u.usertype,t.subjectid from t_user u
65
+        left join t_teacher_powersb t on u.userid=t.teacherid
66
+        where t.teacherid=#{userid}
67
+    </select>
62 68
 </mapper>

Loading…
Cancel
Save