From 9969bea2a8c1eab64c12a51a2d24d65e5b6c0dd0 Mon Sep 17 00:00:00 2001 From: wl <173@qq.com> Date: 星期一, 24 十月 2022 18:12:41 +0800 Subject: [PATCH] 日志导出乱码 日志查询导出 代码重构 --- ycl-common/src/main/java/com/ycl/utils/common/RandomUtils.java | 22 +++++++++++++++++++++- 1 files changed, 21 insertions(+), 1 deletions(-) diff --git a/ycl-common/src/main/java/com/ycl/utils/common/RandomUtils.java b/ycl-common/src/main/java/com/ycl/utils/common/RandomUtils.java index 22a574e..67b56a5 100644 --- a/ycl-common/src/main/java/com/ycl/utils/common/RandomUtils.java +++ b/ycl-common/src/main/java/com/ycl/utils/common/RandomUtils.java @@ -21,13 +21,15 @@ */ 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); @@ -38,6 +40,24 @@ * * @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; -- Gitblit v1.8.0