package com.quinn.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.quinn.pojo.Invite;
import com.quinn.mapper.InviteMapper;
import com.quinn.service.InviteService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.quinn.utils.QuinnUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author limqsh
 * @since 2020-06-28
 */
@Service
public class InviteServiceImpl extends ServiceImpl<InviteMapper, Invite> implements InviteService {


    @Override
    public String getCode() {
        String code = "";
        while (true){
            code = QuinnUtils.getCode();
            int count = count(new QueryWrapper<Invite>().eq("apply_email", code).eq("status",'0'));
            if (count <= 0){
                break;
            }
        }
        return code;
    }
}
