package com.srs.web.controller.comprehensive;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;

import com.srs.comprehensive.domain.SrsStudentInfoCheck;
import com.srs.comprehensive.service.ISrsStudentInfoCheckService;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.enums.BusinessType;
import com.srs.common.annotation.Log;
import com.srs.common.core.page.TableDataInfo;
import com.srs.common.utils.poi.ExcelUtil;

/**
 * 学生信息核对 Controller
 *
 * @author srs
 * @date 2024-03-27
 */
@RestController
@RequestMapping("/comprehensive/studentInfo")
@Api(value = "学生信息核对管理", tags = "学生信息核对")
public class SrsStudentInfoCheckController extends BaseController {
    
    @Autowired
    private ISrsStudentInfoCheckService srsStudentInfoCheckService;

    /**
     * 查询学生自己的信息
     */
    @GetMapping("/getOwnInfo")
    @ApiOperation("查询学生自己的信息")
    public AjaxResult getOwnInfo() {
        SrsStudentInfoCheck info = srsStudentInfoCheckService.getStuInfo(getUsername());
        return AjaxResult.success(info);
    }

    /**
     * 根据学号查询学生信息（辅导员专用）
     */
    @GetMapping("/getStuInfoByStuNo")
    @ApiOperation("根据学号查询学生信息")
    public AjaxResult getStuInfoByStuNo(@RequestParam String stuNo) {
        SrsStudentInfoCheck info = srsStudentInfoCheckService.getStuInfo(stuNo);
        return AjaxResult.success(info);
    }

    /**
     * 修改学生自己的信息
     */
    @PostMapping("/editOwnInfo")
    @ApiOperation("修改学生自己的信息")
    public AjaxResult editOwnInfo(@RequestBody SrsStudentInfoCheck param) {
        if (param.getStuNo() == null || "".equals(param.getStuNo())) {
            param.setStuNo(getUsername());
        }
        return srsStudentInfoCheckService.editStuInfo(param);
    }

    /**
     * 查询学生信息列表（管理端使用）
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:studentInfo:list')")
    @GetMapping("/list")
    @ApiOperation("查询学生信息列表")
    public TableDataInfo list(SrsStudentInfoCheck srsStudentInfoCheck) {
        startPage();
        List<SrsStudentInfoCheck> list = srsStudentInfoCheckService.selectSrsStudentInfoCheckList(srsStudentInfoCheck);
        return getDataTable(list);
    }

    /**
     * 导出学生信息列表（管理端使用）
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:studentInfo:export')")
    @Log(title = "学生信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出学生信息列表")
    public void export(HttpServletResponse response, SrsStudentInfoCheck srsStudentInfoCheck) {
        List<SrsStudentInfoCheck> list = srsStudentInfoCheckService.selectSrsStudentInfoCheckList(srsStudentInfoCheck);
        ExcelUtil<SrsStudentInfoCheck> util = new ExcelUtil<SrsStudentInfoCheck>(SrsStudentInfoCheck.class);
        util.exportExcel(response, list, "学生信息数据");
    }
}
