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.SysTeachHonoraryAchievement;
import com.vctgo.system.service.ISysTeachHonoraryAchievementService;
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 = "幼儿园教职工与荣誉成果关联C")
@RestController
@RequestMapping("/honor/achievement")
public class SysTeachHonoraryAchievementController extends BaseController {
    @Autowired
    private ISysTeachHonoraryAchievementService sysTeachHonoraryAchievementService;

    /**
     * 查询幼儿园教职工与荣誉成果关联分页列表
     */
    @RequiresPermissions("system:achievement:page")
    @GetMapping("/page")
    public AjaxResult page(SysTeachHonoraryAchievement sysTeachHonoraryAchievement) {
        IPage<SysTeachHonoraryAchievement> pageList = sysTeachHonoraryAchievementService.selectSysTeachHonoraryAchievementPage(sysTeachHonoraryAchievement);
        return AjaxResult.success(pageList);
    }

    /**
     * 导出幼儿园教职工与荣誉成果关联列表
     */
    @RequiresPermissions("system:achievement:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysTeachHonoraryAchievement sysTeachHonoraryAchievement) {
        List<SysTeachHonoraryAchievement> list = sysTeachHonoraryAchievementService.selectSysTeachHonoraryAchievementList(sysTeachHonoraryAchievement);
        ExcelUtil<SysTeachHonoraryAchievement> util = new ExcelUtil<SysTeachHonoraryAchievement>(SysTeachHonoraryAchievement.class);
        util.exportExcel(response, list, "幼儿园教职工与荣誉成果关联数据");
    }

    /**
     * 获取幼儿园教职工与荣誉成果关联详细信息
     */
    @RequiresPermissions("system:achievement:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success((sysTeachHonoraryAchievementService.selectSysTeachHonoraryAchievementById(id)));
    }

    /**
     * 新增幼儿园教职工与荣誉成果关联
     */
    @RequiresPermissions("system:achievement:add")
    @PostMapping
    public AjaxResult add(@RequestBody SysTeachHonoraryAchievement sysTeachHonoraryAchievement) {
        return toAjax(sysTeachHonoraryAchievementService.insertSysTeachHonoraryAchievement(sysTeachHonoraryAchievement));
    }

    /**
     * 修改幼儿园教职工与荣誉成果关联
     */
    @RequiresPermissions("system:achievement:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody SysTeachHonoraryAchievement sysTeachHonoraryAchievement) {
        return toAjax(sysTeachHonoraryAchievementService.updateSysTeachHonoraryAchievement(sysTeachHonoraryAchievement));
    }

    /**
     * 逻辑删除幼儿园教职工与荣誉成果关联
     */
    @RequiresPermissions("system:achievement:abandon")
    @PutMapping("/abandon/{ids}")
    public AjaxResult abandon(@PathVariable Long[] ids) {
        return toAjax(sysTeachHonoraryAchievementService.logicalDeleteSysTeachHonoraryAchievementByIds(ids));
    }

    /**
     * 删除幼儿园教职工与荣誉成果关联
     */
    @RequiresPermissions("system:achievement:remove")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysTeachHonoraryAchievementService.deleteSysTeachHonoraryAchievementByIds(ids));
    }
}
