package shop.alien.store.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import shop.alien.entity.result.R;
import shop.alien.entity.store.RestRankingList;
import shop.alien.store.service.RestRankingListService;

/**
 * @Author: fcw
 * @CreateTime: 2025-04-23
 * @Description: 店铺排行榜
 */
@Api(tags = {"平台-套餐管理"})
@Slf4j
@RestController
@CrossOrigin
@RequestMapping("/restRankingList")
@RequiredArgsConstructor
public class RestRankingListController {

    private final RestRankingListService restRankingListService;

    @ApiOperation("店铺排行榜列表")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "分页页数", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "size", value = "分页条数", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "type", value = "店铺类型", dataType = "String", paramType = "query")})
    @GetMapping("/getRestRankingList")
    public R<IPage<RestRankingList>> getRestRankingList(Integer page, Integer size, String type) {
        log.info("RestRankingListController.getRestRankingList?page={},size={},type={}", page, size, type);
        return R.data(restRankingListService.getRestRankingList(page, size, type));
    }

    @ApiOperation("添加评价")
    @ApiOperationSupport(order = 2)
    @GetMapping("/addEvaluation")
    public R<RestRankingList> addEvaluation(@RequestBody RestRankingList restRankingList) {
        log.info("RestRankingListController.addEvaluation?restRankingList={}", restRankingList.toString());
        if (restRankingListService.addOrUpdateEvaluation(restRankingList) > 0) {
            return R.success("成功");
        }
        return R.fail("失败");
    }


}
