mirror of
https://gitee.com/likeadmin/likeadmin_java.git
synced 2026-09-06 23:01:08 +08:00
优化: 移动端接入sa-token权限管理依赖
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.mdd.common.plugin.notice.engine;
|
||||
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import com.mdd.common.entity.notice.NoticeRecord;
|
||||
import com.mdd.common.enums.NoticeEnum;
|
||||
import com.mdd.common.exception.OperateException;
|
||||
@@ -9,7 +8,6 @@ import com.mdd.common.plugin.notice.vo.NoticeSmsVo;
|
||||
import com.mdd.common.plugin.notice.template.SmsTemplate;
|
||||
import com.mdd.common.plugin.sms.SmsDriver;
|
||||
import com.mdd.common.util.ConfigUtils;
|
||||
import com.mdd.common.util.RedisUtils;
|
||||
import com.mdd.common.util.SpringUtils;
|
||||
import com.mdd.common.util.StringUtils;
|
||||
|
||||
@@ -80,12 +78,6 @@ public class SmsNoticeHandle {
|
||||
noticeRecord.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
noticeRecordMapper.updateById(noticeRecord);
|
||||
}
|
||||
|
||||
// 通知类型: [1=业务, 2=验证码]
|
||||
if (smsTemplate.getType().equals(2) && StringUtils.isNotNull(params.get("code"))) {
|
||||
String code = params.get("code").toLowerCase();
|
||||
RedisUtils.set(GlobalConfig.redisSmsCode+scene+":"+mobile, code, 900);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mdd.common.plugin.notice.template;
|
||||
|
||||
import com.mdd.common.util.ToolsUtils;
|
||||
import com.mdd.common.util.MapUtils;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -27,7 +27,7 @@ public class SmsTemplate {
|
||||
* 设置参数
|
||||
*/
|
||||
public void setParams(String smsNotice) {
|
||||
Map<String, String> config = ToolsUtils.jsonToMap(smsNotice);
|
||||
Map<String, String> config = MapUtils.jsonToMap(smsNotice);
|
||||
this.setTemplateId(config.getOrDefault("templateId", ""));
|
||||
this.setContent(config.getOrDefault("content", ""));
|
||||
this.setStatus(Integer.parseInt(config.getOrDefault("status", "0")));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mdd.common.plugin.sms.engine;
|
||||
|
||||
import com.mdd.common.util.ToolsUtils;
|
||||
import com.mdd.common.util.ToolUtils;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
import java.io.*;
|
||||
@@ -241,7 +241,7 @@ public class HuaweiSms {
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||
String time = sdf.format(new Date()); //Created
|
||||
String nonce = ToolsUtils.makeUUID().replace("-", "");
|
||||
String nonce = ToolUtils.makeUUID().replace("-", "");
|
||||
|
||||
MessageDigest md;
|
||||
byte[] passwordDigest = null;
|
||||
|
||||
@@ -105,7 +105,7 @@ public class ConfigUtils {
|
||||
return new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
return ToolsUtils.jsonToMap(config.getValue());
|
||||
return MapUtils.jsonToMap(config.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,9 +9,9 @@ import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 数组工具类
|
||||
* 列表工具类
|
||||
*/
|
||||
public class ArrayUtils {
|
||||
public class ListUtils {
|
||||
|
||||
/**
|
||||
* JSONArray转树形结构
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.mdd.common.util;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Map工具类
|
||||
*/
|
||||
public class MapUtils {
|
||||
|
||||
/**
|
||||
* JSON转 Map<String, String>
|
||||
*
|
||||
* @author fzr
|
||||
* @param json 对象
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
public static Map<String, String> jsonToMap(String json){
|
||||
Type type = new TypeToken<Map<String, String>>() {}.getType();
|
||||
return JSON.parseObject(json, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON转 Map<String, Object>
|
||||
*
|
||||
* @author fzr
|
||||
* @param json 对象
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
public static Map<String, Object> jsonToMapAsObj(String json){
|
||||
Type type = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
return JSON.parseObject(json, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON转Map<String, String>
|
||||
*
|
||||
* @author fzr
|
||||
* @param object 对象
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
public static Map<String, String> objectToMap(Object object){
|
||||
Type type = new TypeToken<Map<String, String>>() {}.getType();
|
||||
return JSON.parseObject(JSONObject.toJSONString(object), type);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 对象类型Map合并
|
||||
*
|
||||
* @author fzr
|
||||
* @param map 对象
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
public static Map<String, Object> mergeMapByObj(Map<String, Object> map, Map<String, Object> map1){
|
||||
HashMap<String, Object> map2 = new HashMap<>();
|
||||
map2.putAll(map);
|
||||
map2.putAll(map1);
|
||||
return map2;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 字符串类型Map合并
|
||||
*
|
||||
* @author fzr
|
||||
* @param map 对象
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
public static Map<String, String> mergeMapByStr(Map<String, String> map, Map<String, String> map1){
|
||||
HashMap<String, String> map2 = new HashMap<>();
|
||||
map2.putAll(map);
|
||||
map2.putAll(map1);
|
||||
return map2;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,6 +13,9 @@ import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Redis工具
|
||||
*/
|
||||
@Component
|
||||
public class RedisUtils {
|
||||
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
package com.mdd.common.util;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -16,7 +12,7 @@ import java.util.*;
|
||||
/**
|
||||
* 常用工具集合
|
||||
*/
|
||||
public class ToolsUtils {
|
||||
public class ToolUtils {
|
||||
|
||||
/**
|
||||
* 制作UUID
|
||||
@@ -58,10 +54,10 @@ public class ToolsUtils {
|
||||
*/
|
||||
public static String makeToken() {
|
||||
long millisecond = System.currentTimeMillis();
|
||||
String randStr = ToolsUtils.randomString(8);
|
||||
String randStr = ToolUtils.randomString(8);
|
||||
String secret = GlobalConfig.secret;
|
||||
String token = ToolsUtils.makeMd5(ToolsUtils.makeUUID() + millisecond + randStr);
|
||||
return ToolsUtils.makeMd5(token + secret) + ToolsUtils.randomString(6);
|
||||
String token = ToolUtils.makeMd5(ToolUtils.makeUUID() + millisecond + randStr);
|
||||
return ToolUtils.makeMd5(token + secret) + ToolUtils.randomString(6);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +133,7 @@ public class ToolsUtils {
|
||||
* @param urlString (文件网址)
|
||||
* @param savePath (保存路径,如: /www/uploads)
|
||||
* @param filename (保存名称,如: aa.png)
|
||||
* @throws IOException 异常
|
||||
* @throws IOException IO异常
|
||||
*/
|
||||
public static void download(String urlString, String savePath, String filename) throws IOException {
|
||||
URL url = new URL(urlString);
|
||||
@@ -161,68 +157,4 @@ public class ToolsUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON转 Map<String, String>
|
||||
*
|
||||
* @author fzr
|
||||
* @param json 对象
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
public static Map<String, String> jsonToMap(String json){
|
||||
Type type = new TypeToken<Map<String, String>>() {}.getType();
|
||||
return JSON.parseObject(json, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON转 Map<String, Object>
|
||||
*
|
||||
* @author fzr
|
||||
* @param json 对象
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
public static Map<String, Object> jsonToMapAsObj(String json){
|
||||
Type type = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
return JSON.parseObject(json, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON转Map<String, String>
|
||||
*
|
||||
* @author fzr
|
||||
* @param object 对象
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
public static Map<String, String> objectToMap(Object object){
|
||||
Type type = new TypeToken<Map<String, String>>() {}.getType();
|
||||
return JSON.parseObject(JSONObject.toJSONString(object), type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象类型Map合并
|
||||
*
|
||||
* @author fzr
|
||||
* @param map 对象
|
||||
* @return Object
|
||||
*/
|
||||
public static Map<String, Object> mergeMapByObj(Map<String, Object> map, Map<String, Object> map1){
|
||||
HashMap<String, Object> map2 = new HashMap<>();
|
||||
map2.putAll(map);
|
||||
map2.putAll(map1);
|
||||
return map2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串类型Map合并
|
||||
*
|
||||
* @author fzr
|
||||
* @param map 对象
|
||||
* @return Object
|
||||
*/
|
||||
public static Map<String, String> mergeMapByStr(Map<String, String> map, Map<String, String> map1){
|
||||
HashMap<String, String> map2 = new HashMap<>();
|
||||
map2.putAll(map);
|
||||
map2.putAll(map1);
|
||||
return map2;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user