package com.ruoyi.project.training.spec.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.spec.domain.TStSuccessorScore;
import com.ruoyi.project.training.spec.service.ITStSuccessorScoreService;
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 2022-05-17
 */
@RestController
@RequestMapping("/spec/score")
public class TStSuccessorScoreController extends BaseController
{
    @Autowired
    private ITStSuccessorScoreService tStSuccessorScoreService;

    /**
     * 查询继任者年度评分列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TStSuccessorScore tStSuccessorScore)
    {
        startPage();
        List<TStSuccessorScore> list = tStSuccessorScoreService.selectTStSuccessorScoreList(tStSuccessorScore);
        return getDataTable(list);
    }

    /**
     * 导出继任者年度评分列表
     */
    @Log(title = "继任者年度评分", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TStSuccessorScore tStSuccessorScore)
    {
        List<TStSuccessorScore> list = tStSuccessorScoreService.selectTStSuccessorScoreList(tStSuccessorScore);
        ExcelUtil<TStSuccessorScore> util = new ExcelUtil<TStSuccessorScore>(TStSuccessorScore.class);
        return util.exportExcel(list, "score");
    }

    /**
     * 获取继任者年度评分详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tStSuccessorScoreService.selectTStSuccessorScoreById(id));
    }

    /**
     * 获取继任者年度评分详细信息
     */
    @GetMapping("/getTStSuccessorScore")
    public AjaxResult getTStSuccessorScore(TStSuccessorScore tStSuccessorScore)
    {
        return AjaxResult.success(tStSuccessorScoreService.selectTStSuccessorScore(tStSuccessorScore));
    }

    /**
     * 新增继任者年度评分
     */
    @Log(title = "继任者年度评分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TStSuccessorScore tStSuccessorScore)
    {
        return toAjax(tStSuccessorScoreService.insertTStSuccessorScore(tStSuccessorScore));
    }

    /**
     * 修改继任者年度评分
     */
    @Log(title = "继任者年度评分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TStSuccessorScore tStSuccessorScore)
    {
        return toAjax(tStSuccessorScoreService.updateTStSuccessorScore(tStSuccessorScore));
    }

    /**
     * 删除继任者年度评分
     */
    @Log(title = "继任者年度评分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tStSuccessorScoreService.deleteTStSuccessorScoreByIds(ids));
    }
}
