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.SysTeacherThesis;
import com.srs.teacher.service.ISysTeacherThesisService;
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;

/**
 * thesisController
 *
 * @author srs
 * @date 2024-06-29
 */
@RestController
@RequestMapping("/teacher/thesis")
@Api(value = "thesis管理", tags = "thesis管理")
public class SysTeacherThesisController extends BaseController {
    @Autowired
    private ISysTeacherThesisService sysTeacherThesisService;

    /**
     * 查询thesis列表
     */
@PreAuthorize("@ss.hasPermi('teacher:thesis:list')")
@GetMapping("/list")
@ApiOperation("查询thesis列表")
    public TableDataInfo list(SysTeacherThesis sysTeacherThesis)
    {
        startPage();
        List<SysTeacherThesis> list = sysTeacherThesisService.selectSysTeacherThesisList(sysTeacherThesis);
        return getDataTable(list);
    }

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

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

    /**
     * 新增thesis
     */
    @PreAuthorize("@ss.hasPermi('teacher:thesis:add')")
    @Log(title = "thesis", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增thesis")
    public AjaxResult add(@RequestBody SysTeacherThesis sysTeacherThesis)
    {
        return toAjax(sysTeacherThesisService.insertSysTeacherThesis(sysTeacherThesis));
    }

    /**
     * 修改thesis
     */
    @PreAuthorize("@ss.hasPermi('teacher:thesis:edit')")
    @Log(title = "thesis", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改thesis")
    public AjaxResult edit(@RequestBody SysTeacherThesis sysTeacherThesis)
    {
        return toAjax(sysTeacherThesisService.updateSysTeacherThesis(sysTeacherThesis));
    }

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