LeaveApplyController.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package jnpf.controller;
  2. import io.swagger.v3.oas.annotations.Operation;
  3. import io.swagger.v3.oas.annotations.Parameter;
  4. import io.swagger.v3.oas.annotations.Parameters;
  5. import io.swagger.v3.oas.annotations.tags.Tag;
  6. import jnpf.base.ActionResult;
  7. import jnpf.base.controller.SuperController;
  8. import jnpf.constant.MsgCode;
  9. import jnpf.entity.LeaveApplyEntity;
  10. import jnpf.model.leaveapply.LeaveApplyForm;
  11. import jnpf.model.leaveapply.LeaveApplyInfoVO;
  12. import jnpf.service.LeaveApplyService;
  13. import jnpf.util.GeneraterSwapUtil;
  14. import jnpf.util.JsonUtil;
  15. import jnpf.util.StringUtil;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.web.bind.annotation.*;
  18. /**
  19. * 请假申请
  20. *
  21. * @author JNPF开发平台组
  22. * @version V3.1.0
  23. * @copyright 引迈信息技术有限公司
  24. * @date 2019年9月27日 上午9:18
  25. */
  26. @Tag(name = "请假申请", description = "LeaveApply")
  27. @RestController
  28. @RequestMapping("/api/extend/Form/LeaveApply")
  29. public class LeaveApplyController extends SuperController<LeaveApplyService, LeaveApplyEntity> {
  30. @Autowired
  31. private LeaveApplyService leaveApplyService;
  32. @Autowired
  33. private GeneraterSwapUtil generaterSwapUtil;
  34. /**
  35. * 获取请假申请信息
  36. *
  37. * @param id 主键值
  38. * @return
  39. */
  40. @Operation(summary = "获取请假申请信息")
  41. @GetMapping("/{id}")
  42. @Parameters({
  43. @Parameter(name = "id", description = "主键", required = true),
  44. })
  45. public ActionResult<LeaveApplyInfoVO> info(@PathVariable("id") String id) {
  46. LeaveApplyEntity entity = leaveApplyService.getInfo(id);
  47. LeaveApplyInfoVO vo = JsonUtil.getJsonToBean(entity, LeaveApplyInfoVO.class);
  48. return ActionResult.success(vo);
  49. }
  50. /**
  51. * 新建请假申请
  52. *
  53. * @param leaveApplyForm 表单对象
  54. * @return
  55. */
  56. @Operation(summary = "新建请假申请")
  57. @PostMapping("/{id}")
  58. @Parameters({
  59. @Parameter(name = "id", description = "主键", required = true),
  60. @Parameter(name = "leaveApplyForm", description = "请假模型", required = true),
  61. })
  62. public ActionResult create(@RequestBody LeaveApplyForm leaveApplyForm, @PathVariable("id") String id) {
  63. LeaveApplyEntity entity = JsonUtil.getJsonToBean(leaveApplyForm, LeaveApplyEntity.class);
  64. leaveApplyService.submit(id, entity, leaveApplyForm);
  65. return ActionResult.success(MsgCode.SU006.get());
  66. }
  67. /**
  68. * 修改请假申请
  69. *
  70. * @param leaveApplyForm 表单对象
  71. * @param id 主键
  72. * @return
  73. */
  74. @Operation(summary = "修改请假申请")
  75. @PutMapping("/{id}")
  76. @Parameters({
  77. @Parameter(name = "id", description = "主键", required = true),
  78. @Parameter(name = "leaveApplyForm", description = "请假模型", required = true),
  79. })
  80. public ActionResult update(@RequestBody LeaveApplyForm leaveApplyForm, @PathVariable("id") String id) {
  81. LeaveApplyEntity entity = JsonUtil.getJsonToBean(leaveApplyForm, LeaveApplyEntity.class);
  82. entity.setId(id);
  83. leaveApplyService.submit(id, entity, leaveApplyForm);
  84. return ActionResult.success(MsgCode.SU006.get());
  85. }
  86. /**
  87. * 删除请假申请信息
  88. *
  89. * @param id 主键
  90. */
  91. @Operation(summary = "删除请假申请信息")
  92. @DeleteMapping("/{id}")
  93. @Parameters({
  94. @Parameter(name = "id", description = "主键", required = true),
  95. })
  96. public ActionResult delete(@PathVariable("id") String id, @RequestParam(name = "forceDel", defaultValue = "false") Boolean forceDel) {
  97. LeaveApplyEntity entity = leaveApplyService.getInfo(id);
  98. if (null != entity) {
  99. if (!forceDel) {
  100. String errMsg = generaterSwapUtil.deleteFlowTask(entity.getId());
  101. if (StringUtil.isNotBlank(errMsg)) {
  102. throw new RuntimeException(errMsg);
  103. }
  104. }
  105. leaveApplyService.delete(entity);
  106. return ActionResult.success(MsgCode.SU003.get());
  107. }
  108. return ActionResult.fail(MsgCode.FA003.get());
  109. }
  110. }