TBranchPublicizeController.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. package com.ruoyi.web.controller.branch;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import javax.servlet.http.HttpServletResponse;
  5. import com.ruoyi.branch.domain.TFile;
  6. import com.ruoyi.branch.service.ITFileService;
  7. import org.springframework.security.access.prepost.PreAuthorize;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.PostMapping;
  11. import org.springframework.web.bind.annotation.PutMapping;
  12. import org.springframework.web.bind.annotation.DeleteMapping;
  13. import org.springframework.web.bind.annotation.PathVariable;
  14. import org.springframework.web.bind.annotation.RequestBody;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RestController;
  17. import com.ruoyi.common.annotation.Log;
  18. import com.ruoyi.common.core.controller.BaseController;
  19. import com.ruoyi.common.core.domain.AjaxResult;
  20. import com.ruoyi.common.enums.BusinessType;
  21. import com.ruoyi.branch.domain.TBranchPublicize;
  22. import com.ruoyi.branch.service.ITBranchPublicizeService;
  23. import com.ruoyi.common.utils.poi.ExcelUtil;
  24. import com.ruoyi.common.core.page.TableDataInfo;
  25. /**
  26. * 支部园地宣传Controller
  27. *
  28. * @author ruoyi
  29. * @date 2023-07-27
  30. */
  31. @RestController
  32. @RequestMapping("/branch/publicize")
  33. public class TBranchPublicizeController extends BaseController
  34. {
  35. @Autowired
  36. private ITBranchPublicizeService tBranchPublicizeService;
  37. @Autowired
  38. private ITFileService fileService;
  39. /**
  40. * 查询首页置顶图片轮播
  41. */
  42. @PreAuthorize("@ss.hasPermi('branch:publicize:list')")
  43. @GetMapping("/listProfiles")
  44. public AjaxResult listProfiles()
  45. {
  46. TBranchPublicize tBranchPublicize = new TBranchPublicize();
  47. tBranchPublicize.setIsPinned("1");
  48. List<TBranchPublicize> tBranchPublicizes = tBranchPublicizeService.selectTBranchPublicizeList(tBranchPublicize);
  49. List<TFile> fileList = new ArrayList<>();
  50. for (TBranchPublicize branchPublicize : tBranchPublicizes) {
  51. TFile tFile = new TFile();
  52. tFile.setTableName("branchPublicize");
  53. tFile.setTableId(branchPublicize.getPublicizeId());
  54. List<TFile> tFiles = fileService.selectTFileList(tFile);
  55. if (tFiles != null) {
  56. fileList.add(tFiles.get(0));
  57. }
  58. }
  59. return AjaxResult.success(fileList);
  60. }
  61. /**
  62. * 查询支部园地宣传列表
  63. */
  64. @PreAuthorize("@ss.hasPermi('branch:publicize:list')")
  65. @GetMapping("/list")
  66. public TableDataInfo list(TBranchPublicize tBranchPublicize)
  67. {
  68. startPage();
  69. List<TBranchPublicize> list = tBranchPublicizeService.selectTBranchPublicizeList(tBranchPublicize);
  70. return getDataTable(list);
  71. }
  72. /**
  73. * 导出支部园地宣传列表
  74. */
  75. @PreAuthorize("@ss.hasPermi('branch:publicize:export')")
  76. @Log(title = "支部园地宣传", businessType = BusinessType.EXPORT)
  77. @PostMapping("/export")
  78. public void export(HttpServletResponse response, TBranchPublicize tBranchPublicize)
  79. {
  80. List<TBranchPublicize> list = tBranchPublicizeService.selectTBranchPublicizeList(tBranchPublicize);
  81. ExcelUtil<TBranchPublicize> util = new ExcelUtil<TBranchPublicize>(TBranchPublicize.class);
  82. util.exportExcel(response, list, "支部园地宣传数据");
  83. }
  84. /**
  85. * 获取支部园地宣传详细信息
  86. */
  87. @PreAuthorize("@ss.hasPermi('branch:publicize:query')")
  88. @GetMapping(value = "/{publicizeId}")
  89. public AjaxResult getInfo(@PathVariable("publicizeId") Long publicizeId)
  90. {
  91. return success(tBranchPublicizeService.selectTBranchPublicizeByPublicizeId(publicizeId));
  92. }
  93. /**
  94. * 新增支部园地宣传
  95. */
  96. @PreAuthorize("@ss.hasPermi('branch:publicize:add')")
  97. @Log(title = "支部园地宣传", businessType = BusinessType.INSERT)
  98. @PostMapping
  99. public AjaxResult add(@RequestBody TBranchPublicize tBranchPublicize)
  100. {
  101. tBranchPublicize.setCreateBy(getUsername());
  102. return toAjax(tBranchPublicizeService.insertTBranchPublicize(tBranchPublicize));
  103. }
  104. /**
  105. * 修改支部园地宣传
  106. */
  107. @PreAuthorize("@ss.hasPermi('branch:publicize:edit')")
  108. @Log(title = "支部园地宣传", businessType = BusinessType.UPDATE)
  109. @PutMapping
  110. public AjaxResult edit(@RequestBody TBranchPublicize tBranchPublicize)
  111. {
  112. return toAjax(tBranchPublicizeService.updateTBranchPublicize(tBranchPublicize));
  113. }
  114. /**
  115. * 删除支部园地宣传
  116. */
  117. @PreAuthorize("@ss.hasPermi('branch:publicize:remove')")
  118. @Log(title = "支部园地宣传", businessType = BusinessType.DELETE)
  119. @DeleteMapping("/{publicizeIds}")
  120. public AjaxResult remove(@PathVariable Long[] publicizeIds)
  121. {
  122. return toAjax(tBranchPublicizeService.deleteTBranchPublicizeByPublicizeIds(publicizeIds));
  123. }
  124. }