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

import com.red.circle.other.app.dto.clientobject.GrabUserRedPacketResultCO;
import com.red.circle.other.app.dto.clientobject.UserRedPacketCO;
import com.red.circle.other.app.dto.cmd.GrabUserRedPacketCmd;
import com.red.circle.other.app.dto.cmd.QueryUserRedPacketDetailCmd;
import com.red.circle.other.app.dto.cmd.SendUserRedPacketCmd;
import com.red.circle.other.app.service.UserRedPacketService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 用户红包REST控制器
 */
@RestController
@RequestMapping("/user/red-packet")
@RequiredArgsConstructor
public class UserRedPacketRestController {

    private final UserRedPacketService userRedPacketService;

    /**
     * 发送用户红包
     */
    @PostMapping("/send")
    public UserRedPacketCO sendRedPacket(@Valid @RequestBody SendUserRedPacketCmd cmd) {
        return userRedPacketService.sendRedPacket(cmd);
    }

    /**
     * 领取用户红包
     */
    @PostMapping("/grab")
    public GrabUserRedPacketResultCO grabRedPacket(@Valid @RequestBody GrabUserRedPacketCmd cmd) {
        return userRedPacketService.grabRedPacket(cmd);
    }

    /**
     * 查询红包详情
     */
    @GetMapping("/detail")
    public UserRedPacketCO queryRedPacketDetail(@Valid QueryUserRedPacketDetailCmd cmd) {
        return userRedPacketService.queryRedPacketDetail(cmd);
    }
}
