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.TStQuestionAnswer;
import com.ruoyi.project.training.spec.service.ITStQuestionAnswerService;
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-03
 */
@RestController
@RequestMapping("/spec/answer")
public class TStQuestionAnswerController extends BaseController
{
    @Autowired
    private ITStQuestionAnswerService tStQuestionAnswerService;

    /**
     * 获取专项培养反馈问题答案详细信息
     */
    @PreAuthorize("@ss.hasPermi('spec:answer:query')")
    @GetMapping
    public AjaxResult getInfo(TStQuestionAnswer tStQuestionAnswer)
    {
        return AjaxResult.success(tStQuestionAnswerService.selectTStQuestionAnswer(tStQuestionAnswer));
    }

    /**
     * 查询专项培养反馈问题答案列表
     */
    @PreAuthorize("@ss.hasPermi('spec:answer:list')")
    @GetMapping("/list")
    public TableDataInfo list(TStQuestionAnswer tStQuestionAnswer)
    {
        startPage();
        List<TStQuestionAnswer> list = tStQuestionAnswerService.selectTStQuestionAnswerList(tStQuestionAnswer);
        return getDataTable(list);
    }

    /**
     * 导出专项培养反馈问题答案列表
     */
    @PreAuthorize("@ss.hasPermi('spec:answer:export')")
    @Log(title = "专项培养反馈问题答案", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TStQuestionAnswer tStQuestionAnswer)
    {
        List<TStQuestionAnswer> list = tStQuestionAnswerService.selectTStQuestionAnswerList(tStQuestionAnswer);
        ExcelUtil<TStQuestionAnswer> util = new ExcelUtil<TStQuestionAnswer>(TStQuestionAnswer.class);
        return util.exportExcel(list, "answer");
    }

    /**
     * 获取专项培养反馈问题答案详细信息
     */
    @PreAuthorize("@ss.hasPermi('spec:answer:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tStQuestionAnswerService.selectTStQuestionAnswerById(id));
    }

    /**
     * 新增专项培养反馈问题答案
     */
    @PreAuthorize("@ss.hasPermi('spec:answer:add')")
    @Log(title = "专项培养反馈问题答案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TStQuestionAnswer tStQuestionAnswer)
    {
        return toAjax(tStQuestionAnswerService.insertTStQuestionAnswer(tStQuestionAnswer));
    }

    /**
     * 修改专项培养反馈问题答案
     */
    @PreAuthorize("@ss.hasPermi('spec:answer:edit')")
    @Log(title = "专项培养反馈问题答案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TStQuestionAnswer tStQuestionAnswer)
    {
        return toAjax(tStQuestionAnswerService.updateTStQuestionAnswer(tStQuestionAnswer));
    }

    /**
     * 删除专项培养反馈问题答案
     */
    @PreAuthorize("@ss.hasPermi('spec:answer:remove')")
    @Log(title = "专项培养反馈问题答案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tStQuestionAnswerService.deleteTStQuestionAnswerByIds(ids));
    }
}
