package com.srs.web.controller.teacher;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.teacher.domain.SysTeacherAppraise;
import com.srs.teacher.service.ISysTeacherAppraiseService;
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;

/**
 * appraiseController
 *
 * @author srs
 * @date 2024-06-12
 */
@RestController
@RequestMapping("/teacher/appraise")
@Api(value = "辅导员考核年度管理", tags = "辅导员考核年度管理")
public class SysTeacherAppraiseController extends BaseController {
    @Autowired
    private ISysTeacherAppraiseService sysTeacherAppraiseService;

    /**
     * 查询appraise列表
     */
@PreAuthorize("@ss.hasPermi('teacher:appraise:list')")
@GetMapping("/list")
@ApiOperation("查询appraise列表")
    public TableDataInfo list(SysTeacherAppraise sysTeacherAppraise)
    {
        startPage();
        List<SysTeacherAppraise> list = sysTeacherAppraiseService.selectSysTeacherAppraiseList(sysTeacherAppraise);
        return getDataTable(list);
    }

    /**
     * 导出appraise列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:appraise:export')")
    @Log(title = "appraise", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出appraise列表")
    public void export(HttpServletResponse response, SysTeacherAppraise sysTeacherAppraise)
    {
        List<SysTeacherAppraise> list = sysTeacherAppraiseService.selectSysTeacherAppraiseList(sysTeacherAppraise);
        ExcelUtil<SysTeacherAppraise> util = new ExcelUtil<SysTeacherAppraise>(SysTeacherAppraise.class);
        util.exportExcel(response, list, "appraise数据");
    }

    /**
     * 获取appraise详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:appraise:query')")
    @GetMapping(value = "/{appraiseId}")
    @ApiOperation("获取appraise详细信息")
    public AjaxResult getInfo(@PathVariable("appraiseId") Long appraiseId)
    {
        return success(sysTeacherAppraiseService.selectSysTeacherAppraiseByAppraiseId(appraiseId));
    }

    /**
     * 新增appraise
     */
    @PreAuthorize("@ss.hasPermi('teacher:appraise:add')")
    @Log(title = "appraise", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增appraise")
    public AjaxResult add(@RequestBody SysTeacherAppraise sysTeacherAppraise)
    {
        return toAjax(sysTeacherAppraiseService.insertSysTeacherAppraise(sysTeacherAppraise));
    }

    /**
     * 修改appraise
     */
    @PreAuthorize("@ss.hasPermi('teacher:appraise:edit')")
    @Log(title = "appraise", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改appraise")
    public AjaxResult edit(@RequestBody SysTeacherAppraise sysTeacherAppraise)
    {
        return toAjax(sysTeacherAppraiseService.updateSysTeacherAppraise(sysTeacherAppraise));
    }

    /**
     * 删除appraise
     */
    @PreAuthorize("@ss.hasPermi('teacher:appraise:remove')")
    @Log(title = "appraise", businessType = BusinessType.DELETE)
    @PostMapping("/{appraiseIds}")
    @ApiOperation("删除appraise")
    public AjaxResult remove(@PathVariable Long[] appraiseIds)
    {
        return toAjax(sysTeacherAppraiseService.deleteSysTeacherAppraiseByAppraiseIds(appraiseIds));
    }
}
