package cn.iocoder.yudao.module.product.api.storeproduct;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.product.service.storeproduct.StoreProductService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * 商品 SPU API 接口实现类
 *
 * @author LeeYan9
 * @since 2022-09-06
 */
@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class StoreProductApiImpl implements StoreProductApi {

    @Resource
    private StoreProductService storeProductService;

    @Override
    public CommonResult<Integer> decStockIncSales(Integer num, Long productId) {
        return success(storeProductService.decStockIncSales(num, productId));
    }

    @Override
    public CommonResult<Integer> inStockIncSales(Integer num, Long productId) {
        return success(storeProductService.inStockIncSales(num, productId));
    }

    @Override
    public CommonResult<Long> selectCount() {
        return success(storeProductService.count());
    }

}
