package com.sqx.modules.app.controller.app;

import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.userSign.dto.UserSignDTO;
import com.sqx.modules.userSign.service.UserSignRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author tankaikai
 * @since 2024-12-19 15:23
 */

@Slf4j
@RestController
@Api(value = "用户签到", tags = {"用户签到"})
@RequestMapping(value = "/app/userSignRecord")
public class AppUserSignController {

    @Autowired
    private UserSignRecordService userSignRecordService;

    /**
     * 获取用户连续签到数据
     */
    @Login
    @GetMapping("/getUserSignData")
    @ApiOperation("获取用户连续签到数据")
    public Result getUserSignData(@RequestAttribute("userId") Long userId) {
        UserSignDTO data = userSignRecordService.getUserSignData(userId);
        return Result.success().put("data", data);
    }

    /**
     * 获取连续签到奖励配置
     */
    @Login
    @GetMapping("/getUserSignAwardConfig")
    @ApiOperation(value = "获取连续签到奖励配置", notes = "如：[7,7] = 连续签到7天奖励7元")
    public Result getUserSignAwardConfig() {
        String[] data = userSignRecordService.getUserSignAwardConfig();
        return Result.success().put("data", data);
    }
}
