ExamCardController.java 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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.dto.CardCustDto;
  5. import com.qmth.distributed.print.business.bean.dto.CardDetailDto;
  6. import com.qmth.distributed.print.business.bean.dto.ExamCardPageDto;
  7. import com.qmth.distributed.print.business.bean.params.ExamCardParams;
  8. import com.qmth.distributed.print.business.bean.params.GenericExamCardParams;
  9. import com.qmth.distributed.print.business.entity.ExamCard;
  10. import com.qmth.distributed.print.business.service.BasicPrintConfigService;
  11. import com.qmth.distributed.print.business.service.ExamCardService;
  12. import com.qmth.teachcloud.common.annotation.OperationLogDetail;
  13. import com.qmth.teachcloud.common.bean.params.ArraysParams;
  14. import com.qmth.teachcloud.common.contant.SystemConstant;
  15. import com.qmth.teachcloud.common.entity.BasicPrintConfig;
  16. import com.qmth.teachcloud.common.enums.log.CustomizedOperationTypeEnum;
  17. import com.qmth.teachcloud.common.util.Result;
  18. import com.qmth.teachcloud.common.util.ResultUtil;
  19. import io.swagger.annotations.Api;
  20. import io.swagger.annotations.ApiModelProperty;
  21. import io.swagger.annotations.ApiOperation;
  22. import org.springframework.validation.annotation.Validated;
  23. import org.springframework.web.bind.annotation.*;
  24. import javax.annotation.Resource;
  25. import javax.servlet.http.HttpServletResponse;
  26. import javax.validation.constraints.Max;
  27. import javax.validation.constraints.Min;
  28. import java.util.List;
  29. /**
  30. * <p>
  31. * 题卡 前端控制器
  32. * </p>
  33. *
  34. * @author xf
  35. * @since 2021-03-23
  36. */
  37. @Api(tags = "题卡Controller")
  38. @RestController
  39. @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_EXAM + "/card")
  40. @Validated
  41. public class ExamCardController {
  42. @Resource
  43. private ExamCardService examCardService;
  44. @Resource
  45. private BasicPrintConfigService basicPrintConfigService;
  46. //====================================通卡接口(start)===================================
  47. /**
  48. * 题卡管理
  49. *
  50. * @param cardType 题卡类型(通卡或专卡)
  51. * @param title 题卡名称模糊查询
  52. * @param createMethod 题卡创建方式(上传、自定义)
  53. * @param enable 1正常/0禁用
  54. * @param createStartTime 创建时间(开始)
  55. * @param createEndTime 创建时间(结束)
  56. * @param pageNumber 分页参数
  57. * @param pageSize 分页参数
  58. * @return Result
  59. */
  60. @ApiOperation(value = "分页查询")
  61. @RequestMapping(value = "/page", method = RequestMethod.POST)
  62. public Result page(@RequestParam(value = "cardType", required = false) String cardType,
  63. @RequestParam(value = "title", required = false) String title,
  64. @RequestParam(value = "createMethod", required = false) String createMethod,
  65. @RequestParam(value = "enable", required = false) Boolean enable,
  66. @RequestParam(value = "createStartTime", required = false) Long createStartTime,
  67. @RequestParam(value = "createEndTime", required = false) Long createEndTime,
  68. @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
  69. @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
  70. IPage<ExamCardPageDto> examCardIPage = examCardService.listPage(cardType, title, createMethod, enable, createStartTime, createEndTime, pageNumber, pageSize);
  71. return ResultUtil.ok(examCardIPage);
  72. }
  73. /**
  74. * 题卡管理(通卡管理)-新增/修改
  75. *
  76. * @param params 保存传值参数
  77. * @return Result
  78. */
  79. @ApiOperation(value = "新增/修改")
  80. @RequestMapping(value = "/save_generic", method = RequestMethod.POST)
  81. @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.EDIT)
  82. public Result save(@RequestBody GenericExamCardParams params) throws Exception {
  83. Long id = examCardService.saveGeneric(params);
  84. return ResultUtil.ok(String.valueOf(id), "");
  85. }
  86. /**
  87. * 题卡管理(通卡管理)-删除
  88. *
  89. * @param id 题卡ID
  90. * @return Result
  91. */
  92. @ApiOperation(value = "删除")
  93. @RequestMapping(value = "/delete_generic", method = RequestMethod.POST)
  94. public Result save(@RequestParam(value = "id") Long id) {
  95. Boolean success = examCardService.deleteGeneric(id);
  96. return ResultUtil.ok(success);
  97. }
  98. //====================================通卡接口↑(end)===================================
  99. /**
  100. * 新建专卡
  101. *
  102. * @param examCardParams
  103. */
  104. @ApiOperation(value = "新建")
  105. @RequestMapping(value = "/save", method = RequestMethod.POST)
  106. public Result save(@RequestBody ExamCardParams examCardParams) throws Exception {
  107. String cardId = examCardService.saveExamCard(examCardParams);
  108. return ResultUtil.ok(cardId, "");
  109. }
  110. /**
  111. * 客服制卡申请
  112. *
  113. * @param examCardParams
  114. * @return
  115. */
  116. @ApiOperation(value = "客服制卡申请")
  117. @RequestMapping(value = "/cust_save", method = RequestMethod.POST)
  118. public Result custSave(@RequestBody ExamCardParams examCardParams) {
  119. String cardId = examCardService.saveExamCardCust(examCardParams);
  120. return ResultUtil.ok(cardId, "");
  121. }
  122. /**
  123. * 客服制卡审核查询
  124. *
  125. * @param schoolId
  126. * @param status
  127. * @param paperNumber
  128. * @param userId
  129. * @param applyStartTime
  130. * @param applyEndTime
  131. * @param finishStartTime
  132. * @param finishEndTime
  133. * @param pageNumber
  134. * @param pageSize
  135. * @return
  136. */
  137. @ApiOperation(value = "客服制卡审核查询")
  138. @RequestMapping(value = "/cust_list", method = RequestMethod.POST)
  139. public Result list(@RequestParam(value = "schoolId", required = false) String schoolId,
  140. @RequestParam(value = "status", required = false) String status,
  141. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  142. @RequestParam(value = "userId", required = false) String userId,
  143. @RequestParam(value = "applyStartTime", required = false) Long applyStartTime,
  144. @RequestParam(value = "applyEndTime", required = false) Long applyEndTime,
  145. @RequestParam(value = "finishStartTime", required = false) Long finishStartTime,
  146. @RequestParam(value = "finishEndTime", required = false) Long finishEndTime,
  147. @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
  148. @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
  149. IPage<CardCustDto> cardCustDtoIPage = examCardService.listCardCust(schoolId, status, paperNumber, userId, applyStartTime, applyEndTime, finishStartTime, finishEndTime, pageNumber, pageSize);
  150. return ResultUtil.ok(cardCustDtoIPage);
  151. }
  152. /**
  153. * 根据ID获取题卡详情
  154. *
  155. * @param cardId
  156. * @return
  157. */
  158. @ApiOperation(value = "根据ID获取题卡详情")
  159. @RequestMapping(value = "/get_one", method = RequestMethod.POST)
  160. public Result getOne(@RequestParam("cardId") Long cardId) {
  161. CardDetailDto cardDetailDto = examCardService.getCardDetail(cardId);
  162. return ResultUtil.ok(cardDetailDto);
  163. }
  164. /**
  165. * 选择已有题卡列表
  166. *
  167. * @param examId 考试id
  168. * @param courseCode 课程编号
  169. * @return 结果
  170. */
  171. @ApiOperation(value = "选择已有题卡列表")
  172. @RequestMapping(value = "/select_card_list", method = RequestMethod.POST)
  173. public Result selectCardList(@RequestParam String examId, @RequestParam String courseCode, @RequestParam(required = false) String paperNumber) {
  174. BasicPrintConfig basicPrintConfig = basicPrintConfigService.getByExamIdAndCourseCode(SystemConstant.convertIdToLong(examId), courseCode);
  175. List<ExamCard> list = examCardService.listSelectCard(courseCode, basicPrintConfig.getCardRuleId(), paperNumber);
  176. return ResultUtil.ok(list);
  177. }
  178. /**
  179. * 批量下载客服制卡文件
  180. *
  181. * @param response
  182. * @param arraysParams
  183. */
  184. @ApiOperation(value = "批量下载文件")
  185. @RequestMapping(value = "/download_files", method = RequestMethod.POST)
  186. public void taskPaperDownload(HttpServletResponse response, @RequestBody ArraysParams arraysParams) throws Exception {
  187. examCardService.downloadFiles(response, arraysParams);
  188. }
  189. /**
  190. * 复制题卡
  191. *
  192. * @param id 题卡id
  193. */
  194. @ApiOperation(value = "复制题卡")
  195. @RequestMapping(value = "/copy", method = RequestMethod.POST)
  196. public Result copyCard(@RequestParam(value = "id") String id,
  197. @RequestParam(value = "courseCode") String courseCode) {
  198. Long copyCardId = examCardService.copyCard(SystemConstant.convertIdToLong(id), courseCode);
  199. return ResultUtil.ok(String.valueOf(copyCardId), "");
  200. }
  201. /**
  202. * 题卡转图片
  203. *
  204. * @param id 题卡id
  205. */
  206. @ApiOperation(value = "题卡转图片")
  207. @RequestMapping(value = "/convert_image", method = RequestMethod.POST)
  208. public Result convertImage(@RequestParam(value = "id") String id) {
  209. examCardService.convertImage(SystemConstant.convertIdToLong(id));
  210. return ResultUtil.ok(true, "");
  211. }
  212. /**
  213. * 导出题卡pdf,html,json,jpg
  214. *
  215. * @param response
  216. * @param id 题卡ID
  217. */
  218. @ApiOperation(value = "导出题卡文件")
  219. @RequestMapping(value = "/download_card", method = RequestMethod.POST)
  220. public void cardDownload(HttpServletResponse response, @RequestParam(value = "id") String id) {
  221. examCardService.cardDownload(response, id);
  222. }
  223. }