ApplyController.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package com.benyun.controller;
  2. import com.benyun.boot.core.vo.Result;
  3. import com.benyun.vo.ApplyEventVo;
  4. import lombok.RequiredArgsConstructor;
  5. import com.benyun.entity.Apply;
  6. import com.benyun.service.ApplyService;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.web.bind.annotation.*;
  9. import org.beetl.sql.core.engine.PageQuery;
  10. import java.util.List;
  11. /**
  12. * @author makejava
  13. * create on 2023-03-17 10:03:25
  14. */
  15. @RestController
  16. @RequestMapping("apply")
  17. @RequiredArgsConstructor(onConstructor_ = {@Autowired})
  18. @CrossOrigin
  19. public class ApplyController {
  20. /**
  21. * 服务对象
  22. */
  23. private final ApplyService applyService;
  24. /**
  25. * 查询所有数据
  26. *
  27. * @return 所有数据
  28. */
  29. @GetMapping("/queryAll")
  30. public Result<List<Apply>> queryAll() {
  31. return Result.success(applyService.queryAll());
  32. }
  33. /**
  34. * 查询所有数据
  35. *
  36. * @return 所有数据
  37. */
  38. @GetMapping("/queryList")
  39. public Result<List<Apply>> queryList(@RequestParam(required = false) String applyName) {
  40. return Result.success(applyService.queryList(applyName));
  41. }
  42. /**
  43. * 分页查询数据
  44. *
  45. * @return 所有数据
  46. */
  47. @GetMapping("/queryPage")
  48. public Result<List<Apply>> queryPage(@RequestParam Integer pageNum, @RequestParam Integer pageSize, Apply apply) {
  49. PageQuery<Apply> pageQuery = new PageQuery<Apply>();
  50. pageQuery.setPageSize(pageSize);
  51. pageQuery.setPageNumber(pageNum);
  52. pageQuery.setParas(apply);
  53. return applyService.queryByPage(pageQuery);
  54. }
  55. /**
  56. * 通过主键查询单条数据
  57. *
  58. * @param id 主键
  59. * @return 单条数据
  60. */
  61. @GetMapping("/queryOne")
  62. public Result<Apply> queryOne(@RequestParam("id") String id) {
  63. return Result.success(applyService.queryById(id));
  64. }
  65. /**
  66. * 新增数据
  67. *
  68. * @param apply 实体对象
  69. * @return 新增结果
  70. */
  71. @PostMapping("/create")
  72. public Result<?> create(@RequestBody Apply apply) {
  73. applyService.insert(apply);
  74. return Result.success(apply);
  75. }
  76. /**
  77. * 修改数据
  78. *
  79. * @param apply 实体对象
  80. * @return 修改结果
  81. */
  82. @PostMapping("/update")
  83. public Result<?> update(@RequestBody Apply apply) {
  84. return applyService.updateById(apply) ? Result.success() : Result.failure();
  85. }
  86. /**
  87. * 删除数据
  88. *
  89. * @param id 主键
  90. * @return 删除结果
  91. */
  92. @PostMapping("/delete")
  93. public Result<Boolean> delete(@RequestParam("id") String id) {
  94. return Result.success(this.applyService.deleteById(id));
  95. }
  96. /**
  97. * 通过应用id查询应用的事件数据
  98. *
  99. * @return 所有数据
  100. */
  101. @GetMapping("/queryApplyEventByUUId")
  102. public Result<ApplyEventVo> queryApplyEventByUUId(@RequestParam("uuid") String uuid) {
  103. return Result.success(applyService.queryApplyEventByUUId(uuid));
  104. }
  105. }