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.SysTeachEducation;
import com.vctgo.system.service.ISysTeachEducationService;
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("/education")
public class SysTeachEducationController extends BaseController {
    @Autowired
    private ISysTeachEducationService sysTeachEducationService;

    /**
     * 查询幼儿园教职工与学历关联分页列表
     */
    @RequiresPermissions("system:education:page")
    @GetMapping("/page")
    public AjaxResult page(SysTeachEducation sysTeachEducation) {
        IPage<SysTeachEducation> pageList = sysTeachEducationService.selectSysTeachEducationPage(sysTeachEducation);
        return AjaxResult.success(pageList);
    }

    /**
     * 导出幼儿园教职工与学历关联列表
     */
    @RequiresPermissions("system:education:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysTeachEducation sysTeachEducation) {
        List<SysTeachEducation> list = sysTeachEducationService.selectSysTeachEducationList(sysTeachEducation);
        ExcelUtil<SysTeachEducation> util = new ExcelUtil<SysTeachEducation>(SysTeachEducation.class);
        util.exportExcel(response, list, "幼儿园教职工与学历关联数据");
    }

    /**
     * 获取幼儿园教职工与学历关联详细信息
     */
    @RequiresPermissions("system:education:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success((sysTeachEducationService.selectSysTeachEducationById(id)));
    }

    /**
     * 新增幼儿园教职工与学历关联
     */
    @RequiresPermissions("system:education:add")
    @PostMapping
    public AjaxResult add(@RequestBody SysTeachEducation sysTeachEducation) {
        return toAjax(sysTeachEducationService.insertSysTeachEducation(sysTeachEducation));
    }

    /**
     * 修改幼儿园教职工与学历关联
     */
    @RequiresPermissions("system:education:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody SysTeachEducation sysTeachEducation) {
        return toAjax(sysTeachEducationService.updateSysTeachEducation(sysTeachEducation));
    }

    /**
     * 逻辑删除幼儿园教职工与学历关联
     */
    @RequiresPermissions("system:education:abandon")
    @PutMapping("/abandon/{ids}")
    public AjaxResult abandon(@PathVariable Long[] ids) {
        return toAjax(sysTeachEducationService.logicalDeleteSysTeachEducationByIds(ids));
    }

    /**
     * 删除幼儿园教职工与学历关联
     */
    @RequiresPermissions("system:education:remove")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysTeachEducationService.deleteSysTeachEducationByIds(ids));
    }
}
