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

import com.red.circle.other.app.dto.clientobject.GrabRoomRedPacketResultCO;
import com.red.circle.other.app.dto.clientobject.RoomRedPacketCO;
import com.red.circle.other.app.dto.clientobject.RoomRedPacketDetailCO;
import com.red.circle.other.app.dto.cmd.GrabRoomRedPacketCmd;
import com.red.circle.other.app.dto.cmd.QueryRoomRedPacketDetailCmd;
import com.red.circle.other.app.dto.cmd.QueryRoomRedPacketListCmd;
import com.red.circle.other.app.dto.cmd.SendRoomRedPacketCmd;
import com.red.circle.other.app.service.RoomRedPacketService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 房间红包REST控制器
 */
@RestController
@RequestMapping("/room/red-packet")
@RequiredArgsConstructor
public class RoomRedPacketRestController {

    private final RoomRedPacketService roomRedPacketService;

    /**
     * 发送红包
     */
    @PostMapping("/send")
    public RoomRedPacketCO sendRedPacket(@Valid @RequestBody SendRoomRedPacketCmd cmd) {
        return roomRedPacketService.sendRedPacket(cmd);
    }

    /**
     * 发送平台红包
     *
     * @eo.name 发送平台红包
     * @eo.url /send-platform
     * @eo.method post
     * @eo.request-type json
     */
    @PostMapping("/send-platform")
    public RoomRedPacketCO sendPlatformRedPacket(@Valid @RequestBody SendRoomRedPacketCmd cmd) {
        return roomRedPacketService.sendPlatformRedPacket(cmd);
    }

    /**
     * 抢红包
     */
    @PostMapping("/grab")
    public GrabRoomRedPacketResultCO grabRedPacket(@Valid @RequestBody GrabRoomRedPacketCmd cmd) {
        return roomRedPacketService.grabRedPacket(cmd);
    }

    /**
     * 查询房间红包列表
     */
    @GetMapping("/list")
    public List<RoomRedPacketCO> queryRoomRedPacketList(@Valid QueryRoomRedPacketListCmd cmd) {
        return roomRedPacketService.queryRoomRedPacketList(cmd);
    }

    /**
     * 查询红包详情
     */
    @GetMapping("/detail")
    public RoomRedPacketDetailCO queryRedPacketDetail(@Valid QueryRoomRedPacketDetailCmd cmd) {
        return roomRedPacketService.queryRedPacketDetail(cmd);
    }
}
