package com.vctgo.system.controller;

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

import io.swagger.annotations.Api;
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.domain.SysTeachQualifyCertificate;
import com.vctgo.system.service.ISysTeachQualifyCertificateService;
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-27
 */
@Api(tags = "幼儿园教职工与教师资格证关系")
@RestController
@RequestMapping("/certificate")
public class SysTeachQualifyCertificateController extends BaseController {
    @Autowired
    private ISysTeachQualifyCertificateService sysTeachQualifyCertificateService;

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

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

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

    /**
     * 新增幼儿园教职工与教师资格证关系
     */
    @RequiresPermissions("system:certificate:add")
    @PostMapping
    public AjaxResult add(@RequestBody SysTeachQualifyCertificate sysTeachQualifyCertificate) {
        return toAjax(sysTeachQualifyCertificateService.insertSysTeachQualifyCertificate(sysTeachQualifyCertificate));
    }

    /**
     * 修改幼儿园教职工与教师资格证关系
     */
    @RequiresPermissions("system:certificate:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody SysTeachQualifyCertificate sysTeachQualifyCertificate) {
        return toAjax(sysTeachQualifyCertificateService.updateSysTeachQualifyCertificate(sysTeachQualifyCertificate));
    }

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

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