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.TTnFirstplanTmpl;
import com.ruoyi.project.training.newstaff.service.ITTnFirstplanTmplService;
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-06-29
 */
@RestController
@RequestMapping("/newstaff/firstplantmpl")
public class TTnFirstplanTmplController extends BaseController
{
    @Autowired
    private ITTnFirstplanTmplService tTnFirstplanTmplService;

    /**
     * 查询进组培训模版列表
     */
    @PreAuthorize("@ss.hasPermi('newstaff:firstplantmpl:list')")
    @GetMapping("/list")
    public TableDataInfo list(TTnFirstplanTmpl tTnFirstplanTmpl)
    {
        startPage();
        List<TTnFirstplanTmpl> list = tTnFirstplanTmplService.selectTTnFirstplanTmplList(tTnFirstplanTmpl);
        return getDataTable(list);
    }

    /**
     * 导出进组培训模版列表
     */
    @PreAuthorize("@ss.hasPermi('newstaff:firstplantmpl:export')")
    @Log(title = "进组培训模版", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TTnFirstplanTmpl tTnFirstplanTmpl)
    {
        List<TTnFirstplanTmpl> list = tTnFirstplanTmplService.selectTTnFirstplanTmplList(tTnFirstplanTmpl);
        ExcelUtil<TTnFirstplanTmpl> util = new ExcelUtil<TTnFirstplanTmpl>(TTnFirstplanTmpl.class);
        return util.exportExcel(list, "firstplantmpl");
    }

    /**
     * 获取进组培训模版详细信息
     */
    @PreAuthorize("@ss.hasPermi('newstaff:firstplantmpl:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tTnFirstplanTmplService.selectTTnFirstplanTmplById(id));
    }

    /**
     * 新增进组培训模版
     */
    @PreAuthorize("@ss.hasPermi('newstaff:firstplantmpl:add')")
    @Log(title = "进组培训模版", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TTnFirstplanTmpl tTnFirstplanTmpl)
    {
        return toAjax(tTnFirstplanTmplService.insertTTnFirstplanTmpl(tTnFirstplanTmpl));
    }

    /**
     * 修改进组培训模版
     */
    @PreAuthorize("@ss.hasPermi('newstaff:firstplantmpl:edit')")
    @Log(title = "进组培训模版", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TTnFirstplanTmpl tTnFirstplanTmpl)
    {
        return toAjax(tTnFirstplanTmplService.updateTTnFirstplanTmpl(tTnFirstplanTmpl));
    }

    /**
     * 删除进组培训模版
     */
    @PreAuthorize("@ss.hasPermi('newstaff:firstplantmpl:remove')")
    @Log(title = "进组培训模版", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tTnFirstplanTmplService.deleteTTnFirstplanTmplByIds(ids));
    }
}
