package com.yida.data.user.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yida.data.common.core.entity.user.EduParentType;
import com.yida.data.user.mapper.EduParentTypeMapper;
import com.yida.data.user.service.EduParentTypeService;

import org.springframework.stereotype.Service;

@Service
public class EduParentTypeServiceImpl extends ServiceImpl<EduParentTypeMapper, EduParentType
        > implements EduParentTypeService {

    @Override
    public EduParentType getParentType(String typeName) {
        EduParentType one = getOne(Wrappers.<EduParentType>lambdaQuery().eq(EduParentType::getName, typeName));
        if (one == null) {
            one = new EduParentType();
            one.setName(typeName);
            save(one);
        }
        return one;
    }
}
