package com.srs.comprehensive.controller;

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

import com.srs.comprehensive.domain.SrsIdentifytable;
import com.srs.comprehensive.service.GraduateTextService;
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.comprehensive.domain.SrsGraduateStudent;
import com.srs.comprehensive.service.ISrsGraduateStudentService;
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-07-10
 */
@RestController
@RequestMapping("/comprehensive/remarkstext")
@Api(value = "学生评语信息管理", tags = "学生评语信息管理")
public class SrsGraduateStudentController extends BaseController {
    @Autowired
    private ISrsGraduateStudentService srsGraduateStudentService;

    @Autowired
    private GraduateTextService graduateTextService;

    /**
     * 查询学生评语信息列表
     */
@PreAuthorize("@ss.hasPermi('comprehensive:remarkstext:list')")
@GetMapping("/list")
@ApiOperation("查询学生评语信息列表")
    public TableDataInfo list(SrsGraduateStudent srsGraduateStudent)
    {
        if(srsGraduateStudent.getClassId() != null) {
            String className = graduateTextService.selectGraduateClassData(srsGraduateStudent.getClassId());
            srsGraduateStudent.setStudentClass(className);
        }
        startPage();
        List<SrsIdentifytable> list = srsGraduateStudentService.selectSrsGraduateStudentLists(srsGraduateStudent);
        return getDataTable(list);
    }

    /**
     * 导出学生评语信息列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:remarkstext:export')")
    @Log(title = "学生评语信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出学生评语信息列表")
    public void export(HttpServletResponse response, SrsGraduateStudent srsGraduateStudent)
    {
        List<SrsGraduateStudent> list = srsGraduateStudentService.selectSrsGraduateStudentList(srsGraduateStudent);
        ExcelUtil<SrsGraduateStudent> util = new ExcelUtil<SrsGraduateStudent>(SrsGraduateStudent.class);
        util.exportExcel(response, list, "学生评语信息数据");
    }

    /**
     * 获取学生评语信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:remarkstext:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取学生评语信息详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(srsGraduateStudentService.selectSrsGraduateStudentById(id));
    }

    /**
     * 新增学生评语信息
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:remarkstext:add')")
    @Log(title = "学生评语信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增学生评语信息")
    public AjaxResult add(@RequestBody SrsGraduateStudent srsGraduateStudent)
    {
        return toAjax(srsGraduateStudentService.insertSrsGraduateStudent(srsGraduateStudent));
    }

    /**
     * 修改学生评语信息
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:remarkstext:edit')")
    @Log(title = "学生评语信息", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改学生评语信息")
    public AjaxResult edit(@RequestBody SrsGraduateStudent srsGraduateStudent)
    {
        return toAjax(srsGraduateStudentService.updateSrsGraduateStudent(srsGraduateStudent));
    }

    /**
     * 删除学生评语信息
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:remarkstext:remove')")
    @Log(title = "学生评语信息", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除学生评语信息")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(srsGraduateStudentService.deleteSrsGraduateStudentByIds(ids));
    }
}
