package com.ym.mec.biz.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ym.mec.biz.dal.dao.MusicGroupSubjectPlanDao;
import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
import com.ym.mec.biz.dal.entity.StudentRegistration;
import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
import com.ym.mec.biz.service.StudentRegistrationService;
import com.ym.mec.common.dal.BaseDAO;
import com.ym.mec.common.service.impl.BaseServiceImpl;

import java.util.List;

@Service
public class MusicGroupSubjectPlanServiceImpl extends BaseServiceImpl<Integer, MusicGroupSubjectPlan> implements MusicGroupSubjectPlanService {

    @Autowired
    private MusicGroupSubjectPlanDao musicGroupSubjectPlanDao;

    @Autowired
	private StudentRegistrationService studentRegistrationService;

    @Override
    public BaseDAO<Integer, MusicGroupSubjectPlan> getDAO() {
        return musicGroupSubjectPlanDao;
    }

    @Override
    public List<MusicGroupSubjectPlan> getMusicSubjectClassPlan(int musicGroupId) {
        List<MusicGroupSubjectPlan> musicSubjectClassPlans = musicGroupSubjectPlanDao.getMusicSubjectClassPlan(musicGroupId);
        for (MusicGroupSubjectPlan musicSubjectClassPlan : musicSubjectClassPlans) {
			Integer noClassStuCount = studentRegistrationService.getNoClassStuCountBySubjectId(musicGroupId, musicSubjectClassPlan.getSubjectId());
			musicSubjectClassPlan.setNoClassStudentNum(noClassStuCount);
		}
        return musicSubjectClassPlans;
    }
}