package com.liquidnet.client.admin.web.controller.zhengzai.goblin;

import com.liquidnet.client.admin.common.core.controller.BaseController;
import com.liquidnet.client.admin.zhengzai.goblin.service.ISqbPerformanceGoodsService;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.vo.GoblinSqbPerfGoodsVo;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 演出-收钱吧商品关联管理接口
 */
@Slf4j
@RestController
@Api(tags = "收钱吧-演出商品关联管理")
@RequestMapping("sqb/performance/goods")
public class SqbPerformanceGoodsController extends BaseController {

    @Autowired
    private ISqbPerformanceGoodsService sqbPerformanceGoodsService;

    @PostMapping("bind")
    @ApiOperation("关联演出与商品")
    @ApiResponse(code = 200, message = "接口返回对象参数")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "performancesId", value = "演出ID"),
            @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "skuIds", value = "SKU ID列表（多个逗号分隔）"),
            @ApiImplicitParam(type = "form", required = false, dataType = "Integer", name = "sort", value = "排序权重", example = "0"),
    })
    public ResponseDto<Boolean> bind(@RequestParam("performancesId") String performancesId,
                                     @RequestParam("skuIds") List<String> skuIds,
                                     @RequestParam(value = "sort", required = false, defaultValue = "0") Integer sort) {
        return sqbPerformanceGoodsService.bind(performancesId, skuIds, sort);
    }

    @DeleteMapping("unbind")
    @ApiOperation("解除演出与商品关联")
    @ApiResponse(code = 200, message = "接口返回对象参数")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "performancesId", value = "演出ID"),
            @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "skuId", value = "SKU ID"),
    })
    public ResponseDto<Boolean> unbind(@RequestParam("performancesId") String performancesId,
                                       @RequestParam("skuId") String skuId) {
        return sqbPerformanceGoodsService.unbind(performancesId, skuId);
    }

    @GetMapping("list")
    @ApiOperation("查询演出关联商品列表（管理后台）")
    @ApiResponse(code = 200, message = "接口返回对象参数")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "query", required = true, dataType = "String", name = "performancesId", value = "演出ID"),
    })
    public ResponseDto<List<GoblinSqbPerfGoodsVo>> list(@RequestParam("performancesId") String performancesId) {
        return sqbPerformanceGoodsService.list(performancesId);
    }
}
