|
@@ -1,146 +1,146 @@
|
|
|
-package com.qmth.cqb.paper.web;
|
|
|
-
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-
|
|
|
-import org.apache.commons.lang.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-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.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
-import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
-
|
|
|
-import com.qmth.cqb.paper.dao.PaperDetailRepo;
|
|
|
-import com.qmth.cqb.paper.dao.PaperRepo;
|
|
|
-import com.qmth.cqb.paper.model.PaperDetail;
|
|
|
-import com.qmth.cqb.paper.model.PaperDetailUnit;
|
|
|
-import com.qmth.cqb.paper.service.PaperDetailService;
|
|
|
-import com.qmth.cqb.paper.service.PaperService;
|
|
|
-
|
|
|
-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 PaperDetailController {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- PaperDetailService paperDetailService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- PaperService paperService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- PaperDetailRepo paperDetailRepo;
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取大题对应的小题
|
|
|
- *
|
|
|
- * @param detail_id
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiOperation(value = "获取大题对应的小题", notes = "获取大题对应的小题")
|
|
|
- @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
- @GetMapping(value = "/paperDetail/units/{detail_id}")
|
|
|
- public List<PaperDetailUnit> getUnitsByPaperDetailId(String detail_id) {
|
|
|
- return paperDetailService.getUnitsByPaperDetailId(detail_id);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取大题
|
|
|
- *
|
|
|
- * @param detail_id
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiOperation(value = "获取大题", notes = "获取大题")
|
|
|
- @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
- @GetMapping(value = "/paperDetail/{detail_id}")
|
|
|
- public PaperDetail getPaperDetailId(@PathVariable String detail_id) {
|
|
|
- return paperDetailService.findById(detail_id);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 更新大题信息
|
|
|
- *
|
|
|
- * @param pd
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiOperation(value = "更新试卷中的大题", notes = "更新试卷中的大题")
|
|
|
- @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
- @PostMapping(value = "/updatePaperDetail/{paperId}")
|
|
|
- public ResponseEntity updatePaperDetail( HttpServletRequest request,
|
|
|
- @PathVariable String paperId,
|
|
|
- @RequestBody PaperDetail pd) {
|
|
|
- AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
- PaperDetail paperDetail = paperDetailService.savePaperDetail(pd,paperId,user);
|
|
|
- return new ResponseEntity(paperDetail, HttpStatus.OK);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增大题
|
|
|
- *
|
|
|
- * @param pd
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiOperation(value = "新增大题", notes = "新增大题")
|
|
|
- @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
- @PostMapping(value = "/paperDetail")
|
|
|
- public ResponseEntity addPaperDetail(@RequestBody PaperDetail pd) {
|
|
|
- PaperDetail paperDetail = paperDetailRepo.save(pd);
|
|
|
- return new ResponseEntity(paperDetail, HttpStatus.OK);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除大题
|
|
|
- *
|
|
|
- * @param detailId
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiOperation(value = "删除大题", notes = "删除大题")
|
|
|
- @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
- @DeleteMapping(value = "/paperDetail/{detailId}")
|
|
|
- public ResponseEntity removePaperDetail(@PathVariable String detailId) {
|
|
|
- paperDetailService.deletePaperDetail(detailId);
|
|
|
- return new ResponseEntity(detailId, HttpStatus.OK);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据试卷ID得到所有大题
|
|
|
- *
|
|
|
- * @param paperId
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiOperation(value = "根据试卷ID得到所有大题", notes = "根据试卷ID得到所有大题")
|
|
|
- @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
- @GetMapping(value = "/paperDetail/paper/{paperId}")
|
|
|
- public ResponseEntity getPaperDetailsByPaperId(@PathVariable String paperId) {
|
|
|
- return new ResponseEntity(paperService.findPaperDetailsById(paperId), HttpStatus.OK);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @ApiOperation(value = "上传音频文件", notes = "上传音频文件")
|
|
|
- @PostMapping(value = "/uploadRadio")
|
|
|
- public ResponseEntity uploadRadio(List<MultipartFile> files,HttpServletRequest request){
|
|
|
- for(MultipartFile file:files){
|
|
|
- System.out.println("名称:"+file.getOriginalFilename()+",大小:"+file.getSize());
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-}
|
|
|
+package com.qmth.cqb.paper.web;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+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.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
+
|
|
|
+import com.qmth.cqb.paper.dao.PaperDetailRepo;
|
|
|
+import com.qmth.cqb.paper.dao.PaperRepo;
|
|
|
+import com.qmth.cqb.paper.model.PaperDetail;
|
|
|
+import com.qmth.cqb.paper.model.PaperDetailUnit;
|
|
|
+import com.qmth.cqb.paper.service.PaperDetailService;
|
|
|
+import com.qmth.cqb.paper.service.PaperService;
|
|
|
+
|
|
|
+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 PaperDetailController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ PaperDetailService paperDetailService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ PaperService paperService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ PaperDetailRepo paperDetailRepo;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取大题对应的小题
|
|
|
+ *
|
|
|
+ * @param detail_id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "获取大题对应的小题", notes = "获取大题对应的小题")
|
|
|
+ @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
+ @GetMapping(value = "/paperDetail/units/{detail_id}")
|
|
|
+ public List<PaperDetailUnit> getUnitsByPaperDetailId(String detail_id) {
|
|
|
+ return paperDetailService.getUnitsByPaperDetailId(detail_id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取大题
|
|
|
+ *
|
|
|
+ * @param detail_id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "获取大题", notes = "获取大题")
|
|
|
+ @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
+ @GetMapping(value = "/paperDetail/{detail_id}")
|
|
|
+ public PaperDetail getPaperDetailId(@PathVariable String detail_id) {
|
|
|
+ return paperDetailService.findById(detail_id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新大题信息
|
|
|
+ *
|
|
|
+ * @param pd
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "更新试卷中的大题", notes = "更新试卷中的大题")
|
|
|
+ @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
+ @PostMapping(value = "/updatePaperDetail/{paperId}")
|
|
|
+ public ResponseEntity updatePaperDetail( HttpServletRequest request,
|
|
|
+ @PathVariable String paperId,
|
|
|
+ @RequestBody PaperDetail pd) {
|
|
|
+ AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
+ PaperDetail paperDetail = paperDetailService.savePaperDetail(pd,paperId,user);
|
|
|
+ return new ResponseEntity(paperDetail, HttpStatus.OK);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增大题
|
|
|
+ *
|
|
|
+ * @param pd
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "新增大题", notes = "新增大题")
|
|
|
+ @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
+ @PostMapping(value = "/paperDetail")
|
|
|
+ public ResponseEntity addPaperDetail(@RequestBody PaperDetail pd) {
|
|
|
+ PaperDetail paperDetail = paperDetailRepo.save(pd);
|
|
|
+ return new ResponseEntity(paperDetail, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除大题
|
|
|
+ *
|
|
|
+ * @param detailId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "删除大题", notes = "删除大题")
|
|
|
+ @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
+ @DeleteMapping(value = "/paperDetail/{detailId}")
|
|
|
+ public ResponseEntity removePaperDetail(@PathVariable String detailId) {
|
|
|
+ paperDetailService.deletePaperDetail(detailId);
|
|
|
+ return new ResponseEntity(detailId, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据试卷ID得到所有大题
|
|
|
+ *
|
|
|
+ * @param paperId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "根据试卷ID得到所有大题", notes = "根据试卷ID得到所有大题")
|
|
|
+ @Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
|
+ @GetMapping(value = "/paperDetail/paper/{paperId}")
|
|
|
+ public ResponseEntity getPaperDetailsByPaperId(@PathVariable String paperId) {
|
|
|
+ return new ResponseEntity(paperService.findPaperDetailsById(paperId), HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "上传音频文件", notes = "上传音频文件")
|
|
|
+ @PostMapping(value = "/uploadRadio")
|
|
|
+ public ResponseEntity uploadRadio(List<MultipartFile> files,HttpServletRequest request){
|
|
|
+ for(MultipartFile file:files){
|
|
|
+ System.out.println("名称:"+file.getOriginalFilename()+",大小:"+file.getSize());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|