package com.red.circle.other.adapter.app.props;

import com.red.circle.framework.dto.PageResult;
import com.red.circle.other.app.dto.clientobject.PropCouponCO;
import com.red.circle.other.app.dto.clientobject.PropCouponRecordCO;
import com.red.circle.other.inner.model.cmd.material.PropCouponGrantCmd;
import com.red.circle.other.app.dto.cmd.PropCouponQueryCmd;
import com.red.circle.other.app.dto.cmd.PropCouponSendCmd;
import com.red.circle.other.app.dto.cmd.PropCouponUseCmd;
import com.red.circle.other.app.service.PropCouponService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 道具券控制器
 *
 * @author system
 * @date 2025-11-05
 */
@RestController
@RequestMapping("/prop/coupon")
@RequiredArgsConstructor
public class PropCouponRestController {

    private final PropCouponService propCouponService;

    /**
     * 使用道具券
     */
    @PostMapping("/use")
    public void useCoupon(@RequestBody @Validated PropCouponUseCmd cmd) {
        propCouponService.useCoupon(cmd);
    }

    /**
     * 赠送道具券
     */
    @PostMapping("/send")
    public void sendCoupon(@RequestBody @Validated PropCouponSendCmd cmd) {
        propCouponService.sendCoupon(cmd);
    }

    /**
     * 查询我的有效道具券列表
     */
    @PostMapping("/list")
    public PageResult<PropCouponCO> queryMyCoupons(@RequestBody @Validated PropCouponQueryCmd cmd) {
        return propCouponService.queryMyCoupons(cmd);
    }

    /**
     * 查询使用记录
     */
    @PostMapping("/record/list")
    public PageResult<PropCouponRecordCO> queryUseRecords(@RequestBody @Validated PropCouponQueryCmd cmd) {
        return propCouponService.queryUseRecords(cmd);
    }

    /**
     * 发放道具券
     */
    @PostMapping("/grant")
    public void grantCoupons(@RequestBody @Validated PropCouponGrantCmd cmd) {
      propCouponService.grantCoupons(cmd);
    }

}