123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- package com.ruoyi.web.controller.system;
- import cn.hutool.core.util.ObjectUtil;
- import cn.hutool.core.util.StrUtil;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.ruoyi.common.core.domain.AjaxResult;
- import com.ruoyi.web.domain.dto.government.GovernmentInfoAddRequest;
- import com.ruoyi.web.domain.dto.government.GovernmentInfoEditRequest;
- import com.ruoyi.web.domain.dto.government.GovernmentInfoQueryRequest;
- import com.ruoyi.web.domain.vo.GovernmentInfoVO;
- import com.ruoyi.web.service.GovernmentInfoService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import java.util.Map;
- import static com.ruoyi.common.core.domain.AjaxResult.error;
- import static com.ruoyi.common.core.domain.AjaxResult.success;
- @Api(tags ="政府信息")
- @RestController
- @RequestMapping("/system/government")
- public class GovernmentInfoController {
- @Autowired
- private GovernmentInfoService governmentInfoService;
- /**
- * 添加政府信息
- *
- * @param governmentInfoAddRequest
- * @return
- */
- @ApiOperation("添加政府信息")
- @PostMapping("/add")
- public AjaxResult addGovernmentInfo(@RequestBody GovernmentInfoAddRequest governmentInfoAddRequest) {
- if (governmentInfoAddRequest == null) {
- return error("请求参数为空");
- }
- System.out.println(governmentInfoAddRequest.getContent());
- Integer id = governmentInfoService.addGovernmentInfo(governmentInfoAddRequest);
- return success(id);
- }
- /**
- * 删除政府信息
- *
- * @param paramsMap
- * @return
- */
- @ApiOperation("删除政府信息")
- @PostMapping("/delete")
- public AjaxResult deleteGovernmentInfo(@RequestBody Map<String, String> paramsMap) {
- String ids = paramsMap.get("ids");
- if (StrUtil.isBlank(ids)) {
- return error("请求参数为空");
- }
- boolean b = governmentInfoService.deleteGovernmentInfo(ids);
- if (b) {
- return success("删除成功");
- }
- return error("删除失败");
- }
- /**
- * 编辑政府信息
- *
- * @param governmentInfoEditRequest
- * @return
- */
- @ApiOperation("编辑政府信息")
- @PostMapping("/edit")
- public AjaxResult editGovernmentInfo(@RequestBody GovernmentInfoEditRequest governmentInfoEditRequest) {
- if (governmentInfoEditRequest == null) {
- return error("请求参数为空");
- }
- governmentInfoService.editGovernmentInfo(governmentInfoEditRequest);
- return AjaxResult.success();
- }
- /**
- * 发布政府信息
- *
- * @param id
- * @return
- */
- @ApiOperation("发布政府信息")
- @PostMapping("/publish")
- public AjaxResult publishGovernmentInfo(@RequestBody Map<String, Integer> params) {
- int id = params.get("id");
- if (id <= 0) {
- return error("请求参数为空");
- }
- boolean b = governmentInfoService.publishGovernmentInfo(id);
- if (b) {
- return AjaxResult.success("发布成功");
- } else {
- return AjaxResult.error("发布失败");
- }
- }
- /**
- * 下架政府信息
- *
- * @param id
- * @return
- */
- @ApiOperation("下架政府信息")
- @PostMapping("/remove")
- public AjaxResult removeGovernmentInfo(@RequestBody Map<String, Integer> params) {
- int id = params.get("id");
- if (id <= 0) {
- return error("请求参数为空");
- }
- boolean b = governmentInfoService.removeGovernmentInfo(id);
- if (b) {
- return AjaxResult.success("下架成功");
- } else {
- return AjaxResult.error("下架失败");
- }
- }
- /**
- * 根据id获取政府信息
- *
- * @param id
- * @return
- */
- @ApiOperation("根据id获取政府信息")
- @GetMapping("/get")
- public AjaxResult getGovernmentInfoById(@RequestParam int id) {
- if (ObjectUtil.isEmpty(id)) {
- return error("请求参数为空");
- }
- GovernmentInfoVO governmentInfoById = governmentInfoService.getGovernmentInfoById(id);
- return success(governmentInfoById);
- }
- /**
- * 分页获取政府信息列表
- *
- * @param governmentInfoQueryRequest
- * @return
- */
- @ApiOperation("分页获取政府信息列表")
- @PostMapping("/list/page")
- public AjaxResult listGovernmentInfoByPage(@RequestBody GovernmentInfoQueryRequest governmentInfoQueryRequest) {
- if (governmentInfoQueryRequest == null) {
- return error("请求参数为空");
- }
- Page<GovernmentInfoVO> listGovernmentInfoByPageVO = governmentInfoService.getListGovernmentInfoByPage(governmentInfoQueryRequest);
- return success(listGovernmentInfoByPageVO);
- }
- }
|