ApplyFormController.java 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package com.bowintek.practice.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.bowintek.practice.filter.exception.BaseResponse;
  4. import com.bowintek.practice.filter.exception.RespGenerstor;
  5. import com.bowintek.practice.model.CfApplyFormReviewer;
  6. import com.bowintek.practice.model.CfApplyFormWellFile;
  7. import com.bowintek.practice.services.service.AccountService;
  8. import com.bowintek.practice.services.service.ApplyFormService;
  9. import com.github.pagehelper.PageInfo;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.*;
  12. import java.util.HashMap;
  13. import java.util.List;
  14. @RestController
  15. @RequestMapping("/api/applyForm")
  16. public class ApplyFormController {
  17. @Autowired
  18. private AccountService accountService;
  19. @Autowired
  20. private ApplyFormService applyFormService;
  21. @GetMapping("getApplyFormList")
  22. public BaseResponse<PageInfo<HashMap<String, Object>>> getApplyFormList(@RequestParam("page") int page, @RequestParam("rows") int rows,
  23. @RequestParam(required = false) String beginDate,
  24. @RequestParam(required = false) String endDate) {
  25. return RespGenerstor.success(applyFormService.selectApplyFormList(page, rows, accountService.getLoginUserID(), null, null, beginDate, endDate));
  26. }
  27. @GetMapping("getReviewerFormList")
  28. public BaseResponse<PageInfo<HashMap<String, Object>>> getReviewerFormList(@RequestParam("page") int page, @RequestParam("rows") int rows,
  29. @RequestParam(required = false) String applyUserName,
  30. @RequestParam(required = false) String beginDate,
  31. @RequestParam(required = false) String endDate) {
  32. return RespGenerstor.success(applyFormService.selectApplyFormList(page, rows, null, applyUserName, accountService.getLoginUserID(), beginDate, endDate));
  33. }
  34. @GetMapping("getApplyFormFileList")
  35. public BaseResponse<List<HashMap<String, Object>>> getApplyFormFileList(@RequestParam(required = false) String applyId) {
  36. return RespGenerstor.success(applyFormService.selectApplyFormFileList(applyId,null,null));
  37. }
  38. @ResponseBody
  39. @PostMapping("/submit")
  40. public BaseResponse submit(@RequestBody JSONObject reqMap) {
  41. int count = 0;
  42. try {
  43. String reason = reqMap.getString("reason");
  44. List<CfApplyFormWellFile> docList = reqMap.getJSONArray("docList").toJavaList(CfApplyFormWellFile.class);
  45. count = applyFormService.submit(reason, docList, accountService.getLoginUserID(), accountService.getUserByUserID(accountService.getLoginUserID()).name);
  46. } catch (Exception e) {
  47. return RespGenerstor.fail("-1", "程序异常:" + e.getMessage());
  48. }
  49. return RespGenerstor.success(count);
  50. }
  51. @ResponseBody
  52. @PostMapping("/approve")
  53. public BaseResponse approve(@RequestBody CfApplyFormReviewer reviewer) {
  54. int count = 0;
  55. try {
  56. count = applyFormService.approve(reviewer, accountService.getLoginUserID());
  57. } catch (Exception e) {
  58. return RespGenerstor.fail("-1", "程序异常:" + e.getMessage());
  59. }
  60. return RespGenerstor.success(count);
  61. }
  62. }