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

import com.ssj.bean.sys.teacher.domain.TeacherWeightRule;
import com.ssj.dao.sys.teacher.dao.TeacherWeightRuleDao;
import com.ssj.framework.core.common.service.BaseServiceImpl;
import com.ssj.service.sys.teacher.TeacherWeightRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 *
 * @author yrf
 * @date 2019/5/9 10:43
 */
@Service
public class TeacherWeightRuleServiceImpl extends BaseServiceImpl<TeacherWeightRule, String> implements TeacherWeightRuleService {

    @Autowired
    private TeacherWeightRuleDao teacherWeightRuleDao;

    @Override
    public PagingAndSortingRepository<TeacherWeightRule, String> getDao() {
        return teacherWeightRuleDao;
    }

    @Override
    public TeacherWeightRule findByTypeAndGradeAndValue(int type, String grade, BigDecimal value) {
        switch (type) {
            case 1:
                return teacherWeightRuleDao.findByTypeAndGradeAndMinValueLessThanEqualAndMaxValueGreaterThan(type, grade, value, value);
            case 2:
            case 3:
                return teacherWeightRuleDao.findByTypeAndMinValueLessThanEqualAndMaxValueGreaterThan(type, value, value);
        }
        return null;
    }
}
