package org.dromara.mall.promotion.controller.app;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.web.core.BaseController;
import org.dromara.mall.promotion.domain.vo.MallBargainVo;
import org.dromara.mall.promotion.service.MallBargainService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 砍价活动（移动端）
 *
 * @author pengles
 */
@Tag(name = "移动端-砍价活动", description = "砍价活动接口")
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/app/mall/bargain")
public class AppMallBargainController extends BaseController {

    private final MallBargainService mallBargainService;

    /**
     * 查询可用砍价活动列表
     */
    @Operation(summary = "查询可用砍价活动列表", description = "查询当前可用的砍价活动列表")
    @GetMapping("/list")
    public R<List<MallBargainVo>> list() {
        List<MallBargainVo> list = mallBargainService.queryAvailableList();
        return R.ok(list);
    }

    /**
     * 获取砍价活动详情
     */
    @Operation(summary = "获取砍价活动详情", description = "根据砍价活动ID获取详细信息")
    @GetMapping("/{id}")
    public R<MallBargainVo> getInfo(@Parameter(description = "砍价活动ID", required = true)
                                     @PathVariable Long id) {
        return R.ok(mallBargainService.queryById(id));
    }

    /**
     * 根据SKU ID查询砍价活动
     */
    @Operation(summary = "根据SKU ID查询砍价活动", description = "查询指定SKU的砍价活动")
    @GetMapping("/sku/{skuId}")
    public R<MallBargainVo> getBySkuId(@Parameter(description = "SKU ID", required = true)
                                        @PathVariable Long skuId) {
        MallBargainVo vo = mallBargainService.queryBySkuId(skuId);
        return R.ok(vo);
    }

}
