package com.srs.web.controller.survey;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;

import com.srs.survey.domain.SurSurvey;
import com.srs.survey.service.ISurSurveyService;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.utils.poi.ExcelUtil;
import com.srs.common.enums.BusinessType;
import com.srs.common.annotation.Log;
import com.srs.common.core.page.TableDataInfo;

/**
 * 学工去向调查发布	Controller
 *
 * @author srs
 * @date 2025-03-13
 */
@RestController
@RequestMapping("/survey/survey")
@Api(value = "学工去向调查发布	管理", tags = "学工去向调查发布	管理")
public class SurSurveyController extends BaseController {
    @Autowired
    private ISurSurveyService surSurveyService;

    @GetMapping("/listAllSurvey")
    public AjaxResult listAllSurvey(){
        List<SurSurvey> list = surSurveyService.list(
                new QueryWrapper<SurSurvey>()
                        .orderByDesc("survey_id")
        );
        return AjaxResult.success(list);
    }


    @GetMapping("/listStu")
    @ApiOperation("学生查询学工去向调查发布	列表")
    public AjaxResult listStu(SurSurvey param) {
        return surSurveyService.listStu(param);
    }


    /**
     * 查询学工去向调查发布	列表
     */
    @PreAuthorize("@ss.hasPermi('survey:survey:list')")
    @GetMapping("/list")
    @ApiOperation("查询学工去向调查发布	列表")
    public TableDataInfo list(SurSurvey surSurvey) {
        startPage();
        List<SurSurvey> list = surSurveyService.selectSurSurveyList(surSurvey);
        return getDataTable(list);
    }

    /**
     * 导出学工去向调查发布	列表
     */
    @PreAuthorize("@ss.hasPermi('survey:survey:export')")
    @Log(title = "学工去向调查发布	", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出学工去向调查发布	列表")
    public void export(HttpServletResponse response, SurSurvey surSurvey) {
        List<SurSurvey> list = surSurveyService.selectSurSurveyList(surSurvey);
        ExcelUtil<SurSurvey> util = new ExcelUtil<SurSurvey>(SurSurvey.class);
        util.exportExcel(response, list, "学工去向调查发布	数据");
    }

    /**
     * 获取学工去向调查发布	详细信息
     */
    @PreAuthorize("@ss.hasPermi('survey:survey:query')")
    @GetMapping(value = "/{surveyId}")
    @ApiOperation("获取学工去向调查发布	详细信息")
    public AjaxResult getInfo(@PathVariable("surveyId") Long surveyId) {
        return success(surSurveyService.selectSurSurveyBySurveyId(surveyId));
    }

    /**
     * 新增学工去向调查发布
     */
    @PreAuthorize("@ss.hasPermi('survey:survey:add')")
    @Log(title = "学工去向调查发布	", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增学工去向调查发布	")
    public AjaxResult add(@RequestBody SurSurvey surSurvey) {
        return toAjax(surSurveyService.insertSurSurvey(surSurvey));
    }

    /**
     * 修改学工去向调查发布
     */
    @PreAuthorize("@ss.hasPermi('survey:survey:edit')")
    @Log(title = "学工去向调查发布	", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改学工去向调查发布	")
    public AjaxResult edit(@RequestBody SurSurvey surSurvey) {
        return toAjax(surSurveyService.updateSurSurvey(surSurvey));
    }

    /**
     * 删除学工去向调查发布
     */
    @PreAuthorize("@ss.hasPermi('survey:survey:remove')")
    @Log(title = "学工去向调查发布	", businessType = BusinessType.DELETE)
    @PostMapping("/{surveyIds}")
    @ApiOperation("删除学工去向调查发布	")
    public AjaxResult remove(@PathVariable Long[] surveyIds) {
        return toAjax(surSurveyService.deleteSurSurveyBySurveyIds(surveyIds));
    }
}
