mirror of
https://gitee.com/jzsw-it/yexuejc-base.git
synced 2025-06-06 13:54:03 +08:00
1.1.9
This commit is contained in:
parent
5545bcfc9f
commit
e890fd94c3
@ -1,13 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: javax.validation:validation-api:1.1.0.Final">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar!/" />
|
||||
<root url="jar://J:/localRepo/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final-javadoc.jar!/" />
|
||||
<root url="jar://J:/localRepo/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final-sources.jar!/" />
|
||||
<root url="jar://J:/localRepo/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
13
README.md
13
README.md
@ -3,11 +3,20 @@
|
||||
### 说明
|
||||
>1. 支持环境:java8
|
||||
>2. 该工具包基于springboot提取,按理说适用于所有java工程
|
||||
>3. 其中依赖jjwt、validation-api,但不传递依赖
|
||||
>3. 其中依赖jjwt、validation-api,排除请使用
|
||||
```
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>xxx</artifactId>
|
||||
<groupId>xxxx</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
```
|
||||
>4. 1.1.9升级JWT为单例类
|
||||
|
||||
|
||||
### 使用
|
||||
>yexuejc.base.version=1.1.7
|
||||
>yexuejc.base.version=1.1.9
|
||||
|
||||
pom.xml
|
||||
```
|
||||
|
@ -1,6 +1,14 @@
|
||||
yexuejc-base 更新记录
|
||||
------------------
|
||||
|
||||
#### version :1.1.9
|
||||
**time:2018-9-23 11:57:36** <br/>
|
||||
**branch:** master <br/>
|
||||
**update:** <br/>
|
||||
>1. 优化工具类包名:不向下兼容,升级请修改
|
||||
>2. 升级JWT工具类:更改为单例模式,可配置参数
|
||||
#
|
||||
|
||||
#### version :1.1.8
|
||||
**time:2018-9-3 19:29:56** <br/>
|
||||
**branch:** master <br/>
|
||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.yexuejc.base</groupId>
|
||||
<artifactId>yexuejc-base</artifactId>
|
||||
<version>1.1.8</version>
|
||||
<version>1.1.9</version>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
package com.yexuejc.base.util;
|
||||
|
||||
|
||||
import sun.misc.BASE64Decoder;
|
||||
|
||||
/**
|
||||
* 算法工具类
|
||||
*
|
||||
@ -11,13 +9,13 @@ import sun.misc.BASE64Decoder;
|
||||
* @author: maxf
|
||||
* @date: 2017年11月23日 下午3:17:58
|
||||
*/
|
||||
public class AlgorithmUtils {
|
||||
public class AlgorithmUtil {
|
||||
private static final int LENGTH_1 = 1;
|
||||
private static final int LENGTH_2 = 2;
|
||||
private static final int LENGTH_3 = 3;
|
||||
private static final int LENGTH_36 = 36;
|
||||
|
||||
private AlgorithmUtils() {
|
||||
private AlgorithmUtil() {
|
||||
}
|
||||
|
||||
private static final String X36 = "0123456789abcdefghijklmnopqrstuvwxyz";
|
@ -13,6 +13,9 @@ import java.util.Date;
|
||||
* @date: 2018/3/27 10:44
|
||||
*/
|
||||
public class DateTimeUtil {
|
||||
private DateTimeUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本年第一天
|
||||
*
|
||||
@ -106,7 +109,8 @@ public class DateTimeUtil {
|
||||
* @return
|
||||
*/
|
||||
public static LocalDate getWeek4First(LocalDate date) {
|
||||
TemporalAdjuster FIRST_OF_WEEK = TemporalAdjusters.ofDateAdjuster(localDate -> localDate.minusDays(localDate.getDayOfWeek().getValue() - DayOfWeek.MONDAY.getValue()));
|
||||
TemporalAdjuster FIRST_OF_WEEK =
|
||||
TemporalAdjusters.ofDateAdjuster(localDate -> localDate.minusDays(localDate.getDayOfWeek().getValue() - DayOfWeek.MONDAY.getValue()));
|
||||
return date.with(FIRST_OF_WEEK);
|
||||
}
|
||||
|
||||
@ -126,7 +130,8 @@ public class DateTimeUtil {
|
||||
* @return
|
||||
*/
|
||||
public static LocalDate getWeek4Last(LocalDate date) {
|
||||
TemporalAdjuster LAST_OF_WEEK = TemporalAdjusters.ofDateAdjuster(localDate -> localDate.plusDays(DayOfWeek.SUNDAY.getValue() - localDate.getDayOfWeek().getValue()));
|
||||
TemporalAdjuster LAST_OF_WEEK =
|
||||
TemporalAdjusters.ofDateAdjuster(localDate -> localDate.plusDays(DayOfWeek.SUNDAY.getValue() - localDate.getDayOfWeek().getValue()));
|
||||
return date.with(LAST_OF_WEEK);
|
||||
}
|
||||
|
||||
|
@ -6,12 +6,14 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* java.util.Date 时间工具类
|
||||
* @ClassName DateUtil
|
||||
* java.util.Date 时间工具类
|
||||
*
|
||||
* @author maxf
|
||||
* @ClassName DateUtil
|
||||
* @Description
|
||||
* @author maxf
|
||||
* @date 2018/9/3 15:27
|
||||
* @date 2018/9/3 15:27
|
||||
*/
|
||||
public class DateUtil {
|
||||
private DateUtil() {
|
||||
@ -87,7 +89,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期字符串转date
|
||||
* date转字符串
|
||||
*
|
||||
* @param date
|
||||
* @return Date
|
||||
@ -101,6 +103,34 @@ public class DateUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期字符串转dateTime
|
||||
*
|
||||
* @param dateStr
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
public static Date str2dateTime(String dateStr) throws ParseException {
|
||||
Date date = DATE_TIME_FORMAT.parse(dateStr);
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
* dateTime转字符串
|
||||
*
|
||||
* @param date
|
||||
* @return Date
|
||||
* @throws ParseException
|
||||
*/
|
||||
public static String dateTime2str(Date date) throws ParseException {
|
||||
if (date != null) {
|
||||
return DATE_TIME_FORMAT.format(date);
|
||||
} else {
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取本周的日期
|
||||
*
|
||||
|
@ -8,8 +8,9 @@ package com.yexuejc.base.util;
|
||||
* @author: maxf
|
||||
* @date: 2017/12/27 16:42
|
||||
*/
|
||||
public class ExcelImportUtils {
|
||||
|
||||
public class ExcelImportUtil {
|
||||
private ExcelImportUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是2003的excel,返回true是2003
|
@ -22,6 +22,8 @@ import java.util.Iterator;
|
||||
* @date 2018/9/3 15:25
|
||||
*/
|
||||
public class ImgUtil {
|
||||
private ImgUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一张网络图片转化成Base64字符串
|
||||
|
@ -8,65 +8,59 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* jwt工具类
|
||||
* <p>
|
||||
* 升级2.0
|
||||
* <br/>
|
||||
* 由静态类分装成单例类,可配置参数config()
|
||||
* </p>
|
||||
*
|
||||
* @author maxf
|
||||
* @version 2.0
|
||||
* @ClassName JwtUtil
|
||||
* @Description
|
||||
* @date 2018/9/3 15:28
|
||||
*/
|
||||
public class JwtUtil {
|
||||
/**
|
||||
* 加密用KEY
|
||||
*/
|
||||
private static String JWT_SIGNATURE_KEY = "h%OG8Y3WgA5AN7&6Ke7I#C1XvneW0N8a";
|
||||
/**
|
||||
* token类型
|
||||
*/
|
||||
private static String JWT_HEADER_TYP = "JWT";
|
||||
/**
|
||||
* token发行商
|
||||
*/
|
||||
private static String JWT_CLAIMS_ISS = "yexuejc.com";
|
||||
|
||||
private JwtUtil() {
|
||||
}
|
||||
|
||||
public static JwtUtil instace() {
|
||||
return Instace.jwtUtil;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置配置
|
||||
* 参数配置:设置一次即可,多次设置会覆盖之前的
|
||||
*
|
||||
* @param key
|
||||
* @param type
|
||||
* @param iss
|
||||
* @param key 加密key 默认:h%OG8Y3WgA5AN7&6Ke7I#C1XvneW0N8a
|
||||
* @param type 加密类型:默认JWT
|
||||
* @param iss token发行商: 默认yexuejc.com
|
||||
* @return
|
||||
*/
|
||||
public static void setConf(String key, String type, String iss) {
|
||||
JWT_SIGNATURE_KEY = key;
|
||||
JWT_HEADER_TYP = type;
|
||||
JWT_CLAIMS_ISS = iss;
|
||||
public static JwtUtil config(String key, String type, String iss) {
|
||||
JwtUtil jwtUtil = instace();
|
||||
jwtUtil.JWT_SIGNATURE_KEY = key;
|
||||
jwtUtil.JWT_HEADER_TYP = type;
|
||||
jwtUtil.JWT_CLAIMS_ISS = iss;
|
||||
return jwtUtil;
|
||||
}
|
||||
|
||||
public static class Instace {
|
||||
private static JwtUtil jwtUtil = new JwtUtil();
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密用KEY
|
||||
*
|
||||
* @param key
|
||||
*/
|
||||
public static void setSignatureKey(String key) {
|
||||
JWT_SIGNATURE_KEY = key;
|
||||
}
|
||||
|
||||
private String JWT_SIGNATURE_KEY = "h%OG8Y3WgA5AN7&6Ke7I#C1XvneW0N8a";
|
||||
/**
|
||||
* token类型
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public static void setHeaderType(String type) {
|
||||
JWT_HEADER_TYP = type;
|
||||
}
|
||||
|
||||
private String JWT_HEADER_TYP = "JWT";
|
||||
/**
|
||||
* token发行商
|
||||
*
|
||||
* @param iss
|
||||
*/
|
||||
public static void setClaimsIss(String iss) {
|
||||
JWT_CLAIMS_ISS = iss;
|
||||
}
|
||||
private String JWT_CLAIMS_ISS = "yexuejc.com";
|
||||
|
||||
/**
|
||||
* 加密内容生成token
|
||||
@ -74,7 +68,7 @@ public class JwtUtil {
|
||||
* @param subjectObj
|
||||
* @return
|
||||
*/
|
||||
public static String compact(Object subjectObj) {
|
||||
public String compact(Object subjectObj) {
|
||||
String subject = null;
|
||||
if (subjectObj instanceof String) {
|
||||
subject = (String) subjectObj;
|
||||
@ -106,7 +100,7 @@ public class JwtUtil {
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public static Map<?, ?> parse(String token) {
|
||||
public Map<?, ?> parse(String token) {
|
||||
return parse(token, Map.class);
|
||||
}
|
||||
|
||||
@ -117,7 +111,7 @@ public class JwtUtil {
|
||||
* @param cls
|
||||
* @return
|
||||
*/
|
||||
public static <T> T parse(String token, Class<T> cls) {
|
||||
public <T> T parse(String token, Class<T> cls) {
|
||||
String subject = null;
|
||||
try {
|
||||
subject = Jwts.parser().setSigningKey(JWT_SIGNATURE_KEY).parseClaimsJws(token).getBody().getSubject();
|
||||
|
@ -11,8 +11,8 @@ import java.text.DecimalFormat;
|
||||
* @author: maxf
|
||||
* @date: 2017年12月1日 下午5:33:57
|
||||
*/
|
||||
public class MoneyUtils {
|
||||
private MoneyUtils() {
|
||||
public class MoneyUtil {
|
||||
private MoneyUtil() {
|
||||
}
|
||||
|
||||
/**
|
@ -10,8 +10,8 @@ import java.util.regex.Pattern;
|
||||
* @expl
|
||||
* @time 2017年11月9日 上午11:01:24
|
||||
*/
|
||||
public class RegexUtils {
|
||||
private RegexUtils() {
|
||||
public class RegexUtil {
|
||||
private RegexUtil() {
|
||||
}
|
||||
|
||||
/**
|
@ -16,6 +16,9 @@ import java.util.regex.Pattern;
|
||||
* @date: 2018/5/12 19:13
|
||||
*/
|
||||
public final class StrUtil {
|
||||
private StrUtil() {
|
||||
}
|
||||
|
||||
public static char[] HEX_CHAR = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||
|
||||
/**
|
||||
|
@ -10,10 +10,10 @@ import java.net.URL;
|
||||
* @author: maxf
|
||||
* @date: 2017/12/28 16:12
|
||||
*/
|
||||
public class SysUtils {
|
||||
public class SysUtil {
|
||||
private static final String PROJECT_ROOT_PATH = "java.io.tmpdir";
|
||||
|
||||
private SysUtils() {
|
||||
private SysUtil() {
|
||||
}
|
||||
|
||||
/**
|
@ -20,6 +20,8 @@ import java.security.Key;
|
||||
* @date 2018/9/3 17:09
|
||||
*/
|
||||
public class ThreeDES {
|
||||
private ThreeDES() {
|
||||
}
|
||||
|
||||
private static final String IV = "1234567-";
|
||||
private final static String encoding = "utf-8";
|
||||
|
Loading…
x
Reference in New Issue
Block a user