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

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import jakarta.validation.constraints.NotNull;
import com.red.circle.other.app.dto.clientobject.task.RoomDailyTaskClaimCO;
import com.red.circle.other.app.dto.clientobject.task.RoomDailyTaskClaimableCountCO;
import com.red.circle.other.app.dto.clientobject.task.RoomDailyTaskListCO;
import com.red.circle.other.app.dto.cmd.task.RoomDailyTaskClaimCmd;
import com.red.circle.other.app.service.task.RoomDailyTaskService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * 每日任务接口
 */
@RestController
@RequestMapping("/room-task")
@RequiredArgsConstructor
public class RoomDailyTaskRestController {

    private final RoomDailyTaskService roomDailyTaskService;

    /**
     * 获取任务列表
     * @eo.name 获取每日任务列表
     * @eo.url /list
     * @eo.method get
     */
    @GetMapping("/list")
    public RoomDailyTaskListCO getTaskList(AppExtCommand cmd,
            @RequestParam @NotNull(message = "任务分类不能为空") Integer taskCategory) {
        return roomDailyTaskService.getTaskList(cmd.getReqUserId(), taskCategory);
    }

    /**
     * 领取任务奖励
     * @eo.name 领取任务奖励
     * @eo.url /claim
     * @eo.method post
     * @eo.request-type json
     */
    @PostMapping("/claim")
    public RoomDailyTaskClaimCO claimReward(@RequestBody @Validated RoomDailyTaskClaimCmd cmd) {
        return roomDailyTaskService.claimReward(cmd);
    }

    /**
     * 获取当前可领取奖励数量
     * @eo.name 获取可领取奖励数量
     * @eo.url /claimable-count
     * @eo.method get
     */
    @GetMapping("/claimable-count")
    public RoomDailyTaskClaimableCountCO getClaimableCount(AppExtCommand cmd) {
        return roomDailyTaskService.getClaimableCount(cmd.getReqUserId());
    }
}
