package com.sqx.modules.activity.controller;

import com.sqx.common.utils.Result;
import com.sqx.modules.activity.dto.ActivityGoodsDTO;
import com.sqx.modules.activity.service.ActivityGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 活动商品
 * @author : codingliang
 * @date : 2024-6-17
 */
@Api(tags = "活动-活动商品管理")
@RestController
@RequestMapping("admin/activity-goods")
@RequiredArgsConstructor
public class ActivityGoodsController{
    
    private final ActivityGoodsService activityGoodsService;
    
    @PostMapping
    @ApiOperation("添加或者修改参与活动商品")
    public Result updateActivityGoods(@RequestBody @Valid ActivityGoodsDTO activityGoodsDTO) {
        activityGoodsService.updateActivityGoods(activityGoodsDTO);
        return Result.success();
    }

     @GetMapping("{activityShopId}")
     @ApiOperation("根据活动店铺id获取参与的商品id列表")
     public Result getGoodsIdsByActivityShopId(@PathVariable Long activityShopId) {
         List<Long> goodsIds = activityGoodsService.getByActivityShopId(activityShopId);
         return Result.success().put("data", goodsIds);
     }
}
