package com.seer.teach.teacher.api;

import com.seer.teach.iot.api.UserDeviceServiceApi;
import com.seer.teach.teacher.service.registry.updateLearningDuration.UpdateLearningDurationHandlerRegistry;
import com.seer.teach.teacher.service.registry.updateLearningDuration.UpdateLearningDurationHandler;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 *
 * <p>
 *
 * </p >
 *
 * @author Captain
 * @since 2025-09-20 16:05
 */
@Slf4j
@RestController
@RequiredArgsConstructor
public class LearningDurationServiceApiImpl implements LearningDurationServiceApi{

    private final UpdateLearningDurationHandlerRegistry updateLearningDurationHandlerRegistry;

    private final UserDeviceServiceApi userDeviceServiceApi;
    @Override
    public void saveLearningDuration(Integer id,String device, Integer type, BigDecimal time) {
        Integer userId = userDeviceServiceApi.getUserIdByDevice(device);
        UpdateLearningDurationHandler handler = updateLearningDurationHandlerRegistry.getHandler(type);
        handler.updateVideoLearningDuration(userId,id, time);
    }
}
