package com.seer.teach.teacher.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.seer.teach.common.enums.ResultCodeEnum;
import com.seer.teach.common.utils.AssertUtils;
import com.seer.teach.teacher.common.req.WrongQuestionBookReq;
import com.seer.teach.teacher.common.resp.WrongQuestionResp;
import com.seer.teach.teacher.module.entity.LessonQuestionsEntity;
import com.seer.teach.teacher.module.entity.LessonsEntity;
import com.seer.teach.teacher.module.mapper.LessonQuestionsMapper;
import com.seer.teach.teacher.service.LessonQuestionsService;
import com.seer.teach.teacher.service.LessonsService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Wang
 * @since 2025-12-02 21:29:37
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class LessonQuestionsServiceImpl extends ServiceImpl<LessonQuestionsMapper, LessonQuestionsEntity> implements LessonQuestionsService {

    private final LessonsService lessonsService;

    /**
     * 获取错题本
     * @param userId 用户ID
     * @param params 请求参数
     * @return 错题本
     */
    @Override
    public WrongQuestionResp getWrongQuestion(Integer userId, WrongQuestionBookReq params) {
        log.info("开始获取用户[{}]课程错题本数据",userId);
        List<LessonsEntity>  lessons = lessonsService.lambdaQuery()
                .eq(LessonsEntity::getUserId, userId)
                .eq(LessonsEntity::getSubjectId, params.getSubjectId())
                .list();
        AssertUtils.notEmpty(lessons,ResultCodeEnum.SMART_CODE_ALREADY_EXISTS);
        log.info("用户[{}]课程错题本数据获取成功，课程数量：{}",userId,lessons.size());
        return null;
    }
}
