SurveyTaskController.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package com.fs.survey;
  2. import java.util.Date;
  3. import java.util.List;
  4. import com.fs.common.core.domain.model.LoginUser;
  5. import com.fs.common.utils.SecurityUtils;
  6. import org.springframework.security.access.prepost.PreAuthorize;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.web.bind.annotation.GetMapping;
  9. import org.springframework.web.bind.annotation.PostMapping;
  10. import org.springframework.web.bind.annotation.PutMapping;
  11. import org.springframework.web.bind.annotation.DeleteMapping;
  12. import org.springframework.web.bind.annotation.PathVariable;
  13. import org.springframework.web.bind.annotation.RequestBody;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import com.fs.common.annotation.Log;
  17. import com.fs.common.core.controller.BaseController;
  18. import com.fs.common.core.domain.AjaxResult;
  19. import com.fs.common.enums.BusinessType;
  20. import com.fs.survey.domain.SurveyTask;
  21. import com.fs.survey.service.ISurveyTaskService;
  22. import com.fs.common.utils.poi.ExcelUtil;
  23. import com.fs.common.core.page.TableDataInfo;
  24. /**
  25. * 问卷任务Controller
  26. *
  27. * @author fs
  28. * @date 2026-02-06
  29. */
  30. @RestController
  31. @RequestMapping("/survey/task")
  32. public class SurveyTaskController extends BaseController
  33. {
  34. @Autowired
  35. private ISurveyTaskService surveyTaskService;
  36. /**
  37. * 查询问卷任务列表
  38. */
  39. @PreAuthorize("@ss.hasPermi('survey:task:list')")
  40. @GetMapping("/list")
  41. public TableDataInfo list(SurveyTask surveyTask)
  42. {
  43. startPage();
  44. List<SurveyTask> list = surveyTaskService.selectSurveyTaskList(surveyTask);
  45. return getDataTable(list);
  46. }
  47. /**
  48. * 导出问卷任务列表
  49. */
  50. @PreAuthorize("@ss.hasPermi('survey:task:export')")
  51. @Log(title = "问卷任务", businessType = BusinessType.EXPORT)
  52. @GetMapping("/export")
  53. public AjaxResult export(SurveyTask surveyTask)
  54. {
  55. List<SurveyTask> list = surveyTaskService.selectSurveyTaskList(surveyTask);
  56. ExcelUtil<SurveyTask> util = new ExcelUtil<SurveyTask>(SurveyTask.class);
  57. return util.exportExcel(list, "问卷任务数据");
  58. }
  59. /**
  60. * 获取问卷任务详细信息
  61. */
  62. @PreAuthorize("@ss.hasPermi('survey:task:query')")
  63. @GetMapping(value = "/{id}")
  64. public AjaxResult getInfo(@PathVariable("id") Long id)
  65. {
  66. return AjaxResult.success(surveyTaskService.selectSurveyTaskById(id));
  67. }
  68. /**
  69. * 新增问卷任务
  70. */
  71. @PreAuthorize("@ss.hasPermi('survey:task:add')")
  72. @Log(title = "问卷任务", businessType = BusinessType.INSERT)
  73. @PostMapping
  74. public AjaxResult add(@RequestBody SurveyTask surveyTask)
  75. {
  76. //删除标记
  77. surveyTask.setDeleted(0l);
  78. //时间标记
  79. surveyTask.setCreateTime(new Date());
  80. surveyTask.setUpdateTime(new Date());
  81. LoginUser loginUser = SecurityUtils.getLoginUser();
  82. surveyTask.setCreateBy(loginUser.getUserId()+"");
  83. surveyTask.setUpdateBy(loginUser.getUserId()+"");
  84. return toAjax(surveyTaskService.insertSurveyTask(surveyTask));
  85. }
  86. /**
  87. * 修改问卷任务
  88. */
  89. @PreAuthorize("@ss.hasPermi('survey:task:edit')")
  90. @Log(title = "问卷任务", businessType = BusinessType.UPDATE)
  91. @PutMapping
  92. public AjaxResult edit(@RequestBody SurveyTask surveyTask)
  93. {
  94. surveyTask.setUpdateTime(new Date());
  95. LoginUser loginUser = SecurityUtils.getLoginUser();
  96. surveyTask.setUpdateBy(loginUser.getUserId()+"");
  97. return toAjax(surveyTaskService.updateSurveyTaskBaseInfo(surveyTask));
  98. }
  99. /**
  100. * 删除问卷任务
  101. */
  102. @PreAuthorize("@ss.hasPermi('survey:task:remove')")
  103. @Log(title = "问卷任务", businessType = BusinessType.DELETE)
  104. @DeleteMapping("/{ids}")
  105. public AjaxResult remove(@PathVariable Long[] ids)
  106. {
  107. return toAjax(surveyTaskService.deleteSurveyTaskByIds(ids));
  108. }
  109. }