CentereventTEventCollectController.java 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package com.sooka.sponest.event.centereventteventcollect.controller;
  2. import java.util.List;
  3. import java.io.IOException;
  4. import javax.servlet.http.HttpServletResponse;
  5. import com.ruoyi.common.core.utils.StringUtils;
  6. import com.ruoyi.common.core.utils.uuid.IdUtils;
  7. import com.ruoyi.common.security.utils.SecurityUtils;
  8. import com.sooka.sponest.event.centereventteventcollect.domain.CentereventTEventCollect;
  9. import com.sooka.sponest.event.centereventteventcollect.service.ICentereventTEventCollectService;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.GetMapping;
  12. import org.springframework.web.bind.annotation.PostMapping;
  13. import org.springframework.web.bind.annotation.PutMapping;
  14. import org.springframework.web.bind.annotation.DeleteMapping;
  15. import org.springframework.web.bind.annotation.PathVariable;
  16. import org.springframework.web.bind.annotation.RequestBody;
  17. import org.springframework.web.bind.annotation.RequestMapping;
  18. import org.springframework.web.bind.annotation.RestController;
  19. import com.ruoyi.common.log.annotation.Log;
  20. import com.ruoyi.common.log.enums.BusinessType;
  21. import com.ruoyi.common.security.annotation.RequiresPermissions;
  22. import com.ruoyi.common.core.web.controller.BaseController;
  23. import com.ruoyi.common.core.web.domain.AjaxResult;
  24. import com.ruoyi.common.core.utils.poi.ExcelUtil;
  25. import com.ruoyi.common.core.web.page.TableDataInfo;
  26. /**
  27. * 事件收藏Controller
  28. *
  29. * @author ruoyi
  30. * @date 2025-06-24
  31. */
  32. @RestController
  33. @RequestMapping("/collect")
  34. public class CentereventTEventCollectController extends BaseController {
  35. @Autowired
  36. private ICentereventTEventCollectService centereventTEventCollectService;
  37. /**
  38. * 查询事件收藏列表
  39. */
  40. @RequiresPermissions("system:collect:list")
  41. @GetMapping("/list")
  42. public TableDataInfo list(CentereventTEventCollect centereventTEventCollect) {
  43. startPage();
  44. List<CentereventTEventCollect> list = centereventTEventCollectService.selectCentereventTEventCollectList(centereventTEventCollect);
  45. return getDataTable(list);
  46. }
  47. /**
  48. * 导出事件收藏列表
  49. */
  50. @RequiresPermissions("system:collect:export")
  51. @Log(title = "事件收藏", businessType = BusinessType.EXPORT)
  52. @PostMapping("/export")
  53. public void export(HttpServletResponse response, CentereventTEventCollect centereventTEventCollect) {
  54. List<CentereventTEventCollect> list = centereventTEventCollectService.selectCentereventTEventCollectList(centereventTEventCollect);
  55. ExcelUtil<CentereventTEventCollect> util = new ExcelUtil<CentereventTEventCollect>(CentereventTEventCollect.class);
  56. util.exportExcel(response, list, "事件收藏数据");
  57. }
  58. /**
  59. * 获取事件收藏详细信息
  60. */
  61. @RequiresPermissions("system:collect:query")
  62. @GetMapping(value = "/{id}")
  63. public AjaxResult getInfo(@PathVariable("id") String id) {
  64. return AjaxResult.success(centereventTEventCollectService.selectCentereventTEventCollectById(id));
  65. }
  66. /**
  67. * 新增事件收藏
  68. */
  69. @RequiresPermissions("system:collect:add")
  70. @Log(title = "事件收藏", businessType = BusinessType.INSERT)
  71. @PostMapping
  72. public AjaxResult add(@RequestBody CentereventTEventCollect centereventTEventCollect) {
  73. String uuid = IdUtils.simpleUUID();
  74. centereventTEventCollect.setId(uuid);
  75. centereventTEventCollect.setSort("0");
  76. if(StringUtils.isBlank(centereventTEventCollect.getUserId())){
  77. centereventTEventCollect.setUserId(SecurityUtils.getUserId().toString());
  78. }
  79. if(centereventTEventCollectService.isCollect(centereventTEventCollect)){
  80. return AjaxResult.error("您已收藏该事件");
  81. }
  82. int i = centereventTEventCollectService.insertCentereventTEventCollect(centereventTEventCollect);
  83. if(i>0){
  84. return AjaxResult.success("收藏成功", uuid);
  85. }else{
  86. return AjaxResult.error("收藏失败");
  87. }
  88. }
  89. /**
  90. * 修改事件收藏
  91. */
  92. @RequiresPermissions("system:collect:edit")
  93. @Log(title = "事件收藏", businessType = BusinessType.UPDATE)
  94. @PutMapping
  95. public AjaxResult edit(@RequestBody CentereventTEventCollect centereventTEventCollect) {
  96. return toAjax(centereventTEventCollectService.updateCentereventTEventCollect(centereventTEventCollect));
  97. }
  98. /**
  99. * 删除事件收藏
  100. */
  101. @RequiresPermissions("system:collect:remove")
  102. @Log(title = "事件收藏", businessType = BusinessType.DELETE)
  103. @DeleteMapping("/{ids}")
  104. public AjaxResult remove(@PathVariable String[] ids) {
  105. return toAjax(centereventTEventCollectService.deleteCentereventTEventCollectByIds(ids));
  106. }
  107. }