| | |
| | | */ |
| | | private static final String FORMT_STRING = "888888"; |
| | | |
| | | private static final String FORMT_STRING_0 = "000000"; |
| | | |
| | | /** |
| | | * 获取用户名 |
| | | * |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | public static String getUserId(long userId) { |
| | | public static String getUserId(long userId) { |
| | | return NICK_NAME + formatSign(userId) |
| | | + generateRandomInt(SIGN_LENGTH); |
| | | |
| | |
| | | * |
| | | * @return4 |
| | | */ |
| | | public static String formatSign(Integer param, Integer lenght) { |
| | | String str = Long.toString(param); |
| | | int length = str.length() - lenght; |
| | | if (length == 0) { |
| | | return str; |
| | | } else if (length < 0) { |
| | | str = "0" + str; |
| | | return FORMT_STRING_0.substring(0, Math.abs(length) - 1) + str; |
| | | } else { |
| | | return str.substring(length); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 格式化标记 |
| | | * |
| | | * @return4 |
| | | */ |
| | | private static String formatSign(long param) { |
| | | String str = Long.toString(param); |
| | | int length = str.length() - SIGN_LENGTH; |