|
@@ -1,108 +1,135 @@
|
|
|
-package com.qmth.cqb.genpaper.web;
|
|
|
-
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
-import com.qmth.cqb.genpaper.model.GenPaperDto;
|
|
|
-import com.qmth.cqb.genpaper.service.GenPaperService;
|
|
|
-import com.qmth.cqb.utils.enums.RandomGenPaperPolicy;
|
|
|
-
|
|
|
-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.enums.RoleMeta;
|
|
|
-import cn.com.qmth.examcloud.common.uac.enums.UacPolicy;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-
|
|
|
-/**
|
|
|
- * Created by songyue on 16/12/28.
|
|
|
- */
|
|
|
-@RestController
|
|
|
-@RequestMapping("${api_cqb}/")
|
|
|
-public class GenPaperController {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- GenPaperService genPaperService;
|
|
|
-
|
|
|
- @ApiOperation(value = "简易随机组卷", notes = "简易随机组卷")
|
|
|
- @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
- @PostMapping("/genPaper/simple")
|
|
|
- public ResponseEntity genPaperSimple(HttpServletRequest request, @RequestBody GenPaperDto genPaperDto) {
|
|
|
- AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
- genPaperDto.setOrgId(user.getRootOrgId().toString());
|
|
|
- genPaperDto.setCreator(user.getName());
|
|
|
- Map<String, Object> paperMap = new HashMap<String, Object>();
|
|
|
- String paperName = genPaperDto.getPaperName();
|
|
|
- if (genPaperDto.getGenNumber() == 1) {
|
|
|
- if (genPaperDto.getSimpleGenPaperPolicy().getKey() == 1L) {
|
|
|
- paperMap = genPaperService.genPaperByQuestionNum(genPaperDto);
|
|
|
- } else if (genPaperDto.getSimpleGenPaperPolicy().getKey() == 2L) {
|
|
|
- paperMap = genPaperService.genPaperByScore(genPaperDto);
|
|
|
- }
|
|
|
- } else if (genPaperDto.getGenNumber() > 1) {
|
|
|
- if (genPaperDto.getSimpleGenPaperPolicy() == RandomGenPaperPolicy.BY_QUESTIONNUM) {
|
|
|
- for (int i = 1; i <= genPaperDto.getGenNumber(); i++) {
|
|
|
- genPaperDto.setPaperName(paperName + "_" + i);
|
|
|
- paperMap.putAll(genPaperService.genPaperByQuestionNum(genPaperDto));
|
|
|
- if (!paperMap.get("msg").equals("success")) {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else if (genPaperDto.getSimpleGenPaperPolicy() == RandomGenPaperPolicy.BY_SCORE) {
|
|
|
- for (int i = 1; i <= genPaperDto.getGenNumber(); i++) {
|
|
|
- genPaperDto.setPaperName(paperName + "_" + i);
|
|
|
- paperMap.putAll(genPaperService.genPaperByScore(genPaperDto));
|
|
|
- if (!paperMap.get("msg").equals("success")) {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- if (paperMap.get("msg").equals("success")) {
|
|
|
- return new ResponseEntity(paperMap, HttpStatus.OK);
|
|
|
- } else {
|
|
|
- return new ResponseEntity(paperMap, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "精细组卷", notes = "精细组卷")
|
|
|
- @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
- @PostMapping("/genPaper/normal")
|
|
|
- public ResponseEntity genPaperNormal(HttpServletRequest request, @RequestBody GenPaperDto genPaperDto) {
|
|
|
- AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
- genPaperDto.setOrgId(user.getRootOrgId().toString());
|
|
|
- genPaperDto.setCreator(user.getName());
|
|
|
- Map<String, Object> paperMap = new HashMap<String, Object>();
|
|
|
- String paperName = genPaperDto.getPaperName();
|
|
|
- if (genPaperDto.getGenNumber() > 1) {
|
|
|
- for (int i = 1; i <= genPaperDto.getGenNumber(); i++) {
|
|
|
- genPaperDto.setPaperName(paperName + "_" + i);
|
|
|
- paperMap.putAll(genPaperService.genPaper(genPaperDto));
|
|
|
- if (!paperMap.get("msg").equals("success")) {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (genPaperDto.getGenNumber() == 1) {
|
|
|
- paperMap = genPaperService.genPaper(genPaperDto);
|
|
|
- }
|
|
|
- if (paperMap.get("msg").equals("success")) {
|
|
|
- return new ResponseEntity(paperMap, HttpStatus.OK);
|
|
|
- } else {
|
|
|
- return new ResponseEntity(paperMap, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+package com.qmth.cqb.genpaper.web;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import com.qmth.cqb.genpaper.model.GenPaperDto;
|
|
|
+import com.qmth.cqb.genpaper.service.GenPaperService;
|
|
|
+import com.qmth.cqb.utils.enums.RandomGenPaperPolicy;
|
|
|
+
|
|
|
+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.enums.RoleMeta;
|
|
|
+import cn.com.qmth.examcloud.common.uac.enums.UacPolicy;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by songyue on 16/12/28.
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("${api_cqb}/")
|
|
|
+public class GenPaperController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ GenPaperService genPaperService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "简易随机组卷", notes = "简易随机组卷")
|
|
|
+ @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
+ @PostMapping("/genPaper/simple")
|
|
|
+ public ResponseEntity genPaperSimple(HttpServletRequest request, @RequestBody GenPaperDto genPaperDto) {
|
|
|
+ AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
+ genPaperDto.setOrgId(user.getRootOrgId().toString());
|
|
|
+ genPaperDto.setCreator(user.getName());
|
|
|
+ Map<String, Object> paperMap = new HashMap<String, Object>();
|
|
|
+ String paperName = genPaperDto.getPaperName();
|
|
|
+ if (genPaperDto.getGenNumber() == 1) {
|
|
|
+ if (genPaperDto.getSimpleGenPaperPolicy().getKey() == 1L) {
|
|
|
+ paperMap = genPaperService.genPaperByQuestionNum(genPaperDto);
|
|
|
+ } else if (genPaperDto.getSimpleGenPaperPolicy().getKey() == 2L) {
|
|
|
+ paperMap = genPaperService.genPaperByScore(genPaperDto);
|
|
|
+ }
|
|
|
+ } else if (genPaperDto.getGenNumber() > 1) {
|
|
|
+ if (genPaperDto.getSimpleGenPaperPolicy() == RandomGenPaperPolicy.BY_QUESTIONNUM) {
|
|
|
+ for (int i = 1; i <= genPaperDto.getGenNumber(); i++) {
|
|
|
+ genPaperDto.setPaperName(paperName + "_" + i);
|
|
|
+ paperMap.putAll(genPaperService.genPaperByQuestionNum(genPaperDto));
|
|
|
+ if (!paperMap.get("msg").equals("success")) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (genPaperDto.getSimpleGenPaperPolicy() == RandomGenPaperPolicy.BY_SCORE) {
|
|
|
+ for (int i = 1; i <= genPaperDto.getGenNumber(); i++) {
|
|
|
+ genPaperDto.setPaperName(paperName + "_" + i);
|
|
|
+ paperMap.putAll(genPaperService.genPaperByScore(genPaperDto));
|
|
|
+ if (!paperMap.get("msg").equals("success")) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (paperMap.get("msg").equals("success")) {
|
|
|
+ return new ResponseEntity(paperMap, HttpStatus.OK);
|
|
|
+ } else {
|
|
|
+ return new ResponseEntity(paperMap, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "精细组卷", notes = "精细组卷")
|
|
|
+ @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
+ @PostMapping("/genPaper/normal")
|
|
|
+ public ResponseEntity genPaperNormal(HttpServletRequest request, @RequestBody GenPaperDto genPaperDto) {
|
|
|
+ AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
+ genPaperDto.setOrgId(user.getRootOrgId().toString());
|
|
|
+ genPaperDto.setCreator(user.getName());
|
|
|
+ Map<String, Object> paperMap = new HashMap<String, Object>();
|
|
|
+ String paperName = genPaperDto.getPaperName();
|
|
|
+ if (genPaperDto.getGenNumber() > 1) {
|
|
|
+ for (int i = 1; i <= genPaperDto.getGenNumber(); i++) {
|
|
|
+ genPaperDto.setPaperName(paperName + "_" + i);
|
|
|
+ paperMap.putAll(genPaperService.genPaper(genPaperDto));
|
|
|
+ if (!paperMap.get("msg").equals("success")) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (genPaperDto.getGenNumber() == 1) {
|
|
|
+ paperMap = genPaperService.genPaper(genPaperDto);
|
|
|
+ }
|
|
|
+ if (paperMap.get("msg").equals("success")) {
|
|
|
+ return new ResponseEntity(paperMap, HttpStatus.OK);
|
|
|
+ } else {
|
|
|
+ return new ResponseEntity(paperMap, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "蓝图组卷", notes = "蓝图组卷")
|
|
|
+ @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
+ @PostMapping("/genPaper/blue")
|
|
|
+ public ResponseEntity genPaperBlue(HttpServletRequest request, @RequestBody GenPaperDto genPaperDto) {
|
|
|
+ AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
+ genPaperDto.setOrgId(user.getRootOrgId().toString());
|
|
|
+ genPaperDto.setCreator(user.getName());
|
|
|
+ Map<String, Object> paperMap = new HashMap<String, Object>();
|
|
|
+ String paperName = genPaperDto.getPaperName();
|
|
|
+ if (genPaperDto.getGenNumber() > 1) {
|
|
|
+ for (int i = 1; i <= genPaperDto.getGenNumber(); i++) {
|
|
|
+ genPaperDto.setPaperName(paperName + "_" + i);
|
|
|
+ paperMap.putAll(genPaperService.genBluePaper(genPaperDto));
|
|
|
+ if (!paperMap.get("msg").equals("success")) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (genPaperDto.getGenNumber() == 1) {
|
|
|
+ paperMap = genPaperService.genBluePaper(genPaperDto);
|
|
|
+ }
|
|
|
+ if (paperMap.get("msg").equals("success")) {
|
|
|
+ return new ResponseEntity(paperMap, HttpStatus.OK);
|
|
|
+ } else {
|
|
|
+ return new ResponseEntity(paperMap, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|