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.SysPlatformExpertWorkExperience;
import com.vctgo.system.service.ISysPlatformExpertWorkExperienceService;
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/experience")
public class SysPlatformExpertWorkExperienceController extends BaseController {
    @Autowired
    private ISysPlatformExpertWorkExperienceService sysPlatformExpertWorkExperienceService;

    /**
     * 查询专家与工作经历关联分页列表
     */
    @RequiresPermissions("system:platform:experience:page")
    @GetMapping("/page")
    public AjaxResult page(SysPlatformExpertWorkExperience sysPlatformExpertWorkExperience) {
        IPage<SysPlatformExpertWorkExperience> pageList = sysPlatformExpertWorkExperienceService.selectSysPlatformExpertWorkExperiencePage(sysPlatformExpertWorkExperience);
        return AjaxResult.success(pageList);
    }

    /**
     * 导出专家与工作经历关联列表
     */
    @RequiresPermissions("system:platform:experience:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysPlatformExpertWorkExperience sysPlatformExpertWorkExperience) {
        List<SysPlatformExpertWorkExperience> list = sysPlatformExpertWorkExperienceService.selectSysPlatformExpertWorkExperienceList(sysPlatformExpertWorkExperience);
        ExcelUtil<SysPlatformExpertWorkExperience> util = new ExcelUtil<SysPlatformExpertWorkExperience>(SysPlatformExpertWorkExperience.class);
        util.exportExcel(response, list, "专家与工作经历关联数据");
    }

    /**
     * 获取专家与工作经历关联详细信息
     */
    @RequiresPermissions("system:platform:experience:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success((sysPlatformExpertWorkExperienceService.selectSysPlatformExpertWorkExperienceById(id)));
    }

    /**
     * 新增专家与工作经历关联
     */
    @RequiresPermissions("system:platform:experience:add")
    @PostMapping
    public AjaxResult add(@RequestBody SysPlatformExpertWorkExperience sysPlatformExpertWorkExperience) {
        return toAjax(sysPlatformExpertWorkExperienceService.insertSysPlatformExpertWorkExperience(sysPlatformExpertWorkExperience));
    }

    /**
     * 修改专家与工作经历关联
     */
    @RequiresPermissions("system:platform:experience:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody SysPlatformExpertWorkExperience sysPlatformExpertWorkExperience) {
        return toAjax(sysPlatformExpertWorkExperienceService.updateSysPlatformExpertWorkExperience(sysPlatformExpertWorkExperience));
    }

    /**
     * 逻辑删除专家与工作经历关联
     */
    @RequiresPermissions("system:platform:experience:abandon")
    @PutMapping("/abandon/{ids}")
    public AjaxResult abandon(@PathVariable Long[] ids) {
        return toAjax(sysPlatformExpertWorkExperienceService.logicalDeleteSysPlatformExpertWorkExperienceByIds(ids));
    }

    /**
     * 删除专家与工作经历关联
     */
    @RequiresPermissions("system:platform:experience:remove")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysPlatformExpertWorkExperienceService.deleteSysPlatformExpertWorkExperienceByIds(ids));
    }
}
