|
@@ -1,166 +1,166 @@
|
|
|
-package com.qmth.cqb.paper.web;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-import java.util.stream.Stream;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-
|
|
|
-import cn.com.qmth.examcloud.common.dto.question.enums.QuesStructType;
|
|
|
-import com.qmth.cqb.paper.dto.QuesNameDto;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-
|
|
|
-import com.qmth.cqb.paper.dao.PaperStructRepo;
|
|
|
-import com.qmth.cqb.paper.model.PaperStruct;
|
|
|
-import com.qmth.cqb.paper.model.PaperStructSearchInfo;
|
|
|
-import com.qmth.cqb.paper.service.PaperStructService;
|
|
|
-
|
|
|
-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 PaperStructController {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- PaperStructService paperStructService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- PaperStructRepo paperStructRepo;
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取所有试卷结构
|
|
|
- * @param
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiOperation(value = "获取试卷结构带分页", notes = "获取试卷结构带分页")
|
|
|
- @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
- @GetMapping(value = "/paperStruct/{curPage}/{pageSize}")
|
|
|
- public ResponseEntity getPaperStructs(HttpServletRequest request,
|
|
|
- @ModelAttribute PaperStructSearchInfo searchInfo,
|
|
|
- @PathVariable int curPage,
|
|
|
- @PathVariable int pageSize) {
|
|
|
- AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
|
|
|
- if(accessUser != null){
|
|
|
- searchInfo.setOrgId(accessUser.getRootOrgId().toString());
|
|
|
- }
|
|
|
- Page<PaperStruct> paperStructs= paperStructService.getPaperStructs(searchInfo, curPage, pageSize);
|
|
|
- return new ResponseEntity(paperStructs, HttpStatus.OK);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取所有试卷结构
|
|
|
- * @param
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiOperation(value = "获取试卷结构不带分页", notes = "获取试卷结构不带分页")
|
|
|
- @GetMapping(value = "/paperStruct")
|
|
|
- @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
- public ResponseEntity getPaperStructs(HttpServletRequest request,@ModelAttribute PaperStructSearchInfo searchInfo) {
|
|
|
- AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
|
|
|
- if(accessUser != null){
|
|
|
- searchInfo.setOrgId(accessUser.getRootOrgId().toString());
|
|
|
- }
|
|
|
- List<PaperStruct> paperStructs = paperStructService.getPaperStructs(searchInfo);
|
|
|
- return new ResponseEntity(paperStructs, HttpStatus.OK);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据id获取试卷结构
|
|
|
- *
|
|
|
- * @param
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiOperation(value = "获取试卷结构", notes = "获取试卷结构")
|
|
|
- @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
- @GetMapping(value = "/paperStruct/{id}")
|
|
|
- public ResponseEntity getPaperStructById(@PathVariable String id) {
|
|
|
- return new ResponseEntity(paperStructRepo.findOne(id), HttpStatus.OK);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 更新试卷结构
|
|
|
- *
|
|
|
- * @param
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiOperation(value = "更新试卷结构", notes = "更新试卷结构")
|
|
|
- @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
- @PutMapping(value = "/paperStruct")
|
|
|
- public ResponseEntity updatePaperStruct(HttpServletRequest request, @RequestBody PaperStruct ps) {
|
|
|
- AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
- PaperStruct paperStruct = paperStructService.save(ps, user);
|
|
|
- if (paperStruct == null) {
|
|
|
- return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- } else {
|
|
|
- return new ResponseEntity(paperStruct, HttpStatus.OK);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增试卷结构
|
|
|
- *
|
|
|
- * @param ps
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiOperation(value = "新增试卷结构", notes = "新增试卷结构")
|
|
|
- @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
- @PostMapping(value = "/paperStruct")
|
|
|
- public ResponseEntity addPaperStruct(HttpServletRequest request, @RequestBody PaperStruct ps) {
|
|
|
- AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
- PaperStruct paperStructTemp = paperStructService.checkNameUnique(ps.getName(), user.getRootOrgId().toString());
|
|
|
- if (paperStructTemp != null) {
|
|
|
- return new ResponseEntity("试卷结构名称重复,请重新命名!", HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- } else {
|
|
|
- PaperStruct paperStruct = paperStructService.save(ps, user);
|
|
|
- return new ResponseEntity(paperStruct, HttpStatus.OK);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除试卷结构
|
|
|
- *
|
|
|
- * @param ids
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiOperation(value = "删除试卷结构", notes = "删除试卷结构")
|
|
|
- @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
- @DeleteMapping(value = "/paperStruct/{ids}")
|
|
|
- public ResponseEntity removePaperStruct(@PathVariable String ids) {
|
|
|
- List<String> paperList = Stream.of(ids.split(",")).collect(Collectors.toList());
|
|
|
- paperStructRepo.delete(paperStructRepo.findAll(paperList));
|
|
|
- return new ResponseEntity(HttpStatus.OK);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据题型获取来源大题
|
|
|
- *
|
|
|
- * @param
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiOperation(value = "获取来源大题", notes = "获取来源大题")
|
|
|
- @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
- @GetMapping(value = "/paperStruct/quesNames")
|
|
|
- public ResponseEntity getPaperStructById(HttpServletRequest request,
|
|
|
- @RequestParam(required = false) String courseNo,
|
|
|
- @RequestParam QuesStructType quesType) {
|
|
|
- List<QuesNameDto> quesNameDtos = new ArrayList<>();
|
|
|
- AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
- if(user != null){
|
|
|
- quesNameDtos = paperStructService.getQuesNameList(user.getOrgId().toString(),courseNo,quesType);
|
|
|
- }
|
|
|
- return new ResponseEntity(quesNameDtos, HttpStatus.OK);
|
|
|
- }
|
|
|
-}
|
|
|
+package com.qmth.cqb.paper.web;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.common.dto.question.enums.QuesStructType;
|
|
|
+import com.qmth.cqb.paper.dto.QuesNameDto;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import com.qmth.cqb.paper.dao.PaperStructRepo;
|
|
|
+import com.qmth.cqb.paper.model.PaperStruct;
|
|
|
+import com.qmth.cqb.paper.model.PaperStructSearchInfo;
|
|
|
+import com.qmth.cqb.paper.service.PaperStructService;
|
|
|
+
|
|
|
+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 PaperStructController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ PaperStructService paperStructService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ PaperStructRepo paperStructRepo;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取所有试卷结构
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "获取试卷结构带分页", notes = "获取试卷结构带分页")
|
|
|
+ @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
+ @GetMapping(value = "/paperStruct/{curPage}/{pageSize}")
|
|
|
+ public ResponseEntity getPaperStructs(HttpServletRequest request,
|
|
|
+ @ModelAttribute PaperStructSearchInfo searchInfo,
|
|
|
+ @PathVariable int curPage,
|
|
|
+ @PathVariable int pageSize) {
|
|
|
+ AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
|
|
|
+ if(accessUser != null){
|
|
|
+ searchInfo.setOrgId(accessUser.getRootOrgId().toString());
|
|
|
+ }
|
|
|
+ Page<PaperStruct> paperStructs= paperStructService.getPaperStructs(searchInfo, curPage, pageSize);
|
|
|
+ return new ResponseEntity(paperStructs, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取所有试卷结构
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "获取试卷结构不带分页", notes = "获取试卷结构不带分页")
|
|
|
+ @GetMapping(value = "/paperStruct")
|
|
|
+ @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
+ public ResponseEntity getPaperStructs(HttpServletRequest request,@ModelAttribute PaperStructSearchInfo searchInfo) {
|
|
|
+ AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
|
|
|
+ if(accessUser != null){
|
|
|
+ searchInfo.setOrgId(accessUser.getRootOrgId().toString());
|
|
|
+ }
|
|
|
+ List<PaperStruct> paperStructs = paperStructService.getPaperStructs(searchInfo);
|
|
|
+ return new ResponseEntity(paperStructs, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据id获取试卷结构
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "获取试卷结构", notes = "获取试卷结构")
|
|
|
+ @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
+ @GetMapping(value = "/paperStruct/{id}")
|
|
|
+ public ResponseEntity getPaperStructById(@PathVariable String id) {
|
|
|
+ return new ResponseEntity(paperStructRepo.findOne(id), HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新试卷结构
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "更新试卷结构", notes = "更新试卷结构")
|
|
|
+ @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
+ @PutMapping(value = "/paperStruct")
|
|
|
+ public ResponseEntity updatePaperStruct(HttpServletRequest request, @RequestBody PaperStruct ps) {
|
|
|
+ AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
+ PaperStruct paperStruct = paperStructService.save(ps, user);
|
|
|
+ if (paperStruct == null) {
|
|
|
+ return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ } else {
|
|
|
+ return new ResponseEntity(paperStruct, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增试卷结构
|
|
|
+ *
|
|
|
+ * @param ps
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "新增试卷结构", notes = "新增试卷结构")
|
|
|
+ @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
+ @PostMapping(value = "/paperStruct")
|
|
|
+ public ResponseEntity addPaperStruct(HttpServletRequest request, @RequestBody PaperStruct ps) {
|
|
|
+ AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
+ PaperStruct paperStructTemp = paperStructService.checkNameUnique(ps.getName(), user.getRootOrgId().toString(),ps.getType());
|
|
|
+ if (paperStructTemp != null) {
|
|
|
+ return new ResponseEntity("试卷结构名称重复,请重新命名!", HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ } else {
|
|
|
+ PaperStruct paperStruct = paperStructService.save(ps, user);
|
|
|
+ return new ResponseEntity(paperStruct, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除试卷结构
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "删除试卷结构", notes = "删除试卷结构")
|
|
|
+ @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
+ @DeleteMapping(value = "/paperStruct/{ids}")
|
|
|
+ public ResponseEntity removePaperStruct(@PathVariable String ids) {
|
|
|
+ List<String> paperList = Stream.of(ids.split(",")).collect(Collectors.toList());
|
|
|
+ paperStructRepo.delete(paperStructRepo.findAll(paperList));
|
|
|
+ return new ResponseEntity(HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据题型获取来源大题
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "获取来源大题", notes = "获取来源大题")
|
|
|
+ @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
+ @GetMapping(value = "/paperStruct/quesNames")
|
|
|
+ public ResponseEntity getPaperStructById(HttpServletRequest request,
|
|
|
+ @RequestParam(required = false) String courseNo,
|
|
|
+ @RequestParam QuesStructType quesType) {
|
|
|
+ List<QuesNameDto> quesNameDtos = new ArrayList<>();
|
|
|
+ AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
+ if(user != null){
|
|
|
+ quesNameDtos = paperStructService.getQuesNameList(user.getOrgId().toString(),courseNo,quesType);
|
|
|
+ }
|
|
|
+ return new ResponseEntity(quesNameDtos, HttpStatus.OK);
|
|
|
+ }
|
|
|
+}
|