| | |
| | | package com.yeshi.fanli.util;
|
| | |
|
| | | import java.util.HashSet;
|
| | | import java.util.Scanner;
|
| | | import java.util.Set;
|
| | |
|
| | | public class InviteCodeFilterUtil {
|
| | |
|
| | | // 特殊邀请码
|
| | | private static Set<String> spcialInviteCodeSet;
|
| | |
|
| | | /**
|
| | | * 是否为特殊的邀请码
|
| | | * |
| | | * @param code
|
| | | * @return
|
| | | */
|
| | | public static boolean isSpecialCode(String code) {
|
| | | if (StringUtil.isNullOrEmpty(code))
|
| | | return false;
|
| | | if (spcialInviteCodeSet == null) {
|
| | | spcialInviteCodeSet = new HashSet<>();
|
| | | }
|
| | |
|
| | | if (spcialInviteCodeSet.size() == 0) {
|
| | | Scanner scanner = new Scanner(
|
| | | InviteCodeFilterUtil.class.getClassLoader().getResourceAsStream("invite_code_special.txt"));
|
| | | while (scanner.hasNext()) {
|
| | | String c = scanner.next();
|
| | | if (!StringUtil.isNullOrEmpty(c))
|
| | | spcialInviteCodeSet.add(c.trim());
|
| | | }
|
| | | scanner.close();
|
| | | }
|
| | | if (spcialInviteCodeSet.contains(code.trim().toUpperCase()))
|
| | | return true;
|
| | | else
|
| | | return false;
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.util; |
| | | |
| | | import java.util.HashSet; |
| | | import java.util.Scanner; |
| | | import java.util.Set; |
| | | |
| | | public class InviteCodeFilterUtil { |
| | | |
| | | // 特殊邀请码 |
| | | private static Set<String> spcialInviteCodeSet; |
| | | |
| | | /** |
| | | * 是否为特殊的邀请码 |
| | | * |
| | | * @param code |
| | | * @return |
| | | */ |
| | | public static boolean isSpecialCode(String code) { |
| | | if (StringUtil.isNullOrEmpty(code)) |
| | | return false; |
| | | if (spcialInviteCodeSet == null) { |
| | | spcialInviteCodeSet = new HashSet<>(); |
| | | } |
| | | |
| | | if (spcialInviteCodeSet.size() == 0) { |
| | | Scanner scanner = new Scanner( |
| | | InviteCodeFilterUtil.class.getClassLoader().getResourceAsStream("invite_code_special.txt")); |
| | | while (scanner.hasNext()) { |
| | | String c = scanner.next(); |
| | | if (!StringUtil.isNullOrEmpty(c)) |
| | | spcialInviteCodeSet.add(c.trim()); |
| | | } |
| | | scanner.close(); |
| | | } |
| | | if (spcialInviteCodeSet.contains(code.trim().toUpperCase())) |
| | | return true; |
| | | else |
| | | return false; |
| | | } |
| | | |
| | | } |