package org.dromara.mall.coupon.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.mall.coupon.domain.vo.MallCouponVo;
import org.dromara.mall.coupon.service.MallCouponService;
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 = "优惠券接口")
@RequiredArgsConstructor
@RestController
@RequestMapping("/app/mall/coupon")
public class AppMallCouponController {

    private final MallCouponService mallCouponService;

    /**
     * 查询可领取的优惠券列表
     */
    @Operation(summary = "查询可领取的优惠券列表", description = "查询用户可以领取的优惠券列表")
    @GetMapping("/available/list")
    public R<List<MallCouponVo>> getAvailableList() {
        List<MallCouponVo> list = mallCouponService.queryAvailableList();
        return R.ok(list);
    }

    /**
     * 获取优惠券详情
     */
    @Operation(summary = "获取优惠券详情", description = "根据优惠券ID获取详细信息")
    @GetMapping("/{id}")
    public R<MallCouponVo> getInfo(@Parameter(description = "优惠券ID", required = true)
                                   @PathVariable Long id) {
        return R.ok(mallCouponService.queryById(id));
    }

}
