
package com.tmerclub.cloud.product.controller.platform;

import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.product.service.SpuExtensionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * @Author lth
 * @Date 2021/7/19 15:32
 */
@RestController("platformSpuExtensionController")
@RequestMapping("/p/spuExtension")
@Tag(name = "platform-spuExtension信息")
public class SpuExtensionController {

    @Autowired
    private SpuExtensionService spuExtensionService;

    @PutMapping("/water_sold_num")
    @Operation(summary = "更新商品注水销量", description = "更新商品注水销量")
    public ServerResponseEntity<Void> updateWaterSoldNum(@RequestParam("waterSoldNum") Integer waterSoldNum, @RequestParam("spuId") Long spuId) {
        if (Objects.isNull(waterSoldNum)) {
            waterSoldNum = 0;
        }
        spuExtensionService.updateWaterSoldNumBySpuId(spuId, waterSoldNum);
        return ServerResponseEntity.success();
    }
}
