clazz) {
+ return clazz.cast(CacheUtil.get(key));
+ }
+
+ /**
+ * 清除缓存
+ *
+ * @param key
+ * @return
+ */
+ public synchronized static Object remove(String key) {
+ //清除原缓存数据
+ Entity entity = map.remove(key);
+ if (entity == null) {
+ return null;
+ }
+ //清除原键值对定时器
+ Future future = entity.getFuture();
+ if (future != null) {
+ future.cancel(true);
+ }
+ return entity.getValue();
+ }
+
+ /**
+ * 查询当前缓存的键值对数量
+ *
+ * @return
+ */
+ public synchronized static int size() {
+ return map.size();
+ }
+
+ /**
+ * 缓存实体类
+ */
+ private static class Entity {
+ //键值对的value
+ private Object value;
+ //定时器Future
+ private Future future;
+
+ public Entity(Object value, Future future) {
+ this.value = value;
+ this.future = future;
+ }
+
+ /**
+ * 获取值
+ *
+ * @return
+ */
+ public Object getValue() {
+ return value;
+ }
+
+ /**
+ * 获取Future对象
+ *
+ * @return
+ */
+ public Future getFuture() {
+ return future;
+ }
+ }
+}
diff --git a/common/src/main/java/com/huoran/common/utils/CheckCodeUtils.java b/common/src/main/java/com/huoran/common/utils/CheckCodeUtils.java
new file mode 100644
index 0000000..65a252a
--- /dev/null
+++ b/common/src/main/java/com/huoran/common/utils/CheckCodeUtils.java
@@ -0,0 +1,44 @@
+package com.huoran.common.utils;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Random;
+
+/**
+ * @description 验证码工具类
+ * @author: Mr.JK
+ * @create: 2021-06-22 15:56
+ **/
+public class CheckCodeUtils {
+
+ /**
+ * 获取六位随机数验证码
+ * @return
+ */
+ public String sendCode(){
+
+ Random random = new Random();
+ String code="";
+ for (int i=0;i<6;i++)
+ {
+ code+=random.nextInt(10);
+ }
+ return code;
+ }
+
+ /**
+ * 生成时间
+ */
+ public String letTimes(int letTime){
+
+ Calendar instance = Calendar.getInstance();
+ instance.add(Calendar.MINUTE,+letTime);
+ Date time = instance.getTime();
+ SimpleDateFormat myFmt=new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
+ String format1 = myFmt.format(time);
+
+ return format1;
+ }
+
+}
diff --git a/common/src/main/java/com/huoran/common/utils/CheckDateUtil.java b/common/src/main/java/com/huoran/common/utils/CheckDateUtil.java
new file mode 100644
index 0000000..65e3a8f
--- /dev/null
+++ b/common/src/main/java/com/huoran/common/utils/CheckDateUtil.java
@@ -0,0 +1,41 @@
+package com.huoran.common.utils;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * @ProjectName: huorantech
+ * @Package: com.huoran.common.utils
+ * @ClassName: CheckDateUtil
+ * @Description: 校验用户输入的时间
+ * @Author: Maureen.Rong
+ * @CreateDate: 2021/8/19 11:12
+ * @UpdateDate: 2021/8/19 11:12
+ * @Version: 1.0
+ */
+public class CheckDateUtil {
+ /**
+ * 如果为true表示
+ * 校验用户输入的时间
+ *
+ * @param startTime
+ * @return
+ */
+ public static boolean checStartkTime(String startTime) {
+ try {
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ //用户输入的时间
+ Date dateTime1 = dateFormat.parse(startTime);
+ //当前时间
+ String DateStr2 = DateUtils.nowTime();
+ Date dateTime2 = dateFormat.parse(DateStr2);
+ int i = dateTime1.compareTo(dateTime2);
+ boolean ret = false;
+ ret = i > 0;
+ return ret;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+}
diff --git a/common/src/main/java/com/huoran/common/utils/ConstantPropertiesUtil.java b/common/src/main/java/com/huoran/common/utils/ConstantPropertiesUtil.java
new file mode 100644
index 0000000..66a3765
--- /dev/null
+++ b/common/src/main/java/com/huoran/common/utils/ConstantPropertiesUtil.java
@@ -0,0 +1,39 @@
+package com.huoran.common.utils;
+
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.stereotype.Component;
+
+/**
+ * 常量类,读取配置文件application.properties中的配置
+ */
+@Component
+@PropertySource("classpath:application.properties")
+public class ConstantPropertiesUtil implements InitializingBean {
+
+ @Value("${aliyun.oss.file.endpoint}")
+ private String endpoint;
+
+ @Value("${aliyun.oss.file.keyid}")
+ private String keyId;
+
+ @Value("${aliyun.oss.file.keysecret}")
+ private String keySecret;
+
+ @Value("${aliyun.oss.file.bucketname}")
+ private String bucketName;
+
+ public static String END_POINT;
+ public static String ACCESS_KEY_ID;
+ public static String ACCESS_KEY_SECRET;
+ public static String BUCKET_NAME;
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ END_POINT = endpoint;
+ ACCESS_KEY_ID = keyId;
+ ACCESS_KEY_SECRET = keySecret;
+ BUCKET_NAME = bucketName;
+ }
+}
diff --git a/common/src/main/java/com/huoran/common/utils/DateUtil.java b/common/src/main/java/com/huoran/common/utils/DateUtil.java
new file mode 100644
index 0000000..14660b0
--- /dev/null
+++ b/common/src/main/java/com/huoran/common/utils/DateUtil.java
@@ -0,0 +1,45 @@
+package com.huoran.common.utils;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * @Author chen
+ * @DATE 2020/10/20 10:46
+ * @Version 1.0
+ */
+public class DateUtil {
+
+ public static String lastDate(Integer month){
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ Calendar c = Calendar.getInstance();
+
+ if (month==1){
+ c.add(Calendar.MONTH,-1);
+ Date time = c.getTime();
+ return format.format(time);
+ }
+ if (month==3){
+ c.add(Calendar.MONTH,-3);
+ Date time = c.getTime();
+ return format.format(time);
+ }
+ if (month==6){
+ c.add(Calendar.MONTH,-6);
+ Date time = c.getTime();
+ return format.format(time);
+ }
+ return "";
+ }
+
+ public static String currentDate(){
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ return format.format(new Date());
+ }
+
+ public static void main(String[] args) {
+ System.out.println(currentDate());
+ }
+
+}
diff --git a/common/src/main/java/com/huoran/common/utils/DateUtils.java b/common/src/main/java/com/huoran/common/utils/DateUtils.java
new file mode 100644
index 0000000..d65ccd0
--- /dev/null
+++ b/common/src/main/java/com/huoran/common/utils/DateUtils.java
@@ -0,0 +1,193 @@
+package com.huoran.common.utils;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.Calendar;
+import java.util.Date;
+
+public class DateUtils {
+
+ public static String handleTime(Date date) {
+ Instant instant = date.toInstant();
+ ZoneId zoneId = ZoneId.systemDefault();
+ LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime();
+ return localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); // 当前日期和时间
+ }
+
+ public static String formatTime(LocalDateTime time) {
+ String timeStr1 = time.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+ return timeStr1;
+ }
+
+ /**
+ * 时间类型转换
+ *
+ * @param time
+ * @return
+ */
+ public static String dateForByStr(String time) {
+ try {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+ Date date = sdf.parse(time);
+ //获取String类型的时间
+ String createdate = sdf.format(date);
+ return createdate;
+ } catch (ParseException e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ }
+
+ /**
+ * 获取当前时间
+ *
+ * @return
+ */
+ /*public static String getNowTime(Integer userId) {
+
+ String getDate = template.opsForValue().get("date:userId_" + userId);
+ SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ String datetime = tempDate.format(new java.utils.Date());
+ //也可以用这个
+ String datetimes = tempDate.format(new Date(System.currentTimeMillis()));
+ return getDate;
+ }*/
+ public static String getNowTime() {
+ SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+ String datetime = tempDate.format(new Date());
+ //也可以用这个
+ String datetimes = tempDate.format(new Date(System.currentTimeMillis()));
+ return datetime;
+ }
+
+ public static String nowTime() {
+ SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ String datetime = tempDate.format(new Date());
+ //也可以用这个
+ String datetimes = tempDate.format(new Date(System.currentTimeMillis()));
+ return datetime;
+ }
+
+ /**
+ * 获取当前时间往后推几个月
+ *
+ * @param startDate
+ * @param number
+ * @return
+ */
+ public static String getAfterDate(Date startDate, int number) {
+ Calendar c = Calendar.getInstance();//获得一个日历的实例
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+
+ c.setTime(startDate);
+ c.add(Calendar.MONTH, number);
+
+ return sdf.format(c.getTime());
+ }
+
+ //获取两个日期之间的天数
+ public static int getDatePoor(Date endDate, Date nowDate) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(endDate);
+ long time1 = cal.getTimeInMillis();
+ cal.setTime(nowDate);
+ long time2 = cal.getTimeInMillis();
+ long between_days = (time2 - time1) / (1000 * 3600 * 24);
+ int parseInt = Integer.parseInt(String.valueOf(between_days));
+ parseInt = parseInt + 1;
+ return parseInt;
+ }
+
+ public static void main(String[] args) throws ParseException {
+ String d1 = "2022-06-09 00:00";
+ String d2 = "2022-06-10 23:00";
+
+ System.out.println(getTheNumberOfDaysBetweenTwoDates(d2, d1));
+ }
+
+ public static int getTheNumberOfDaysBetweenTwoDates(String endDate, String nowDate) throws ParseException {
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ Date date1 = simpleDateFormat.parse(nowDate);
+ Date date2 = simpleDateFormat.parse(endDate);
+ int l = (int) (date2.getTime() - date1.getTime()) / (1000 * 24 * 60 * 60);
+ // System.out.println("两个时间相差" + l + "天");
+ return l;
+ }
+
+ /**
+ * Date 转换为 String
+ *
+ * @param date
+ * @return
+ */
+ public static String getDateByString(Date date) {
+ String pattern2 = "yyyy-MM-dd HH:mm:ss";
+ SimpleDateFormat sdf2 = new SimpleDateFormat(pattern2);
+ System.out.println(sdf2.format(date));
+ return sdf2.format(date);
+ }
+
+ public static Date getDateByDay(int day) {
+ Calendar calendar = Calendar.getInstance();
+ // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ calendar.add(Calendar.DAY_OF_YEAR, day);
+ return calendar.getTime();
+ }
+
+ /*public static long dateDiff(String startTime, String endTime) {
+ //按照dao传入的格式生成一个simpledateformate对象
+ SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+ long nd = 1000 * 24 * 60 * 60;//一天的毫秒数
+ long nh = 1000 * 60 * 60;//一小时的毫秒数
+ long nm = 1000 * 60;//一分钟的毫秒数
+ long ns = 1000;//一秒钟的毫秒数
+ long diff;
+ try {
+ //获得两个时间的毫秒时间差异
+ diff = sd.parse(endTime).getTime() - sd.parse(startTime).getTime();
+ long day = diff / nd;//计算差多少天
+ long hour = diff % nd / nh;//计算差多少小时
+ long min = diff % nd % nh / nm;//计算差多少分钟
+ long sec = diff % nd % nh % nm / ns;//计算差多少秒//输出结果
+ System.out.println("时间相差:" + day + "天" + hour + "小时" + min + "分钟" + sec + "秒。");
+
+
+ long countHour = 0;//统计分钟
+ countHour = (day * 24 * 60) + (hour * 60) + min;//天数*24小时
+ return countHour;
+
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ return 0;
+ }
+ }*/
+
+ public static long dateDiffByLong(String startTime) throws ParseException {
+
+ SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+ long start = sd.parse(startTime).getTime();
+
+ long end = System.currentTimeMillis();
+
+ long min = (end - start) / (1000 * 60);
+
+ System.out.println(min);
+
+ if (min == 0) {
+ return 1;
+ }
+ return min;
+ }
+
+
+ /*public static void main(String[] args) throws ParseException {
+ dateDiffByLong("2021-05-28 09:52:05");
+ }*/
+
+}
diff --git a/common/src/main/java/com/huoran/common/utils/DeleteFilesUtil.java b/common/src/main/java/com/huoran/common/utils/DeleteFilesUtil.java
new file mode 100644
index 0000000..9990bf6
--- /dev/null
+++ b/common/src/main/java/com/huoran/common/utils/DeleteFilesUtil.java
@@ -0,0 +1,31 @@
+package com.huoran.common.utils;
+
+import java.io.File;
+
+/**
+ * @描述:
+ * @作者: Rong
+ * @日期: 2021/12/17 14:54
+ */
+public class DeleteFilesUtil {
+
+ /**
+ * 删除生成的文件
+ *
+ * @param path
+ */
+ public static void deleteFile(String path) {
+ File file = new File(path);
+ // 判断目录或文件是否存在
+ if (file.exists()) { // 不存在返回 false
+ // 判断是否为文件
+ if (file.isFile()) {
+ // 路径为文件且不为空则进行删除
+ if (file.isFile() && file.exists()) {
+ file.delete();
+ }
+ }
+ }
+
+ }
+}
diff --git a/common/src/main/java/com/huoran/common/utils/EmailUtils.java b/common/src/main/java/com/huoran/common/utils/EmailUtils.java
new file mode 100644
index 0000000..df39b5a
--- /dev/null
+++ b/common/src/main/java/com/huoran/common/utils/EmailUtils.java
@@ -0,0 +1,81 @@
+package com.huoran.common.utils;
+
+import org.apache.commons.mail.DefaultAuthenticator;
+import org.apache.commons.mail.HtmlEmail;
+
+import javax.mail.Message;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+import java.util.Properties;
+
+/**
+ * @description
+ * @author: Mr.JK
+ * @create: 2021-06-22 16:08
+ **/
+public class EmailUtils {
+
+ //服务器地址
+ private static final String SERVER_ADDRESS = "smtp.mxhichina.com";
+ //邮箱地址
+ private static final String EMAILADDRESS = "postmaster@huorantech.cn";
+ //发生邮箱密码
+ private static final String EMAILPASSWORD = "HR111aaa";
+ //发送人姓名
+ private static final String EMAILUSERNAME = "DataForward";
+ //授权码
+ //private static final String AUTHORIZATION_CODE = "smtp.mxhichina.com";
+ //邮件标题
+ private static final String EMAILHEAD = "数据前瞻平台";
+ //邮件信息(后接验证码)头部信息
+ private static final String EMAILMASSAGEHEAD = "尊敬的用户,欢迎使用数据前瞻平台,您本次的验证码是: ";
+ //邮件信息(后接验证码)尾部信息
+ private static final String EMAILMASSAGETAIL = ",有效时间为5分钟";
+
+
+ //邮箱验证码
+ public static boolean sendEmail(String emailaddress,String code){
+ try {
+ HtmlEmail email = new HtmlEmail();
+ email.setHostName(SERVER_ADDRESS);
+ email.setSSLOnConnect(true); //使用ssl加密true
+ email.setSslSmtpPort("465"); //使用465端口
+ email.setCharset("UTF-8");
+ email.addTo(emailaddress);
+
+ email.setFrom(EMAILADDRESS, EMAILUSERNAME);
+// -- 使用阿里企业邮箱无授权码
+// email.setAuthentication(EMAILADDRESS, AUTHORIZATION_CODE);
+
+ email.setAuthenticator(new DefaultAuthenticator(EMAILADDRESS,EMAILPASSWORD));
+ email.setSubject(EMAILHEAD);
+ email.setMsg( EMAILMASSAGEHEAD + code + EMAILMASSAGETAIL);
+
+ email.send();
+ return true;
+ }
+ catch(Exception e){
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ /**
+ * 描述:是否是邮箱.
+ *
+ * @param str 指定的字符串
+ * @return 是否是邮箱:是为true,否则false
+ */
+ public static Boolean isEmail(String str) {
+ Boolean isEmail = false;
+ String expr = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})$";
+
+ if (str.matches(expr)) {
+ isEmail = true;
+ }
+ return isEmail;
+ }
+
+}
\ No newline at end of file
diff --git a/common/src/main/java/com/huoran/common/utils/HttpContextUtils.java b/common/src/main/java/com/huoran/common/utils/HttpContextUtils.java
new file mode 100644
index 0000000..335761a
--- /dev/null
+++ b/common/src/main/java/com/huoran/common/utils/HttpContextUtils.java
@@ -0,0 +1,32 @@
+package com.huoran.common.utils;
+
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Objects;
+
+/**
+ * HttpContextUtils
+ *
+ * @author cheney
+ * @version V1.0
+ * @date 2022年7月28日
+ */
+public class HttpContextUtils {
+
+ public static HttpServletRequest getHttpServletRequest() {
+ return ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
+ }
+
+ public static boolean isAjaxRequest(HttpServletRequest request) {
+
+ String accept = request.getHeader("accept");
+ String xRequestedWith = request.getHeader("X-Requested-With");
+
+ // 如果是异步请求或是手机端,则直接返回信息
+ return ((accept != null && accept.contains("application/json")
+ || (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequest"))
+ ));
+ }
+}
diff --git a/common/src/main/java/com/huoran/common/utils/IPUtils.java b/common/src/main/java/com/huoran/common/utils/IPUtils.java
new file mode 100644
index 0000000..14c0a2c
--- /dev/null
+++ b/common/src/main/java/com/huoran/common/utils/IPUtils.java
@@ -0,0 +1,73 @@
+package com.huoran.common.utils;
+
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.http.HttpServletRequest;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * IPUtils
+ *
+ * @author cheney
+ * @version V1.0
+ * @date 2022年7月28日
+ */
+public class IPUtils {
+
+ private static Logger logger = LoggerFactory.getLogger(IPUtils.class);
+
+ /**
+ * 获取IP地址
+ *
+ * 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
+ * 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
+ */
+ public static String getIpAddr(HttpServletRequest request) {
+ String ip = null;
+ try {
+ ip = request.getHeader("x-forwarded-for");
+ if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("Proxy-Client-IP");
+ }
+ if (StringUtils.isEmpty(ip) || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("WL-Proxy-Client-IP");
+ }
+ if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("HTTP_CLIENT_IP");
+ }
+ if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("HTTP_X_FORWARDED_FOR");
+ }
+ if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getRemoteAddr();
+ }
+ } catch (Exception e) {
+ logger.error("IPUtils ERROR ", e);
+ }
+
+ // 使用代理,则获取第一个IP地址
+ if (!StringUtils.isEmpty(ip) && ip.length() > 15) {
+ if (ip.indexOf(",") > 0) {
+ ip = ip.substring(0, ip.indexOf(","));
+ }
+ }
+
+ return ip;
+ }
+
+ /**
+ * 获取客户端主机名称
+ */
+ public static String getHostName() {
+ try {
+ return InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ logger.error(e.getMessage(), e);
+ }
+ return "未知";
+ }
+
+}
diff --git a/common/src/main/java/com/huoran/common/utils/JwtUtils.java b/common/src/main/java/com/huoran/common/utils/JwtUtils.java
new file mode 100644
index 0000000..7ad49da
--- /dev/null
+++ b/common/src/main/java/com/huoran/common/utils/JwtUtils.java
@@ -0,0 +1,57 @@
+package com.huoran.common.utils;
+
+
+import io.jsonwebtoken.Jwts;
+import io.jsonwebtoken.SignatureAlgorithm;
+import org.springframework.util.StringUtils;
+
+import java.util.Date;
+
+/**
+ * @author cheney
+ */
+public class JwtUtils {
+
+ public static final long EXPIRE = 1000 * 60 * 600 * 24;//失效时间
+ public static final String APP_SECRET = "HuoRan2021chenHS25666";//hs256对称加密算法
+
+ public static String getJwtToken(String id){
+
+ String JwtToken = Jwts.builder()
+ .setHeaderParam("typ", "JWT")
+ .setHeaderParam("alg", "HS256")
+ .setSubject("user")
+ .setIssuedAt(new Date())
+ .setExpiration(new Date(System.currentTimeMillis() + EXPIRE))
+ .claim("accountId", id)
+ .signWith(SignatureAlgorithm.HS256, APP_SECRET)
+ .compact();
+
+ return JwtToken;
+ }
+
+ public static void main(String[] args) {
+ String jwtToken = getJwtToken("108");
+ System.out.println(jwtToken);
+
+// boolean jwtToken = checkToken("\n" +
+// "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyIiwiaWF0IjoxNjk4OTkwNzc3LCJleHAiOjE2OTk4NTQ3NzcsImFjY291bnRJZCI6IjMxIn0.PkzSpCHaRNtFd2k0ik4zfqg0KhoYR1e-r51lbb1S0nc");
+// System.out.println(jwtToken);
+ }
+
+ /**
+ * 判断token是否存在与有效
+ */
+ public static boolean checkToken(String jwtToken) {
+ if(StringUtils.isEmpty(jwtToken)) {
+ return false;
+ }
+ try {
+ Jwts.parser().setSigningKey(APP_SECRET).parseClaimsJws(jwtToken);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/common/src/main/java/com/huoran/common/utils/MD5.java b/common/src/main/java/com/huoran/common/utils/MD5.java
new file mode 100644
index 0000000..f0e0ebb
--- /dev/null
+++ b/common/src/main/java/com/huoran/common/utils/MD5.java
@@ -0,0 +1,34 @@
+package com.huoran.common.utils;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+public final class MD5 {
+ public static void main(String[] args) {
+ System.out.println(encrypt("admin"));
+ }
+
+ public static String encrypt(String strSrc) {
+ try {
+ char hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8',
+ '9', 'a', 'b', 'c', 'd', 'e', 'f' };
+ byte[] bytes = strSrc.getBytes();
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ md.update(bytes);
+ bytes = md.digest();
+ int j = bytes.length;
+ char[] chars = new char[j * 2];
+ int k = 0;
+ for (int i = 0; i < bytes.length; i++) {
+ byte b = bytes[i];
+ chars[k++] = hexChars[b >>> 4 & 0xf];
+ chars[k++] = hexChars[b & 0xf];
+ }
+ return new String(chars);
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ throw new RuntimeException("MD5加密出错!!+" + e);
+ }
+ }
+
+}
diff --git a/common/src/main/java/com/huoran/common/utils/PageUtils.java b/common/src/main/java/com/huoran/common/utils/PageUtils.java
new file mode 100644
index 0000000..b300d6a
--- /dev/null
+++ b/common/src/main/java/com/huoran/common/utils/PageUtils.java
@@ -0,0 +1,111 @@
+/**
+ * Copyright (c) 2016-2019 人人开源 All rights reserved.
+ *
+ * https://www.renren.io
+ *
+ * 版权所有,侵权必究!
+ */
+
+package com.huoran.common.utils;
+
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 分页工具类
+ *
+ * @author Mark sunlightcs@gmail.com
+ */
+public class PageUtils implements Serializable {
+ private static final long serialVersionUID = 1L;
+ /**
+ * 总记录数
+ */
+ private int totalCount;
+ /**
+ * 每页记录数
+ */
+ private int pageSize;
+ /**
+ * 总页数
+ */
+ private int totalPage;
+ /**
+ * 当前页数
+ */
+ private int currPage;
+ /**
+ * 列表数据
+ */
+ private List> list;
+
+ /**
+ * 分页
+ * @param list 列表数据
+ * @param totalCount 总记录数
+ * @param pageSize 每页记录数
+ * @param currPage 当前页数
+ */
+ public PageUtils(List> list, int totalCount, int pageSize, int currPage) {
+ this.list = list;
+ this.totalCount = totalCount;
+ this.pageSize = pageSize;
+ this.currPage = currPage;
+ this.totalPage = (int) Math.ceil((double) totalCount / pageSize);
+ }
+
+ /**
+ * 分页
+ */
+ public PageUtils(IPage> page) {
+ this.list = page.getRecords();
+ this.totalCount = (int) page.getTotal();
+ this.pageSize = (int) page.getSize();
+ this.currPage = (int) page.getCurrent();
+ this.totalPage = (int) page.getPages();
+ }
+
+ public int getTotalCount() {
+ return totalCount;
+ }
+
+ public void setTotalCount(int totalCount) {
+ this.totalCount = totalCount;
+ }
+
+ public int getPageSize() {
+ return pageSize;
+ }
+
+ public void setPageSize(int pageSize) {
+ this.pageSize = pageSize;
+ }
+
+ public int getTotalPage() {
+ return totalPage;
+ }
+
+ public void setTotalPage(int totalPage) {
+ this.totalPage = totalPage;
+ }
+
+ public int getCurrPage() {
+ return currPage;
+ }
+
+ public void setCurrPage(int currPage) {
+ this.currPage = currPage;
+ }
+
+ public List> getList() {
+ return list;
+ }
+
+ public void setList(List> list) {
+ this.list = list;
+ }
+
+}
diff --git a/common/src/main/java/com/huoran/common/utils/RandomUtil.java b/common/src/main/java/com/huoran/common/utils/RandomUtil.java
new file mode 100644
index 0000000..5c34a5e
--- /dev/null
+++ b/common/src/main/java/com/huoran/common/utils/RandomUtil.java
@@ -0,0 +1,64 @@
+package com.huoran.common.utils;
+
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Random;
+
+/**
+ * 获取随机数
+ *
+ * @author cheney
+ *
+ */
+public class RandomUtil {
+
+ private static final Random random = new Random();
+
+ private static final DecimalFormat fourdf = new DecimalFormat("0000");
+
+ private static final DecimalFormat sixdf = new DecimalFormat("000000");
+
+ public static String getFourBitRandom() {
+ return fourdf.format(random.nextInt(10000));
+ }
+
+ public static String getSixBitRandom() {
+ return sixdf.format(random.nextInt(1000000));
+ }
+
+ /**
+ * 给定数组,抽取n个数据
+ * @param list
+ * @param n
+ * @return
+ */
+ public static ArrayList getRandom(List list, int n) {
+
+ Random random = new Random();
+
+ HashMap