package com.yinlihupo.enlish.service.service.vocabulary;

import com.yinlihupo.enlish.service.domain.dataobject.VocabularyBankDO;
import com.yinlihupo.enlish.service.domain.mapper.VocabularyBankDOMapper;
import com.yinlihupo.enlish.service.domain.mapper.WordMasteryLogDOMapper;
import com.yinlihupo.enlish.service.model.vo.vocabulary.FindStudentWordDetailRspVO;
import com.yinlihupo.enlish.service.service.VocabularyService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
@Slf4j
public class VocabularyServiceImpl implements VocabularyService {

    @Resource
    private VocabularyBankDOMapper vocabularyBankDOMapper;
    @Resource
    private WordMasteryLogDOMapper wordMasteryLogDOMapper;

    @Override
    public List<VocabularyBankDO> findVocabularyBankDOListById(List<Integer> ids) {
        return vocabularyBankDOMapper.selectVocabularyBankDOListByIds(ids);
    }

    @Override
    public FindStudentWordDetailRspVO findStudentWordDetail(Integer studentId) {
        Integer wordMastery = wordMasteryLogDOMapper.selectMasteryCount(studentId);
        Integer wordNotMastery = wordMasteryLogDOMapper.selectNotMasteryCount(studentId);
        Integer total = vocabularyBankDOMapper.selectWordTotal();
        return FindStudentWordDetailRspVO.builder().masteredWordCount(wordMastery).unmasteredWordCount(wordNotMastery).pendingReviewWordCount(total - wordMastery - wordNotMastery).build();
    }
}
