-{
- private static final long serialVersionUID = -1185015143654744140L;
-
- /**
- * SecureRandom 鐨勫崟渚
- *
- */
- private static class Holder
- {
- static final SecureRandom numberGenerator = getSecureRandom();
- }
-
- /** 姝UID鐨勬渶楂64鏈夋晥浣 */
- private final long mostSigBits;
-
- /** 姝UID鐨勬渶浣64鏈夋晥浣 */
- private final long leastSigBits;
-
- /**
- * 绉佹湁鏋勯
- *
- * @param data 鏁版嵁
- */
- private UUID(byte[] data)
- {
- long msb = 0;
- long lsb = 0;
- assert data.length == 16 : "data must be 16 bytes in length";
- for (int i = 0; i < 8; i++)
- {
- msb = (msb << 8) | (data[i] & 0xff);
- }
- for (int i = 8; i < 16; i++)
- {
- lsb = (lsb << 8) | (data[i] & 0xff);
- }
- this.mostSigBits = msb;
- this.leastSigBits = lsb;
- }
-
- /**
- * 浣跨敤鎸囧畾鐨勬暟鎹瀯閫犳柊鐨 UUID銆
- *
- * @param mostSigBits 鐢ㄤ簬 {@code UUID} 鐨勬渶楂樻湁鏁 64 浣
- * @param leastSigBits 鐢ㄤ簬 {@code UUID} 鐨勬渶浣庢湁鏁 64 浣
- */
- public UUID(long mostSigBits, long leastSigBits)
- {
- this.mostSigBits = mostSigBits;
- this.leastSigBits = leastSigBits;
- }
-
- /**
- * 鑾峰彇绫诲瀷 4锛堜吉闅忔満鐢熸垚鐨勶級UUID 鐨勯潤鎬佸伐鍘傘 浣跨敤鍔犲瘑鐨勬湰鍦扮嚎绋嬩吉闅忔満鏁扮敓鎴愬櫒鐢熸垚璇 UUID銆
- *
- * @return 闅忔満鐢熸垚鐨 {@code UUID}
- */
- public static UUID fastUUID()
- {
- return randomUUID(false);
- }
-
- /**
- * 鑾峰彇绫诲瀷 4锛堜吉闅忔満鐢熸垚鐨勶級UUID 鐨勯潤鎬佸伐鍘傘 浣跨敤鍔犲瘑鐨勫己浼殢鏈烘暟鐢熸垚鍣ㄧ敓鎴愯 UUID銆
- *
- * @return 闅忔満鐢熸垚鐨 {@code UUID}
- */
- public static UUID randomUUID()
- {
- return randomUUID(true);
- }
-
- /**
- * 鑾峰彇绫诲瀷 4锛堜吉闅忔満鐢熸垚鐨勶級UUID 鐨勯潤鎬佸伐鍘傘 浣跨敤鍔犲瘑鐨勫己浼殢鏈烘暟鐢熸垚鍣ㄧ敓鎴愯 UUID銆
- *
- * @param isSecure 鏄惁浣跨敤{@link SecureRandom}濡傛灉鏄彲浠ヨ幏寰楁洿瀹夊叏鐨勯殢鏈虹爜锛屽惁鍒欏彲浠ュ緱鍒版洿濂界殑鎬ц兘
- * @return 闅忔満鐢熸垚鐨 {@code UUID}
- */
- public static UUID randomUUID(boolean isSecure)
- {
- final Random ng = isSecure ? Holder.numberGenerator : getRandom();
-
- byte[] randomBytes = new byte[16];
- ng.nextBytes(randomBytes);
- randomBytes[6] &= 0x0f; /* clear version */
- randomBytes[6] |= 0x40; /* set to version 4 */
- randomBytes[8] &= 0x3f; /* clear variant */
- randomBytes[8] |= 0x80; /* set to IETF variant */
- return new UUID(randomBytes);
- }
-
- /**
- * 鏍规嵁鎸囧畾鐨勫瓧鑺傛暟缁勮幏鍙栫被鍨 3锛堝熀浜庡悕绉扮殑锛塙UID 鐨勯潤鎬佸伐鍘傘
- *
- * @param name 鐢ㄤ簬鏋勯 UUID 鐨勫瓧鑺傛暟缁勩
- *
- * @return 鏍规嵁鎸囧畾鏁扮粍鐢熸垚鐨 {@code UUID}
- */
- public static UUID nameUUIDFromBytes(byte[] name)
- {
- MessageDigest md;
- try
- {
- md = MessageDigest.getInstance("MD5");
- }
- catch (NoSuchAlgorithmException nsae)
- {
- throw new InternalError("MD5 not supported");
- }
- byte[] md5Bytes = md.digest(name);
- md5Bytes[6] &= 0x0f; /* clear version */
- md5Bytes[6] |= 0x30; /* set to version 3 */
- md5Bytes[8] &= 0x3f; /* clear variant */
- md5Bytes[8] |= 0x80; /* set to IETF variant */
- return new UUID(md5Bytes);
- }
-
- /**
- * 鏍规嵁 {@link #toString()} 鏂规硶涓弿杩扮殑瀛楃涓叉爣鍑嗚〃绀哄舰寮忓垱寤簕@code UUID}銆
- *
- * @param name 鎸囧畾 {@code UUID} 瀛楃涓
- * @return 鍏锋湁鎸囧畾鍊肩殑 {@code UUID}
- * @throws IllegalArgumentException 濡傛灉 name 涓 {@link #toString} 涓弿杩扮殑瀛楃涓茶〃绀哄舰寮忎笉绗︽姏鍑烘寮傚父
- *
- */
- public static UUID fromString(String name)
- {
- String[] components = name.split("-");
- if (components.length != 5)
- {
- throw new IllegalArgumentException("Invalid UUID string: " + name);
- }
- for (int i = 0; i < 5; i++)
- {
- components[i] = "0x" + components[i];
- }
-
- long mostSigBits = Long.decode(components[0]).longValue();
- mostSigBits <<= 16;
- mostSigBits |= Long.decode(components[1]).longValue();
- mostSigBits <<= 16;
- mostSigBits |= Long.decode(components[2]).longValue();
-
- long leastSigBits = Long.decode(components[3]).longValue();
- leastSigBits <<= 48;
- leastSigBits |= Long.decode(components[4]).longValue();
-
- return new UUID(mostSigBits, leastSigBits);
- }
-
- /**
- * 杩斿洖姝 UUID 鐨 128 浣嶅间腑鐨勬渶浣庢湁鏁 64 浣嶃
- *
- * @return 姝 UUID 鐨 128 浣嶅间腑鐨勬渶浣庢湁鏁 64 浣嶃
- */
- public long getLeastSignificantBits()
- {
- return leastSigBits;
- }
-
- /**
- * 杩斿洖姝 UUID 鐨 128 浣嶅间腑鐨勬渶楂樻湁鏁 64 浣嶃
- *
- * @return 姝 UUID 鐨 128 浣嶅间腑鏈楂樻湁鏁 64 浣嶃
- */
- public long getMostSignificantBits()
- {
- return mostSigBits;
- }
-
- /**
- * 涓庢 {@code UUID} 鐩稿叧鑱旂殑鐗堟湰鍙. 鐗堟湰鍙锋弿杩版 {@code UUID} 鏄浣曠敓鎴愮殑銆
- *
- * 鐗堟湰鍙峰叿鏈変互涓嬪惈鎰:
- *
- * - 1 鍩轰簬鏃堕棿鐨 UUID
- *
- 2 DCE 瀹夊叏 UUID
- *
- 3 鍩轰簬鍚嶇О鐨 UUID
- *
- 4 闅忔満鐢熸垚鐨 UUID
- *
- *
- * @return 姝 {@code UUID} 鐨勭増鏈彿
- */
- public int version()
- {
- // Version is bits masked by 0x000000000000F000 in MS long
- return (int) ((mostSigBits >> 12) & 0x0f);
- }
-
- /**
- * 涓庢 {@code UUID} 鐩稿叧鑱旂殑鍙樹綋鍙枫傚彉浣撳彿鎻忚堪 {@code UUID} 鐨勫竷灞銆
- *
- * 鍙樹綋鍙峰叿鏈変互涓嬪惈鎰忥細
- *
- * - 0 涓 NCS 鍚戝悗鍏煎淇濈暀
- *
- 2 IETF RFC 4122(Leach-Salz), 鐢ㄤ簬姝ょ被
- *
- 6 淇濈暀锛屽井杞悜鍚庡吋瀹
- *
- 7 淇濈暀渚涗互鍚庡畾涔変娇鐢
- *
- *
- * @return 姝 {@code UUID} 鐩稿叧鑱旂殑鍙樹綋鍙
- */
- public int variant()
- {
- // This field is composed of a varying number of bits.
- // 0 - - Reserved for NCS backward compatibility
- // 1 0 - The IETF aka Leach-Salz variant (used by this class)
- // 1 1 0 Reserved, Microsoft backward compatibility
- // 1 1 1 Reserved for future definition.
- return (int) ((leastSigBits >>> (64 - (leastSigBits >>> 62))) & (leastSigBits >> 63));
- }
-
- /**
- * 涓庢 UUID 鐩稿叧鑱旂殑鏃堕棿鎴冲笺
- *
- *
- * 60 浣嶇殑鏃堕棿鎴冲兼牴鎹 {@code UUID} 鐨 time_low銆乼ime_mid 鍜 time_hi 瀛楁鏋勯犮
- * 鎵寰楀埌鐨勬椂闂存埑浠 100 姣井绉掍负鍗曚綅锛屼粠 UTC锛堥氱敤鍗忚皟鏃堕棿锛 1582 骞 10 鏈 15 鏃ラ浂鏃跺紑濮嬨
- *
- *
- * 鏃堕棿鎴冲间粎鍦ㄥ湪鍩轰簬鏃堕棿鐨 UUID锛堝叾 version 绫诲瀷涓 1锛変腑鎵嶆湁鎰忎箟銆
- * 濡傛灉姝 {@code UUID} 涓嶆槸鍩轰簬鏃堕棿鐨 UUID锛屽垯姝ゆ柟娉曟姏鍑 UnsupportedOperationException銆
- *
- * @throws UnsupportedOperationException 濡傛灉姝 {@code UUID} 涓嶆槸 version 涓 1 鐨 UUID銆
- */
- public long timestamp() throws UnsupportedOperationException
- {
- checkTimeBase();
- return (mostSigBits & 0x0FFFL) << 48//
- | ((mostSigBits >> 16) & 0x0FFFFL) << 32//
- | mostSigBits >>> 32;
- }
-
- /**
- * 涓庢 UUID 鐩稿叧鑱旂殑鏃堕挓搴忓垪鍊笺
- *
- *
- * 14 浣嶇殑鏃堕挓搴忓垪鍊兼牴鎹 UUID 鐨 clock_seq 瀛楁鏋勯犮俢lock_seq 瀛楁鐢ㄤ簬淇濊瘉鍦ㄥ熀浜庢椂闂寸殑 UUID 涓殑鏃堕棿鍞竴鎬с
- *
- * {@code clockSequence} 鍊间粎鍦ㄥ熀浜庢椂闂寸殑 UUID锛堝叾 version 绫诲瀷涓 1锛変腑鎵嶆湁鎰忎箟銆 濡傛灉姝 UUID 涓嶆槸鍩轰簬鏃堕棿鐨 UUID锛屽垯姝ゆ柟娉曟姏鍑
- * UnsupportedOperationException銆
- *
- * @return 姝 {@code UUID} 鐨勬椂閽熷簭鍒
- *
- * @throws UnsupportedOperationException 濡傛灉姝 UUID 鐨 version 涓嶄负 1
- */
- public int clockSequence() throws UnsupportedOperationException
- {
- checkTimeBase();
- return (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48);
- }
-
- /**
- * 涓庢 UUID 鐩稿叧鐨勮妭鐐瑰笺
- *
- *
- * 48 浣嶇殑鑺傜偣鍊兼牴鎹 UUID 鐨 node 瀛楁鏋勯犮傛瀛楁鏃ㄥ湪鐢ㄤ簬淇濆瓨鏈哄櫒鐨 IEEE 802 鍦板潃锛岃鍦板潃鐢ㄤ簬鐢熸垚姝 UUID 浠ヤ繚璇佺┖闂村敮涓鎬с
- *
- * 鑺傜偣鍊间粎鍦ㄥ熀浜庢椂闂寸殑 UUID锛堝叾 version 绫诲瀷涓 1锛変腑鎵嶆湁鎰忎箟銆
- * 濡傛灉姝 UUID 涓嶆槸鍩轰簬鏃堕棿鐨 UUID锛屽垯姝ゆ柟娉曟姏鍑 UnsupportedOperationException銆
- *
- * @return 姝 {@code UUID} 鐨勮妭鐐瑰
- *
- * @throws UnsupportedOperationException 濡傛灉姝 UUID 鐨 version 涓嶄负 1
- */
- public long node() throws UnsupportedOperationException
- {
- checkTimeBase();
- return leastSigBits & 0x0000FFFFFFFFFFFFL;
- }
-
- /**
- * 杩斿洖姝@code UUID} 鐨勫瓧绗︿覆琛ㄧ幇褰㈠紡銆
- *
- *
- * UUID 鐨勫瓧绗︿覆琛ㄧず褰㈠紡鐢辨 BNF 鎻忚堪锛
- *
- *
- * {@code
- * UUID = ----
- * time_low = 4*
- * time_mid = 2*
- * time_high_and_version = 2*
- * variant_and_sequence = 2*
- * node = 6*
- * hexOctet =
- * hexDigit = [0-9a-fA-F]
- * }
- *
- *
- *
- *
- * @return 姝@code UUID} 鐨勫瓧绗︿覆琛ㄧ幇褰㈠紡
- * @see #toString(boolean)
- */
- @Override
- public String toString()
- {
- return toString(false);
- }
-
- /**
- * 杩斿洖姝@code UUID} 鐨勫瓧绗︿覆琛ㄧ幇褰㈠紡銆
- *
- *
- * UUID 鐨勫瓧绗︿覆琛ㄧず褰㈠紡鐢辨 BNF 鎻忚堪锛
- *
- *
- * {@code
- * UUID = ----
- * time_low = 4*
- * time_mid = 2*
- * time_high_and_version = 2*
- * variant_and_sequence = 2*
- * node = 6*
- * hexOctet =
- * hexDigit = [0-9a-fA-F]
- * }
- *
- *
- *
- *
- * @param isSimple 鏄惁绠鍗曟ā寮忥紝绠鍗曟ā寮忎负涓嶅甫'-'鐨刄UID瀛楃涓
- * @return 姝@code UUID} 鐨勫瓧绗︿覆琛ㄧ幇褰㈠紡
- */
- public String toString(boolean isSimple)
- {
- final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36);
- // time_low
- builder.append(digits(mostSigBits >> 32, 8));
- if (false == isSimple)
- {
- builder.append('-');
- }
- // time_mid
- builder.append(digits(mostSigBits >> 16, 4));
- if (false == isSimple)
- {
- builder.append('-');
- }
- // time_high_and_version
- builder.append(digits(mostSigBits, 4));
- if (false == isSimple)
- {
- builder.append('-');
- }
- // variant_and_sequence
- builder.append(digits(leastSigBits >> 48, 4));
- if (false == isSimple)
- {
- builder.append('-');
- }
- // node
- builder.append(digits(leastSigBits, 12));
-
- return builder.toString();
- }
-
- /**
- * 杩斿洖姝 UUID 鐨勫搱甯岀爜銆
- *
- * @return UUID 鐨勫搱甯岀爜鍊笺
- */
- public int hashCode()
- {
- long hilo = mostSigBits ^ leastSigBits;
- return ((int) (hilo >> 32)) ^ (int) hilo;
- }
-
- /**
- * 灏嗘瀵硅薄涓庢寚瀹氬璞℃瘮杈冦
- *
- * 褰撲笖浠呭綋鍙傛暟涓嶄负 {@code null}銆佽屾槸涓涓 UUID 瀵硅薄銆佸叿鏈変笌姝 UUID 鐩稿悓鐨 varriant銆佸寘鍚浉鍚岀殑鍊硷紙姣忎竴浣嶅潎鐩稿悓锛夋椂锛岀粨鏋滄墠涓 {@code true}銆
- *
- * @param obj 瑕佷笌涔嬫瘮杈冪殑瀵硅薄
- *
- * @return 濡傛灉瀵硅薄鐩稿悓锛屽垯杩斿洖 {@code true}锛涘惁鍒欒繑鍥 {@code false}
- */
- public boolean equals(Object obj)
- {
- if ((null == obj) || (obj.getClass() != UUID.class))
- {
- return false;
- }
- UUID id = (UUID) obj;
- return (mostSigBits == id.mostSigBits && leastSigBits == id.leastSigBits);
- }
-
- // Comparison Operations
-
- /**
- * 灏嗘 UUID 涓庢寚瀹氱殑 UUID 姣旇緝銆
- *
- *
- * 濡傛灉涓や釜 UUID 涓嶅悓锛屼笖绗竴涓 UUID 鐨勬渶楂樻湁鏁堝瓧娈靛ぇ浜庣浜屼釜 UUID 鐨勫搴斿瓧娈碉紝鍒欑涓涓 UUID 澶т簬绗簩涓 UUID銆
- *
- * @param val 涓庢 UUID 姣旇緝鐨 UUID
- *
- * @return 鍦ㄦ UUID 灏忎簬銆佺瓑浜庢垨澶т簬 val 鏃讹紝鍒嗗埆杩斿洖 -1銆0 鎴 1銆
- *
- */
- public int compareTo(UUID val)
- {
- // The ordering is intentionally set up so that the UUIDs
- // can simply be numerically compared as two numbers
- return (this.mostSigBits < val.mostSigBits ? -1 : //
- (this.mostSigBits > val.mostSigBits ? 1 : //
- (this.leastSigBits < val.leastSigBits ? -1 : //
- (this.leastSigBits > val.leastSigBits ? 1 : //
- 0))));
- }
-
- // -------------------------------------------------------------------------------------------------------------------
- // Private method start
- /**
- * 杩斿洖鎸囧畾鏁板瓧瀵瑰簲鐨刪ex鍊
- *
- * @param val 鍊
- * @param digits 浣
- * @return 鍊
- */
- private static String digits(long val, int digits)
- {
- long hi = 1L << (digits * 4);
- return Long.toHexString(hi | (val & (hi - 1))).substring(1);
- }
-
- /**
- * 妫鏌ユ槸鍚︿负time-based鐗堟湰UUID
- */
- private void checkTimeBase()
- {
- if (version() != 1)
- {
- throw new UnsupportedOperationException("Not a time-based UUID");
- }
- }
-
- /**
- * 鑾峰彇{@link SecureRandom}锛岀被鎻愪緵鍔犲瘑鐨勫己闅忔満鏁扮敓鎴愬櫒 (RNG)
- *
- * @return {@link SecureRandom}
- */
- public static SecureRandom getSecureRandom()
- {
- try
- {
- return SecureRandom.getInstance("SHA1PRNG");
- }
- catch (NoSuchAlgorithmException e)
- {
- throw new UtilException(e);
- }
- }
-
- /**
- * 鑾峰彇闅忔満鏁扮敓鎴愬櫒瀵硅薄
- * ThreadLocalRandom鏄疛DK 7涔嬪悗鎻愪緵骞跺彂浜х敓闅忔満鏁帮紝鑳藉瑙e喅澶氫釜绾跨▼鍙戠敓鐨勭珵浜変簤澶恒
- *
- * @return {@link ThreadLocalRandom}
- */
- public static ThreadLocalRandom getRandom()
- {
- return ThreadLocalRandom.current();
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/core/text/CharsetKit.java b/ruoyi/src/main/java/com/ruoyi/common/core/text/CharsetKit.java
deleted file mode 100644
index 8297661a..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/core/text/CharsetKit.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.ruoyi.common.core.text;
-
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import com.ruoyi.common.utils.StringUtils;
-
-/**
- * 瀛楃闆嗗伐鍏风被
- *
- * @author ruoyi
- */
-public class CharsetKit
-{
- /** ISO-8859-1 */
- public static final String ISO_8859_1 = "ISO-8859-1";
- /** UTF-8 */
- public static final String UTF_8 = "UTF-8";
- /** GBK */
- public static final String GBK = "GBK";
-
- /** ISO-8859-1 */
- public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1);
- /** UTF-8 */
- public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8);
- /** GBK */
- public static final Charset CHARSET_GBK = Charset.forName(GBK);
-
- /**
- * 杞崲涓篊harset瀵硅薄
- *
- * @param charset 瀛楃闆嗭紝涓虹┖鍒欒繑鍥為粯璁ゅ瓧绗﹂泦
- * @return Charset
- */
- public static Charset charset(String charset)
- {
- return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset);
- }
-
- /**
- * 杞崲瀛楃涓茬殑瀛楃闆嗙紪鐮
- *
- * @param source 瀛楃涓
- * @param srcCharset 婧愬瓧绗﹂泦锛岄粯璁SO-8859-1
- * @param destCharset 鐩爣瀛楃闆嗭紝榛樿UTF-8
- * @return 杞崲鍚庣殑瀛楃闆
- */
- public static String convert(String source, String srcCharset, String destCharset)
- {
- return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset));
- }
-
- /**
- * 杞崲瀛楃涓茬殑瀛楃闆嗙紪鐮
- *
- * @param source 瀛楃涓
- * @param srcCharset 婧愬瓧绗﹂泦锛岄粯璁SO-8859-1
- * @param destCharset 鐩爣瀛楃闆嗭紝榛樿UTF-8
- * @return 杞崲鍚庣殑瀛楃闆
- */
- public static String convert(String source, Charset srcCharset, Charset destCharset)
- {
- if (null == srcCharset)
- {
- srcCharset = StandardCharsets.ISO_8859_1;
- }
-
- if (null == destCharset)
- {
- srcCharset = StandardCharsets.UTF_8;
- }
-
- if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset))
- {
- return source;
- }
- return new String(source.getBytes(srcCharset), destCharset);
- }
-
- /**
- * @return 绯荤粺瀛楃闆嗙紪鐮
- */
- public static String systemCharset()
- {
- return Charset.defaultCharset().name();
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/core/text/Convert.java b/ruoyi/src/main/java/com/ruoyi/common/core/text/Convert.java
deleted file mode 100644
index 9dd076d0..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/core/text/Convert.java
+++ /dev/null
@@ -1,999 +0,0 @@
-package com.ruoyi.common.core.text;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.text.NumberFormat;
-import java.util.Set;
-import com.ruoyi.common.utils.StringUtils;
-
-/**
- * 绫诲瀷杞崲鍣
- *
- * @author ruoyi
- */
-public class Convert
-{
- /**
- * 杞崲涓哄瓧绗︿覆
- * 濡傛灉缁欏畾鐨勫间负null锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊
- * @return 缁撴灉
- */
- public static String toStr(Object value, String defaultValue)
- {
- if (null == value)
- {
- return defaultValue;
- }
- if (value instanceof String)
- {
- return (String) value;
- }
- return value.toString();
- }
-
- /**
- * 杞崲涓哄瓧绗︿覆
- * 濡傛灉缁欏畾鐨勫间负null
锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊null
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @return 缁撴灉
- */
- public static String toStr(Object value)
- {
- return toStr(value, null);
- }
-
- /**
- * 杞崲涓哄瓧绗
- * 濡傛灉缁欏畾鐨勫间负null锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊
- * @return 缁撴灉
- */
- public static Character toChar(Object value, Character defaultValue)
- {
- if (null == value)
- {
- return defaultValue;
- }
- if (value instanceof Character)
- {
- return (Character) value;
- }
-
- final String valueStr = toStr(value, null);
- return StringUtils.isEmpty(valueStr) ? defaultValue : valueStr.charAt(0);
- }
-
- /**
- * 杞崲涓哄瓧绗
- * 濡傛灉缁欏畾鐨勫间负null
锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊null
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @return 缁撴灉
- */
- public static Character toChar(Object value)
- {
- return toChar(value, null);
- }
-
- /**
- * 杞崲涓篵yte
- * 濡傛灉缁欏畾鐨勫间负null
锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊
- * @return 缁撴灉
- */
- public static Byte toByte(Object value, Byte defaultValue)
- {
- if (value == null)
- {
- return defaultValue;
- }
- if (value instanceof Byte)
- {
- return (Byte) value;
- }
- if (value instanceof Number)
- {
- return ((Number) value).byteValue();
- }
- final String valueStr = toStr(value, null);
- if (StringUtils.isEmpty(valueStr))
- {
- return defaultValue;
- }
- try
- {
- return Byte.parseByte(valueStr);
- }
- catch (Exception e)
- {
- return defaultValue;
- }
- }
-
- /**
- * 杞崲涓篵yte
- * 濡傛灉缁欏畾鐨勫间负null
锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊null
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @return 缁撴灉
- */
- public static Byte toByte(Object value)
- {
- return toByte(value, null);
- }
-
- /**
- * 杞崲涓篠hort
- * 濡傛灉缁欏畾鐨勫间负null
锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊
- * @return 缁撴灉
- */
- public static Short toShort(Object value, Short defaultValue)
- {
- if (value == null)
- {
- return defaultValue;
- }
- if (value instanceof Short)
- {
- return (Short) value;
- }
- if (value instanceof Number)
- {
- return ((Number) value).shortValue();
- }
- final String valueStr = toStr(value, null);
- if (StringUtils.isEmpty(valueStr))
- {
- return defaultValue;
- }
- try
- {
- return Short.parseShort(valueStr.trim());
- }
- catch (Exception e)
- {
- return defaultValue;
- }
- }
-
- /**
- * 杞崲涓篠hort
- * 濡傛灉缁欏畾鐨勫间负null
锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊null
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @return 缁撴灉
- */
- public static Short toShort(Object value)
- {
- return toShort(value, null);
- }
-
- /**
- * 杞崲涓篘umber
- * 濡傛灉缁欏畾鐨勫间负绌猴紝鎴栬呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊
- * @return 缁撴灉
- */
- public static Number toNumber(Object value, Number defaultValue)
- {
- if (value == null)
- {
- return defaultValue;
- }
- if (value instanceof Number)
- {
- return (Number) value;
- }
- final String valueStr = toStr(value, null);
- if (StringUtils.isEmpty(valueStr))
- {
- return defaultValue;
- }
- try
- {
- return NumberFormat.getInstance().parse(valueStr);
- }
- catch (Exception e)
- {
- return defaultValue;
- }
- }
-
- /**
- * 杞崲涓篘umber
- * 濡傛灉缁欏畾鐨勫间负绌猴紝鎴栬呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊null
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @return 缁撴灉
- */
- public static Number toNumber(Object value)
- {
- return toNumber(value, null);
- }
-
- /**
- * 杞崲涓篿nt
- * 濡傛灉缁欏畾鐨勫间负绌猴紝鎴栬呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊
- * @return 缁撴灉
- */
- public static Integer toInt(Object value, Integer defaultValue)
- {
- if (value == null)
- {
- return defaultValue;
- }
- if (value instanceof Integer)
- {
- return (Integer) value;
- }
- if (value instanceof Number)
- {
- return ((Number) value).intValue();
- }
- final String valueStr = toStr(value, null);
- if (StringUtils.isEmpty(valueStr))
- {
- return defaultValue;
- }
- try
- {
- return Integer.parseInt(valueStr.trim());
- }
- catch (Exception e)
- {
- return defaultValue;
- }
- }
-
- /**
- * 杞崲涓篿nt
- * 濡傛灉缁欏畾鐨勫间负null
锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊null
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @return 缁撴灉
- */
- public static Integer toInt(Object value)
- {
- return toInt(value, null);
- }
-
- /**
- * 杞崲涓篒nteger鏁扮粍
- *
- * @param str 琚浆鎹㈢殑鍊
- * @return 缁撴灉
- */
- public static Integer[] toIntArray(String str)
- {
- return toIntArray(",", str);
- }
-
- /**
- * 杞崲涓篖ong鏁扮粍
- *
- * @param str 琚浆鎹㈢殑鍊
- * @return 缁撴灉
- */
- public static Long[] toLongArray(String str)
- {
- return toLongArray(",", str);
- }
-
- /**
- * 杞崲涓篒nteger鏁扮粍
- *
- * @param split 鍒嗛殧绗
- * @param split 琚浆鎹㈢殑鍊
- * @return 缁撴灉
- */
- public static Integer[] toIntArray(String split, String str)
- {
- if (StringUtils.isEmpty(str))
- {
- return new Integer[] {};
- }
- String[] arr = str.split(split);
- final Integer[] ints = new Integer[arr.length];
- for (int i = 0; i < arr.length; i++)
- {
- final Integer v = toInt(arr[i], 0);
- ints[i] = v;
- }
- return ints;
- }
-
- /**
- * 杞崲涓篖ong鏁扮粍
- *
- * @param split 鍒嗛殧绗
- * @param str 琚浆鎹㈢殑鍊
- * @return 缁撴灉
- */
- public static Long[] toLongArray(String split, String str)
- {
- if (StringUtils.isEmpty(str))
- {
- return new Long[] {};
- }
- String[] arr = str.split(split);
- final Long[] longs = new Long[arr.length];
- for (int i = 0; i < arr.length; i++)
- {
- final Long v = toLong(arr[i], null);
- longs[i] = v;
- }
- return longs;
- }
-
- /**
- * 杞崲涓篠tring鏁扮粍
- *
- * @param str 琚浆鎹㈢殑鍊
- * @return 缁撴灉
- */
- public static String[] toStrArray(String str)
- {
- return toStrArray(",", str);
- }
-
- /**
- * 杞崲涓篠tring鏁扮粍
- *
- * @param split 鍒嗛殧绗
- * @param split 琚浆鎹㈢殑鍊
- * @return 缁撴灉
- */
- public static String[] toStrArray(String split, String str)
- {
- return str.split(split);
- }
-
- /**
- * 杞崲涓簂ong
- * 濡傛灉缁欏畾鐨勫间负绌猴紝鎴栬呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊
- * @return 缁撴灉
- */
- public static Long toLong(Object value, Long defaultValue)
- {
- if (value == null)
- {
- return defaultValue;
- }
- if (value instanceof Long)
- {
- return (Long) value;
- }
- if (value instanceof Number)
- {
- return ((Number) value).longValue();
- }
- final String valueStr = toStr(value, null);
- if (StringUtils.isEmpty(valueStr))
- {
- return defaultValue;
- }
- try
- {
- // 鏀寔绉戝璁℃暟娉
- return new BigDecimal(valueStr.trim()).longValue();
- }
- catch (Exception e)
- {
- return defaultValue;
- }
- }
-
- /**
- * 杞崲涓簂ong
- * 濡傛灉缁欏畾鐨勫间负null
锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊null
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @return 缁撴灉
- */
- public static Long toLong(Object value)
- {
- return toLong(value, null);
- }
-
- /**
- * 杞崲涓篸ouble
- * 濡傛灉缁欏畾鐨勫间负绌猴紝鎴栬呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊
- * @return 缁撴灉
- */
- public static Double toDouble(Object value, Double defaultValue)
- {
- if (value == null)
- {
- return defaultValue;
- }
- if (value instanceof Double)
- {
- return (Double) value;
- }
- if (value instanceof Number)
- {
- return ((Number) value).doubleValue();
- }
- final String valueStr = toStr(value, null);
- if (StringUtils.isEmpty(valueStr))
- {
- return defaultValue;
- }
- try
- {
- // 鏀寔绉戝璁℃暟娉
- return new BigDecimal(valueStr.trim()).doubleValue();
- }
- catch (Exception e)
- {
- return defaultValue;
- }
- }
-
- /**
- * 杞崲涓篸ouble
- * 濡傛灉缁欏畾鐨勫间负绌猴紝鎴栬呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊null
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @return 缁撴灉
- */
- public static Double toDouble(Object value)
- {
- return toDouble(value, null);
- }
-
- /**
- * 杞崲涓篎loat
- * 濡傛灉缁欏畾鐨勫间负绌猴紝鎴栬呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊
- * @return 缁撴灉
- */
- public static Float toFloat(Object value, Float defaultValue)
- {
- if (value == null)
- {
- return defaultValue;
- }
- if (value instanceof Float)
- {
- return (Float) value;
- }
- if (value instanceof Number)
- {
- return ((Number) value).floatValue();
- }
- final String valueStr = toStr(value, null);
- if (StringUtils.isEmpty(valueStr))
- {
- return defaultValue;
- }
- try
- {
- return Float.parseFloat(valueStr.trim());
- }
- catch (Exception e)
- {
- return defaultValue;
- }
- }
-
- /**
- * 杞崲涓篎loat
- * 濡傛灉缁欏畾鐨勫间负绌猴紝鎴栬呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊null
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @return 缁撴灉
- */
- public static Float toFloat(Object value)
- {
- return toFloat(value, null);
- }
-
- /**
- * 杞崲涓篵oolean
- * String鏀寔鐨勫间负锛歵rue銆乫alse銆亂es銆乷k銆乶o锛1,0 濡傛灉缁欏畾鐨勫间负绌猴紝鎴栬呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊
- * @return 缁撴灉
- */
- public static Boolean toBool(Object value, Boolean defaultValue)
- {
- if (value == null)
- {
- return defaultValue;
- }
- if (value instanceof Boolean)
- {
- return (Boolean) value;
- }
- String valueStr = toStr(value, null);
- if (StringUtils.isEmpty(valueStr))
- {
- return defaultValue;
- }
- valueStr = valueStr.trim().toLowerCase();
- switch (valueStr)
- {
- case "true":
- return true;
- case "false":
- return false;
- case "yes":
- return true;
- case "ok":
- return true;
- case "no":
- return false;
- case "1":
- return true;
- case "0":
- return false;
- default:
- return defaultValue;
- }
- }
-
- /**
- * 杞崲涓篵oolean
- * 濡傛灉缁欏畾鐨勫间负绌猴紝鎴栬呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊null
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @return 缁撴灉
- */
- public static Boolean toBool(Object value)
- {
- return toBool(value, null);
- }
-
- /**
- * 杞崲涓篍num瀵硅薄
- * 濡傛灉缁欏畾鐨勫间负绌猴紝鎴栬呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊
- *
- * @param clazz Enum鐨凜lass
- * @param value 鍊
- * @param defaultValue 榛樿鍊
- * @return Enum
- */
- public static > E toEnum(Class clazz, Object value, E defaultValue)
- {
- if (value == null)
- {
- return defaultValue;
- }
- if (clazz.isAssignableFrom(value.getClass()))
- {
- @SuppressWarnings("unchecked")
- E myE = (E) value;
- return myE;
- }
- final String valueStr = toStr(value, null);
- if (StringUtils.isEmpty(valueStr))
- {
- return defaultValue;
- }
- try
- {
- return Enum.valueOf(clazz, valueStr);
- }
- catch (Exception e)
- {
- return defaultValue;
- }
- }
-
- /**
- * 杞崲涓篍num瀵硅薄
- * 濡傛灉缁欏畾鐨勫间负绌猴紝鎴栬呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊null
- *
- * @param clazz Enum鐨凜lass
- * @param value 鍊
- * @return Enum
- */
- public static > E toEnum(Class clazz, Object value)
- {
- return toEnum(clazz, value, null);
- }
-
- /**
- * 杞崲涓築igInteger
- * 濡傛灉缁欏畾鐨勫间负绌猴紝鎴栬呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊
- * @return 缁撴灉
- */
- public static BigInteger toBigInteger(Object value, BigInteger defaultValue)
- {
- if (value == null)
- {
- return defaultValue;
- }
- if (value instanceof BigInteger)
- {
- return (BigInteger) value;
- }
- if (value instanceof Long)
- {
- return BigInteger.valueOf((Long) value);
- }
- final String valueStr = toStr(value, null);
- if (StringUtils.isEmpty(valueStr))
- {
- return defaultValue;
- }
- try
- {
- return new BigInteger(valueStr);
- }
- catch (Exception e)
- {
- return defaultValue;
- }
- }
-
- /**
- * 杞崲涓築igInteger
- * 濡傛灉缁欏畾鐨勫间负绌猴紝鎴栬呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊null
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @return 缁撴灉
- */
- public static BigInteger toBigInteger(Object value)
- {
- return toBigInteger(value, null);
- }
-
- /**
- * 杞崲涓築igDecimal
- * 濡傛灉缁欏畾鐨勫间负绌猴紝鎴栬呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊
- * @return 缁撴灉
- */
- public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue)
- {
- if (value == null)
- {
- return defaultValue;
- }
- if (value instanceof BigDecimal)
- {
- return (BigDecimal) value;
- }
- if (value instanceof Long)
- {
- return new BigDecimal((Long) value);
- }
- if (value instanceof Double)
- {
- return new BigDecimal((Double) value);
- }
- if (value instanceof Integer)
- {
- return new BigDecimal((Integer) value);
- }
- final String valueStr = toStr(value, null);
- if (StringUtils.isEmpty(valueStr))
- {
- return defaultValue;
- }
- try
- {
- return new BigDecimal(valueStr);
- }
- catch (Exception e)
- {
- return defaultValue;
- }
- }
-
- /**
- * 杞崲涓築igDecimal
- * 濡傛灉缁欏畾鐨勫间负绌猴紝鎴栬呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊
- * 杞崲澶辫触涓嶄細鎶ラ敊
- *
- * @param value 琚浆鎹㈢殑鍊
- * @return 缁撴灉
- */
- public static BigDecimal toBigDecimal(Object value)
- {
- return toBigDecimal(value, null);
- }
-
- /**
- * 灏嗗璞¤浆涓哄瓧绗︿覆
- * 1銆丅yte鏁扮粍鍜孊yteBuffer浼氳杞崲涓哄搴斿瓧绗︿覆鐨勬暟缁 2銆佸璞℃暟缁勪細璋冪敤Arrays.toString鏂规硶
- *
- * @param obj 瀵硅薄
- * @return 瀛楃涓
- */
- public static String utf8Str(Object obj)
- {
- return str(obj, CharsetKit.CHARSET_UTF_8);
- }
-
- /**
- * 灏嗗璞¤浆涓哄瓧绗︿覆
- * 1銆丅yte鏁扮粍鍜孊yteBuffer浼氳杞崲涓哄搴斿瓧绗︿覆鐨勬暟缁 2銆佸璞℃暟缁勪細璋冪敤Arrays.toString鏂规硶
- *
- * @param obj 瀵硅薄
- * @param charsetName 瀛楃闆
- * @return 瀛楃涓
- */
- public static String str(Object obj, String charsetName)
- {
- return str(obj, Charset.forName(charsetName));
- }
-
- /**
- * 灏嗗璞¤浆涓哄瓧绗︿覆
- * 1銆丅yte鏁扮粍鍜孊yteBuffer浼氳杞崲涓哄搴斿瓧绗︿覆鐨勬暟缁 2銆佸璞℃暟缁勪細璋冪敤Arrays.toString鏂规硶
- *
- * @param obj 瀵硅薄
- * @param charset 瀛楃闆
- * @return 瀛楃涓
- */
- public static String str(Object obj, Charset charset)
- {
- if (null == obj)
- {
- return null;
- }
-
- if (obj instanceof String)
- {
- return (String) obj;
- }
- else if (obj instanceof byte[] || obj instanceof Byte[])
- {
- return str((Byte[]) obj, charset);
- }
- else if (obj instanceof ByteBuffer)
- {
- return str((ByteBuffer) obj, charset);
- }
- return obj.toString();
- }
-
- /**
- * 灏哹yte鏁扮粍杞负瀛楃涓
- *
- * @param bytes byte鏁扮粍
- * @param charset 瀛楃闆
- * @return 瀛楃涓
- */
- public static String str(byte[] bytes, String charset)
- {
- return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset));
- }
-
- /**
- * 瑙g爜瀛楄妭鐮
- *
- * @param data 瀛楃涓
- * @param charset 瀛楃闆嗭紝濡傛灉姝ゅ瓧娈典负绌猴紝鍒欒В鐮佺殑缁撴灉鍙栧喅浜庡钩鍙
- * @return 瑙g爜鍚庣殑瀛楃涓
- */
- public static String str(byte[] data, Charset charset)
- {
- if (data == null)
- {
- return null;
- }
-
- if (null == charset)
- {
- return new String(data);
- }
- return new String(data, charset);
- }
-
- /**
- * 灏嗙紪鐮佺殑byteBuffer鏁版嵁杞崲涓哄瓧绗︿覆
- *
- * @param data 鏁版嵁
- * @param charset 瀛楃闆嗭紝濡傛灉涓虹┖浣跨敤褰撳墠绯荤粺瀛楃闆
- * @return 瀛楃涓
- */
- public static String str(ByteBuffer data, String charset)
- {
- if (data == null)
- {
- return null;
- }
-
- return str(data, Charset.forName(charset));
- }
-
- /**
- * 灏嗙紪鐮佺殑byteBuffer鏁版嵁杞崲涓哄瓧绗︿覆
- *
- * @param data 鏁版嵁
- * @param charset 瀛楃闆嗭紝濡傛灉涓虹┖浣跨敤褰撳墠绯荤粺瀛楃闆
- * @return 瀛楃涓
- */
- public static String str(ByteBuffer data, Charset charset)
- {
- if (null == charset)
- {
- charset = Charset.defaultCharset();
- }
- return charset.decode(data).toString();
- }
-
- // ----------------------------------------------------------------------- 鍏ㄨ鍗婅杞崲
- /**
- * 鍗婅杞叏瑙
- *
- * @param input String.
- * @return 鍏ㄨ瀛楃涓.
- */
- public static String toSBC(String input)
- {
- return toSBC(input, null);
- }
-
- /**
- * 鍗婅杞叏瑙
- *
- * @param input String
- * @param notConvertSet 涓嶆浛鎹㈢殑瀛楃闆嗗悎
- * @return 鍏ㄨ瀛楃涓.
- */
- public static String toSBC(String input, Set notConvertSet)
- {
- char c[] = input.toCharArray();
- for (int i = 0; i < c.length; i++)
- {
- if (null != notConvertSet && notConvertSet.contains(c[i]))
- {
- // 璺宠繃涓嶆浛鎹㈢殑瀛楃
- continue;
- }
-
- if (c[i] == ' ')
- {
- c[i] = '\u3000';
- }
- else if (c[i] < '\177')
- {
- c[i] = (char) (c[i] + 65248);
-
- }
- }
- return new String(c);
- }
-
- /**
- * 鍏ㄨ杞崐瑙
- *
- * @param input String.
- * @return 鍗婅瀛楃涓
- */
- public static String toDBC(String input)
- {
- return toDBC(input, null);
- }
-
- /**
- * 鏇挎崲鍏ㄨ涓哄崐瑙
- *
- * @param text 鏂囨湰
- * @param notConvertSet 涓嶆浛鎹㈢殑瀛楃闆嗗悎
- * @return 鏇挎崲鍚庣殑瀛楃
- */
- public static String toDBC(String text, Set notConvertSet)
- {
- char c[] = text.toCharArray();
- for (int i = 0; i < c.length; i++)
- {
- if (null != notConvertSet && notConvertSet.contains(c[i]))
- {
- // 璺宠繃涓嶆浛鎹㈢殑瀛楃
- continue;
- }
-
- if (c[i] == '\u3000')
- {
- c[i] = ' ';
- }
- else if (c[i] > '\uFF00' && c[i] < '\uFF5F')
- {
- c[i] = (char) (c[i] - 65248);
- }
- }
- String returnString = new String(c);
-
- return returnString;
- }
-
- /**
- * 鏁板瓧閲戦澶у啓杞崲 鍏堝啓涓畬鏁寸殑鐒跺悗灏嗗闆舵嬀鏇挎崲鎴愰浂
- *
- * @param n 鏁板瓧
- * @return 涓枃澶у啓鏁板瓧
- */
- public static String digitUppercase(double n)
- {
- String[] fraction = { "瑙", "鍒" };
- String[] digit = { "闆", "澹", "璐", "鍙", "鑲", "浼", "闄", "鏌", "鎹", "鐜" };
- String[][] unit = { { "鍏", "涓", "浜" }, { "", "鎷", "浣", "浠" } };
-
- String head = n < 0 ? "璐" : "";
- n = Math.abs(n);
-
- String s = "";
- for (int i = 0; i < fraction.length; i++)
- {
- s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(闆.)+", "");
- }
- if (s.length() < 1)
- {
- s = "鏁";
- }
- int integerPart = (int) Math.floor(n);
-
- for (int i = 0; i < unit[0].length && integerPart > 0; i++)
- {
- String p = "";
- for (int j = 0; j < unit[1].length && n > 0; j++)
- {
- p = digit[integerPart % 10] + unit[1][j] + p;
- integerPart = integerPart / 10;
- }
- s = p.replaceAll("(闆.)*闆$", "").replaceAll("^$", "闆") + unit[0][i] + s;
- }
- return head + s.replaceAll("(闆.)*闆跺厓", "鍏").replaceFirst("(闆.)+", "").replaceAll("(闆.)+", "闆").replaceAll("^鏁$", "闆跺厓鏁");
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/core/text/StrFormatter.java b/ruoyi/src/main/java/com/ruoyi/common/core/text/StrFormatter.java
deleted file mode 100644
index dbf3e237..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/core/text/StrFormatter.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package com.ruoyi.common.core.text;
-
-import com.ruoyi.common.utils.StringUtils;
-
-/**
- * 瀛楃涓叉牸寮忓寲
- *
- * @author ruoyi
- */
-public class StrFormatter
-{
- public static final String EMPTY_JSON = "{}";
- public static final char C_BACKSLASH = '\\';
- public static final char C_DELIM_START = '{';
- public static final char C_DELIM_END = '}';
-
- /**
- * 鏍煎紡鍖栧瓧绗︿覆
- * 姝ゆ柟娉曞彧鏄畝鍗曞皢鍗犱綅绗 {} 鎸夌収椤哄簭鏇挎崲涓哄弬鏁
- * 濡傛灉鎯宠緭鍑 {} 浣跨敤 \\杞箟 { 鍗冲彲锛屽鏋滄兂杈撳嚭 {} 涔嬪墠鐨 \ 浣跨敤鍙岃浆涔夌 \\\\ 鍗冲彲
- * 渚嬶細
- * 閫氬父浣跨敤锛歠ormat("this is {} for {}", "a", "b") -> this is a for b
- * 杞箟{}锛 format("this is \\{} for {}", "a", "b") -> this is \{} for a
- * 杞箟\锛 format("this is \\\\{} for {}", "a", "b") -> this is \a for b
- *
- * @param strPattern 瀛楃涓叉ā鏉
- * @param argArray 鍙傛暟鍒楄〃
- * @return 缁撴灉
- */
- public static String format(final String strPattern, final Object... argArray)
- {
- if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray))
- {
- return strPattern;
- }
- final int strPatternLength = strPattern.length();
-
- // 鍒濆鍖栧畾涔夊ソ鐨勯暱搴︿互鑾峰緱鏇村ソ鐨勬ц兘
- StringBuilder sbuf = new StringBuilder(strPatternLength + 50);
-
- int handledPosition = 0;
- int delimIndex;// 鍗犱綅绗︽墍鍦ㄤ綅缃
- for (int argIndex = 0; argIndex < argArray.length; argIndex++)
- {
- delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition);
- if (delimIndex == -1)
- {
- if (handledPosition == 0)
- {
- return strPattern;
- }
- else
- { // 瀛楃涓叉ā鏉垮墿浣欓儴鍒嗕笉鍐嶅寘鍚崰浣嶇锛屽姞鍏ュ墿浣欓儴鍒嗗悗杩斿洖缁撴灉
- sbuf.append(strPattern, handledPosition, strPatternLength);
- return sbuf.toString();
- }
- }
- else
- {
- if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH)
- {
- if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH)
- {
- // 杞箟绗︿箣鍓嶈繕鏈変竴涓浆涔夌锛屽崰浣嶇渚濇棫鏈夋晥
- sbuf.append(strPattern, handledPosition, delimIndex - 1);
- sbuf.append(Convert.utf8Str(argArray[argIndex]));
- handledPosition = delimIndex + 2;
- }
- else
- {
- // 鍗犱綅绗﹁杞箟
- argIndex--;
- sbuf.append(strPattern, handledPosition, delimIndex - 1);
- sbuf.append(C_DELIM_START);
- handledPosition = delimIndex + 1;
- }
- }
- else
- {
- // 姝e父鍗犱綅绗
- sbuf.append(strPattern, handledPosition, delimIndex);
- sbuf.append(Convert.utf8Str(argArray[argIndex]));
- handledPosition = delimIndex + 2;
- }
- }
- }
- // 鍔犲叆鏈鍚庝竴涓崰浣嶇鍚庢墍鏈夌殑瀛楃
- sbuf.append(strPattern, handledPosition, strPattern.length());
-
- return sbuf.toString();
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/enums/HttpMethod.java b/ruoyi/src/main/java/com/ruoyi/common/enums/HttpMethod.java
deleted file mode 100644
index 2fa9f867..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/enums/HttpMethod.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.ruoyi.common.enums;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.springframework.lang.Nullable;
-
-/**
- * 璇锋眰鏂瑰紡
- *
- * @author ruoyi
- */
-public enum HttpMethod
-{
- GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
-
- private static final Map mappings = new HashMap<>(16);
-
- static
- {
- for (HttpMethod httpMethod : values())
- {
- mappings.put(httpMethod.name(), httpMethod);
- }
- }
-
- @Nullable
- public static HttpMethod resolve(@Nullable String method)
- {
- return (method != null ? mappings.get(method) : null);
- }
-
- public boolean matches(String method)
- {
- return (this == resolve(method));
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/enums/UserStatus.java b/ruoyi/src/main/java/com/ruoyi/common/enums/UserStatus.java
deleted file mode 100644
index a4613ff9..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/enums/UserStatus.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.ruoyi.common.enums;
-
-/**
- * 鐢ㄦ埛鐘舵
- *
- * @author ruoyi
- */
-public enum UserStatus
-{
- OK("0", "姝e父"), DISABLE("1", "鍋滅敤"), DELETED("2", "鍒犻櫎");
-
- private final String code;
- private final String info;
-
- UserStatus(String code, String info)
- {
- this.code = code;
- this.info = info;
- }
-
- public String getCode()
- {
- return code;
- }
-
- public String getInfo()
- {
- return info;
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/BaseException.java b/ruoyi/src/main/java/com/ruoyi/common/exception/BaseException.java
deleted file mode 100644
index c1e55c17..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/exception/BaseException.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package com.ruoyi.common.exception;
-
-import com.ruoyi.common.utils.MessageUtils;
-import com.ruoyi.common.utils.StringUtils;
-
-/**
- * 鍩虹寮傚父
- *
- * @author ruoyi
- */
-public class BaseException extends RuntimeException
-{
- private static final long serialVersionUID = 1L;
-
- /**
- * 鎵灞炴ā鍧
- */
- private String module;
-
- /**
- * 閿欒鐮
- */
- private String code;
-
- /**
- * 閿欒鐮佸搴旂殑鍙傛暟
- */
- private Object[] args;
-
- /**
- * 閿欒娑堟伅
- */
- private String defaultMessage;
-
- public BaseException(String module, String code, Object[] args, String defaultMessage)
- {
- this.module = module;
- this.code = code;
- this.args = args;
- this.defaultMessage = defaultMessage;
- }
-
- public BaseException(String module, String code, Object[] args)
- {
- this(module, code, args, null);
- }
-
- public BaseException(String module, String defaultMessage)
- {
- this(module, null, null, defaultMessage);
- }
-
- public BaseException(String code, Object[] args)
- {
- this(null, code, args, null);
- }
-
- public BaseException(String defaultMessage)
- {
- this(null, null, null, defaultMessage);
- }
-
- @Override
- public String getMessage()
- {
- String message = null;
- if (!StringUtils.isEmpty(code))
- {
- message = MessageUtils.message(code, args);
- }
- if (message == null)
- {
- message = defaultMessage;
- }
- return message;
- }
-
- public String getModule()
- {
- return module;
- }
-
- public String getCode()
- {
- return code;
- }
-
- public Object[] getArgs()
- {
- return args;
- }
-
- public String getDefaultMessage()
- {
- return defaultMessage;
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/CustomException.java b/ruoyi/src/main/java/com/ruoyi/common/exception/CustomException.java
deleted file mode 100644
index a99a1001..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/exception/CustomException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.ruoyi.common.exception;
-
-/**
- * 鑷畾涔夊紓甯
- *
- * @author ruoyi
- */
-public class CustomException extends RuntimeException
-{
- private static final long serialVersionUID = 1L;
-
- private Integer code;
-
- private String message;
-
- public CustomException(String message)
- {
- this.message = message;
- }
-
- public CustomException(String message, Integer code)
- {
- this.message = message;
- this.code = code;
- }
-
- public CustomException(String message, Throwable e)
- {
- super(message, e);
- this.message = message;
- }
-
- @Override
- public String getMessage()
- {
- return message;
- }
-
- public Integer getCode()
- {
- return code;
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/DemoModeException.java b/ruoyi/src/main/java/com/ruoyi/common/exception/DemoModeException.java
deleted file mode 100644
index 57bffc47..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/exception/DemoModeException.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.ruoyi.common.exception;
-
-/**
- * 婕旂ず妯″紡寮傚父
- *
- * @author ruoyi
- */
-public class DemoModeException extends RuntimeException
-{
- private static final long serialVersionUID = 1L;
-
- public DemoModeException()
- {
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/UtilException.java b/ruoyi/src/main/java/com/ruoyi/common/exception/UtilException.java
deleted file mode 100644
index a544fb64..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/exception/UtilException.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.ruoyi.common.exception;
-
-/**
- * 宸ュ叿绫诲紓甯
- *
- * @author ruoyi
- */
-public class UtilException extends RuntimeException
-{
- private static final long serialVersionUID = 8247610319171014183L;
-
- public UtilException(Throwable e)
- {
- super(e.getMessage(), e);
- }
-
- public UtilException(String message)
- {
- super(message);
- }
-
- public UtilException(String message, Throwable throwable)
- {
- super(message, throwable);
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/file/FileException.java b/ruoyi/src/main/java/com/ruoyi/common/exception/file/FileException.java
deleted file mode 100644
index f0ae563a..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/exception/file/FileException.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.ruoyi.common.exception.file;
-
-import com.ruoyi.common.exception.BaseException;
-
-/**
- * 鏂囦欢淇℃伅寮傚父绫
- *
- * @author ruoyi
- */
-public class FileException extends BaseException
-{
- private static final long serialVersionUID = 1L;
-
- public FileException(String code, Object[] args)
- {
- super("file", code, args, null);
- }
-
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java b/ruoyi/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java
deleted file mode 100644
index 44941b8b..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.ruoyi.common.exception.file;
-
-/**
- * 鏂囦欢鍚嶇О瓒呴暱闄愬埗寮傚父绫
- *
- * @author ruoyi
- */
-public class FileNameLengthLimitExceededException extends FileException
-{
- private static final long serialVersionUID = 1L;
-
- public FileNameLengthLimitExceededException(int defaultFileNameLength)
- {
- super("upload.filename.exceed.length", new Object[] { defaultFileNameLength });
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java b/ruoyi/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java
deleted file mode 100644
index f855e72f..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.ruoyi.common.exception.file;
-
-/**
- * 鏂囦欢鍚嶅ぇ灏忛檺鍒跺紓甯哥被
- *
- * @author ruoyi
- */
-public class FileSizeLimitExceededException extends FileException
-{
- private static final long serialVersionUID = 1L;
-
- public FileSizeLimitExceededException(long defaultMaxSize)
- {
- super("upload.exceed.maxSize", new Object[] { defaultMaxSize });
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java b/ruoyi/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java
deleted file mode 100644
index 81cd78b8..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.ruoyi.common.exception.file;
-
-import java.util.Arrays;
-import org.apache.commons.fileupload.FileUploadException;
-
-/**
- * 鏂囦欢涓婁紶 璇紓甯哥被
- *
- * @author ruoyi
- */
-public class InvalidExtensionException extends FileUploadException
-{
- private static final long serialVersionUID = 1L;
-
- private String[] allowedExtension;
- private String extension;
- private String filename;
-
- public InvalidExtensionException(String[] allowedExtension, String extension, String filename)
- {
- super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]");
- this.allowedExtension = allowedExtension;
- this.extension = extension;
- this.filename = filename;
- }
-
- public String[] getAllowedExtension()
- {
- return allowedExtension;
- }
-
- public String getExtension()
- {
- return extension;
- }
-
- public String getFilename()
- {
- return filename;
- }
-
- public static class InvalidImageExtensionException extends InvalidExtensionException
- {
- private static final long serialVersionUID = 1L;
-
- public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename)
- {
- super(allowedExtension, extension, filename);
- }
- }
-
- public static class InvalidFlashExtensionException extends InvalidExtensionException
- {
- private static final long serialVersionUID = 1L;
-
- public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename)
- {
- super(allowedExtension, extension, filename);
- }
- }
-
- public static class InvalidMediaExtensionException extends InvalidExtensionException
- {
- private static final long serialVersionUID = 1L;
-
- public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename)
- {
- super(allowedExtension, extension, filename);
- }
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java b/ruoyi/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java
deleted file mode 100644
index e3334ae3..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.ruoyi.common.exception.user;
-
-/**
- * 楠岃瘉鐮侀敊璇紓甯哥被
- *
- * @author ruoyi
- */
-public class CaptchaException extends UserException
-{
- private static final long serialVersionUID = 1L;
-
- public CaptchaException()
- {
- super("user.jcaptcha.error", null);
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/user/CaptchaExpireException.java b/ruoyi/src/main/java/com/ruoyi/common/exception/user/CaptchaExpireException.java
deleted file mode 100644
index 5e6fd0f7..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/exception/user/CaptchaExpireException.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.ruoyi.common.exception.user;
-
-/**
- * 楠岃瘉鐮佸け鏁堝紓甯哥被
- *
- * @author ruoyi
- */
-public class CaptchaExpireException extends UserException
-{
- private static final long serialVersionUID = 1L;
-
- public CaptchaExpireException()
- {
- super("user.jcaptcha.expire", null);
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/user/UserException.java b/ruoyi/src/main/java/com/ruoyi/common/exception/user/UserException.java
deleted file mode 100644
index b85dab6d..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/exception/user/UserException.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.ruoyi.common.exception.user;
-
-import com.ruoyi.common.exception.BaseException;
-
-/**
- * 鐢ㄦ埛淇℃伅寮傚父绫
- *
- * @author ruoyi
- */
-public class UserException extends BaseException
-{
- private static final long serialVersionUID = 1L;
-
- public UserException(String code, Object[] args)
- {
- super("user", code, args, null);
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java b/ruoyi/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java
deleted file mode 100644
index 71449e29..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.ruoyi.common.exception.user;
-
-/**
- * 鐢ㄦ埛瀵嗙爜涓嶆纭垨涓嶇鍚堣鑼冨紓甯哥被
- *
- * @author ruoyi
- */
-public class UserPasswordNotMatchException extends UserException
-{
- private static final long serialVersionUID = 1L;
-
- public UserPasswordNotMatchException()
- {
- super("user.password.not.match", null);
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/Arith.java b/ruoyi/src/main/java/com/ruoyi/common/utils/Arith.java
deleted file mode 100644
index 86683197..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/Arith.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package com.ruoyi.common.utils;
-
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-
-/**
- * 绮剧‘鐨勬诞鐐规暟杩愮畻
- *
- * @author ruoyi
- */
-public class Arith
-{
-
- /** 榛樿闄ゆ硶杩愮畻绮惧害 */
- private static final int DEF_DIV_SCALE = 10;
-
- /** 杩欎釜绫讳笉鑳藉疄渚嬪寲 */
- private Arith()
- {
- }
-
- /**
- * 鎻愪緵绮剧‘鐨勫姞娉曡繍绠椼
- * @param v1 琚姞鏁
- * @param v2 鍔犳暟
- * @return 涓や釜鍙傛暟鐨勫拰
- */
- public static double add(double v1, double v2)
- {
- BigDecimal b1 = new BigDecimal(Double.toString(v1));
- BigDecimal b2 = new BigDecimal(Double.toString(v2));
- return b1.add(b2).doubleValue();
- }
-
- /**
- * 鎻愪緵绮剧‘鐨勫噺娉曡繍绠椼
- * @param v1 琚噺鏁
- * @param v2 鍑忔暟
- * @return 涓や釜鍙傛暟鐨勫樊
- */
- public static double sub(double v1, double v2)
- {
- BigDecimal b1 = new BigDecimal(Double.toString(v1));
- BigDecimal b2 = new BigDecimal(Double.toString(v2));
- return b1.subtract(b2).doubleValue();
- }
-
- /**
- * 鎻愪緵绮剧‘鐨勪箻娉曡繍绠椼
- * @param v1 琚箻鏁
- * @param v2 涔樻暟
- * @return 涓や釜鍙傛暟鐨勭Н
- */
- public static double mul(double v1, double v2)
- {
- BigDecimal b1 = new BigDecimal(Double.toString(v1));
- BigDecimal b2 = new BigDecimal(Double.toString(v2));
- return b1.multiply(b2).doubleValue();
- }
-
- /**
- * 鎻愪緵锛堢浉瀵癸級绮剧‘鐨勯櫎娉曡繍绠楋紝褰撳彂鐢熼櫎涓嶅敖鐨勬儏鍐垫椂锛岀簿纭埌
- * 灏忔暟鐐逛互鍚10浣嶏紝浠ュ悗鐨勬暟瀛楀洓鑸嶄簲鍏ャ
- * @param v1 琚櫎鏁
- * @param v2 闄ゆ暟
- * @return 涓や釜鍙傛暟鐨勫晢
- */
- public static double div(double v1, double v2)
- {
- return div(v1, v2, DEF_DIV_SCALE);
- }
-
- /**
- * 鎻愪緵锛堢浉瀵癸級绮剧‘鐨勯櫎娉曡繍绠椼傚綋鍙戠敓闄や笉灏界殑鎯呭喌鏃讹紝鐢眘cale鍙傛暟鎸
- * 瀹氱簿搴︼紝浠ュ悗鐨勬暟瀛楀洓鑸嶄簲鍏ャ
- * @param v1 琚櫎鏁
- * @param v2 闄ゆ暟
- * @param scale 琛ㄧず琛ㄧず闇瑕佺簿纭埌灏忔暟鐐逛互鍚庡嚑浣嶃
- * @return 涓や釜鍙傛暟鐨勫晢
- */
- public static double div(double v1, double v2, int scale)
- {
- if (scale < 0)
- {
- throw new IllegalArgumentException(
- "The scale must be a positive integer or zero");
- }
- BigDecimal b1 = new BigDecimal(Double.toString(v1));
- BigDecimal b2 = new BigDecimal(Double.toString(v2));
- if (b1.compareTo(BigDecimal.ZERO) == 0)
- {
- return BigDecimal.ZERO.doubleValue();
- }
- return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue();
- }
-
- /**
- * 鎻愪緵绮剧‘鐨勫皬鏁颁綅鍥涜垗浜斿叆澶勭悊銆
- * @param v 闇瑕佸洓鑸嶄簲鍏ョ殑鏁板瓧
- * @param scale 灏忔暟鐐瑰悗淇濈暀鍑犱綅
- * @return 鍥涜垗浜斿叆鍚庣殑缁撴灉
- */
- public static double round(double v, int scale)
- {
- if (scale < 0)
- {
- throw new IllegalArgumentException(
- "The scale must be a positive integer or zero");
- }
- BigDecimal b = new BigDecimal(Double.toString(v));
- BigDecimal one = new BigDecimal("1");
- return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue();
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/DateUtils.java b/ruoyi/src/main/java/com/ruoyi/common/utils/DateUtils.java
deleted file mode 100644
index 8ff95f1b..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/DateUtils.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package com.ruoyi.common.utils;
-
-import java.lang.management.ManagementFactory;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import org.apache.commons.lang3.time.DateFormatUtils;
-
-/**
- * 鏃堕棿宸ュ叿绫
- *
- * @author ruoyi
- */
-public class DateUtils extends org.apache.commons.lang3.time.DateUtils
-{
- public static String YYYY = "yyyy";
-
- public static String YYYY_MM = "yyyy-MM";
-
- public static String YYYY_MM_DD = "yyyy-MM-dd";
-
- public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
-
- public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
-
- private static String[] parsePatterns = {
- "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
- "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
- "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
-
- /**
- * 鑾峰彇褰撳墠Date鍨嬫棩鏈
- *
- * @return Date() 褰撳墠鏃ユ湡
- */
- public static Date getNowDate()
- {
- return new Date();
- }
-
- /**
- * 鑾峰彇褰撳墠鏃ユ湡, 榛樿鏍煎紡涓簓yyy-MM-dd
- *
- * @return String
- */
- public static String getDate()
- {
- return dateTimeNow(YYYY_MM_DD);
- }
-
- public static final String getTime()
- {
- return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
- }
-
- public static final String dateTimeNow()
- {
- return dateTimeNow(YYYYMMDDHHMMSS);
- }
-
- public static final String dateTimeNow(final String format)
- {
- return parseDateToStr(format, new Date());
- }
-
- public static final String dateTime(final Date date)
- {
- return parseDateToStr(YYYY_MM_DD, date);
- }
-
- public static final String parseDateToStr(final String format, final Date date)
- {
- return new SimpleDateFormat(format).format(date);
- }
-
- public static final Date dateTime(final String format, final String ts)
- {
- try
- {
- return new SimpleDateFormat(format).parse(ts);
- }
- catch (ParseException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * 鏃ユ湡璺緞 鍗冲勾/鏈/鏃 濡2018/08/08
- */
- public static final String datePath()
- {
- Date now = new Date();
- return DateFormatUtils.format(now, "yyyy/MM/dd");
- }
-
- /**
- * 鏃ユ湡璺緞 鍗冲勾/鏈/鏃 濡20180808
- */
- public static final String dateTime()
- {
- Date now = new Date();
- return DateFormatUtils.format(now, "yyyyMMdd");
- }
-
- /**
- * 鏃ユ湡鍨嬪瓧绗︿覆杞寲涓烘棩鏈 鏍煎紡
- */
- public static Date parseDate(Object str)
- {
- if (str == null)
- {
- return null;
- }
- try
- {
- return parseDate(str.toString(), parsePatterns);
- }
- catch (ParseException e)
- {
- return null;
- }
- }
-
- /**
- * 鑾峰彇鏈嶅姟鍣ㄥ惎鍔ㄦ椂闂
- */
- public static Date getServerStartDate()
- {
- long time = ManagementFactory.getRuntimeMXBean().getStartTime();
- return new Date(time);
- }
-
- /**
- * 璁$畻涓や釜鏃堕棿宸
- */
- public static String getDatePoor(Date endDate, Date nowDate)
- {
- long nd = 1000 * 24 * 60 * 60;
- long nh = 1000 * 60 * 60;
- long nm = 1000 * 60;
- // long ns = 1000;
- // 鑾峰緱涓や釜鏃堕棿鐨勬绉掓椂闂村樊寮
- long diff = endDate.getTime() - nowDate.getTime();
- // 璁$畻宸灏戝ぉ
- long day = diff / nd;
- // 璁$畻宸灏戝皬鏃
- long hour = diff % nd / nh;
- // 璁$畻宸灏戝垎閽
- long min = diff % nd % nh / nm;
- // 璁$畻宸灏戠//杈撳嚭缁撴灉
- // long sec = diff % nd % nh % nm / ns;
- return day + "澶" + hour + "灏忔椂" + min + "鍒嗛挓";
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/IdUtils.java b/ruoyi/src/main/java/com/ruoyi/common/utils/IdUtils.java
deleted file mode 100644
index 45d8ac91..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/IdUtils.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.ruoyi.common.utils;
-
-import com.ruoyi.common.core.lang.UUID;
-
-/**
- * ID鐢熸垚鍣ㄥ伐鍏风被
- *
- * @author ruoyi
- */
-public class IdUtils
-{
- /**
- * 鑾峰彇闅忔満UUID
- *
- * @return 闅忔満UUID
- */
- public static String randomUUID()
- {
- return UUID.randomUUID().toString();
- }
-
- /**
- * 绠鍖栫殑UUID锛屽幓鎺変簡妯嚎
- *
- * @return 绠鍖栫殑UUID锛屽幓鎺変簡妯嚎
- */
- public static String simpleUUID()
- {
- return UUID.randomUUID().toString(true);
- }
-
- /**
- * 鑾峰彇闅忔満UUID锛屼娇鐢ㄦц兘鏇村ソ鐨凾hreadLocalRandom鐢熸垚UUID
- *
- * @return 闅忔満UUID
- */
- public static String fastUUID()
- {
- return UUID.fastUUID().toString();
- }
-
- /**
- * 绠鍖栫殑UUID锛屽幓鎺変簡妯嚎锛屼娇鐢ㄦц兘鏇村ソ鐨凾hreadLocalRandom鐢熸垚UUID
- *
- * @return 绠鍖栫殑UUID锛屽幓鎺変簡妯嚎
- */
- public static String fastSimpleUUID()
- {
- return UUID.fastUUID().toString(true);
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/LogUtils.java b/ruoyi/src/main/java/com/ruoyi/common/utils/LogUtils.java
deleted file mode 100644
index e415c9c3..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/LogUtils.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.ruoyi.common.utils;
-
-/**
- * 澶勭悊骞惰褰曟棩蹇楁枃浠
- *
- * @author ruoyi
- */
-public class LogUtils
-{
- public static String getBlock(Object msg)
- {
- if (msg == null)
- {
- msg = "";
- }
- return "[" + msg.toString() + "]";
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/MessageUtils.java b/ruoyi/src/main/java/com/ruoyi/common/utils/MessageUtils.java
deleted file mode 100644
index 5f2d9ea2..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/MessageUtils.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.ruoyi.common.utils;
-
-import org.springframework.context.MessageSource;
-import org.springframework.context.i18n.LocaleContextHolder;
-import com.ruoyi.common.utils.spring.SpringUtils;
-
-/**
- * 鑾峰彇i18n璧勬簮鏂囦欢
- *
- * @author ruoyi
- */
-public class MessageUtils
-{
- /**
- * 鏍规嵁娑堟伅閿拰鍙傛暟 鑾峰彇娑堟伅 濮旀墭缁檚pring messageSource
- *
- * @param code 娑堟伅閿
- * @param args 鍙傛暟
- * @return 鑾峰彇鍥介檯鍖栫炕璇戝
- */
- public static String message(String code, Object... args)
- {
- MessageSource messageSource = SpringUtils.getBean(MessageSource.class);
- return messageSource.getMessage(code, args, LocaleContextHolder.getLocale());
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/SecurityUtils.java b/ruoyi/src/main/java/com/ruoyi/common/utils/SecurityUtils.java
deleted file mode 100644
index c8d1783e..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/SecurityUtils.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package com.ruoyi.common.utils;
-
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import com.ruoyi.common.constant.HttpStatus;
-import com.ruoyi.common.exception.CustomException;
-import com.ruoyi.framework.security.LoginUser;
-
-/**
- * 瀹夊叏鏈嶅姟宸ュ叿绫
- *
- * @author ruoyi
- */
-public class SecurityUtils
-{
- /**
- * 鑾峰彇鐢ㄦ埛璐︽埛
- **/
- public static String getUsername()
- {
- try
- {
- return getLoginUser().getUsername();
- }
- catch (Exception e)
- {
- throw new CustomException("鑾峰彇鐢ㄦ埛璐︽埛寮傚父", HttpStatus.UNAUTHORIZED);
- }
- }
-
- /**
- * 鑾峰彇鐢ㄦ埛
- **/
- public static LoginUser getLoginUser()
- {
- try
- {
- return (LoginUser) getAuthentication().getPrincipal();
- }
- catch (Exception e)
- {
- throw new CustomException("鑾峰彇鐢ㄦ埛淇℃伅寮傚父", HttpStatus.UNAUTHORIZED);
- }
- }
-
- /**
- * 鑾峰彇Authentication
- */
- public static Authentication getAuthentication()
- {
- return SecurityContextHolder.getContext().getAuthentication();
- }
-
- /**
- * 鐢熸垚BCryptPasswordEncoder瀵嗙爜
- *
- * @param password 瀵嗙爜
- * @return 鍔犲瘑瀛楃涓
- */
- public static String encryptPassword(String password)
- {
- BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
- return passwordEncoder.encode(password);
- }
-
- /**
- * 鍒ゆ柇瀵嗙爜鏄惁鐩稿悓
- *
- * @param rawPassword 鐪熷疄瀵嗙爜
- * @param encodedPassword 鍔犲瘑鍚庡瓧绗
- * @return 缁撴灉
- */
- public static boolean matchesPassword(String rawPassword, String encodedPassword)
- {
- BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
- return passwordEncoder.matches(rawPassword, encodedPassword);
- }
-
- /**
- * 鏄惁涓虹鐞嗗憳
- *
- * @param userId 鐢ㄦ埛ID
- * @return 缁撴灉
- */
- public static boolean isAdmin(Long userId)
- {
- return userId != null && 1L == userId;
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/ServletUtils.java b/ruoyi/src/main/java/com/ruoyi/common/utils/ServletUtils.java
deleted file mode 100644
index 9e6fd59a..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/ServletUtils.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package com.ruoyi.common.utils;
-
-import java.io.IOException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import org.springframework.web.context.request.RequestAttributes;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
-import com.ruoyi.common.core.text.Convert;
-
-/**
- * 瀹㈡埛绔伐鍏风被
- *
- * @author ruoyi
- */
-public class ServletUtils
-{
- /**
- * 鑾峰彇String鍙傛暟
- */
- public static String getParameter(String name)
- {
- return getRequest().getParameter(name);
- }
-
- /**
- * 鑾峰彇String鍙傛暟
- */
- public static String getParameter(String name, String defaultValue)
- {
- return Convert.toStr(getRequest().getParameter(name), defaultValue);
- }
-
- /**
- * 鑾峰彇Integer鍙傛暟
- */
- public static Integer getParameterToInt(String name)
- {
- return Convert.toInt(getRequest().getParameter(name));
- }
-
- /**
- * 鑾峰彇Integer鍙傛暟
- */
- public static Integer getParameterToInt(String name, Integer defaultValue)
- {
- return Convert.toInt(getRequest().getParameter(name), defaultValue);
- }
-
- /**
- * 鑾峰彇request
- */
- public static HttpServletRequest getRequest()
- {
- return getRequestAttributes().getRequest();
- }
-
- /**
- * 鑾峰彇response
- */
- public static HttpServletResponse getResponse()
- {
- return getRequestAttributes().getResponse();
- }
-
- /**
- * 鑾峰彇session
- */
- public static HttpSession getSession()
- {
- return getRequest().getSession();
- }
-
- public static ServletRequestAttributes getRequestAttributes()
- {
- RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
- return (ServletRequestAttributes) attributes;
- }
-
- /**
- * 灏嗗瓧绗︿覆娓叉煋鍒板鎴风
- *
- * @param response 娓叉煋瀵硅薄
- * @param string 寰呮覆鏌撶殑瀛楃涓
- * @return null
- */
- public static String renderString(HttpServletResponse response, String string)
- {
- try
- {
- response.setStatus(200);
- response.setContentType("application/json");
- response.setCharacterEncoding("utf-8");
- response.getWriter().print(string);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * 鏄惁鏄疉jax寮傛璇锋眰
- *
- * @param request
- */
- public static boolean isAjaxRequest(HttpServletRequest request)
- {
- String accept = request.getHeader("accept");
- if (accept != null && accept.indexOf("application/json") != -1)
- {
- return true;
- }
-
- String xRequestedWith = request.getHeader("X-Requested-With");
- if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1)
- {
- return true;
- }
-
- String uri = request.getRequestURI();
- if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml"))
- {
- return true;
- }
-
- String ajax = request.getParameter("__ajax");
- if (StringUtils.inStringIgnoreCase(ajax, "json", "xml"))
- {
- return true;
- }
- return false;
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/StringUtils.java b/ruoyi/src/main/java/com/ruoyi/common/utils/StringUtils.java
deleted file mode 100644
index a865c35d..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/StringUtils.java
+++ /dev/null
@@ -1,453 +0,0 @@
-package com.ruoyi.common.utils;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import com.ruoyi.common.core.text.StrFormatter;
-
-/**
- * 瀛楃涓插伐鍏风被
- *
- * @author ruoyi
- */
-public class StringUtils extends org.apache.commons.lang3.StringUtils
-{
- /** 绌哄瓧绗︿覆 */
- private static final String NULLSTR = "";
-
- /** 涓嬪垝绾 */
- private static final char SEPARATOR = '_';
-
- /**
- * 鑾峰彇鍙傛暟涓嶄负绌哄
- *
- * @param value defaultValue 瑕佸垽鏂殑value
- * @return value 杩斿洖鍊
- */
- public static T nvl(T value, T defaultValue)
- {
- return value != null ? value : defaultValue;
- }
-
- /**
- * * 鍒ゆ柇涓涓狢ollection鏄惁涓虹┖锛 鍖呭惈List锛孲et锛孮ueue
- *
- * @param coll 瑕佸垽鏂殑Collection
- * @return true锛氫负绌 false锛氶潪绌
- */
- public static boolean isEmpty(Collection> coll)
- {
- return isNull(coll) || coll.isEmpty();
- }
-
- /**
- * * 鍒ゆ柇涓涓狢ollection鏄惁闈炵┖锛屽寘鍚獿ist锛孲et锛孮ueue
- *
- * @param coll 瑕佸垽鏂殑Collection
- * @return true锛氶潪绌 false锛氱┖
- */
- public static boolean isNotEmpty(Collection> coll)
- {
- return !isEmpty(coll);
- }
-
- /**
- * * 鍒ゆ柇涓涓璞℃暟缁勬槸鍚︿负绌
- *
- * @param objects 瑕佸垽鏂殑瀵硅薄鏁扮粍
- ** @return true锛氫负绌 false锛氶潪绌
- */
- public static boolean isEmpty(Object[] objects)
- {
- return isNull(objects) || (objects.length == 0);
- }
-
- /**
- * * 鍒ゆ柇涓涓璞℃暟缁勬槸鍚﹂潪绌
- *
- * @param objects 瑕佸垽鏂殑瀵硅薄鏁扮粍
- * @return true锛氶潪绌 false锛氱┖
- */
- public static boolean isNotEmpty(Object[] objects)
- {
- return !isEmpty(objects);
- }
-
- /**
- * * 鍒ゆ柇涓涓狹ap鏄惁涓虹┖
- *
- * @param map 瑕佸垽鏂殑Map
- * @return true锛氫负绌 false锛氶潪绌
- */
- public static boolean isEmpty(Map, ?> map)
- {
- return isNull(map) || map.isEmpty();
- }
-
- /**
- * * 鍒ゆ柇涓涓狹ap鏄惁涓虹┖
- *
- * @param map 瑕佸垽鏂殑Map
- * @return true锛氶潪绌 false锛氱┖
- */
- public static boolean isNotEmpty(Map, ?> map)
- {
- return !isEmpty(map);
- }
-
- /**
- * * 鍒ゆ柇涓涓瓧绗︿覆鏄惁涓虹┖涓
- *
- * @param str String
- * @return true锛氫负绌 false锛氶潪绌
- */
- public static boolean isEmpty(String str)
- {
- return isNull(str) || NULLSTR.equals(str.trim());
- }
-
- /**
- * * 鍒ゆ柇涓涓瓧绗︿覆鏄惁涓洪潪绌轰覆
- *
- * @param str String
- * @return true锛氶潪绌轰覆 false锛氱┖涓
- */
- public static boolean isNotEmpty(String str)
- {
- return !isEmpty(str);
- }
-
- /**
- * * 鍒ゆ柇涓涓璞℃槸鍚︿负绌
- *
- * @param object Object
- * @return true锛氫负绌 false锛氶潪绌
- */
- public static boolean isNull(Object object)
- {
- return object == null;
- }
-
- /**
- * * 鍒ゆ柇涓涓璞℃槸鍚﹂潪绌
- *
- * @param object Object
- * @return true锛氶潪绌 false锛氱┖
- */
- public static boolean isNotNull(Object object)
- {
- return !isNull(object);
- }
-
- /**
- * * 鍒ゆ柇涓涓璞℃槸鍚︽槸鏁扮粍绫诲瀷锛圝ava鍩烘湰鍨嬪埆鐨勬暟缁勶級
- *
- * @param object 瀵硅薄
- * @return true锛氭槸鏁扮粍 false锛氫笉鏄暟缁
- */
- public static boolean isArray(Object object)
- {
- return isNotNull(object) && object.getClass().isArray();
- }
-
- /**
- * 鍘荤┖鏍
- */
- public static String trim(String str)
- {
- return (str == null ? "" : str.trim());
- }
-
- /**
- * 鎴彇瀛楃涓
- *
- * @param str 瀛楃涓
- * @param start 寮濮
- * @return 缁撴灉
- */
- public static String substring(final String str, int start)
- {
- if (str == null)
- {
- return NULLSTR;
- }
-
- if (start < 0)
- {
- start = str.length() + start;
- }
-
- if (start < 0)
- {
- start = 0;
- }
- if (start > str.length())
- {
- return NULLSTR;
- }
-
- return str.substring(start);
- }
-
- /**
- * 鎴彇瀛楃涓
- *
- * @param str 瀛楃涓
- * @param start 寮濮
- * @param end 缁撴潫
- * @return 缁撴灉
- */
- public static String substring(final String str, int start, int end)
- {
- if (str == null)
- {
- return NULLSTR;
- }
-
- if (end < 0)
- {
- end = str.length() + end;
- }
- if (start < 0)
- {
- start = str.length() + start;
- }
-
- if (end > str.length())
- {
- end = str.length();
- }
-
- if (start > end)
- {
- return NULLSTR;
- }
-
- if (start < 0)
- {
- start = 0;
- }
- if (end < 0)
- {
- end = 0;
- }
-
- return str.substring(start, end);
- }
-
- /**
- * 鏍煎紡鍖栨枃鏈, {} 琛ㄧず鍗犱綅绗
- * 姝ゆ柟娉曞彧鏄畝鍗曞皢鍗犱綅绗 {} 鎸夌収椤哄簭鏇挎崲涓哄弬鏁
- * 濡傛灉鎯宠緭鍑 {} 浣跨敤 \\杞箟 { 鍗冲彲锛屽鏋滄兂杈撳嚭 {} 涔嬪墠鐨 \ 浣跨敤鍙岃浆涔夌 \\\\ 鍗冲彲
- * 渚嬶細
- * 閫氬父浣跨敤锛歠ormat("this is {} for {}", "a", "b") -> this is a for b
- * 杞箟{}锛 format("this is \\{} for {}", "a", "b") -> this is \{} for a
- * 杞箟\锛 format("this is \\\\{} for {}", "a", "b") -> this is \a for b
- *
- * @param template 鏂囨湰妯℃澘锛岃鏇挎崲鐨勯儴鍒嗙敤 {} 琛ㄧず
- * @param params 鍙傛暟鍊
- * @return 鏍煎紡鍖栧悗鐨勬枃鏈
- */
- public static String format(String template, Object... params)
- {
- if (isEmpty(params) || isEmpty(template))
- {
- return template;
- }
- return StrFormatter.format(template, params);
- }
-
- /**
- * 瀛楃涓茶浆set
- *
- * @param str 瀛楃涓
- * @param sep 鍒嗛殧绗
- * @return set闆嗗悎
- */
- public static final Set str2Set(String str, String sep)
- {
- return new HashSet(str2List(str, sep, true, false));
- }
-
- /**
- * 瀛楃涓茶浆list
- *
- * @param str 瀛楃涓
- * @param sep 鍒嗛殧绗
- * @param filterBlank 杩囨护绾┖鐧
- * @param trim 鍘绘帀棣栧熬绌虹櫧
- * @return list闆嗗悎
- */
- public static final List str2List(String str, String sep, boolean filterBlank, boolean trim)
- {
- List list = new ArrayList();
- if (StringUtils.isEmpty(str))
- {
- return list;
- }
-
- // 杩囨护绌虹櫧瀛楃涓
- if (filterBlank && StringUtils.isBlank(str))
- {
- return list;
- }
- String[] split = str.split(sep);
- for (String string : split)
- {
- if (filterBlank && StringUtils.isBlank(string))
- {
- continue;
- }
- if (trim)
- {
- string = string.trim();
- }
- list.add(string);
- }
-
- return list;
- }
-
- /**
- * 涓嬪垝绾胯浆椹煎嘲鍛藉悕
- */
- public static String toUnderScoreCase(String str)
- {
- if (str == null)
- {
- return null;
- }
- StringBuilder sb = new StringBuilder();
- // 鍓嶇疆瀛楃鏄惁澶у啓
- boolean preCharIsUpperCase = true;
- // 褰撳墠瀛楃鏄惁澶у啓
- boolean curreCharIsUpperCase = true;
- // 涓嬩竴瀛楃鏄惁澶у啓
- boolean nexteCharIsUpperCase = true;
- for (int i = 0; i < str.length(); i++)
- {
- char c = str.charAt(i);
- if (i > 0)
- {
- preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1));
- }
- else
- {
- preCharIsUpperCase = false;
- }
-
- curreCharIsUpperCase = Character.isUpperCase(c);
-
- if (i < (str.length() - 1))
- {
- nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1));
- }
-
- if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase)
- {
- sb.append(SEPARATOR);
- }
- else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase)
- {
- sb.append(SEPARATOR);
- }
- sb.append(Character.toLowerCase(c));
- }
-
- return sb.toString();
- }
-
- /**
- * 鏄惁鍖呭惈瀛楃涓
- *
- * @param str 楠岃瘉瀛楃涓
- * @param strs 瀛楃涓茬粍
- * @return 鍖呭惈杩斿洖true
- */
- public static boolean inStringIgnoreCase(String str, String... strs)
- {
- if (str != null && strs != null)
- {
- for (String s : strs)
- {
- if (str.equalsIgnoreCase(trim(s)))
- {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * 灏嗕笅鍒掔嚎澶у啓鏂瑰紡鍛藉悕鐨勫瓧绗︿覆杞崲涓洪┘宄板紡銆傚鏋滆浆鎹㈠墠鐨勪笅鍒掔嚎澶у啓鏂瑰紡鍛藉悕鐨勫瓧绗︿覆涓虹┖锛屽垯杩斿洖绌哄瓧绗︿覆銆 渚嬪锛欻ELLO_WORLD->HelloWorld
- *
- * @param name 杞崲鍓嶇殑涓嬪垝绾垮ぇ鍐欐柟寮忓懡鍚嶇殑瀛楃涓
- * @return 杞崲鍚庣殑椹煎嘲寮忓懡鍚嶇殑瀛楃涓
- */
- public static String convertToCamelCase(String name)
- {
- StringBuilder result = new StringBuilder();
- // 蹇熸鏌
- if (name == null || name.isEmpty())
- {
- // 娌″繀瑕佽浆鎹
- return "";
- }
- else if (!name.contains("_"))
- {
- // 涓嶅惈涓嬪垝绾匡紝浠呭皢棣栧瓧姣嶅ぇ鍐
- return name.substring(0, 1).toUpperCase() + name.substring(1);
- }
- // 鐢ㄤ笅鍒掔嚎灏嗗師濮嬪瓧绗︿覆鍒嗗壊
- String[] camels = name.split("_");
- for (String camel : camels)
- {
- // 璺宠繃鍘熷瀛楃涓蹭腑寮澶淬佺粨灏剧殑涓嬫崲绾挎垨鍙岄噸涓嬪垝绾
- if (camel.isEmpty())
- {
- continue;
- }
- // 棣栧瓧姣嶅ぇ鍐
- result.append(camel.substring(0, 1).toUpperCase());
- result.append(camel.substring(1).toLowerCase());
- }
- return result.toString();
- }
-
- /**
- * 椹煎嘲寮忓懡鍚嶆硶 渚嬪锛歶ser_name->userName
- */
- public static String toCamelCase(String s)
- {
- if (s == null)
- {
- return null;
- }
- s = s.toLowerCase();
- StringBuilder sb = new StringBuilder(s.length());
- boolean upperCase = false;
- for (int i = 0; i < s.length(); i++)
- {
- char c = s.charAt(i);
-
- if (c == SEPARATOR)
- {
- upperCase = true;
- }
- else if (upperCase)
- {
- sb.append(Character.toUpperCase(c));
- upperCase = false;
- }
- else
- {
- sb.append(c);
- }
- }
- return sb.toString();
- }
-}
\ No newline at end of file
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/Threads.java b/ruoyi/src/main/java/com/ruoyi/common/utils/Threads.java
deleted file mode 100644
index 395920a2..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/Threads.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package com.ruoyi.common.utils;
-
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * 绾跨▼鐩稿叧宸ュ叿绫.
- *
- * @author ruoyi
- */
-public class Threads
-{
- private static final Logger logger = LoggerFactory.getLogger(Threads.class);
-
- /**
- * sleep绛夊緟,鍗曚綅涓烘绉
- */
- public static void sleep(long milliseconds)
- {
- try
- {
- Thread.sleep(milliseconds);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
-
- /**
- * 鍋滄绾跨▼姹
- * 鍏堜娇鐢╯hutdown, 鍋滄鎺ユ敹鏂颁换鍔″苟灏濊瘯瀹屾垚鎵鏈夊凡瀛樺湪浠诲姟.
- * 濡傛灉瓒呮椂, 鍒欒皟鐢╯hutdownNow, 鍙栨秷鍦╳orkQueue涓璓ending鐨勪换鍔,骞朵腑鏂墍鏈夐樆濉炲嚱鏁.
- * 濡傛灉浠嶄汉瓒呮檪锛屽墖寮峰埗閫鍑.
- * 鍙﹀鍦╯hutdown鏃剁嚎绋嬫湰韬璋冪敤涓柇鍋氫簡澶勭悊.
- */
- public static void shutdownAndAwaitTermination(ExecutorService pool)
- {
- if (pool != null && !pool.isShutdown())
- {
- pool.shutdown();
- try
- {
- if (!pool.awaitTermination(120, TimeUnit.SECONDS))
- {
- pool.shutdownNow();
- if (!pool.awaitTermination(120, TimeUnit.SECONDS))
- {
- logger.info("Pool did not terminate");
- }
- }
- }
- catch (InterruptedException ie)
- {
- pool.shutdownNow();
- Thread.currentThread().interrupt();
- }
- }
- }
-
- /**
- * 鎵撳嵃绾跨▼寮傚父淇℃伅
- */
- public static void printException(Runnable r, Throwable t)
- {
- if (t == null && r instanceof Future>)
- {
- try
- {
- Future> future = (Future>) r;
- if (future.isDone())
- {
- future.get();
- }
- }
- catch (CancellationException ce)
- {
- t = ce;
- }
- catch (ExecutionException ee)
- {
- t = ee.getCause();
- }
- catch (InterruptedException ie)
- {
- Thread.currentThread().interrupt();
- }
- }
- if (t != null)
- {
- logger.error(t.getMessage(), t);
- }
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/VerifyCodeUtils.java b/ruoyi/src/main/java/com/ruoyi/common/utils/VerifyCodeUtils.java
deleted file mode 100644
index 80b8c84f..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/VerifyCodeUtils.java
+++ /dev/null
@@ -1,226 +0,0 @@
-package com.ruoyi.common.utils;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.geom.AffineTransform;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.security.SecureRandom;
-import java.util.Arrays;
-import java.util.Random;
-import javax.imageio.ImageIO;
-
-/**
- * 楠岃瘉鐮佸伐鍏风被
- *
- * @author ruoyi
- */
-public class VerifyCodeUtils
-{
- // 浣跨敤鍒癆lgerian瀛椾綋锛岀郴缁熼噷娌℃湁鐨勮瘽闇瑕佸畨瑁呭瓧浣擄紝瀛椾綋鍙樉绀哄ぇ鍐欙紝鍘绘帀浜1,0,i,o鍑犱釜瀹规槗娣锋穯鐨勫瓧绗
- public static final String VERIFY_CODES = "123456789ABCDEFGHJKLMNPQRSTUVWXYZ";
-
- private static Random random = new SecureRandom();
-
- /**
- * 浣跨敤绯荤粺榛樿瀛楃婧愮敓鎴愰獙璇佺爜
- *
- * @param verifySize 楠岃瘉鐮侀暱搴
- * @return
- */
- public static String generateVerifyCode(int verifySize)
- {
- return generateVerifyCode(verifySize, VERIFY_CODES);
- }
-
- /**
- * 浣跨敤鎸囧畾婧愮敓鎴愰獙璇佺爜
- *
- * @param verifySize 楠岃瘉鐮侀暱搴
- * @param sources 楠岃瘉鐮佸瓧绗︽簮
- * @return
- */
- public static String generateVerifyCode(int verifySize, String sources)
- {
- if (sources == null || sources.length() == 0)
- {
- sources = VERIFY_CODES;
- }
- int codesLen = sources.length();
- Random rand = new Random(System.currentTimeMillis());
- StringBuilder verifyCode = new StringBuilder(verifySize);
- for (int i = 0; i < verifySize; i++)
- {
- verifyCode.append(sources.charAt(rand.nextInt(codesLen - 1)));
- }
- return verifyCode.toString();
- }
-
- /**
- * 杈撳嚭鎸囧畾楠岃瘉鐮佸浘鐗囨祦
- *
- * @param w
- * @param h
- * @param os
- * @param code
- * @throws IOException
- */
- public static void outputImage(int w, int h, OutputStream os, String code) throws IOException
- {
- int verifySize = code.length();
- BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
- Random rand = new Random();
- Graphics2D g2 = image.createGraphics();
- g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- Color[] colors = new Color[5];
- Color[] colorSpaces = new Color[] { Color.WHITE, Color.CYAN, Color.GRAY, Color.LIGHT_GRAY, Color.MAGENTA,
- Color.ORANGE, Color.PINK, Color.YELLOW };
- float[] fractions = new float[colors.length];
- for (int i = 0; i < colors.length; i++)
- {
- colors[i] = colorSpaces[rand.nextInt(colorSpaces.length)];
- fractions[i] = rand.nextFloat();
- }
- Arrays.sort(fractions);
-
- g2.setColor(Color.GRAY);// 璁剧疆杈规鑹
- g2.fillRect(0, 0, w, h);
-
- Color c = getRandColor(200, 250);
- g2.setColor(c);// 璁剧疆鑳屾櫙鑹
- g2.fillRect(0, 2, w, h - 4);
-
- // 缁樺埗骞叉壈绾
- Random random = new Random();
- g2.setColor(getRandColor(160, 200));// 璁剧疆绾挎潯鐨勯鑹
- for (int i = 0; i < 20; i++)
- {
- int x = random.nextInt(w - 1);
- int y = random.nextInt(h - 1);
- int xl = random.nextInt(6) + 1;
- int yl = random.nextInt(12) + 1;
- g2.drawLine(x, y, x + xl + 40, y + yl + 20);
- }
-
- // 娣诲姞鍣偣
- float yawpRate = 0.05f;// 鍣0鐜
- int area = (int) (yawpRate * w * h);
- for (int i = 0; i < area; i++)
- {
- int x = random.nextInt(w);
- int y = random.nextInt(h);
- int rgb = getRandomIntColor();
- image.setRGB(x, y, rgb);
- }
-
- shear(g2, w, h, c);// 浣垮浘鐗囨壄鏇
-
- g2.setColor(getRandColor(100, 160));
- int fontSize = h - 4;
- Font font = new Font("Algerian", Font.ITALIC, fontSize);
- g2.setFont(font);
- char[] chars = code.toCharArray();
- for (int i = 0; i < verifySize; i++)
- {
- AffineTransform affine = new AffineTransform();
- affine.setToRotation(Math.PI / 4 * rand.nextDouble() * (rand.nextBoolean() ? 1 : -1),
- (w / verifySize) * i + fontSize / 2, h / 2);
- g2.setTransform(affine);
- g2.drawChars(chars, i, 1, ((w - 10) / verifySize) * i + 5, h / 2 + fontSize / 2 - 10);
- }
-
- g2.dispose();
- ImageIO.write(image, "jpg", os);
- }
-
- private static Color getRandColor(int fc, int bc)
- {
- if (fc > 255)
- fc = 255;
- if (bc > 255)
- bc = 255;
- int r = fc + random.nextInt(bc - fc);
- int g = fc + random.nextInt(bc - fc);
- int b = fc + random.nextInt(bc - fc);
- return new Color(r, g, b);
- }
-
- private static int getRandomIntColor()
- {
- int[] rgb = getRandomRgb();
- int color = 0;
- for (int c : rgb)
- {
- color = color << 8;
- color = color | c;
- }
- return color;
- }
-
- private static int[] getRandomRgb()
- {
- int[] rgb = new int[3];
- for (int i = 0; i < 3; i++)
- {
- rgb[i] = random.nextInt(255);
- }
- return rgb;
- }
-
- private static void shear(Graphics g, int w1, int h1, Color color)
- {
- shearX(g, w1, h1, color);
- shearY(g, w1, h1, color);
- }
-
- private static void shearX(Graphics g, int w1, int h1, Color color)
- {
-
- int period = random.nextInt(2);
-
- boolean borderGap = true;
- int frames = 1;
- int phase = random.nextInt(2);
-
- for (int i = 0; i < h1; i++)
- {
- double d = (double) (period >> 1)
- * Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames);
- g.copyArea(0, i, w1, 1, (int) d, 0);
- if (borderGap)
- {
- g.setColor(color);
- g.drawLine((int) d, i, 0, i);
- g.drawLine((int) d + w1, i, w1, i);
- }
- }
-
- }
-
- private static void shearY(Graphics g, int w1, int h1, Color color)
- {
-
- int period = random.nextInt(40) + 10; // 50;
-
- boolean borderGap = true;
- int frames = 20;
- int phase = 7;
- for (int i = 0; i < w1; i++)
- {
- double d = (double) (period >> 1)
- * Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames);
- g.copyArea(i, 0, 1, h1, 0, (int) d);
- if (borderGap)
- {
- g.setColor(color);
- g.drawLine(i, (int) d, i, 0);
- g.drawLine(i, (int) d + h1, i, h1);
- }
-
- }
- }
-}
\ No newline at end of file
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java b/ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java
deleted file mode 100644
index 6921fea7..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java
+++ /dev/null
@@ -1,243 +0,0 @@
-package com.ruoyi.common.utils.file;
-
-import java.io.File;
-import java.io.IOException;
-import org.apache.commons.io.FilenameUtils;
-import org.springframework.web.multipart.MultipartFile;
-import com.ruoyi.common.constant.Constants;
-import com.ruoyi.common.exception.file.FileNameLengthLimitExceededException;
-import com.ruoyi.common.exception.file.FileSizeLimitExceededException;
-import com.ruoyi.common.exception.file.InvalidExtensionException;
-import com.ruoyi.common.utils.DateUtils;
-import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.utils.security.Md5Utils;
-import com.ruoyi.framework.config.RuoYiConfig;
-
-/**
- * 鏂囦欢涓婁紶宸ュ叿绫
- *
- * @author ruoyi
- */
-public class FileUploadUtils
-{
- /**
- * 榛樿澶у皬 50M
- */
- public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024;
-
- /**
- * 榛樿鐨勬枃浠跺悕鏈澶ч暱搴 100
- */
- public static final int DEFAULT_FILE_NAME_LENGTH = 100;
-
- /**
- * 榛樿涓婁紶鐨勫湴鍧
- */
- private static String defaultBaseDir = RuoYiConfig.getProfile();
-
- private static int counter = 0;
-
- public static void setDefaultBaseDir(String defaultBaseDir)
- {
- FileUploadUtils.defaultBaseDir = defaultBaseDir;
- }
-
- public static String getDefaultBaseDir()
- {
- return defaultBaseDir;
- }
-
- /**
- * 浠ラ粯璁ら厤缃繘琛屾枃浠朵笂浼
- *
- * @param file 涓婁紶鐨勬枃浠
- * @return 鏂囦欢鍚嶇О
- * @throws Exception
- */
- public static final String upload(MultipartFile file) throws IOException
- {
- try
- {
- return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
- }
- catch (Exception e)
- {
- throw new IOException(e.getMessage(), e);
- }
- }
-
- /**
- * 鏍规嵁鏂囦欢璺緞涓婁紶
- *
- * @param baseDir 鐩稿搴旂敤鐨勫熀鐩綍
- * @param file 涓婁紶鐨勬枃浠
- * @return 鏂囦欢鍚嶇О
- * @throws IOException
- */
- public static final String upload(String baseDir, MultipartFile file) throws IOException
- {
- try
- {
- return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
- }
- catch (Exception e)
- {
- throw new IOException(e.getMessage(), e);
- }
- }
-
- /**
- * 鏂囦欢涓婁紶
- *
- * @param baseDir 鐩稿搴旂敤鐨勫熀鐩綍
- * @param file 涓婁紶鐨勬枃浠
- * @param extension 涓婁紶鏂囦欢绫诲瀷
- * @return 杩斿洖涓婁紶鎴愬姛鐨勬枃浠跺悕
- * @throws FileSizeLimitExceededException 濡傛灉瓒呭嚭鏈澶уぇ灏
- * @throws FileNameLengthLimitExceededException 鏂囦欢鍚嶅お闀
- * @throws IOException 姣斿璇诲啓鏂囦欢鍑洪敊鏃
- * @throws InvalidExtensionException 鏂囦欢鏍¢獙寮傚父
- */
- public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension)
- throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
- InvalidExtensionException
- {
- int fileNamelength = file.getOriginalFilename().length();
- if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
- {
- throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
- }
-
- assertAllowed(file, allowedExtension);
-
- String fileName = extractFilename(file);
-
- File desc = getAbsoluteFile(baseDir, fileName);
- file.transferTo(desc);
- String pathFileName = getPathFileName(baseDir, fileName);
- return pathFileName;
- }
-
- /**
- * 缂栫爜鏂囦欢鍚
- */
- public static final String extractFilename(MultipartFile file)
- {
- String fileName = file.getOriginalFilename();
- String extension = getExtension(file);
- fileName = DateUtils.datePath() + "/" + encodingFilename(fileName) + "." + extension;
- return fileName;
- }
-
- private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
- {
- File desc = new File(uploadDir + File.separator + fileName);
-
- if (!desc.getParentFile().exists())
- {
- desc.getParentFile().mkdirs();
- }
- if (!desc.exists())
- {
- desc.createNewFile();
- }
- return desc;
- }
-
- private static final String getPathFileName(String uploadDir, String fileName) throws IOException
- {
- int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
- String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
- String pathFileName = Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
- return pathFileName;
- }
-
- /**
- * 缂栫爜鏂囦欢鍚
- */
- private static final String encodingFilename(String fileName)
- {
- fileName = fileName.replace("_", " ");
- fileName = Md5Utils.hash(fileName + System.nanoTime() + counter++);
- return fileName;
- }
-
- /**
- * 鏂囦欢澶у皬鏍¢獙
- *
- * @param file 涓婁紶鐨勬枃浠
- * @return
- * @throws FileSizeLimitExceededException 濡傛灉瓒呭嚭鏈澶уぇ灏
- * @throws InvalidExtensionException
- */
- public static final void assertAllowed(MultipartFile file, String[] allowedExtension)
- throws FileSizeLimitExceededException, InvalidExtensionException
- {
- long size = file.getSize();
- if (DEFAULT_MAX_SIZE != -1 && size > DEFAULT_MAX_SIZE)
- {
- throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024);
- }
-
- String fileName = file.getOriginalFilename();
- String extension = getExtension(file);
- if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension))
- {
- if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION)
- {
- throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension,
- fileName);
- }
- else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION)
- {
- throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension,
- fileName);
- }
- else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION)
- {
- throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension,
- fileName);
- }
- else
- {
- throw new InvalidExtensionException(allowedExtension, extension, fileName);
- }
- }
-
- }
-
- /**
- * 鍒ゆ柇MIME绫诲瀷鏄惁鏄厑璁哥殑MIME绫诲瀷
- *
- * @param extension
- * @param allowedExtension
- * @return
- */
- public static final boolean isAllowedExtension(String extension, String[] allowedExtension)
- {
- for (String str : allowedExtension)
- {
- if (str.equalsIgnoreCase(extension))
- {
- return true;
- }
- }
- return false;
- }
-
- /**
- * 鑾峰彇鏂囦欢鍚嶇殑鍚庣紑
- *
- * @param file 琛ㄥ崟鏂囦欢
- * @return 鍚庣紑鍚
- */
- public static final String getExtension(MultipartFile file)
- {
- String extension = FilenameUtils.getExtension(file.getOriginalFilename());
- if (StringUtils.isEmpty(extension))
- {
- extension = MimeTypeUtils.getExtension(file.getContentType());
- }
- return extension;
- }
-}
\ No newline at end of file
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUtils.java b/ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUtils.java
deleted file mode 100644
index 03f5aa2a..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUtils.java
+++ /dev/null
@@ -1,142 +0,0 @@
-package com.ruoyi.common.utils.file;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * 鏂囦欢澶勭悊宸ュ叿绫
- *
- * @author ruoyi
- */
-public class FileUtils
-{
- public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
-
- /**
- * 杈撳嚭鎸囧畾鏂囦欢鐨刡yte鏁扮粍
- *
- * @param filePath 鏂囦欢璺緞
- * @param os 杈撳嚭娴
- * @return
- */
- public static void writeBytes(String filePath, OutputStream os) throws IOException
- {
- FileInputStream fis = null;
- try
- {
- File file = new File(filePath);
- if (!file.exists())
- {
- throw new FileNotFoundException(filePath);
- }
- fis = new FileInputStream(file);
- byte[] b = new byte[1024];
- int length;
- while ((length = fis.read(b)) > 0)
- {
- os.write(b, 0, length);
- }
- }
- catch (IOException e)
- {
- throw e;
- }
- finally
- {
- if (os != null)
- {
- try
- {
- os.close();
- }
- catch (IOException e1)
- {
- e1.printStackTrace();
- }
- }
- if (fis != null)
- {
- try
- {
- fis.close();
- }
- catch (IOException e1)
- {
- e1.printStackTrace();
- }
- }
- }
- }
-
- /**
- * 鍒犻櫎鏂囦欢
- *
- * @param filePath 鏂囦欢
- * @return
- */
- public static boolean deleteFile(String filePath)
- {
- boolean flag = false;
- File file = new File(filePath);
- // 璺緞涓烘枃浠朵笖涓嶄负绌哄垯杩涜鍒犻櫎
- if (file.isFile() && file.exists())
- {
- file.delete();
- flag = true;
- }
- return flag;
- }
-
- /**
- * 鏂囦欢鍚嶇О楠岃瘉
- *
- * @param filename 鏂囦欢鍚嶇О
- * @return true 姝e父 false 闈炴硶
- */
- public static boolean isValidFilename(String filename)
- {
- return filename.matches(FILENAME_PATTERN);
- }
-
- /**
- * 涓嬭浇鏂囦欢鍚嶉噸鏂扮紪鐮
- *
- * @param request 璇锋眰瀵硅薄
- * @param fileName 鏂囦欢鍚
- * @return 缂栫爜鍚庣殑鏂囦欢鍚
- */
- public static String setFileDownloadHeader(HttpServletRequest request, String fileName)
- throws UnsupportedEncodingException
- {
- final String agent = request.getHeader("USER-AGENT");
- String filename = fileName;
- if (agent.contains("MSIE"))
- {
- // IE娴忚鍣
- filename = URLEncoder.encode(filename, "utf-8");
- filename = filename.replace("+", " ");
- }
- else if (agent.contains("Firefox"))
- {
- // 鐏嫄娴忚鍣
- filename = new String(fileName.getBytes(), "ISO8859-1");
- }
- else if (agent.contains("Chrome"))
- {
- // google娴忚鍣
- filename = URLEncoder.encode(filename, "utf-8");
- }
- else
- {
- // 鍏跺畠娴忚鍣
- filename = URLEncoder.encode(filename, "utf-8");
- }
- return filename;
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java b/ruoyi/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java
deleted file mode 100644
index d179a918..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.ruoyi.common.utils.file;
-
-/**
- * 濯掍綋绫诲瀷宸ュ叿绫
- *
- * @author ruoyi
- */
-public class MimeTypeUtils
-{
- public static final String IMAGE_PNG = "image/png";
-
- public static final String IMAGE_JPG = "image/jpg";
-
- public static final String IMAGE_JPEG = "image/jpeg";
-
- public static final String IMAGE_BMP = "image/bmp";
-
- public static final String IMAGE_GIF = "image/gif";
-
- public static final String[] IMAGE_EXTENSION = { "bmp", "gif", "jpg", "jpeg", "png" };
-
- public static final String[] FLASH_EXTENSION = { "swf", "flv" };
-
- public static final String[] MEDIA_EXTENSION = { "swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg",
- "asf", "rm", "rmvb" };
-
- public static final String[] DEFAULT_ALLOWED_EXTENSION = {
- // 鍥剧墖
- "bmp", "gif", "jpg", "jpeg", "png",
- // word excel powerpoint
- "doc", "docx", "xls", "xlsx", "ppt", "pptx", "html", "htm", "txt",
- // 鍘嬬缉鏂囦欢
- "rar", "zip", "gz", "bz2",
- // pdf
- "pdf" };
-
- public static String getExtension(String prefix)
- {
- switch (prefix)
- {
- case IMAGE_PNG:
- return "png";
- case IMAGE_JPG:
- return "jpg";
- case IMAGE_JPEG:
- return "jpeg";
- case IMAGE_BMP:
- return "bmp";
- case IMAGE_GIF:
- return "gif";
- default:
- return "";
- }
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/html/EscapeUtil.java b/ruoyi/src/main/java/com/ruoyi/common/utils/html/EscapeUtil.java
deleted file mode 100644
index 0f455275..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/html/EscapeUtil.java
+++ /dev/null
@@ -1,152 +0,0 @@
-package com.ruoyi.common.utils.html;
-
-import com.ruoyi.common.utils.StringUtils;
-
-/**
- * 杞箟鍜屽弽杞箟宸ュ叿绫
- *
- * @author ruoyi
- */
-public class EscapeUtil
-{
- public static final String RE_HTML_MARK = "(<[^<]*?>)|(<[\\s]*?/[^<]*?>)|(<[^<]*?/[\\s]*?>)";
-
- private static final char[][] TEXT = new char[64][];
-
- static
- {
- for (int i = 0; i < 64; i++)
- {
- TEXT[i] = new char[] { (char) i };
- }
-
- // special HTML characters
- TEXT['\''] = "'".toCharArray(); // 鍗曞紩鍙
- TEXT['"'] = """.toCharArray(); // 鍗曞紩鍙
- TEXT['&'] = "&".toCharArray(); // &绗
- TEXT['<'] = "<".toCharArray(); // 灏忎簬鍙
- TEXT['>'] = ">".toCharArray(); // 澶т簬鍙
- }
-
- /**
- * 杞箟鏂囨湰涓殑HTML瀛楃涓哄畨鍏ㄧ殑瀛楃
- *
- * @param text 琚浆涔夌殑鏂囨湰
- * @return 杞箟鍚庣殑鏂囨湰
- */
- public static String escape(String text)
- {
- return encode(text);
- }
-
- /**
- * 杩樺師琚浆涔夌殑HTML鐗规畩瀛楃
- *
- * @param content 鍖呭惈杞箟绗︾殑HTML鍐呭
- * @return 杞崲鍚庣殑瀛楃涓
- */
- public static String unescape(String content)
- {
- return decode(content);
- }
-
- /**
- * 娓呴櫎鎵鏈塇TML鏍囩锛屼絾鏄笉鍒犻櫎鏍囩鍐呯殑鍐呭
- *
- * @param content 鏂囨湰
- * @return 娓呴櫎鏍囩鍚庣殑鏂囨湰
- */
- public static String clean(String content)
- {
- return new HTMLFilter().filter(content);
- }
-
- /**
- * Escape缂栫爜
- *
- * @param text 琚紪鐮佺殑鏂囨湰
- * @return 缂栫爜鍚庣殑瀛楃
- */
- private static String encode(String text)
- {
- int len;
- if ((text == null) || ((len = text.length()) == 0))
- {
- return StringUtils.EMPTY;
- }
- StringBuilder buffer = new StringBuilder(len + (len >> 2));
- char c;
- for (int i = 0; i < len; i++)
- {
- c = text.charAt(i);
- if (c < 64)
- {
- buffer.append(TEXT[c]);
- }
- else
- {
- buffer.append(c);
- }
- }
- return buffer.toString();
- }
-
- /**
- * Escape瑙g爜
- *
- * @param content 琚浆涔夌殑鍐呭
- * @return 瑙g爜鍚庣殑瀛楃涓
- */
- public static String decode(String content)
- {
- if (StringUtils.isEmpty(content))
- {
- return content;
- }
-
- StringBuilder tmp = new StringBuilder(content.length());
- int lastPos = 0, pos = 0;
- char ch;
- while (lastPos < content.length())
- {
- pos = content.indexOf("%", lastPos);
- if (pos == lastPos)
- {
- if (content.charAt(pos + 1) == 'u')
- {
- ch = (char) Integer.parseInt(content.substring(pos + 2, pos + 6), 16);
- tmp.append(ch);
- lastPos = pos + 6;
- }
- else
- {
- ch = (char) Integer.parseInt(content.substring(pos + 1, pos + 3), 16);
- tmp.append(ch);
- lastPos = pos + 3;
- }
- }
- else
- {
- if (pos == -1)
- {
- tmp.append(content.substring(lastPos));
- lastPos = content.length();
- }
- else
- {
- tmp.append(content.substring(lastPos, pos));
- lastPos = pos;
- }
- }
- }
- return tmp.toString();
- }
-
- public static void main(String[] args)
- {
- String html = "";
- System.out.println(EscapeUtil.clean(html));
- System.out.println(EscapeUtil.escape(html));
- System.out.println(EscapeUtil.unescape(html));
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java b/ruoyi/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java
deleted file mode 100644
index 6244cd57..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java
+++ /dev/null
@@ -1,569 +0,0 @@
-package com.ruoyi.common.utils.html;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * HTML杩囨护鍣紝鐢ㄤ簬鍘婚櫎XSS婕忔礊闅愭偅銆
- *
- * @author ruoyi
- */
-public final class HTMLFilter
-{
- /**
- * regex flag union representing /si modifiers in php
- **/
- private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL;
- private static final Pattern P_COMMENTS = Pattern.compile("", Pattern.DOTALL);
- private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI);
- private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL);
- private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI);
- private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI);
- private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI);
- private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI);
- private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI);
- private static final Pattern P_ENTITY = Pattern.compile("(\\d+);?");
- private static final Pattern P_ENTITY_UNICODE = Pattern.compile("([0-9a-f]+);?");
- private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?");
- private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))");
- private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", Pattern.DOTALL);
- private static final Pattern P_END_ARROW = Pattern.compile("^>");
- private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)");
- private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)");
- private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)");
- private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)");
- private static final Pattern P_AMP = Pattern.compile("&");
- private static final Pattern P_QUOTE = Pattern.compile("\"");
- private static final Pattern P_LEFT_ARROW = Pattern.compile("<");
- private static final Pattern P_RIGHT_ARROW = Pattern.compile(">");
- private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>");
-
- // @xxx could grow large... maybe use sesat's ReferenceMap
- private static final ConcurrentMap P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<>();
- private static final ConcurrentMap P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<>();
-
- /**
- * set of allowed html elements, along with allowed attributes for each element
- **/
- private final Map> vAllowed;
- /**
- * counts of open tags for each (allowable) html element
- **/
- private final Map vTagCounts = new HashMap<>();
-
- /**
- * html elements which must always be self-closing (e.g. "")
- **/
- private final String[] vSelfClosingTags;
- /**
- * html elements which must always have separate opening and closing tags (e.g. "")
- **/
- private final String[] vNeedClosingTags;
- /**
- * set of disallowed html elements
- **/
- private final String[] vDisallowed;
- /**
- * attributes which should be checked for valid protocols
- **/
- private final String[] vProtocolAtts;
- /**
- * allowed protocols
- **/
- private final String[] vAllowedProtocols;
- /**
- * tags which should be removed if they contain no content (e.g. "" or "")
- **/
- private final String[] vRemoveBlanks;
- /**
- * entities allowed within html markup
- **/
- private final String[] vAllowedEntities;
- /**
- * flag determining whether comments are allowed in input String.
- */
- private final boolean stripComment;
- private final boolean encodeQuotes;
- /**
- * flag determining whether to try to make tags when presented with "unbalanced" angle brackets (e.g. ""
- * becomes " text "). If set to false, unbalanced angle brackets will be html escaped.
- */
- private final boolean alwaysMakeTags;
-
- /**
- * Default constructor.
- */
- public HTMLFilter()
- {
- vAllowed = new HashMap<>();
-
- final ArrayList a_atts = new ArrayList<>();
- a_atts.add("href");
- a_atts.add("target");
- vAllowed.put("a", a_atts);
-
- final ArrayList img_atts = new ArrayList<>();
- img_atts.add("src");
- img_atts.add("width");
- img_atts.add("height");
- img_atts.add("alt");
- vAllowed.put("img", img_atts);
-
- final ArrayList no_atts = new ArrayList<>();
- vAllowed.put("b", no_atts);
- vAllowed.put("strong", no_atts);
- vAllowed.put("i", no_atts);
- vAllowed.put("em", no_atts);
-
- vSelfClosingTags = new String[] { "img" };
- vNeedClosingTags = new String[] { "a", "b", "strong", "i", "em" };
- vDisallowed = new String[] {};
- vAllowedProtocols = new String[] { "http", "mailto", "https" }; // no ftp.
- vProtocolAtts = new String[] { "src", "href" };
- vRemoveBlanks = new String[] { "a", "b", "strong", "i", "em" };
- vAllowedEntities = new String[] { "amp", "gt", "lt", "quot" };
- stripComment = true;
- encodeQuotes = true;
- alwaysMakeTags = true;
- }
-
- /**
- * Map-parameter configurable constructor.
- *
- * @param conf map containing configuration. keys match field names.
- */
- @SuppressWarnings("unchecked")
- public HTMLFilter(final Map conf)
- {
-
- assert conf.containsKey("vAllowed") : "configuration requires vAllowed";
- assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags";
- assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags";
- assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed";
- assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols";
- assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts";
- assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks";
- assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities";
-
- vAllowed = Collections.unmodifiableMap((HashMap>) conf.get("vAllowed"));
- vSelfClosingTags = (String[]) conf.get("vSelfClosingTags");
- vNeedClosingTags = (String[]) conf.get("vNeedClosingTags");
- vDisallowed = (String[]) conf.get("vDisallowed");
- vAllowedProtocols = (String[]) conf.get("vAllowedProtocols");
- vProtocolAtts = (String[]) conf.get("vProtocolAtts");
- vRemoveBlanks = (String[]) conf.get("vRemoveBlanks");
- vAllowedEntities = (String[]) conf.get("vAllowedEntities");
- stripComment = conf.containsKey("stripComment") ? (Boolean) conf.get("stripComment") : true;
- encodeQuotes = conf.containsKey("encodeQuotes") ? (Boolean) conf.get("encodeQuotes") : true;
- alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true;
- }
-
- private void reset()
- {
- vTagCounts.clear();
- }
-
- // ---------------------------------------------------------------
- // my versions of some PHP library functions
- public static String chr(final int decimal)
- {
- return String.valueOf((char) decimal);
- }
-
- public static String htmlSpecialChars(final String s)
- {
- String result = s;
- result = regexReplace(P_AMP, "&", result);
- result = regexReplace(P_QUOTE, """, result);
- result = regexReplace(P_LEFT_ARROW, "<", result);
- result = regexReplace(P_RIGHT_ARROW, ">", result);
- return result;
- }
-
- // ---------------------------------------------------------------
-
- /**
- * given a user submitted input String, filter out any invalid or restricted html.
- *
- * @param input text (i.e. submitted by a user) than may contain html
- * @return "clean" version of input, with only valid, whitelisted html elements allowed
- */
- public String filter(final String input)
- {
- reset();
- String s = input;
-
- s = escapeComments(s);
-
- s = balanceHTML(s);
-
- s = checkTags(s);
-
- s = processRemoveBlanks(s);
-
- s = validateEntities(s);
-
- return s;
- }
-
- public boolean isAlwaysMakeTags()
- {
- return alwaysMakeTags;
- }
-
- public boolean isStripComments()
- {
- return stripComment;
- }
-
- private String escapeComments(final String s)
- {
- final Matcher m = P_COMMENTS.matcher(s);
- final StringBuffer buf = new StringBuffer();
- if (m.find())
- {
- final String match = m.group(1); // (.*?)
- m.appendReplacement(buf, Matcher.quoteReplacement(""));
- }
- m.appendTail(buf);
-
- return buf.toString();
- }
-
- private String balanceHTML(String s)
- {
- if (alwaysMakeTags)
- {
- //
- // try and form html
- //
- s = regexReplace(P_END_ARROW, "", s);
- s = regexReplace(P_BODY_TO_END, "<$1>", s);
- s = regexReplace(P_XML_CONTENT, "$1<$2", s);
-
- }
- else
- {
- //
- // escape stray brackets
- //
- s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s);
- s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s);
-
- //
- // the last regexp causes '<>' entities to appear
- // (we need to do a lookahead assertion so that the last bracket can
- // be used in the next pass of the regexp)
- //
- s = regexReplace(P_BOTH_ARROWS, "", s);
- }
-
- return s;
- }
-
- private String checkTags(String s)
- {
- Matcher m = P_TAGS.matcher(s);
-
- final StringBuffer buf = new StringBuffer();
- while (m.find())
- {
- String replaceStr = m.group(1);
- replaceStr = processTag(replaceStr);
- m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr));
- }
- m.appendTail(buf);
-
- // these get tallied in processTag
- // (remember to reset before subsequent calls to filter method)
- final StringBuilder sBuilder = new StringBuilder(buf.toString());
- for (String key : vTagCounts.keySet())
- {
- for (int ii = 0; ii < vTagCounts.get(key); ii++)
- {
- sBuilder.append("").append(key).append(">");
- }
- }
- s = sBuilder.toString();
-
- return s;
- }
-
- private String processRemoveBlanks(final String s)
- {
- String result = s;
- for (String tag : vRemoveBlanks)
- {
- if (!P_REMOVE_PAIR_BLANKS.containsKey(tag))
- {
- P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?>" + tag + ">"));
- }
- result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result);
- if (!P_REMOVE_SELF_BLANKS.containsKey(tag))
- {
- P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>"));
- }
- result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result);
- }
-
- return result;
- }
-
- private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s)
- {
- Matcher m = regex_pattern.matcher(s);
- return m.replaceAll(replacement);
- }
-
- private String processTag(final String s)
- {
- // ending tags
- Matcher m = P_END_TAG.matcher(s);
- if (m.find())
- {
- final String name = m.group(1).toLowerCase();
- if (allowed(name))
- {
- if (false == inArray(name, vSelfClosingTags))
- {
- if (vTagCounts.containsKey(name))
- {
- vTagCounts.put(name, vTagCounts.get(name) - 1);
- return "" + name + ">";
- }
- }
- }
- }
-
- // starting tags
- m = P_START_TAG.matcher(s);
- if (m.find())
- {
- final String name = m.group(1).toLowerCase();
- final String body = m.group(2);
- String ending = m.group(3);
-
- // debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" );
- if (allowed(name))
- {
- final StringBuilder params = new StringBuilder();
-
- final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body);
- final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body);
- final List paramNames = new ArrayList<>();
- final List paramValues = new ArrayList<>();
- while (m2.find())
- {
- paramNames.add(m2.group(1)); // ([a-z0-9]+)
- paramValues.add(m2.group(3)); // (.*?)
- }
- while (m3.find())
- {
- paramNames.add(m3.group(1)); // ([a-z0-9]+)
- paramValues.add(m3.group(3)); // ([^\"\\s']+)
- }
-
- String paramName, paramValue;
- for (int ii = 0; ii < paramNames.size(); ii++)
- {
- paramName = paramNames.get(ii).toLowerCase();
- paramValue = paramValues.get(ii);
-
- // debug( "paramName='" + paramName + "'" );
- // debug( "paramValue='" + paramValue + "'" );
- // debug( "allowed? " + vAllowed.get( name ).contains( paramName ) );
-
- if (allowedAttribute(name, paramName))
- {
- if (inArray(paramName, vProtocolAtts))
- {
- paramValue = processParamProtocol(paramValue);
- }
- params.append(' ').append(paramName).append("=\"").append(paramValue).append("\"");
- }
- }
-
- if (inArray(name, vSelfClosingTags))
- {
- ending = " /";
- }
-
- if (inArray(name, vNeedClosingTags))
- {
- ending = "";
- }
-
- if (ending == null || ending.length() < 1)
- {
- if (vTagCounts.containsKey(name))
- {
- vTagCounts.put(name, vTagCounts.get(name) + 1);
- }
- else
- {
- vTagCounts.put(name, 1);
- }
- }
- else
- {
- ending = " /";
- }
- return "<" + name + params + ending + ">";
- }
- else
- {
- return "";
- }
- }
-
- // comments
- m = P_COMMENT.matcher(s);
- if (!stripComment && m.find())
- {
- return "<" + m.group() + ">";
- }
-
- return "";
- }
-
- private String processParamProtocol(String s)
- {
- s = decodeEntities(s);
- final Matcher m = P_PROTOCOL.matcher(s);
- if (m.find())
- {
- final String protocol = m.group(1);
- if (!inArray(protocol, vAllowedProtocols))
- {
- // bad protocol, turn into local anchor link instead
- s = "#" + s.substring(protocol.length() + 1);
- if (s.startsWith("#//"))
- {
- s = "#" + s.substring(3);
- }
- }
- }
-
- return s;
- }
-
- private String decodeEntities(String s)
- {
- StringBuffer buf = new StringBuffer();
-
- Matcher m = P_ENTITY.matcher(s);
- while (m.find())
- {
- final String match = m.group(1);
- final int decimal = Integer.decode(match).intValue();
- m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
- }
- m.appendTail(buf);
- s = buf.toString();
-
- buf = new StringBuffer();
- m = P_ENTITY_UNICODE.matcher(s);
- while (m.find())
- {
- final String match = m.group(1);
- final int decimal = Integer.valueOf(match, 16).intValue();
- m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
- }
- m.appendTail(buf);
- s = buf.toString();
-
- buf = new StringBuffer();
- m = P_ENCODE.matcher(s);
- while (m.find())
- {
- final String match = m.group(1);
- final int decimal = Integer.valueOf(match, 16).intValue();
- m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
- }
- m.appendTail(buf);
- s = buf.toString();
-
- s = validateEntities(s);
- return s;
- }
-
- private String validateEntities(final String s)
- {
- StringBuffer buf = new StringBuffer();
-
- // validate entities throughout the string
- Matcher m = P_VALID_ENTITIES.matcher(s);
- while (m.find())
- {
- final String one = m.group(1); // ([^&;]*)
- final String two = m.group(2); // (?=(;|&|$))
- m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two)));
- }
- m.appendTail(buf);
-
- return encodeQuotes(buf.toString());
- }
-
- private String encodeQuotes(final String s)
- {
- if (encodeQuotes)
- {
- StringBuffer buf = new StringBuffer();
- Matcher m = P_VALID_QUOTES.matcher(s);
- while (m.find())
- {
- final String one = m.group(1); // (>|^)
- final String two = m.group(2); // ([^<]+?)
- final String three = m.group(3); // (<|$)
- // 涓嶆浛鎹㈠弻寮曞彿涓"锛岄槻姝son鏍煎紡鏃犳晥 regexReplace(P_QUOTE, """, two)
- m.appendReplacement(buf, Matcher.quoteReplacement(one + two + three));
- }
- m.appendTail(buf);
- return buf.toString();
- }
- else
- {
- return s;
- }
- }
-
- private String checkEntity(final String preamble, final String term)
- {
-
- return ";".equals(term) && isValidEntity(preamble) ? '&' + preamble : "&" + preamble;
- }
-
- private boolean isValidEntity(final String entity)
- {
- return inArray(entity, vAllowedEntities);
- }
-
- private static boolean inArray(final String s, final String[] array)
- {
- for (String item : array)
- {
- if (item != null && item.equals(s))
- {
- return true;
- }
- }
- return false;
- }
-
- private boolean allowed(final String name)
- {
- return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed);
- }
-
- private boolean allowedAttribute(final String name, final String paramName)
- {
- return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName));
- }
-}
\ No newline at end of file
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java b/ruoyi/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java
deleted file mode 100644
index 323dbc1a..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java
+++ /dev/null
@@ -1,248 +0,0 @@
-package com.ruoyi.common.utils.http;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.net.ConnectException;
-import java.net.SocketTimeoutException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.security.cert.X509Certificate;
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * 閫氱敤http鍙戦佹柟娉
- *
- * @author ruoyi
- */
-public class HttpUtils
-{
- private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);
-
- /**
- * 鍚戞寚瀹 URL 鍙戦丟ET鏂规硶鐨勮姹
- *
- * @param url 鍙戦佽姹傜殑 URL
- * @param param 璇锋眰鍙傛暟锛岃姹傚弬鏁板簲璇ユ槸 name1=value1&name2=value2 鐨勫舰寮忋
- * @return 鎵浠h〃杩滅▼璧勬簮鐨勫搷搴旂粨鏋
- */
- public static String sendGet(String url, String param)
- {
- StringBuilder result = new StringBuilder();
- BufferedReader in = null;
- try
- {
- String urlNameString = url + "?" + param;
- log.info("sendGet - {}", urlNameString);
- URL realUrl = new URL(urlNameString);
- URLConnection connection = realUrl.openConnection();
- connection.setRequestProperty("accept", "*/*");
- connection.setRequestProperty("connection", "Keep-Alive");
- connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
- connection.connect();
- in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
- String line;
- while ((line = in.readLine()) != null)
- {
- result.append(line);
- }
- log.info("recv - {}", result);
- }
- catch (ConnectException e)
- {
- log.error("璋冪敤HttpUtils.sendGet ConnectException, url=" + url + ",param=" + param, e);
- }
- catch (SocketTimeoutException e)
- {
- log.error("璋冪敤HttpUtils.sendGet SocketTimeoutException, url=" + url + ",param=" + param, e);
- }
- catch (IOException e)
- {
- log.error("璋冪敤HttpUtils.sendGet IOException, url=" + url + ",param=" + param, e);
- }
- catch (Exception e)
- {
- log.error("璋冪敤HttpsUtil.sendGet Exception, url=" + url + ",param=" + param, e);
- }
- finally
- {
- try
- {
- if (in != null)
- {
- in.close();
- }
- }
- catch (Exception ex)
- {
- log.error("璋冪敤in.close Exception, url=" + url + ",param=" + param, ex);
- }
- }
- return result.toString();
- }
-
- /**
- * 鍚戞寚瀹 URL 鍙戦丳OST鏂规硶鐨勮姹
- *
- * @param url 鍙戦佽姹傜殑 URL
- * @param param 璇锋眰鍙傛暟锛岃姹傚弬鏁板簲璇ユ槸 name1=value1&name2=value2 鐨勫舰寮忋
- * @return 鎵浠h〃杩滅▼璧勬簮鐨勫搷搴旂粨鏋
- */
- public static String sendPost(String url, String param)
- {
- PrintWriter out = null;
- BufferedReader in = null;
- StringBuilder result = new StringBuilder();
- try
- {
- String urlNameString = url + "?" + param;
- log.info("sendPost - {}", urlNameString);
- URL realUrl = new URL(urlNameString);
- URLConnection conn = realUrl.openConnection();
- conn.setRequestProperty("accept", "*/*");
- conn.setRequestProperty("connection", "Keep-Alive");
- conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
- conn.setRequestProperty("Accept-Charset", "utf-8");
- conn.setRequestProperty("contentType", "utf-8");
- conn.setDoOutput(true);
- conn.setDoInput(true);
- out = new PrintWriter(conn.getOutputStream());
- out.print(param);
- out.flush();
- in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"));
- String line;
- while ((line = in.readLine()) != null)
- {
- result.append(line);
- }
- log.info("recv - {}", result);
- }
- catch (ConnectException e)
- {
- log.error("璋冪敤HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e);
- }
- catch (SocketTimeoutException e)
- {
- log.error("璋冪敤HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e);
- }
- catch (IOException e)
- {
- log.error("璋冪敤HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e);
- }
- catch (Exception e)
- {
- log.error("璋冪敤HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e);
- }
- finally
- {
- try
- {
- if (out != null)
- {
- out.close();
- }
- if (in != null)
- {
- in.close();
- }
- }
- catch (IOException ex)
- {
- log.error("璋冪敤in.close Exception, url=" + url + ",param=" + param, ex);
- }
- }
- return result.toString();
- }
-
- public static String sendSSLPost(String url, String param)
- {
- StringBuilder result = new StringBuilder();
- String urlNameString = url + "?" + param;
- try
- {
- log.info("sendSSLPost - {}", urlNameString);
- SSLContext sc = SSLContext.getInstance("SSL");
- sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom());
- URL console = new URL(urlNameString);
- HttpsURLConnection conn = (HttpsURLConnection) console.openConnection();
- conn.setRequestProperty("accept", "*/*");
- conn.setRequestProperty("connection", "Keep-Alive");
- conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
- conn.setRequestProperty("Accept-Charset", "utf-8");
- conn.setRequestProperty("contentType", "utf-8");
- conn.setDoOutput(true);
- conn.setDoInput(true);
-
- conn.setSSLSocketFactory(sc.getSocketFactory());
- conn.setHostnameVerifier(new TrustAnyHostnameVerifier());
- conn.connect();
- InputStream is = conn.getInputStream();
- BufferedReader br = new BufferedReader(new InputStreamReader(is));
- String ret = "";
- while ((ret = br.readLine()) != null)
- {
- if (ret != null && !ret.trim().equals(""))
- {
- result.append(new String(ret.getBytes("ISO-8859-1"), "utf-8"));
- }
- }
- log.info("recv - {}", result);
- conn.disconnect();
- br.close();
- }
- catch (ConnectException e)
- {
- log.error("璋冪敤HttpUtils.sendSSLPost ConnectException, url=" + url + ",param=" + param, e);
- }
- catch (SocketTimeoutException e)
- {
- log.error("璋冪敤HttpUtils.sendSSLPost SocketTimeoutException, url=" + url + ",param=" + param, e);
- }
- catch (IOException e)
- {
- log.error("璋冪敤HttpUtils.sendSSLPost IOException, url=" + url + ",param=" + param, e);
- }
- catch (Exception e)
- {
- log.error("璋冪敤HttpsUtil.sendSSLPost Exception, url=" + url + ",param=" + param, e);
- }
- return result.toString();
- }
-
- private static class TrustAnyTrustManager implements X509TrustManager
- {
- @Override
- public void checkClientTrusted(X509Certificate[] chain, String authType)
- {
- }
-
- @Override
- public void checkServerTrusted(X509Certificate[] chain, String authType)
- {
- }
-
- @Override
- public X509Certificate[] getAcceptedIssuers()
- {
- return new X509Certificate[] {};
- }
- }
-
- private static class TrustAnyHostnameVerifier implements HostnameVerifier
- {
- @Override
- public boolean verify(String hostname, SSLSession session)
- {
- return true;
- }
- }
-}
\ No newline at end of file
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java b/ruoyi/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java
deleted file mode 100644
index d70351f9..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.ruoyi.common.utils.ip;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import com.alibaba.fastjson.JSONObject;
-import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.utils.http.HttpUtils;
-
-/**
- * 鑾峰彇鍦板潃绫
- *
- * @author ruoyi
- */
-public class AddressUtils
-{
- private static final Logger log = LoggerFactory.getLogger(AddressUtils.class);
-
- public static final String IP_URL = "http://ip.taobao.com/service/getIpInfo.php";
-
- public static String getRealAddressByIP(String ip)
- {
- String address = "XX XX";
- // 鍐呯綉涓嶆煡璇
- if (IpUtils.internalIp(ip))
- {
- return "鍐呯綉IP";
- }
- String rspStr = HttpUtils.sendPost(IP_URL, "ip=" + ip);
- if (StringUtils.isEmpty(rspStr))
- {
- log.error("鑾峰彇鍦扮悊浣嶇疆寮傚父 {}", ip);
- return address;
- }
- JSONObject obj = JSONObject.parseObject(rspStr);
- JSONObject data = obj.getObject("data", JSONObject.class);
- String region = data.getString("region");
- String city = data.getString("city");
- address = region + " " + city;
- return address;
- }
-}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/ip/IpUtils.java b/ruoyi/src/main/java/com/ruoyi/common/utils/ip/IpUtils.java
deleted file mode 100644
index 9e050e9f..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/ip/IpUtils.java
+++ /dev/null
@@ -1,189 +0,0 @@
-package com.ruoyi.common.utils.ip;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import javax.servlet.http.HttpServletRequest;
-import com.ruoyi.common.utils.StringUtils;
-
-/**
- * 鑾峰彇IP鏂规硶
- *
- * @author ruoyi
- */
-public class IpUtils
-{
- public static String getIpAddr(HttpServletRequest request)
- {
- if (request == null)
- {
- return "unknown";
- }
- String ip = request.getHeader("x-forwarded-for");
- if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
- {
- ip = request.getHeader("Proxy-Client-IP");
- }
- if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
- {
- ip = request.getHeader("X-Forwarded-For");
- }
- if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
- {
- ip = request.getHeader("WL-Proxy-Client-IP");
- }
- if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
- {
- ip = request.getHeader("X-Real-IP");
- }
-
- if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
- {
- ip = request.getRemoteAddr();
- }
-
- return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : ip;
- }
-
- public static boolean internalIp(String ip)
- {
- byte[] addr = textToNumericFormatV4(ip);
- return internalIp(addr) || "127.0.0.1".equals(ip);
- }
-
- private static boolean internalIp(byte[] addr)
- {
- if (StringUtils.isNull(addr) || addr.length < 2)
- {
- return true;
- }
- final byte b0 = addr[0];
- final byte b1 = addr[1];
- // 10.x.x.x/8
- final byte SECTION_1 = 0x0A;
- // 172.16.x.x/12
- final byte SECTION_2 = (byte) 0xAC;
- final byte SECTION_3 = (byte) 0x10;
- final byte SECTION_4 = (byte) 0x1F;
- // 192.168.x.x/16
- final byte SECTION_5 = (byte) 0xC0;
- final byte SECTION_6 = (byte) 0xA8;
- switch (b0)
- {
- case SECTION_1:
- return true;
- case SECTION_2:
- if (b1 >= SECTION_3 && b1 <= SECTION_4)
- {
- return true;
- }
- case SECTION_5:
- switch (b1)
- {
- case SECTION_6:
- return true;
- }
- default:
- return false;
- }
- }
-
- /**
- * 灏咺Pv4鍦板潃杞崲鎴愬瓧鑺
- *
- * @param text IPv4鍦板潃
- * @return byte 瀛楄妭
- */
- public static byte[] textToNumericFormatV4(String text)
- {
- if (text.length() == 0)
- {
- return null;
- }
-
- byte[] bytes = new byte[4];
- String[] elements = text.split("\\.", -1);
- try
- {
- long l;
- int i;
- switch (elements.length)
- {
- case 1:
- l = Long.parseLong(elements[0]);
- if ((l < 0L) || (l > 4294967295L))
- return null;
- bytes[0] = (byte) (int) (l >> 24 & 0xFF);
- bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF);
- bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
- bytes[3] = (byte) (int) (l & 0xFF);
- break;
- case 2:
- l = Integer.parseInt(elements[0]);
- if ((l < 0L) || (l > 255L))
- return null;
- bytes[0] = (byte) (int) (l & 0xFF);
- l = Integer.parseInt(elements[1]);
- if ((l < 0L) || (l > 16777215L))
- return null;
- bytes[1] = (byte) (int) (l >> 16 & 0xFF);
- bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
- bytes[3] = (byte) (int) (l & 0xFF);
- break;
- case 3:
- for (i = 0; i < 2; ++i)
- {
- l = Integer.parseInt(elements[i]);
- if ((l < 0L) || (l > 255L))
- return null;
- bytes[i] = (byte) (int) (l & 0xFF);
- }
- l = Integer.parseInt(elements[2]);
- if ((l < 0L) || (l > 65535L))
- return null;
- bytes[2] = (byte) (int) (l >> 8 & 0xFF);
- bytes[3] = (byte) (int) (l & 0xFF);
- break;
- case 4:
- for (i = 0; i < 4; ++i)
- {
- l = Integer.parseInt(elements[i]);
- if ((l < 0L) || (l > 255L))
- return null;
- bytes[i] = (byte) (int) (l & 0xFF);
- }
- break;
- default:
- return null;
- }
- }
- catch (NumberFormatException e)
- {
- return null;
- }
- return bytes;
- }
-
- public static String getHostIp()
- {
- try
- {
- return InetAddress.getLocalHost().getHostAddress();
- }
- catch (UnknownHostException e)
- {
- }
- return "127.0.0.1";
- }
-
- public static String getHostName()
- {
- try
- {
- return InetAddress.getLocalHost().getHostName();
- }
- catch (UnknownHostException e)
- {
- }
- return "鏈煡";
- }
-}
\ No newline at end of file
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
deleted file mode 100644
index 27652fe1..00000000
--- a/ruoyi/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
+++ /dev/null
@@ -1,872 +0,0 @@
-package com.ruoyi.common.utils.poi;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import org.apache.poi.hssf.usermodel.HSSFDateUtil;
-import org.apache.poi.ss.usermodel.BorderStyle;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.CellType;
-import org.apache.poi.ss.usermodel.DataValidation;
-import org.apache.poi.ss.usermodel.DataValidationConstraint;
-import org.apache.poi.ss.usermodel.DataValidationHelper;
-import org.apache.poi.ss.usermodel.DateUtil;
-import org.apache.poi.ss.usermodel.FillPatternType;
-import org.apache.poi.ss.usermodel.Font;
-import org.apache.poi.ss.usermodel.HorizontalAlignment;
-import org.apache.poi.ss.usermodel.IndexedColors;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.VerticalAlignment;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.ss.usermodel.WorkbookFactory;
-import org.apache.poi.ss.util.CellRangeAddressList;
-import org.apache.poi.xssf.streaming.SXSSFWorkbook;
-import org.apache.poi.xssf.usermodel.XSSFDataValidation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import com.ruoyi.framework.aspectj.lang.annotation.Excel;
-import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType;
-import com.ruoyi.framework.aspectj.lang.annotation.Excel.Type;
-import com.ruoyi.framework.aspectj.lang.annotation.Excels;
-import com.ruoyi.framework.config.RuoYiConfig;
-import com.ruoyi.framework.web.domain.AjaxResult;
-import com.ruoyi.common.core.text.Convert;
-import com.ruoyi.common.exception.CustomException;
-import com.ruoyi.common.utils.DateUtils;
-import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.utils.reflect.ReflectUtils;
-
-/**
- * Excel鐩稿叧澶勭悊
- *
- * @author ruoyi
- */
-public class ExcelUtil
-{
- private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class);
-
- /**
- * Excel sheet鏈澶ц鏁帮紝榛樿65536
- */
- public static final int sheetSize = 65536;
-
- /**
- * 宸ヤ綔琛ㄥ悕绉
- */
- private String sheetName;
-
- /**
- * 瀵煎嚭绫诲瀷锛圗XPORT:瀵煎嚭鏁版嵁锛汭MPORT锛氬鍏ユā鏉匡級
- */
- private Type type;
-
- /**
- * 宸ヤ綔钖勫璞
- */
- private Workbook wb;
-
- /**
- * 宸ヤ綔琛ㄥ璞
- */
- private Sheet sheet;
-
- /**
- * 鏍峰紡鍒楄〃
- */
- private Map styles;
-
- /**
- * 瀵煎叆瀵煎嚭鏁版嵁鍒楄〃
- */
- private List list;
-
- /**
- * 娉ㄨВ鍒楄〃
- */
- private List