package com.xjrsoft.module.evaluate.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.model.result.RT;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.module.evaluate.dto.*;
import com.xjrsoft.module.evaluate.service.IEvaluateResultService;
import com.xjrsoft.module.evaluate.vo.EvaluateResultDetailPageDetailVo;
import com.xjrsoft.module.evaluate.vo.EvaluateResultDetailPageVo;
import com.xjrsoft.module.evaluate.vo.EvaluateResultIndexPageVo;
import com.xjrsoft.module.evaluate.vo.ResultViewingPageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
* @title: 评价结果
* @Author szs
* @Date: 2024-01-16
* @Version 1.0
*/
@RestController
@RequestMapping("/evaluate" + "/evaluateResult")
@Api(value = "/evaluate"  + "/evaluateResult",tags = "评价结果代码")
@AllArgsConstructor
public class EvaluateResultController {


    private final IEvaluateResultService evaluateResultService;

    @GetMapping(value = "/index-page")
    @ApiOperation(value="评价结果首页列表(分页)")
    @SaCheckPermission("evaluateresult:detail")
    public RT<PageOutput<EvaluateResultIndexPageVo>> indexPage(@Valid EvaluateResultIndexPageDto dto){
        IPage<EvaluateResultIndexPageVo> page = evaluateResultService.getIndexPage(dto);
        PageOutput<EvaluateResultIndexPageVo> pageOutput = ConventPage.getPageOutput(page, EvaluateResultIndexPageVo.class);
        return RT.ok(pageOutput);
    }

    @GetMapping(value = "/detail-page")
    @ApiOperation(value="评价结果详情查看列表(分页)")
    @SaCheckPermission("evaluateresult:detail")
    public RT<PageOutput<EvaluateResultDetailPageVo>> detailPage(@Valid EvaluateResultDetailPageDto dto){
        IPage<EvaluateResultDetailPageVo> page = evaluateResultService.getDetailPage(dto);
        PageOutput<EvaluateResultDetailPageVo> pageOutput = ConventPage.getPageOutput(page, EvaluateResultDetailPageVo.class);
        return RT.ok(pageOutput);
    }

    @GetMapping(value = "/detail-page-detail")
    @ApiOperation(value="评价结果详情查看列表的详情")
    @SaCheckPermission("evaluateresult:detail")
    public RT<EvaluateResultDetailPageDetailVo> detailPageDetail(@Valid EvaluateResultDetailPageDetailDto dto){
        EvaluateResultDetailPageDetailVo evaluateResultDetailPageDetailVo = evaluateResultService.getDetailPageDetail(dto);
        return RT.ok(evaluateResultDetailPageDetailVo);
    }

    @GetMapping(value = "/result-viewing-page")
    @ApiOperation(value="结果查看(分页)")
    @SaCheckPermission("evaluateresult:detail")
    public RT<PageOutput<ResultViewingPageVo>> pageResultViewing(@Valid ResultViewingPageDto dto){
        IPage<ResultViewingPageVo> page = evaluateResultService.pageResultViewing(dto);
        PageOutput<ResultViewingPageVo> pageOutput = ConventPage.getPageOutput(page, ResultViewingPageVo.class);
        return RT.ok(pageOutput);
    }

    @PostMapping("/export-query")
//    @GetMapping("/expor")
    @ApiOperation(value = "入参导出")
    public ResponseEntity<byte[]>  exportDataQuery(@Valid @RequestBody ResultViewingExcelDto dto) {
//    public ResponseEntity<byte[]>  exportDataQuery(@Valid ResultViewingExcelDto dto) {
        return evaluateResultService.getList(dto);
    }
}