Commit 45e185d9 by songxiang

错题本二期相关代码

parent 0a9981a5
......@@ -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";
}
......@@ -6,10 +6,10 @@ 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";
......@@ -18,13 +18,39 @@ public class UUIDUitl {
/**
* 生成的token
*/
public static final String someCharStr="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@$%^&*()_+";
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
* 随机字符串长度
* @param length 随机字符串长度
* @return 随机字符串
*/
public static String generateInteger(int length) {
......@@ -39,8 +65,7 @@ public class UUIDUitl {
/**
* 返回一个定长的随机字符串(只包含大小写字母、数字)
*
* @param length
* 随机字符串长度
* @param length 随机字符串长度
* @return 随机字符串
*/
public static String generateString(int length) {
......@@ -55,8 +80,7 @@ public class UUIDUitl {
/**
* 返回一个定长的随机字符串(只包含大小写字母、数字)
*
* @param length
* 随机字符串长度
* @param length 随机字符串长度
* @return 随机字符串
*/
public static String generateAllString(int length) {
......@@ -67,11 +91,11 @@ public class UUIDUitl {
}
return sb.toString();
}
/**
* 返回一个定长的随机字符串(只包含大小写字母、数字),不包含#
*
* @param length
* 随机字符串长度
* @param length 随机字符串长度
* @return 随机字符串
*/
public static String generateSomeString(int length) {
......@@ -82,11 +106,11 @@ public class UUIDUitl {
}
return sb.toString();
}
/**
* 返回一个定长的随机纯字母字符串(只包含大小写字母)
*
* @param length
* 随机字符串长度
* @param length 随机字符串长度
* @return 随机字符串
*/
public static String generateMixString(int length) {
......@@ -101,8 +125,7 @@ public class UUIDUitl {
/**
* 返回一个定长的随机纯大写字母字符串(只包含大小写字母)
*
* @param length
* 随机字符串长度
* @param length 随机字符串长度
* @return 随机字符串
*/
public static String generateLowerString(int length) {
......@@ -112,8 +135,7 @@ public class UUIDUitl {
/**
* 返回一个定长的随机纯小写字母字符串(只包含大小写字母)
*
* @param length
* 随机字符串长度
* @param length 随机字符串长度
* @return 随机字符串
*/
public static String generateUpperString(int length) {
......@@ -123,8 +145,7 @@ public class UUIDUitl {
/**
* 生成一个定长的纯0字符串
*
* @param length
* 字符串长度
* @param length 字符串长度
* @return 纯0字符串
*/
public static String generateZeroString(int length) {
......@@ -138,10 +159,8 @@ public class UUIDUitl {
/**
* 根据数字生成一个定长的字符串,长度不够前面补0
*
* @param num
* 数字
* @param fixdlenth
* 字符串长度
* @param num 数字
* @param fixdlenth 字符串长度
* @return 定长的字符串
*/
public static String toFixdLengthString(long num, int fixdlenth) {
......@@ -159,10 +178,8 @@ public class UUIDUitl {
/**
* 根据数字生成一个定长的字符串,长度不够前面补0
*
* @param num
* 数字
* @param fixdlenth
* 字符串长度
* @param num 数字
* @param fixdlenth 字符串长度
* @return 定长的字符串
*/
public static String toFixdLengthString(int num, int fixdlenth) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment