package com.seer.teach.mall.app.order.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.stp.StpUtil;
import com.seer.teach.common.PageListBean;
import com.seer.teach.common.ResultBean;
import com.seer.teach.common.annotation.DecryptionAnnotation;
import com.seer.teach.common.annotation.EncryptionAnnotation;
import com.seer.teach.common.annotation.LogPrint;
import com.seer.teach.mall.request.GoodsCommentListCreateReq;
import com.seer.teach.mall.request.GoodsCommentPageReqVO;
import com.seer.teach.mall.response.GoodsCommentResp;
import com.seer.teach.mall.app.good.service.IAppGoodsCommentService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@EncryptionAnnotation
@DecryptionAnnotation
@Tag(name = "APP - 我的商品评价")
@Validated
@RequiredArgsConstructor
@RestController
@LogPrint
@RequestMapping("/app/goods/comment")
@SaCheckLogin(type = StpUtil.TYPE)
public class AppMyCommentController {

    private final IAppGoodsCommentService iAppGoodsCommentService;

    @PostMapping("/my-page")
    @SaCheckPermission("app:my-comment:myPage")
    @Operation(summary = "获得商品评价分页")
    public ResultBean<PageListBean<GoodsCommentResp>> getMyOrderPage(@RequestBody GoodsCommentPageReqVO reqVO) {
        return ResultBean.success(iAppGoodsCommentService.getOrderPage(StpUtil.getLoginIdAsInt(),Boolean.FALSE,reqVO));
    }

    @PostMapping("/create")
    @SaCheckPermission("app:my-comment:create")
    @Operation(summary = "创建商品评价")
    public ResultBean<Boolean> createList(@RequestBody GoodsCommentListCreateReq reqVO) {
        return ResultBean.success(iAppGoodsCommentService.createList(reqVO));
    }
}
