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.SysPlatformExpertEducation;
import com.vctgo.system.service.ISysPlatformExpertEducationService;
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("/plat/education")
public class SysPlatformExpertEducationController extends BaseController {
    @Autowired
    private ISysPlatformExpertEducationService sysPlatformExpertEducationService;

    /**
     * 查询专家与学历关联分页列表
     */
    @RequiresPermissions("system:platform:education:page")
    @GetMapping("/page")
    public AjaxResult page(SysPlatformExpertEducation sysPlatformExpertEducation) {
        IPage<SysPlatformExpertEducation> pageList = sysPlatformExpertEducationService.selectSysPlatformExpertEducationPage(sysPlatformExpertEducation);
        return AjaxResult.success(pageList);
    }

    /**
     * 导出专家与学历关联列表
     */
    @RequiresPermissions("system:platform:education:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysPlatformExpertEducation sysPlatformExpertEducation) {
        List<SysPlatformExpertEducation> list = sysPlatformExpertEducationService.selectSysPlatformExpertEducationList(sysPlatformExpertEducation);
        ExcelUtil<SysPlatformExpertEducation> util = new ExcelUtil<SysPlatformExpertEducation>(SysPlatformExpertEducation.class);
        util.exportExcel(response, list, "专家与学历关联数据");
    }

    /**
     * 获取专家与学历关联详细信息
     */
    @RequiresPermissions("system:platform:education:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success((sysPlatformExpertEducationService.selectSysPlatformExpertEducationById(id)));
    }

    /**
     * 新增专家与学历关联
     */
    @RequiresPermissions("system:platform:education:add")
    @PostMapping
    public AjaxResult add(@RequestBody SysPlatformExpertEducation sysPlatformExpertEducation) {
        return toAjax(sysPlatformExpertEducationService.insertSysPlatformExpertEducation(sysPlatformExpertEducation));
    }

    /**
     * 修改专家与学历关联
     */
    @RequiresPermissions("system:platform:education:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody SysPlatformExpertEducation sysPlatformExpertEducation) {
        return toAjax(sysPlatformExpertEducationService.updateSysPlatformExpertEducation(sysPlatformExpertEducation));
    }

    /**
     * 逻辑删除专家与学历关联
     */
    @RequiresPermissions("system:platform:education:abandon")
    @PutMapping("/abandon/{ids}")
    public AjaxResult abandon(@PathVariable Long[] ids) {
        return toAjax(sysPlatformExpertEducationService.logicalDeleteSysPlatformExpertEducationByIds(ids));
    }

    /**
     * 删除专家与学历关联
     */
    @RequiresPermissions("system:platform:education:remove")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysPlatformExpertEducationService.deleteSysPlatformExpertEducationByIds(ids));
    }
}
