GovernmentInfoController.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. package com.ruoyi.web.controller.system;
  2. import cn.hutool.core.util.ObjectUtil;
  3. import cn.hutool.core.util.StrUtil;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.ruoyi.common.core.domain.AjaxResult;
  6. import com.ruoyi.web.domain.dto.government.GovernmentInfoAddRequest;
  7. import com.ruoyi.web.domain.dto.government.GovernmentInfoEditRequest;
  8. import com.ruoyi.web.domain.dto.government.GovernmentInfoQueryRequest;
  9. import com.ruoyi.web.domain.vo.GovernmentInfoVO;
  10. import com.ruoyi.web.service.GovernmentInfoService;
  11. import io.swagger.annotations.Api;
  12. import io.swagger.annotations.ApiOperation;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.web.bind.annotation.*;
  15. import java.util.Map;
  16. import static com.ruoyi.common.core.domain.AjaxResult.error;
  17. import static com.ruoyi.common.core.domain.AjaxResult.success;
  18. @Api(tags ="政府信息")
  19. @RestController
  20. @RequestMapping("/system/government")
  21. public class GovernmentInfoController {
  22. @Autowired
  23. private GovernmentInfoService governmentInfoService;
  24. /**
  25. * 添加政府信息
  26. *
  27. * @param governmentInfoAddRequest
  28. * @return
  29. */
  30. @ApiOperation("添加政府信息")
  31. @PostMapping("/add")
  32. public AjaxResult addGovernmentInfo(@RequestBody GovernmentInfoAddRequest governmentInfoAddRequest) {
  33. if (governmentInfoAddRequest == null) {
  34. return error("请求参数为空");
  35. }
  36. System.out.println(governmentInfoAddRequest.getContent());
  37. Integer id = governmentInfoService.addGovernmentInfo(governmentInfoAddRequest);
  38. return success(id);
  39. }
  40. /**
  41. * 删除政府信息
  42. *
  43. * @param paramsMap
  44. * @return
  45. */
  46. @ApiOperation("删除政府信息")
  47. @PostMapping("/delete")
  48. public AjaxResult deleteGovernmentInfo(@RequestBody Map<String, String> paramsMap) {
  49. String ids = paramsMap.get("ids");
  50. if (StrUtil.isBlank(ids)) {
  51. return error("请求参数为空");
  52. }
  53. boolean b = governmentInfoService.deleteGovernmentInfo(ids);
  54. if (b) {
  55. return success("删除成功");
  56. }
  57. return error("删除失败");
  58. }
  59. /**
  60. * 编辑政府信息
  61. *
  62. * @param governmentInfoEditRequest
  63. * @return
  64. */
  65. @ApiOperation("编辑政府信息")
  66. @PostMapping("/edit")
  67. public AjaxResult editGovernmentInfo(@RequestBody GovernmentInfoEditRequest governmentInfoEditRequest) {
  68. if (governmentInfoEditRequest == null) {
  69. return error("请求参数为空");
  70. }
  71. governmentInfoService.editGovernmentInfo(governmentInfoEditRequest);
  72. return AjaxResult.success();
  73. }
  74. /**
  75. * 发布政府信息
  76. *
  77. * @param id
  78. * @return
  79. */
  80. @ApiOperation("发布政府信息")
  81. @PostMapping("/publish")
  82. public AjaxResult publishGovernmentInfo(@RequestBody Map<String, Integer> params) {
  83. int id = params.get("id");
  84. if (id <= 0) {
  85. return error("请求参数为空");
  86. }
  87. boolean b = governmentInfoService.publishGovernmentInfo(id);
  88. if (b) {
  89. return AjaxResult.success("发布成功");
  90. } else {
  91. return AjaxResult.error("发布失败");
  92. }
  93. }
  94. /**
  95. * 下架政府信息
  96. *
  97. * @param id
  98. * @return
  99. */
  100. @ApiOperation("下架政府信息")
  101. @PostMapping("/remove")
  102. public AjaxResult removeGovernmentInfo(@RequestBody Map<String, Integer> params) {
  103. int id = params.get("id");
  104. if (id <= 0) {
  105. return error("请求参数为空");
  106. }
  107. boolean b = governmentInfoService.removeGovernmentInfo(id);
  108. if (b) {
  109. return AjaxResult.success("下架成功");
  110. } else {
  111. return AjaxResult.error("下架失败");
  112. }
  113. }
  114. /**
  115. * 根据id获取政府信息
  116. *
  117. * @param id
  118. * @return
  119. */
  120. @ApiOperation("根据id获取政府信息")
  121. @GetMapping("/get")
  122. public AjaxResult getGovernmentInfoById(@RequestParam int id) {
  123. if (ObjectUtil.isEmpty(id)) {
  124. return error("请求参数为空");
  125. }
  126. GovernmentInfoVO governmentInfoById = governmentInfoService.getGovernmentInfoById(id);
  127. return success(governmentInfoById);
  128. }
  129. /**
  130. * 分页获取政府信息列表
  131. *
  132. * @param governmentInfoQueryRequest
  133. * @return
  134. */
  135. @ApiOperation("分页获取政府信息列表")
  136. @PostMapping("/list/page")
  137. public AjaxResult listGovernmentInfoByPage(@RequestBody GovernmentInfoQueryRequest governmentInfoQueryRequest) {
  138. if (governmentInfoQueryRequest == null) {
  139. return error("请求参数为空");
  140. }
  141. Page<GovernmentInfoVO> listGovernmentInfoByPageVO = governmentInfoService.getListGovernmentInfoByPage(governmentInfoQueryRequest);
  142. return success(listGovernmentInfoByPageVO);
  143. }
  144. }