package com.ruoyi.project.training.newstaff.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
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.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.training.newstaff.domain.TTnSchoolplan;
import com.ruoyi.project.training.newstaff.service.ITTnSchoolplanService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 校招培训Controller
 *
 * @author ruoyi
 * @date 2023-07-05
 */
@RestController
@RequestMapping("/newstaff/schoolplan")
public class TTnSchoolplanController extends BaseController
{
    @Autowired
    private ITTnSchoolplanService tTnSchoolplanService;

    /**
     * 查询校招培训列表
     */
    @PreAuthorize("@ss.hasPermi('newstaff:schoolplan:list')")
    @GetMapping("/list")
    public TableDataInfo list(TTnSchoolplan tTnSchoolplan)
    {
        startPage();
        List<TTnSchoolplan> list = tTnSchoolplanService.selectTTnSchoolplanList(tTnSchoolplan);
        return getDataTable(list);
    }

    /**
     * 导出校招培训列表
     */
    @PreAuthorize("@ss.hasPermi('newstaff:schoolplan:export')")
    @Log(title = "校招培训", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TTnSchoolplan tTnSchoolplan)
    {
        List<TTnSchoolplan> list = tTnSchoolplanService.selectTTnSchoolplanList(tTnSchoolplan);
        ExcelUtil<TTnSchoolplan> util = new ExcelUtil<TTnSchoolplan>(TTnSchoolplan.class);
        return util.exportExcel(list, "schoolplan");
    }

    /**
     * 获取校招培训详细信息
     */
    @PreAuthorize("@ss.hasPermi('newstaff:schoolplan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tTnSchoolplanService.selectTTnSchoolplanById(id));
    }

    /**
     * 新增校招培训
     */
    @PreAuthorize("@ss.hasPermi('newstaff:schoolplan:add')")
    @Log(title = "校招培训", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TTnSchoolplan tTnSchoolplan)
    {
        return toAjax(tTnSchoolplanService.insertTTnSchoolplan(tTnSchoolplan));
    }

    /**
     * 修改校招培训
     */
    @PreAuthorize("@ss.hasPermi('newstaff:schoolplan:edit')")
    @Log(title = "校招培训", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TTnSchoolplan tTnSchoolplan)
    {
        return toAjax(tTnSchoolplanService.updateTTnSchoolplan(tTnSchoolplan));
    }
    /**
     * 修改校招培训
     */
    @PreAuthorize("@ss.hasPermi('newstaff:schoolplan:remove')")
    @Log(title = "校招培训批量", businessType = BusinessType.UPDATE)
    @GetMapping("batchStatus/{ids}")
    public AjaxResult batchPlan(@PathVariable Long[] ids)
    {
        return toAjax(tTnSchoolplanService.batchStatusByIds(ids));
    }
    /**
     * 删除校招培训
     */
    @PreAuthorize("@ss.hasPermi('newstaff:schoolplan:remove')")
    @Log(title = "校招培训", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tTnSchoolplanService.deleteTTnSchoolplanByIds(ids));
    }
}
