package com.tashow.cloud.productapi.api.product;

import com.tashow.cloud.common.pojo.CommonResult;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.productapi.api.product.dto.ProdDO;
import com.tashow.cloud.productapi.api.product.vo.prod.ProdListVO;
import com.tashow.cloud.productapi.api.product.vo.prod.ProdPageReqVO;
import com.tashow.cloud.productapi.api.product.vo.prod.ProdServiceVO;
import com.tashow.cloud.productapi.enums.ApiConstants;
import jakarta.annotation.security.PermitAll;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(name = ApiConstants.NAME) // TODO 芋艿：fallbackFactory =
/** RPC 服务 - 参数配置 */
public interface ProdApi {

    String PREFIX = ApiConstants.PREFIX + "/prod";
    /**
     * 获取商品详情
     *
     * @param id 商品id
     * @return 编号
     */

    @GetMapping(PREFIX + "/getProdInfo")
    @PermitAll
    CommonResult<ProdDO> getProdInfo(@RequestParam(value = "id", required = false) Long id);

    /**
     * 获取商品服务配置
     *
     * @param id 商品id
     * @return 编号
     */
    @GetMapping(PREFIX + "/getProdService")
    ProdServiceVO getProdService(@RequestParam(value = "id", required = false) Long id);

    /**
     * 获得商品分页
     *
     * @param pageReqVO 分页查询
     * @return 商品分页
     */
    @GetMapping(PREFIX + "/getProdPage")
    PageResult<ProdListVO> getProdPage(ProdPageReqVO pageReqVO);

    /**
     * 扣减库存
     * @param skuId 单品ID
     * @param stocksNum 扣减数量
     */
    @PostMapping(PREFIX + "/reduceStocks")
    CommonResult<Boolean> reduceStocks(@RequestParam(value = "skuId", required = false)Long skuId
            ,@RequestParam(value = "stocksNum", required = false) Integer stocksNum
    ) ;
    /**
     * 增加库存
     * @param skuId 单品ID
     * @param stocksNum 增加数量
     */
    @PostMapping(PREFIX + "/increaseStocks")
    CommonResult<Boolean> increaseStocks(@RequestParam(value = "skuId", required = false)Long skuId
            ,@RequestParam(value = "stocksNum", required = false) Integer stocksNum);


}
