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.SysTeacherCertificate;
import com.srs.teacher.service.ISysTeacherCertificateService;
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;

/**
 * certificateController
 *
 * @author srs
 * @date 2024-05-30
 */
@RestController
@RequestMapping("/teacher/certificate")
@Api(value = "辅导员职业证书管理", tags = "辅导员职业证书管理")
public class SysTeacherCertificateController extends BaseController {
    @Autowired
    private ISysTeacherCertificateService sysTeacherCertificateService;

    /**
     * 查询certificate列表
     */
@PreAuthorize("@ss.hasPermi('teacher:certificate:list')")
@GetMapping("/list")
@ApiOperation("查询certificate列表")
    public TableDataInfo list(SysTeacherCertificate sysTeacherCertificate)
    {
        startPage();
        List<SysTeacherCertificate> list = sysTeacherCertificateService.selectSysTeacherCertificateList(sysTeacherCertificate);
        return getDataTable(list);
    }

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

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

    /**
     * 新增certificate
     */
    @PreAuthorize("@ss.hasPermi('teacher:certificate:add')")
    @Log(title = "certificate", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增certificate")
    public AjaxResult add(@RequestBody SysTeacherCertificate sysTeacherCertificate)
    {
        return toAjax(sysTeacherCertificateService.insertSysTeacherCertificate(sysTeacherCertificate));
    }

    /**
     * 修改certificate
     */
    @PreAuthorize("@ss.hasPermi('teacher:certificate:edit')")
    @Log(title = "certificate", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改certificate")
    public AjaxResult edit(@RequestBody SysTeacherCertificate sysTeacherCertificate)
    {
        return toAjax(sysTeacherCertificateService.updateSysTeacherCertificate(sysTeacherCertificate));
    }

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