ExamCardController.java 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. package com.qmth.distributed.print.api;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import com.qmth.boot.api.constant.ApiConstant;
  4. import com.qmth.distributed.print.business.bean.params.ExamCardParams;
  5. import com.qmth.distributed.print.business.bean.params.GenericExamCardParams;
  6. import com.qmth.distributed.print.business.entity.ExamCard;
  7. import com.qmth.distributed.print.business.service.ExamCardService;
  8. import com.qmth.teachcloud.common.annotation.OperationLogDetail;
  9. import com.qmth.teachcloud.common.contant.SystemConstant;
  10. import com.qmth.teachcloud.common.enums.log.OperationTypeEnum;
  11. import com.qmth.teachcloud.common.util.Result;
  12. import com.qmth.teachcloud.common.util.ResultUtil;
  13. import io.swagger.annotations.*;
  14. import org.springframework.validation.annotation.Validated;
  15. import org.springframework.web.bind.annotation.*;
  16. import javax.annotation.Resource;
  17. import javax.servlet.http.HttpServletResponse;
  18. import javax.validation.constraints.Max;
  19. import javax.validation.constraints.Min;
  20. import java.util.List;
  21. import java.util.Map;
  22. /**
  23. * <p>
  24. * 题卡 前端控制器
  25. * </p>
  26. *
  27. * @author xf
  28. * @since 2021-03-23
  29. */
  30. @Api(tags = "题卡Controller")
  31. @RestController
  32. @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_EXAM + "/card")
  33. @Validated
  34. public class ExamCardController {
  35. @Resource
  36. private ExamCardService examCardService;
  37. //====================================通卡接口(start)===================================
  38. /**
  39. * 题卡管理-分页查询
  40. */
  41. @ApiOperation(value = "分页查询")
  42. @RequestMapping(value = "/page", method = RequestMethod.POST)
  43. public Result page(@ApiParam(value = "学期ID") @RequestParam(required = false) Long semesterId,
  44. @ApiParam(value = "考试ID") @RequestParam(required = false) Long examId,
  45. @ApiParam(value = "课程代码") @RequestParam(required = false) String courseCode,
  46. @ApiParam(value = "试卷编号") @RequestParam(required = false) String paperNumber,
  47. @ApiParam(value = "题卡类型(通卡或专卡)") @RequestParam(value = "cardType", required = false) String cardType,
  48. @ApiParam(value = "题卡名称模糊查询") @RequestParam(value = "title", required = false) String title,
  49. @ApiParam(value = "题卡创建方式(上传、自定义)") @RequestParam(value = "createMethod", required = false) String createMethod,
  50. @ApiParam(value = "1正常/0禁用") @RequestParam(value = "enable", required = false) Boolean enable,
  51. @ApiParam(value = "创建时间(开始)") @RequestParam(value = "createStartTime", required = false) Long createStartTime,
  52. @ApiParam(value = "创建时间(结束)") @RequestParam(value = "createEndTime", required = false) Long createEndTime,
  53. @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
  54. @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
  55. IPage<ExamCard> examCardIPage = examCardService.listPage(semesterId, examId, courseCode, paperNumber, cardType, title, createMethod, enable, createStartTime, createEndTime, pageNumber, pageSize);
  56. return ResultUtil.ok(examCardIPage);
  57. }
  58. /**
  59. * 题卡管理(通卡管理)-新增/修改
  60. *
  61. * @param params 保存传值参数
  62. * @return Result
  63. */
  64. @ApiOperation(value = "新增/修改")
  65. @RequestMapping(value = "/save_generic", method = RequestMethod.POST)
  66. @OperationLogDetail(operationType = OperationTypeEnum.SAVE, detail = "新增/修改操作,题卡ID:{{params.id}}、题卡标题:{{params.title}}")
  67. public Result save(@RequestBody GenericExamCardParams params) throws Exception {
  68. Map<String, String> map = examCardService.saveGeneric(params);
  69. return ResultUtil.ok(map);
  70. }
  71. /**
  72. * 题卡管理(通卡管理)-删除
  73. *
  74. * @param id 题卡ID
  75. * @return Result
  76. */
  77. @ApiOperation(value = "删除")
  78. @RequestMapping(value = "/delete_generic", method = RequestMethod.POST)
  79. @OperationLogDetail(operationType = OperationTypeEnum.DELETE, detail = "删除操作,题卡ID:{{id}}")
  80. public Result save(@RequestParam(value = "id") Long id) {
  81. return ResultUtil.ok(examCardService.deleteGeneric(id));
  82. }
  83. //====================================通卡接口↑(end)===================================
  84. /**
  85. * 新建专卡
  86. *
  87. * @param examCardParams
  88. */
  89. @ApiOperation(value = "新建")
  90. @RequestMapping(value = "/save", method = RequestMethod.POST)
  91. @OperationLogDetail(operationType = OperationTypeEnum.SAVE, detail = "新增/修改操作,题卡ID:{{examCardParams.id}}、题卡标题:{{examCardParams.title}}")
  92. public Result save(@RequestBody ExamCardParams examCardParams) throws Exception {
  93. Map<String, String> map = examCardService.saveExamCard(examCardParams);
  94. return ResultUtil.ok(map);
  95. }
  96. /**
  97. * 根据ID获取题卡详情
  98. *
  99. * @param cardId
  100. * @return
  101. */
  102. @ApiOperation(value = "根据ID获取题卡详情")
  103. @RequestMapping(value = "/get_one", method = RequestMethod.POST)
  104. public Result getOne(@RequestParam(value = "cardId", required = false) Long cardId) {
  105. ExamCard examCard = examCardService.getById(cardId);
  106. return ResultUtil.ok(examCard);
  107. }
  108. @ApiOperation(value = "选择已有题卡列表")
  109. @RequestMapping(value = "/select_card_list", method = RequestMethod.POST)
  110. public Result selectCardList(@ApiParam(value = "考试ID") @RequestParam Long examId,
  111. @ApiParam(value = "课程ID") @RequestParam Long courseId,
  112. @ApiParam(value = "试卷编号") @RequestParam(required = false) String paperNumber) {
  113. List<ExamCard> list = examCardService.listSelectCard(examId, courseId, paperNumber);
  114. return ResultUtil.ok(list);
  115. }
  116. /**
  117. * 复制题卡
  118. *
  119. * @param id 题卡id
  120. */
  121. @ApiOperation(value = "复制题卡")
  122. @RequestMapping(value = "/copy", method = RequestMethod.POST)
  123. @OperationLogDetail(operationType = OperationTypeEnum.UPDATE, detail = "复制题卡操作,题卡ID:{{id}}")
  124. public Result copyCard(@RequestParam(value = "id") String id,
  125. @RequestParam(value = "courseId") Long courseId) {
  126. Long copyCardId = examCardService.copyCard(SystemConstant.convertIdToLong(id), courseId);
  127. return ResultUtil.ok(String.valueOf(copyCardId), "");
  128. }
  129. /**
  130. * 生成图片
  131. *
  132. * @param id 题卡id
  133. */
  134. @ApiOperation(value = "题卡转图片")
  135. @RequestMapping(value = "/convert_image", method = RequestMethod.POST)
  136. @OperationLogDetail(operationType = OperationTypeEnum.UPDATE, detail = "生成图片操作,题卡ID:{{id}}")
  137. public Result convertImage(@RequestParam(value = "id") String id) {
  138. examCardService.convertImage(SystemConstant.convertIdToLong(id));
  139. return ResultUtil.ok(true, "");
  140. }
  141. /**
  142. * 下载(包含pdf,html,json,jpg)
  143. *
  144. * @param response
  145. * @param id 题卡ID
  146. */
  147. @ApiOperation(value = "导出题卡文件")
  148. @RequestMapping(value = "/download_card", method = RequestMethod.POST)
  149. public void downloadCard(HttpServletResponse response, @RequestParam(value = "id") String id) {
  150. examCardService.downloadCard(response, id);
  151. }
  152. /**
  153. * 获取评卷区题卡图片
  154. */
  155. @ApiOperation(value = "获取题卡图片")
  156. @RequestMapping(value = "/find_jpg_file", method = RequestMethod.POST)
  157. @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = Result.class)})
  158. public Result listCardImage(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
  159. @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber,
  160. @ApiParam(value = "试卷类型", required = true) @RequestParam String paperType) {
  161. return ResultUtil.ok(examCardService.listCardImage(examId, paperNumber, paperType));
  162. }
  163. /**
  164. * 下载(包含pdf,html,json,jpg)
  165. *
  166. * @param response
  167. * @param id 题卡ID
  168. */
  169. @ApiOperation(value = "下载卡格式")
  170. @RequestMapping(value = "/download_card_json", method = RequestMethod.POST)
  171. public void downloadCardJson(HttpServletResponse response,
  172. @ApiParam(value = "题卡ID", required = true) @RequestParam(value = "id") String id) {
  173. examCardService.downloadCardJson(response, id);
  174. }
  175. }