package com.xiaoniu.system.order.comment.controller;

import com.xiaoniu.common.core.resdata.Result;
import com.xiaoniu.common.core.resdata.RowsData;
import com.xiaoniu.system.order.comment.dto.CommentQueryDTO;
import com.xiaoniu.system.order.comment.dto.EditCommentDTO;
import com.xiaoniu.system.order.comment.vo.CommentDetailsVO;
import com.xiaoniu.system.order.comment.vo.GoodsCommentListVO;
import com.xiaoniu.system.store.goods.service.ITbGoodsCommentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 商品评论表 前端控制器
 * </p>
 *
 * @author haoxuyang
 * @since 2024-11-10 03:22:48
 */
@Tag(name = "商品评论管理")
@RestController
@RequestMapping("/comment")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class TbGoodsCommentController {
    private final ITbGoodsCommentService tbGoodsCommentService;

    @Operation(summary = "商品评价列表")
    @PostMapping("/list")
    public Result<RowsData<GoodsCommentListVO>> list(@RequestBody CommentQueryDTO dto) {
        return Result.success("查询成功", tbGoodsCommentService.getCommentList(dto));
    }

    @Operation(summary = "审核")
    @PostMapping("/edit")
    public Result<String> edit(@RequestBody @Validated EditCommentDTO dto) {
        tbGoodsCommentService.editComment(dto);
        return Result.success("操作成功");
    }

    @Operation(summary = "商品评价详情")
    @GetMapping("/details")
    public Result<CommentDetailsVO> details(@RequestParam Long id) {
        return Result.success("查询成功", tbGoodsCommentService.details(id));
    }

    @Operation(summary = "删除商品评价")
    @GetMapping("/del")
    public Result<String> delGoods(@RequestParam Long id) {
        tbGoodsCommentService.delComment(id);
        return Result.success("操作成功");
    }

}
