package com.ssj.service.sys.lesson.service.impl;


import com.ssj.bean.sys.lesson.domain.LessonServiceApply;
import com.ssj.dao.sys.lesson.dao.LessonServiceApplyDao;
import com.ssj.framework.core.common.service.BaseServiceImpl;
import com.ssj.service.sys.lesson.service.LessonServiceApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Transactional
@Service
public class LessonServiceApplyServiceImpl extends BaseServiceImpl<LessonServiceApply, String> implements LessonServiceApplyService {
    @Autowired
    private LessonServiceApplyDao dao;

    @Override
    public PagingAndSortingRepository<LessonServiceApply, String> getDao() {
        return dao;
    }

	@Override
	public LessonServiceApply findInfoByCourseId(String courseId, int type) {
		return dao.findInfoByCourseId(courseId,type);
	}

	@Override
	public void updateApplyInvalid() {
		dao.updateApplyInvalid();
	}

	@Override
	public LessonServiceApply findByKmtCourseIdAndType(String kmtCourseId, int type) {
		return dao.findByKmtCourseIdAndTypeAndStatusAndIsDelete(kmtCourseId,type,0,0);
	}

	@Override
	public void updateApplyTeacherInvalid() {
		List<String> list = dao.findApplyTeacherInvalid();
		for (String lessonServiceId : list) {
			//如果家长10小时没有手动确认，那么后台自动确认
			//parentService.confirmTeacher(lessonServiceId);
		}
	}

	@Override
	public LessonServiceApply findFirstByKmtCourseIdAndType(String kmtCourseId, int type) {
		return dao.findFirstByKmtCourseIdAndTypeAndIsDeleteOrderByCreateTimeDesc(kmtCourseId, type, 0);
	}

	@Override
	public LessonServiceApply findHistoryApplyByKmtCourseIdOrLessonServiceIdOrderByCreateTimeDesc(String kmtCourseId,
			String lessonServiceId) {
		return dao.findHistoryApplyByKmtCourseIdOrLessonServiceIdOrderByCreateTimeDesc(kmtCourseId, lessonServiceId);
	}
}
