package com.qmth.teachcloud.report.business.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
import com.qmth.teachcloud.report.business.entity.TBSchoolClazz;
import com.qmth.teachcloud.report.business.mapper.TBSchoolClazzMapper;
import com.qmth.teachcloud.report.business.service.TBSchoolClazzService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 学校班级表 服务实现类
 * </p>
 *
 * @author wangliang
 * @since 2021-06-01
 */
@Service
public class TBSchoolClazzServiceImpl extends ServiceImpl<TBSchoolClazzMapper, TBSchoolClazz> implements TBSchoolClazzService {
    @Override
    public TBSchoolClazz findByForeignKey(Long schoolId, String clazzCode, String clazzName) {
        List<TBSchoolClazz> tbSchoolClazzList = this.list(new QueryWrapper<TBSchoolClazz>().lambda()
                .eq(TBSchoolClazz::getSchoolId,schoolId)
                .eq(TBSchoolClazz::getClazzCode,clazzCode)
                .eq(TBSchoolClazz::getClazzName,clazzName));
        if (tbSchoolClazzList.size() != 1){
            throw ExceptionResultEnum.ERROR.exception("班级基础数据异常");
        }
        return tbSchoolClazzList.get(0);
    }
}
