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.SysTeachWorkExperience;
import com.vctgo.system.service.ISysTeachWorkExperienceService;
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("/experience")
public class SysTeachWorkExperienceController extends BaseController {
    @Autowired
    private ISysTeachWorkExperienceService sysTeachWorkExperienceService;

    /**
     * 查询幼儿园职工与工作经历关联分页列表
     */
    @RequiresPermissions("system:experience:page")
    @GetMapping("/page")
    public AjaxResult page(SysTeachWorkExperience sysTeachWorkExperience) {
        IPage<SysTeachWorkExperience> pageList = sysTeachWorkExperienceService.selectSysTeachWorkExperiencePage(sysTeachWorkExperience);
        return AjaxResult.success(pageList);
    }

    /**
     * 导出幼儿园职工与工作经历关联列表
     */
    @RequiresPermissions("system:experience:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysTeachWorkExperience sysTeachWorkExperience) {
        List<SysTeachWorkExperience> list = sysTeachWorkExperienceService.selectSysTeachWorkExperienceList(sysTeachWorkExperience);
        ExcelUtil<SysTeachWorkExperience> util = new ExcelUtil<SysTeachWorkExperience>(SysTeachWorkExperience.class);
        util.exportExcel(response, list, "幼儿园职工与工作经历关联数据");
    }

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

    /**
     * 新增幼儿园职工与工作经历关联
     */
    @RequiresPermissions("system:experience:add")
    @PostMapping
    public AjaxResult add(@RequestBody SysTeachWorkExperience sysTeachWorkExperience) {
        return toAjax(sysTeachWorkExperienceService.insertSysTeachWorkExperience(sysTeachWorkExperience));
    }

    /**
     * 修改幼儿园职工与工作经历关联
     */
    @RequiresPermissions("system:experience:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody SysTeachWorkExperience sysTeachWorkExperience) {
        return toAjax(sysTeachWorkExperienceService.updateSysTeachWorkExperience(sysTeachWorkExperience));
    }

    /**
     * 逻辑删除幼儿园职工与工作经历关联
     */
    @RequiresPermissions("system:experience:abandon")
    @PutMapping("/abandon/{ids}")
    public AjaxResult abandon(@PathVariable Long[] ids) {
        return toAjax(sysTeachWorkExperienceService.logicalDeleteSysTeachWorkExperienceByIds(ids));
    }

    /**
     * 删除幼儿园职工与工作经历关联
     */
    @RequiresPermissions("system:experience:remove")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysTeachWorkExperienceService.deleteSysTeachWorkExperienceByIds(ids));
    }
}
