package com.srs.comprehensive.controller;

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

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.SrsIdentifytable;
import com.srs.comprehensive.service.ISrsIdentifytableService;
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/identifytexs")
@Api(value = "学生鉴定信息管理", tags = "学生鉴定信息管理")
public class SrsIdentifytableController extends BaseController {
    @Autowired
    private ISrsIdentifytableService srsIdentifytableService;

    @Autowired
    private GraduateTextService graduateTextService;

    /**
     * 查询学生鉴定信息列表
     */
@PreAuthorize("@ss.hasPermi('comprehensive:identifytexs:list')")
@GetMapping("/list")
@ApiOperation("查询学生鉴定信息列表")
    public TableDataInfo list(SrsIdentifytable srsIdentifytable)
    {
        if(srsIdentifytable.getClassId() != null) {
            String className = graduateTextService.selectGraduateClassData(srsIdentifytable.getClassId());
            srsIdentifytable.setStudentClass(className);
        }
        startPage();
        List<SrsIdentifytable> list = srsIdentifytableService.selectSrsIdentifytableList(srsIdentifytable);
        return getDataTable(list);
    }

    /**
     * 导出学生鉴定信息列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:identifytexs:export')")
    @Log(title = "学生鉴定信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出学生鉴定信息列表")
    public void export(HttpServletResponse response, SrsIdentifytable srsIdentifytable)
    {
        List<SrsIdentifytable> list = srsIdentifytableService.selectSrsIdentifytableList(srsIdentifytable);
        ExcelUtil<SrsIdentifytable> util = new ExcelUtil<SrsIdentifytable>(SrsIdentifytable.class);
        util.exportExcel(response, list, "学生鉴定信息数据");
    }

    /**
     * 获取学生鉴定信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:identifytexs:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取学生鉴定信息详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(srsIdentifytableService.selectSrsIdentifytableById(id));
    }

    /**
     * 新增学生鉴定信息
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:identifytexs:add')")
    @Log(title = "学生鉴定信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增学生鉴定信息")
    public AjaxResult add(@RequestBody SrsIdentifytable srsIdentifytable)
    {
        return toAjax(srsIdentifytableService.insertSrsIdentifytable(srsIdentifytable));
    }

    /**
     * 修改学生鉴定信息
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:identifytexs:edit')")
    @Log(title = "学生鉴定信息", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改学生鉴定信息")
    public AjaxResult edit(@RequestBody SrsIdentifytable srsIdentifytable)
    {
        int i = srsIdentifytableService.updateSrsIdentifytable(srsIdentifytable);
        if(i == 1) {
            return success("修改成功");
        }
        return success("没有值变化不进行修改");
    }

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