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