zhuhaiwen преди 3 години
родител
ревизия
53533fcd60

+ 6 - 6
oa-app/src/main/java/com/css/oa/exam/exam/controller/ExamController.java

@ -14,12 +14,6 @@ import java.util.HashMap;
14 14
import java.util.List;
15 15
import java.util.Map;
16 16
17
/**
18
 * @author :朱海文
19
 * @version : 1.0
20
 * @description :考场控制器
21
 * @date :2021/3/5
22
 */
23 17
@Api(tags = {"考试管理"})
24 18
@RestController
25 19
@RequestMapping("/exam")
@ -114,6 +108,8 @@ public class ExamController extends BaseController {
114 108
    public Result add(@RequestBody Exam exam) {
115 109
        Result<Map> result;
116 110
        try {
111
            String token = getToken();
112
            mService.setToken(token);
117 113
            String msg = mService.add(exam);
118 114
            result = setResult(msg);
119 115
        } catch (Exception e) {
@ -128,6 +124,8 @@ public class ExamController extends BaseController {
128 124
    public Result update(@RequestBody Exam obj) {
129 125
        Result<Map> result;
130 126
        try {
127
            String token = getToken();
128
            mService.setToken(token);
131 129
            if (TextUtils.isEmpty(obj.getUuid())) {
132 130
                return setErr("uuid参数不能为空");
133 131
            }
@ -145,6 +143,8 @@ public class ExamController extends BaseController {
145 143
    public Result delete(@RequestBody List<String> ids) {
146 144
        Result<Map> result;
147 145
        try {
146
            String token = getToken();
147
            mService.setToken(token);
148 148
            mService.delete(ids);
149 149
            result = setResult();
150 150
        } catch (Exception e) {

+ 0 - 6
oa-app/src/main/java/com/css/oa/exam/exam/repository/Exam.java

@ -45,15 +45,9 @@ public class Exam implements Serializable {
45 45
    @Column(name = "SUBJECT_NAME")
46 46
    private String subject_name;
47 47
48
    @Column(name = "SERIES_ID")
49
    private String series_id;
50
51 48
    @Column(name = "SERIES_NAME")
52 49
    private String series_name;
53 50
54
    @Column(name = "LEVEL_ID")
55
    private String level_id;
56
57 51
    @Column(name = "LEVEL_NAME")
58 52
    private String level_name;
59 53

+ 34 - 23
oa-app/src/main/java/com/css/oa/exam/exam/service/ExamService.java

@ -1,10 +1,11 @@
1 1
package com.css.oa.exam.exam.service;
2 2
3
import com.css.oa.exam.admin.bean.Admin;
4
import com.css.oa.exam.admin.repository.IUnitRepository;
5
import com.css.oa.exam.admin.repository.Unit;
3 6
import com.css.oa.exam.base.BaseService;
4 7
import com.css.oa.exam.exam.repository.IExamRepository;
5 8
import com.css.oa.exam.exam.repository.Exam;
6
import com.css.oa.exam.subject.repository.ISubjectRepository;
7
import com.css.oa.exam.subject.repository.Subject;
8 9
import com.css.oa.exam.util.UpdateObjectTool;
9 10
import com.css.oa.utils.UUIDGenerator;
10 11
import lombok.extern.slf4j.Slf4j;
@ -27,35 +28,43 @@ public class ExamService extends BaseService implements IExamService {
27 28
28 29
    @Autowired
29 30
    IExamRepository repository;
31
30 32
    @Autowired
31
    ISubjectRepository subjectRepository;
33
    IUnitRepository unitRepository;
34
35
    private void checkPermission(String msg) throws Exception {
36
        String adminUnitId = Admin.getAdminUnitId(token);
37
        List<Unit> unitList = unitRepository.getUnitBy(adminUnitId);
38
        if (unitList.size() > 0) {
39
            Unit unit = unitList.get(0);
40
            String parent_unit_id = unit.getParent_unit_id();
41
            if (!TextUtils.isEmpty(parent_unit_id)) {
42
                throw new Exception(msg);
43
            }
44
        }
45
    }
32 46
33
    private String addSubject(Exam obj){
47
    private String saveExam(Exam obj){
34 48
        if(TextUtils.isEmpty(obj.getSubject_code())){
35 49
            return "subject_code不能为空";
36 50
        }
37
        List<Subject> subjects = subjectRepository.queryById(obj.getSubject_code());
38
        if(subjects.size() == 0){
39
            return "您查找的subject_code不存在";
51
        if(TextUtils.isEmpty(obj.getSubject_name())){
52
            return "subject_name不能为空";
53
        }
54
        if(TextUtils.isEmpty(obj.getSeries_name())){
55
            return "series_name不能为空";
56
        }
57
        if(TextUtils.isEmpty(obj.getSeries_name())){
58
            return "level_name不能为空";
40 59
        }
41
        Subject subject = subjects.get(0);
42
        obj.setSubject_name(subject.getSubject_name());
43
//
44
//        int a = subject.getSeries();
45
//        String seriesName = SubjectMapping.getSeriesName(a);
46
//        obj.setSeries_name(seriesName);
47
//
48
//        int b = subject.getLevel();
49
//        String levelName = SubjectMapping.getLevelName(b);
50
//        obj.setLevel_name(levelName);
51
52 60
        repository.save(obj);
53 61
        return "保存成功";
54 62
    }
55 63
56 64
    @Override
57
    public String add(Exam obj) {
65
    public String add(Exam obj) throws Exception {
58 66
        System.out.println("传入的obj => " + obj.toString());
67
        checkPermission("管理员所在的单位没有创建考试的权限");
59 68
        if (obj.getUuid() == null) {
60 69
            String id = UUIDGenerator.getUUID();
61 70
            obj.setUuid(id);
@ -73,15 +82,16 @@ public class ExamService extends BaseService implements IExamService {
73 82
        if (TextUtils.isEmpty(obj.getUpdate_user()) || obj.getCreate_user().equalsIgnoreCase("null")) {
74 83
            obj.setUpdate_user("系统");
75 84
        }
76
        return addSubject(obj);
85
        return saveExam(obj);
77 86
    }
78 87
79 88
    @Override
80
    public String update(Exam newObj) {
89
    public String update(Exam newObj) throws Exception {
90
        checkPermission("管理员所在的单位没有编辑考试的权限");
81 91
        Optional<Exam> byId = repository.findById(newObj.getUuid());
82 92
        Exam old = byId.get();
83 93
        UpdateObjectTool.copyNullProperties(old, newObj);
84
        return addSubject(newObj);
94
        return saveExam(newObj);
85 95
    }
86 96
87 97
    @Override
@ -150,7 +160,8 @@ public class ExamService extends BaseService implements IExamService {
150 160
    }
151 161
152 162
    @Override
153
    public void delete(List<String> ids) {
163
    public void delete(List<String> ids) throws Exception {
164
        checkPermission("管理员所在的单位没有删除考试的权限");
154 165
        //ids = ["0","2","3"]
155 166
        repository.deleteRealByIds(ids);
156 167
    }

+ 3 - 3
oa-app/src/main/java/com/css/oa/exam/exam/service/IExamService.java

@ -7,15 +7,15 @@ import java.util.Map;
7 7
8 8
public interface IExamService {
9 9
10
    String add(Exam exam);
10
    String add(Exam exam) throws Exception;
11 11
12 12
    Map queryPage(Map map, int curPage, int pageSize);
13 13
14 14
    List queryToYear();
15 15
16
    String update(Exam newExam);
16
    String update(Exam newExam) throws Exception;
17 17
18
    void delete(List<String> ids);
18
    void delete(List<String> ids) throws Exception;
19 19
20 20
    List queryAll(String exam_name);
21 21