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

import com.red.circle.other.app.command.SpinsTaskProgressInitExe;
import com.red.circle.other.app.command.SpinsTaskProgressIncrementExe;
import com.red.circle.other.app.command.SpinsTaskProgressResetExe;
import com.red.circle.other.app.command.SpinsTaskProgressUpdateExe;
import com.red.circle.other.app.dto.cmd.SpinsTaskProgressUpdateCmd;
import com.red.circle.other.app.service.SpinsUserTaskProgressService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Spins用户任务进度服务实现
 *
 * @author system
 * @date 2025-01-21
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class SpinsUserTaskProgressServiceImpl implements SpinsUserTaskProgressService {

    private final SpinsTaskProgressUpdateExe spinsTaskProgressUpdateExe;
    private final SpinsTaskProgressIncrementExe spinsTaskProgressIncrementExe;
    private final SpinsTaskProgressResetExe spinsTaskProgressResetExe;
    private final SpinsTaskProgressInitExe spinsTaskProgressInitExe;

    @Override
    public void updateTaskProgress(SpinsTaskProgressUpdateCmd cmd) {
        log.info("更新用户任务进度, userId={}, taskCode={}, progressValue={}", 
                cmd.getUserId(), cmd.getTaskCode(), cmd.getProgressValue());
        spinsTaskProgressUpdateExe.execute(cmd);
    }

    @Override
    public void incrementTaskProgress(Long userId, String taskCode, Integer incrementValue) {
        log.info("增加用户任务进度, userId={}, taskCode={}, incrementValue={}", 
                userId, taskCode, incrementValue);
        spinsTaskProgressIncrementExe.execute(userId, taskCode, incrementValue);
    }

    @Override
    public void resetDailyTasks(Long userId) {
        log.info("重置用户每日任务, userId={}", userId);
        spinsTaskProgressResetExe.execute(userId);
    }

    @Override
    public void initUserTaskProgress(Long userId, String taskCode) {
        log.info("初始化用户任务进度, userId={}, taskCode={}", userId, taskCode);
        spinsTaskProgressInitExe.execute(userId, taskCode);
    }
}
