|
@@ -15,12 +15,15 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import com.qmth.cqb.genpaper.model.GenPaperDto;
|
|
import com.qmth.cqb.genpaper.model.GenPaperDto;
|
|
import com.qmth.cqb.genpaper.service.GenPaperService;
|
|
import com.qmth.cqb.genpaper.service.GenPaperService;
|
|
|
|
+import com.qmth.cqb.paper.service.PaperService;
|
|
|
|
+import com.qmth.cqb.utils.enums.PaperType;
|
|
import com.qmth.cqb.utils.enums.RandomGenPaperPolicy;
|
|
import com.qmth.cqb.utils.enums.RandomGenPaperPolicy;
|
|
|
|
|
|
import cn.com.qmth.examcloud.common.uac.annotation.Uac;
|
|
import cn.com.qmth.examcloud.common.uac.annotation.Uac;
|
|
import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
import cn.com.qmth.examcloud.common.uac.enums.RoleMeta;
|
|
import cn.com.qmth.examcloud.common.uac.enums.RoleMeta;
|
|
import cn.com.qmth.examcloud.common.uac.enums.UacPolicy;
|
|
import cn.com.qmth.examcloud.common.uac.enums.UacPolicy;
|
|
|
|
+import cn.com.qmth.examcloud.common.util.ErrorMsg;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -32,6 +35,9 @@ public class GenPaperController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
GenPaperService genPaperService;
|
|
GenPaperService genPaperService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ PaperService paperService;
|
|
|
|
|
|
@ApiOperation(value = "简易随机组卷", notes = "简易随机组卷")
|
|
@ApiOperation(value = "简易随机组卷", notes = "简易随机组卷")
|
|
@Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
@Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
@@ -114,6 +120,18 @@ public class GenPaperController {
|
|
genPaperDto.setCreator(user.getName());
|
|
genPaperDto.setCreator(user.getName());
|
|
Map<String, Object> paperMap = new HashMap<String, Object>();
|
|
Map<String, Object> paperMap = new HashMap<String, Object>();
|
|
String paperName = genPaperDto.getPaperName();
|
|
String paperName = genPaperDto.getPaperName();
|
|
|
|
+ //判断试卷名称是否一样
|
|
|
|
+ try {
|
|
|
|
+ boolean result;
|
|
|
|
+ result = paperService.checkPaperName(paperName, PaperType.GENERATE,user.getRootOrgId()+"");
|
|
|
|
+ if(!result){
|
|
|
|
+ String msg = "考试试卷:"+paperName+"已经存在";
|
|
|
|
+ paperMap.put("msg", msg);
|
|
|
|
+ return new ResponseEntity(paperMap, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ return new ResponseEntity(e.getMessage(),HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
|
+ }
|
|
if (genPaperDto.getGenNumber() > 1) {
|
|
if (genPaperDto.getGenNumber() > 1) {
|
|
for (int i = 1; i <= genPaperDto.getGenNumber(); i++) {
|
|
for (int i = 1; i <= genPaperDto.getGenNumber(); i++) {
|
|
genPaperDto.setPaperName(paperName + "_" + i);
|
|
genPaperDto.setPaperName(paperName + "_" + i);
|