package com.xindazhou.platform.controller.admin.service.evaluation;

import com.xindazhou.platform.controller.admin.service.evaluation.vo.EvaluationPageReqVO;
import com.xindazhou.platform.controller.admin.service.evaluation.vo.EvaluationRespVO;
import com.xindazhou.platform.service.service.evaluation.EvaluationService;
import com.xindazhou.framework.common.pojo.CommonResult;
import com.xindazhou.framework.common.pojo.PageResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import static com.xindazhou.framework.common.pojo.CommonResult.success;

/**
 * 管理后台 - 服务评价 Controller
 *
 * @author xindazhou
 */
@Tag(name = "管理后台 - 服务评价管理")
@RestController("platformEvaluationController")
@RequestMapping("/admin/service/evaluation")
@Validated
@Slf4j
public class EvaluationController {

    @Resource
    private EvaluationService evaluationService;

    @GetMapping("/page")
    @Operation(summary = "获得服务评价分页列表")
    @PreAuthorize("@ss.hasPermission('service:evaluation:query')")
    public CommonResult<PageResult<EvaluationRespVO>> getEvaluationPage(@Valid EvaluationPageReqVO pageReqVO) {
        PageResult<EvaluationRespVO> pageResult = evaluationService.getEvaluationPage(pageReqVO);
        return success(pageResult);
    }

    @GetMapping("/{id}")
    @Operation(summary = "获得服务评价")
    @Parameter(name = "id", description = "评价ID", required = true, example = "1")
    @PreAuthorize("@ss.hasPermission('service:evaluation:query')")
    public CommonResult<EvaluationRespVO> getEvaluation(@PathVariable("id") Long id) {
        EvaluationRespVO evaluation = evaluationService.getEvaluation(id);
        return success(evaluation);
    }

}

