package com.vctgo.system.controller;

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

import com.vctgo.system.domain.SysPlatformTeachQualifyCertificate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
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 com.vctgo.common.log.annotation.Log;
import com.vctgo.common.log.enums.BusinessType;
import com.vctgo.common.security.annotation.RequiresPermissions;
import com.vctgo.system.service.ISysPlatformTeachQualifyCertificateService;
import com.vctgo.common.core.web.controller.BaseController;
import com.vctgo.common.core.web.domain.AjaxResult;
import com.vctgo.common.core.utils.poi.ExcelUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
 * 教职工与教师资格证关系Controller
 *
 * @author caesar
 * @date 2024-03-26
 */
@Api(tags = "教师资格证关系")
@RestController
@RequestMapping("/plat/certificate")
public class SysPlatformTeachQualifyCertificateController extends BaseController {

    @Autowired
    private ISysPlatformTeachQualifyCertificateService sysTeachQualifyCertificateService;

    /**
     * 查询教职工与教师资格证关系分页列表
     */
    @ApiOperation(value = "查询教职工与教师资格证关系分页列表")
    @RequiresPermissions("system:platform:certificate:page")
    @GetMapping("/page")
    public AjaxResult page(SysPlatformTeachQualifyCertificate sysPlatformTeachQualifyCertificate) {
        IPage<SysPlatformTeachQualifyCertificate> pageList = sysTeachQualifyCertificateService.selectSysTeachQualifyCertificatePage(sysPlatformTeachQualifyCertificate);
        return AjaxResult.success(pageList);
    }

    /**
     * 导出教职工与教师资格证关系列表
     */
    @ApiOperation(value = "导出教职工与教师资格证关系列表")
    @RequiresPermissions("system:platform:certificate:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysPlatformTeachQualifyCertificate sysPlatformTeachQualifyCertificate) {
        List<SysPlatformTeachQualifyCertificate> list = sysTeachQualifyCertificateService.selectSysTeachQualifyCertificateList(sysPlatformTeachQualifyCertificate);
        ExcelUtil<SysPlatformTeachQualifyCertificate> util = new ExcelUtil<SysPlatformTeachQualifyCertificate>(SysPlatformTeachQualifyCertificate.class);
        util.exportExcel(response, list, "教职工与教师资格证关系数据");
    }

    /**
     * 获取教职工与教师资格证关系详细信息
     */
    @ApiOperation(value = "获取教职工与教师资格证关系详细信息")
    @RequiresPermissions("system:platform:certificate:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success((sysTeachQualifyCertificateService.selectSysTeachQualifyCertificateById(id)));
    }

    /**
     * 新增教职工与教师资格证关系
     */
    @ApiOperation(value = "新增教职工与教师资格证关系")
    @RequiresPermissions("system:platform:certificate:add")
    @PostMapping
    public AjaxResult add(@RequestBody SysPlatformTeachQualifyCertificate sysPlatformTeachQualifyCertificate) {
        return toAjax(sysTeachQualifyCertificateService.insertSysTeachQualifyCertificate(sysPlatformTeachQualifyCertificate));
    }

    /**
     * 修改教职工与教师资格证关系
     */
    @ApiOperation(value = "修改教职工与教师资格证关系")
    @RequiresPermissions("system:platform:certificate:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody SysPlatformTeachQualifyCertificate sysPlatformTeachQualifyCertificate) {
        return toAjax(sysTeachQualifyCertificateService.updateSysTeachQualifyCertificate(sysPlatformTeachQualifyCertificate));
    }

    /**
     * 逻辑删除教职工与教师资格证关系
     */
    @ApiOperation(value = "逻辑删除教职工与教师资格证关系")
    @RequiresPermissions("system:platform:certificate:abandon")
    @PutMapping("/abandon/{ids}")
    public AjaxResult abandon(@PathVariable Long[] ids) {
        return toAjax(sysTeachQualifyCertificateService.logicalDeleteSysTeachQualifyCertificateByIds(ids));
    }

    /**
     * 删除教职工与教师资格证关系
     */
    @ApiOperation(value = "删除教职工与教师资格证关系")
    @RequiresPermissions("system:platform:certificate:remove")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysTeachQualifyCertificateService.deleteSysTeachQualifyCertificateByIds(ids));
    }
}
