package com.ruoyi.project.business.controller.train;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.framework.annotation.DataUpdateCheck;
import com.ruoyi.project.business.domain.dto.TtAssessResultDto;
import com.ruoyi.project.business.domain.train.TtAssessResult;
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.business.service.ITtAssessResultService;
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 2024-07-04
 */
@RestController
@RequestMapping("/train/assessResult")
public class TtAssessResultController extends BaseController
{
    @Autowired
    private ITtAssessResultService ttAssessResultService;

    /**
     * 查询答卷列表
     */
    // @PreAuthorize("@ss.hasPermi('train:assessResult:list')")
    @GetMapping("/list")
    public TableDataInfo list(TtAssessResult ttAssessResult)
    {
        startPage();
        List<TtAssessResult> list = ttAssessResultService.selectTtAssessResultList(ttAssessResult);
        return getDataTable(list);
    }

    /**
     * 导出答卷列表
     */
    // @PreAuthorize("@ss.hasPermi('train:assessResult:export')")
    @Log(title = "答卷", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TtAssessResult ttAssessResult)
    {
        List<TtAssessResult> list = ttAssessResultService.selectTtAssessResultList(ttAssessResult);
        ExcelUtil<TtAssessResult> util = new ExcelUtil<TtAssessResult>(TtAssessResult.class);
        util.exportExcel(response, list, "答卷数据");
    }

    /**
     * 获取答卷详细信息
     */
    // @PreAuthorize("@ss.hasPermi('train:assessResult:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ttAssessResultService.selectTtAssessResultById(id));
    }

    /**
     * 新增答卷
     */
    // @PreAuthorize("@ss.hasPermi('train:assessResult:add')")
    @Log(title = "答卷", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TtAssessResultDto ttAssessResultDto)
    {

        return toAjax(ttAssessResultService.insertTtAssessResult(ttAssessResultDto));
    }

    /**
     * 修改答卷
     */
    // @PreAuthorize("@ss.hasPermi('train:assessResult:edit')")
    @Log(title = "答卷", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TtAssessResult ttAssessResult)
    {
        return toAjax(ttAssessResultService.updateTtAssessResult(ttAssessResult));
    }

    /**
     * 删除答卷
     */
    // @PreAuthorize("@ss.hasPermi('train:assessResult:remove')")
    @Log(title = "答卷", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ttAssessResultService.deleteTtAssessResultByIds(ids));
    }
}
