TBranchManageController.java 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. package com.ruoyi.web.controller.branch;
  2. import java.util.ArrayList;
  3. import java.util.Calendar;
  4. import java.util.Date;
  5. import java.util.List;
  6. import javax.servlet.http.HttpServletResponse;
  7. import com.ruoyi.branch.domain.TBranchPublicize;
  8. import com.ruoyi.branch.domain.TBranchStudy;
  9. import com.ruoyi.branch.domain.TFile;
  10. import com.ruoyi.branch.service.ITFileService;
  11. import com.ruoyi.common.utils.StringUtils;
  12. import com.ruoyi.web.controller.branch.vo.ProfilesVO;
  13. import org.springframework.security.access.prepost.PreAuthorize;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.web.bind.annotation.GetMapping;
  16. import org.springframework.web.bind.annotation.PostMapping;
  17. import org.springframework.web.bind.annotation.PutMapping;
  18. import org.springframework.web.bind.annotation.DeleteMapping;
  19. import org.springframework.web.bind.annotation.PathVariable;
  20. import org.springframework.web.bind.annotation.RequestBody;
  21. import org.springframework.web.bind.annotation.RequestMapping;
  22. import org.springframework.web.bind.annotation.RestController;
  23. import com.ruoyi.common.annotation.Log;
  24. import com.ruoyi.common.core.controller.BaseController;
  25. import com.ruoyi.common.core.domain.AjaxResult;
  26. import com.ruoyi.common.enums.BusinessType;
  27. import com.ruoyi.branch.domain.TBranchManage;
  28. import com.ruoyi.branch.service.ITBranchManageService;
  29. import com.ruoyi.common.utils.poi.ExcelUtil;
  30. import com.ruoyi.common.core.page.TableDataInfo;
  31. /**
  32. * 支部党课学习资料管理Controller
  33. *
  34. * @author ruoyi
  35. * @date 2023-07-14
  36. */
  37. @RestController
  38. @RequestMapping("/branch/manage")
  39. public class TBranchManageController extends BaseController {
  40. @Autowired
  41. private ITBranchManageService tBranchManageService;
  42. @Autowired
  43. private ITFileService tFileService;
  44. /**
  45. * 查询支部党课学习资料管理列表(当年、当月)
  46. */
  47. @PreAuthorize("@ss.hasPermi('branch:manage:list')")
  48. @GetMapping("/listCurrentYearMonth")
  49. public AjaxResult listCurrentYearMonth()
  50. {
  51. Calendar calendar = Calendar.getInstance();//当前日期
  52. int year = calendar.get(Calendar.YEAR);//年
  53. int month = calendar.get(Calendar.MONTH) + 1;//月
  54. List<TFile> tFiles = null;
  55. do {
  56. TBranchManage tBranchManage = new TBranchManage();
  57. tBranchManage.setYear(year + "");
  58. tBranchManage.setMonthly(month + "");
  59. List<TBranchManage> tBranchManages = tBranchManageService.selectTBranchManageList(tBranchManage);
  60. TFile tFile = new TFile();
  61. tFile.setTableName("branchManage");
  62. tFile.setTableId(tBranchManages.get(0).getManageId());
  63. tFiles = tFileService.selectTFileList(tFile);
  64. month -= 1;
  65. } while (tFiles.size() == 0);
  66. return AjaxResult.success(tFiles);
  67. }
  68. /**
  69. * 查询支部党课学习资料管理列表
  70. */
  71. @PreAuthorize("@ss.hasPermi('branch:manage:list')")
  72. @GetMapping("/list")
  73. public TableDataInfo list(TBranchManage tBranchManage) {
  74. startPage();
  75. List<TBranchManage> list = tBranchManageService.selectTBranchManageList(tBranchManage);
  76. return getDataTable(list);
  77. }
  78. /**
  79. * 导出支部党课学习资料管理列表
  80. */
  81. @PreAuthorize("@ss.hasPermi('branch:manage:export')")
  82. @Log(title = "支部党课学习资料管理", businessType = BusinessType.EXPORT)
  83. @PostMapping("/export")
  84. public void export(HttpServletResponse response, TBranchManage tBranchManage) {
  85. List<TBranchManage> list = tBranchManageService.selectTBranchManageList(tBranchManage);
  86. ExcelUtil<TBranchManage> util = new ExcelUtil<TBranchManage>(TBranchManage.class);
  87. util.exportExcel(response, list, "支部党课学习资料管理数据");
  88. }
  89. /**
  90. * 获取支部党课学习资料管理详细信息
  91. */
  92. @PreAuthorize("@ss.hasPermi('branch:manage:query')")
  93. @GetMapping(value = "/{manageId}")
  94. public AjaxResult getInfo(@PathVariable("manageId") Long manageId) {
  95. return success(tBranchManageService.selectTBranchManageByManageId(manageId));
  96. }
  97. /**
  98. * 新增支部党课学习资料管理
  99. */
  100. @PreAuthorize("@ss.hasPermi('branch:manage:add')")
  101. @Log(title = "支部党课学习资料管理", businessType = BusinessType.INSERT)
  102. @PostMapping
  103. public AjaxResult add(@RequestBody TBranchManage tBranchManage) {
  104. return toAjax(tBranchManageService.insertTBranchManage(tBranchManage));
  105. }
  106. /**
  107. * 修改支部党课学习资料管理
  108. */
  109. @PreAuthorize("@ss.hasPermi('branch:manage:edit')")
  110. @Log(title = "支部党课学习资料管理", businessType = BusinessType.UPDATE)
  111. @PutMapping
  112. public AjaxResult edit(@RequestBody TBranchManage tBranchManage) {
  113. if (StringUtils.isNotEmpty(tBranchManage.getFilesId())) {
  114. TBranchManage manage = tBranchManageService.selectTBranchManageByManageId(tBranchManage.getManageId());
  115. if (StringUtils.isNotEmpty(manage.getFilesId())) {
  116. tBranchManage.setFilesId(manage.getFilesId() + "," + tBranchManage.getFilesId());
  117. }
  118. }
  119. return toAjax(tBranchManageService.updateTBranchManage(tBranchManage));
  120. }
  121. /**
  122. * 删除支部党课学习资料管理
  123. */
  124. @PreAuthorize("@ss.hasPermi('branch:manage:remove')")
  125. @Log(title = "支部党课学习资料管理", businessType = BusinessType.DELETE)
  126. @DeleteMapping("/{manageIds}")
  127. public AjaxResult remove(@PathVariable Long[] manageIds) {
  128. return toAjax(tBranchManageService.deleteTBranchManageByManageIds(manageIds));
  129. }
  130. @PreAuthorize("@ss.hasPermi('branch:manage:remove')")
  131. @Log(title = "支部党课学习资料管理删除附件", businessType = BusinessType.DELETE)
  132. @PutMapping("/delFile")
  133. public AjaxResult removeFile(@RequestBody TBranchManage tBranchManage) {
  134. TBranchManage mange = tBranchManageService.selectTBranchManageByManageId(tBranchManage.getManageId());
  135. mange.setFilesId(mange.getFilesId().replace(tBranchManage.getFilesId(), ""));
  136. if (mange.getFilesId().contains(",,")){
  137. mange.setFilesId(mange.getFilesId().replace(",,", ","));
  138. }
  139. if (mange.getFilesId().endsWith(",")) {
  140. mange.setFilesId(mange.getFilesId().substring(0, mange.getFilesId().length()-1));
  141. }
  142. tBranchManageService.updateTBranchManage(mange);
  143. return toAjax(tFileService.deleteTFileById(Long.valueOf(tBranchManage.getFilesId())));
  144. }
  145. }