Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐少华
midjourney-proxy
Commits
45e185d9
Commit
45e185d9
authored
Jun 24, 2019
by
songxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
错题本二期相关代码
parent
0a9981a5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
216 additions
and
195 deletions
+216
-195
MQTopicProducer.java
...java/com/pcloud/common/core/constant/MQTopicProducer.java
+4
-0
UUIDUitl.java
...ommon/src/main/java/com/pcloud/common/utils/UUIDUitl.java
+212
-195
No files found.
pcloud-common-core/src/main/java/com/pcloud/common/core/constant/MQTopicProducer.java
View file @
45e185d9
...
...
@@ -344,4 +344,8 @@ public class MQTopicProducer {
* 微信群用户绑定TOPIC
*/
public
static
final
String
WXGROUP_USER_BIND
=
"topic.wXGroupUserBind"
;
/**
* 商品创建
*/
public
static
final
String
PRODUCT_CREATE
=
"topic.productCreate"
;
}
pcloud-common/src/main/java/com/pcloud/common/utils/UUIDUitl.java
View file @
45e185d9
...
...
@@ -6,201 +6,218 @@ import java.util.UUID;
/**
* @描述:生成随机数
* @作者:DiSeng.H
* @创建时间:2016年3月10日,下午1:17:02
* @版本:1.0
* @创建时间:2016年3月10日,下午1:17:02 @版本:1.0
*/
public
class
UUIDUitl
{
public
static
final
String
allCharStr
=
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+"
;
public
static
final
String
allChar
=
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
public
static
final
String
letterChar
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
public
static
final
String
numberChar
=
"0123456789"
;
public
static
final
String
specialChar
=
"!@#$%^&*()_+"
;
/**
* 生成的token
*/
public
static
final
String
someCharStr
=
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@$%^&*()_+"
;
/**
* 返回一个定长的随机字符串(只包含大小写字母、数字)
*
* @param length
* 随机字符串长度
* @return 随机字符串
*/
public
static
String
generateInteger
(
int
length
)
{
StringBuffer
sb
=
new
StringBuffer
();
Random
random
=
new
Random
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
sb
.
append
(
numberChar
.
charAt
(
random
.
nextInt
(
numberChar
.
length
())));
}
return
sb
.
toString
();
}
/**
* 返回一个定长的随机字符串(只包含大小写字母、数字)
*
* @param length
* 随机字符串长度
* @return 随机字符串
*/
public
static
String
generateString
(
int
length
)
{
StringBuffer
sb
=
new
StringBuffer
();
Random
random
=
new
Random
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
sb
.
append
(
allChar
.
charAt
(
random
.
nextInt
(
allChar
.
length
())));
}
return
sb
.
toString
();
}
/**
* 返回一个定长的随机字符串(只包含大小写字母、数字)
*
* @param length
* 随机字符串长度
* @return 随机字符串
*/
public
static
String
generateAllString
(
int
length
)
{
StringBuffer
sb
=
new
StringBuffer
();
Random
random
=
new
Random
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
sb
.
append
(
allCharStr
.
charAt
(
random
.
nextInt
(
allCharStr
.
length
())));
}
return
sb
.
toString
();
}
/**
* 返回一个定长的随机字符串(只包含大小写字母、数字),不包含#
*
* @param length
* 随机字符串长度
* @return 随机字符串
*/
public
static
String
generateSomeString
(
int
length
)
{
StringBuffer
sb
=
new
StringBuffer
();
Random
random
=
new
Random
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
sb
.
append
(
someCharStr
.
charAt
(
random
.
nextInt
(
someCharStr
.
length
())));
}
return
sb
.
toString
();
}
/**
* 返回一个定长的随机纯字母字符串(只包含大小写字母)
*
* @param length
* 随机字符串长度
* @return 随机字符串
*/
public
static
String
generateMixString
(
int
length
)
{
StringBuffer
sb
=
new
StringBuffer
();
Random
random
=
new
Random
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
sb
.
append
(
allChar
.
charAt
(
random
.
nextInt
(
letterChar
.
length
())));
}
return
sb
.
toString
();
}
/**
* 返回一个定长的随机纯大写字母字符串(只包含大小写字母)
*
* @param length
* 随机字符串长度
* @return 随机字符串
*/
public
static
String
generateLowerString
(
int
length
)
{
return
generateMixString
(
length
).
toLowerCase
();
}
/**
* 返回一个定长的随机纯小写字母字符串(只包含大小写字母)
*
* @param length
* 随机字符串长度
* @return 随机字符串
*/
public
static
String
generateUpperString
(
int
length
)
{
return
generateMixString
(
length
).
toUpperCase
();
}
/**
* 生成一个定长的纯0字符串
*
* @param length
* 字符串长度
* @return 纯0字符串
*/
public
static
String
generateZeroString
(
int
length
)
{
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
sb
.
append
(
'0'
);
}
return
sb
.
toString
();
}
/**
* 根据数字生成一个定长的字符串,长度不够前面补0
*
* @param num
* 数字
* @param fixdlenth
* 字符串长度
* @return 定长的字符串
*/
public
static
String
toFixdLengthString
(
long
num
,
int
fixdlenth
)
{
StringBuffer
sb
=
new
StringBuffer
();
String
strNum
=
String
.
valueOf
(
num
);
if
(
fixdlenth
-
strNum
.
length
()
>=
0
)
{
sb
.
append
(
generateZeroString
(
fixdlenth
-
strNum
.
length
()));
}
else
{
throw
new
RuntimeException
(
"将数字"
+
num
+
"转化为长度为"
+
fixdlenth
+
"的字符串发生异常!"
);
}
sb
.
append
(
strNum
);
return
sb
.
toString
();
}
/**
* 根据数字生成一个定长的字符串,长度不够前面补0
*
* @param num
* 数字
* @param fixdlenth
* 字符串长度
* @return 定长的字符串
*/
public
static
String
toFixdLengthString
(
int
num
,
int
fixdlenth
)
{
StringBuffer
sb
=
new
StringBuffer
();
String
strNum
=
String
.
valueOf
(
num
);
if
(
fixdlenth
-
strNum
.
length
()
>=
0
)
{
sb
.
append
(
generateZeroString
(
fixdlenth
-
strNum
.
length
()));
}
else
{
throw
new
RuntimeException
(
"将数字"
+
num
+
"转化为长度为"
+
fixdlenth
+
"的字符串发生异常!"
);
}
sb
.
append
(
strNum
);
return
sb
.
toString
();
}
/**
* 八位数字+字母+特殊字符随机密码生成
*
* @return
*/
public
static
String
generatePwdStr
()
{
StringBuffer
sb
=
new
StringBuffer
();
Random
random
=
new
Random
();
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
sb
.
append
(
allChar
.
charAt
(
random
.
nextInt
(
letterChar
.
length
())));
sb
.
append
(
numberChar
.
charAt
(
random
.
nextInt
(
numberChar
.
length
())));
}
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
sb
.
append
(
specialChar
.
charAt
(
random
.
nextInt
(
specialChar
.
length
())));
}
return
sb
.
toString
();
}
/**
* 生成随机任务名称
*
* @return
*/
public
static
String
taskName
()
{
return
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
}
public
static
final
String
allCharStr
=
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+"
;
public
static
final
String
allChar
=
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
public
static
final
String
letterChar
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
public
static
final
String
numberChar
=
"0123456789"
;
public
static
final
String
specialChar
=
"!@#$%^&*()_+"
;
/**
* 生成的token
*/
public
static
final
String
someCharStr
=
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@$%^&*()_+"
;
public
static
String
[]
chars
=
new
String
[]{
"a"
,
"b"
,
"c"
,
"d"
,
"e"
,
"f"
,
"g"
,
"h"
,
"i"
,
"j"
,
"k"
,
"l"
,
"m"
,
"n"
,
"o"
,
"p"
,
"q"
,
"r"
,
"s"
,
"t"
,
"u"
,
"v"
,
"w"
,
"x"
,
"y"
,
"z"
,
"0"
,
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"A"
,
"B"
,
"C"
,
"D"
,
"E"
,
"F"
,
"G"
,
"H"
,
"I"
,
"J"
,
"K"
,
"L"
,
"M"
,
"N"
,
"O"
,
"P"
,
"Q"
,
"R"
,
"S"
,
"T"
,
"U"
,
"V"
,
"W"
,
"X"
,
"Y"
,
"Z"
};
/**
* 生成8位不重复的随机码
*
* @return
*/
public
static
String
generateShort
()
{
StringBuffer
shortBuffer
=
new
StringBuffer
();
String
uuid
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
for
(
int
i
=
0
;
i
<
8
;
i
++)
{
String
str
=
uuid
.
substring
(
i
*
4
,
i
*
4
+
4
);
int
x
=
Integer
.
parseInt
(
str
,
16
);
shortBuffer
.
append
(
chars
[
x
%
0x3E
]);
}
return
shortBuffer
.
toString
();
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
generateShort
());
}
/**
* 返回一个定长的随机字符串(只包含大小写字母、数字)
*
* @param length 随机字符串长度
* @return 随机字符串
*/
public
static
String
generateInteger
(
int
length
)
{
StringBuffer
sb
=
new
StringBuffer
();
Random
random
=
new
Random
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
sb
.
append
(
numberChar
.
charAt
(
random
.
nextInt
(
numberChar
.
length
())));
}
return
sb
.
toString
();
}
/**
* 返回一个定长的随机字符串(只包含大小写字母、数字)
*
* @param length 随机字符串长度
* @return 随机字符串
*/
public
static
String
generateString
(
int
length
)
{
StringBuffer
sb
=
new
StringBuffer
();
Random
random
=
new
Random
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
sb
.
append
(
allChar
.
charAt
(
random
.
nextInt
(
allChar
.
length
())));
}
return
sb
.
toString
();
}
/**
* 返回一个定长的随机字符串(只包含大小写字母、数字)
*
* @param length 随机字符串长度
* @return 随机字符串
*/
public
static
String
generateAllString
(
int
length
)
{
StringBuffer
sb
=
new
StringBuffer
();
Random
random
=
new
Random
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
sb
.
append
(
allCharStr
.
charAt
(
random
.
nextInt
(
allCharStr
.
length
())));
}
return
sb
.
toString
();
}
/**
* 返回一个定长的随机字符串(只包含大小写字母、数字),不包含#
*
* @param length 随机字符串长度
* @return 随机字符串
*/
public
static
String
generateSomeString
(
int
length
)
{
StringBuffer
sb
=
new
StringBuffer
();
Random
random
=
new
Random
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
sb
.
append
(
someCharStr
.
charAt
(
random
.
nextInt
(
someCharStr
.
length
())));
}
return
sb
.
toString
();
}
/**
* 返回一个定长的随机纯字母字符串(只包含大小写字母)
*
* @param length 随机字符串长度
* @return 随机字符串
*/
public
static
String
generateMixString
(
int
length
)
{
StringBuffer
sb
=
new
StringBuffer
();
Random
random
=
new
Random
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
sb
.
append
(
allChar
.
charAt
(
random
.
nextInt
(
letterChar
.
length
())));
}
return
sb
.
toString
();
}
/**
* 返回一个定长的随机纯大写字母字符串(只包含大小写字母)
*
* @param length 随机字符串长度
* @return 随机字符串
*/
public
static
String
generateLowerString
(
int
length
)
{
return
generateMixString
(
length
).
toLowerCase
();
}
/**
* 返回一个定长的随机纯小写字母字符串(只包含大小写字母)
*
* @param length 随机字符串长度
* @return 随机字符串
*/
public
static
String
generateUpperString
(
int
length
)
{
return
generateMixString
(
length
).
toUpperCase
();
}
/**
* 生成一个定长的纯0字符串
*
* @param length 字符串长度
* @return 纯0字符串
*/
public
static
String
generateZeroString
(
int
length
)
{
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
sb
.
append
(
'0'
);
}
return
sb
.
toString
();
}
/**
* 根据数字生成一个定长的字符串,长度不够前面补0
*
* @param num 数字
* @param fixdlenth 字符串长度
* @return 定长的字符串
*/
public
static
String
toFixdLengthString
(
long
num
,
int
fixdlenth
)
{
StringBuffer
sb
=
new
StringBuffer
();
String
strNum
=
String
.
valueOf
(
num
);
if
(
fixdlenth
-
strNum
.
length
()
>=
0
)
{
sb
.
append
(
generateZeroString
(
fixdlenth
-
strNum
.
length
()));
}
else
{
throw
new
RuntimeException
(
"将数字"
+
num
+
"转化为长度为"
+
fixdlenth
+
"的字符串发生异常!"
);
}
sb
.
append
(
strNum
);
return
sb
.
toString
();
}
/**
* 根据数字生成一个定长的字符串,长度不够前面补0
*
* @param num 数字
* @param fixdlenth 字符串长度
* @return 定长的字符串
*/
public
static
String
toFixdLengthString
(
int
num
,
int
fixdlenth
)
{
StringBuffer
sb
=
new
StringBuffer
();
String
strNum
=
String
.
valueOf
(
num
);
if
(
fixdlenth
-
strNum
.
length
()
>=
0
)
{
sb
.
append
(
generateZeroString
(
fixdlenth
-
strNum
.
length
()));
}
else
{
throw
new
RuntimeException
(
"将数字"
+
num
+
"转化为长度为"
+
fixdlenth
+
"的字符串发生异常!"
);
}
sb
.
append
(
strNum
);
return
sb
.
toString
();
}
/**
* 八位数字+字母+特殊字符随机密码生成
*
* @return
*/
public
static
String
generatePwdStr
()
{
StringBuffer
sb
=
new
StringBuffer
();
Random
random
=
new
Random
();
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
sb
.
append
(
allChar
.
charAt
(
random
.
nextInt
(
letterChar
.
length
())));
sb
.
append
(
numberChar
.
charAt
(
random
.
nextInt
(
numberChar
.
length
())));
}
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
sb
.
append
(
specialChar
.
charAt
(
random
.
nextInt
(
specialChar
.
length
())));
}
return
sb
.
toString
();
}
/**
* 生成随机任务名称
*
* @return
*/
public
static
String
taskName
()
{
return
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment