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.TTnTransferplanTmpl;
import com.ruoyi.project.training.newstaff.service.ITTnTransferplanTmplService;
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/transferplantmpl")
public class TTnTransferplanTmplController extends BaseController
{
    @Autowired
    private ITTnTransferplanTmplService tTnTransferplanTmplService;

    /**
     * 查询转岗培训模版列表
     */
    @PreAuthorize("@ss.hasPermi('newstaff:transferplantmpl:list')")
    @GetMapping("/list")
    public TableDataInfo list(TTnTransferplanTmpl tTnTransferplanTmpl)
    {
        startPage();
        List<TTnTransferplanTmpl> list = tTnTransferplanTmplService.selectTTnTransferplanTmplList(tTnTransferplanTmpl);
        return getDataTable(list);
    }

    /**
     * 导出转岗培训模版列表
     */
    @PreAuthorize("@ss.hasPermi('newstaff:transferplantmpl:export')")
    @Log(title = "转岗培训模版", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TTnTransferplanTmpl tTnTransferplanTmpl)
    {
        List<TTnTransferplanTmpl> list = tTnTransferplanTmplService.selectTTnTransferplanTmplList(tTnTransferplanTmpl);
        ExcelUtil<TTnTransferplanTmpl> util = new ExcelUtil<TTnTransferplanTmpl>(TTnTransferplanTmpl.class);
        return util.exportExcel(list, "transferplantmpl");
    }

    /**
     * 获取转岗培训模版详细信息
     */
    @PreAuthorize("@ss.hasPermi('newstaff:transferplantmpl:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tTnTransferplanTmplService.selectTTnTransferplanTmplById(id));
    }

    /**
     * 新增转岗培训模版
     */
    @PreAuthorize("@ss.hasPermi('newstaff:transferplantmpl:add')")
    @Log(title = "转岗培训模版", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TTnTransferplanTmpl tTnTransferplanTmpl)
    {
        return toAjax(tTnTransferplanTmplService.insertTTnTransferplanTmpl(tTnTransferplanTmpl));
    }

    /**
     * 修改转岗培训模版
     */
    @PreAuthorize("@ss.hasPermi('newstaff:transferplantmpl:edit')")
    @Log(title = "转岗培训模版", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TTnTransferplanTmpl tTnTransferplanTmpl)
    {
        return toAjax(tTnTransferplanTmplService.updateTTnTransferplanTmpl(tTnTransferplanTmpl));
    }

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