
package com.tmerclub.cloud.distribution.controller.app;

import com.tmerclub.cloud.api.distribution.vo.DistributionSpuVO;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.distribution.service.DistributionSpuService;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 分销商品关联信息
 *
 * @author cl
 * @date 2021-08-09 14:14:07
 */
@RestController("appDistributionSpuController")
@RequestMapping("/ua/distributionSpu")
@Tag(name = "app-分销商品关联信息")
public class DistributionSpuController {

    @Autowired
    private DistributionSpuService distributionSpuService;

    @GetMapping
    @Operation(summary = "获取分销商品关联信息", description = "根据distributionSpuId获取分销商品关联信息")
    public ServerResponseEntity<DistributionSpuVO> getByDistributionSpuId(@RequestParam Long distributionSpuId) {
        return ServerResponseEntity.success(distributionSpuService.getByDistributionSpuId(distributionSpuId));
    }

    @GetMapping("/is_state")
    @Operation(summary = "根据商品id与状态查看该分销商品是处于该状态", description = "根据商品id与状态查看该分销商品是处于该状态")
    public ServerResponseEntity<Boolean> isStateBySpuIdAndState(@RequestParam("spuId") Long spuId, @RequestParam("state") Integer state) {
        return ServerResponseEntity.success(distributionSpuService.isStateBySpuIdAndState(spuId, state));
    }
}
