package com.fs.survey; import java.util.Date; import java.util.List; import com.fs.common.core.domain.model.LoginUser; import com.fs.common.utils.SecurityUtils; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.fs.common.annotation.Log; import com.fs.common.core.controller.BaseController; import com.fs.common.core.domain.AjaxResult; import com.fs.common.enums.BusinessType; import com.fs.survey.domain.SurveyTask; import com.fs.survey.service.ISurveyTaskService; import com.fs.common.utils.poi.ExcelUtil; import com.fs.common.core.page.TableDataInfo; /** * 问卷任务Controller * * @author fs * @date 2026-02-06 */ @RestController @RequestMapping("/survey/task") public class SurveyTaskController extends BaseController { @Autowired private ISurveyTaskService surveyTaskService; /** * 查询问卷任务列表 */ @PreAuthorize("@ss.hasPermi('survey:task:list')") @GetMapping("/list") public TableDataInfo list(SurveyTask surveyTask) { startPage(); List list = surveyTaskService.selectSurveyTaskList(surveyTask); return getDataTable(list); } /** * 导出问卷任务列表 */ @PreAuthorize("@ss.hasPermi('survey:task:export')") @Log(title = "问卷任务", businessType = BusinessType.EXPORT) @GetMapping("/export") public AjaxResult export(SurveyTask surveyTask) { List list = surveyTaskService.selectSurveyTaskList(surveyTask); ExcelUtil util = new ExcelUtil(SurveyTask.class); return util.exportExcel(list, "问卷任务数据"); } /** * 获取问卷任务详细信息 */ @PreAuthorize("@ss.hasPermi('survey:task:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { return AjaxResult.success(surveyTaskService.selectSurveyTaskById(id)); } /** * 新增问卷任务 */ @PreAuthorize("@ss.hasPermi('survey:task:add')") @Log(title = "问卷任务", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody SurveyTask surveyTask) { //删除标记 surveyTask.setDeleted(0l); //时间标记 surveyTask.setCreateTime(new Date()); surveyTask.setUpdateTime(new Date()); LoginUser loginUser = SecurityUtils.getLoginUser(); surveyTask.setCreateBy(loginUser.getUserId()+""); surveyTask.setUpdateBy(loginUser.getUserId()+""); return toAjax(surveyTaskService.insertSurveyTask(surveyTask)); } /** * 修改问卷任务 */ @PreAuthorize("@ss.hasPermi('survey:task:edit')") @Log(title = "问卷任务", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody SurveyTask surveyTask) { surveyTask.setUpdateTime(new Date()); LoginUser loginUser = SecurityUtils.getLoginUser(); surveyTask.setUpdateBy(loginUser.getUserId()+""); return toAjax(surveyTaskService.updateSurveyTaskBaseInfo(surveyTask)); } /** * 删除问卷任务 */ @PreAuthorize("@ss.hasPermi('survey:task:remove')") @Log(title = "问卷任务", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(surveyTaskService.deleteSurveyTaskByIds(ids)); } }