mirror of
https://gitee.com/likeadmin/likeadmin_java.git
synced 2026-09-06 23:01:08 +08:00
优化工具类的命名
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package com.mdd.common.core;
|
||||
|
||||
import com.mdd.common.entity.server.*;
|
||||
import com.mdd.common.utils.ArithUtil;
|
||||
import com.mdd.common.utils.IpUtil;
|
||||
import com.mdd.common.utils.TimeUtil;
|
||||
import com.mdd.common.util.ArithUtils;
|
||||
import com.mdd.common.util.IpUtils;
|
||||
import com.mdd.common.util.TimeUtils;
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.CentralProcessor;
|
||||
import oshi.hardware.CentralProcessor.TickType;
|
||||
@@ -69,11 +69,11 @@ public class ServerResult {
|
||||
long idle = ticks[TickType.IDLE.getIndex()] - prevTicks[TickType.IDLE.getIndex()];
|
||||
long totalCpu = user + nice + cSys + idle + ioWait + irq + softer + steal;
|
||||
cpu.setCpuNum(processor.getLogicalProcessorCount());
|
||||
cpu.setTotal(ArithUtil.round(ArithUtil.mul(totalCpu, 100), 2));
|
||||
cpu.setSys(ArithUtil.round(ArithUtil.mul(cSys / cpu.getTotal(), 100), 2));
|
||||
cpu.setUsed(ArithUtil.round(ArithUtil.mul(user / cpu.getTotal(), 100), 2));
|
||||
cpu.setWait(ArithUtil.round(ArithUtil.mul(ioWait / cpu.getTotal(), 100), 2));
|
||||
cpu.setFree( ArithUtil.round(ArithUtil.mul(idle / cpu.getTotal(), 100), 2));
|
||||
cpu.setTotal(ArithUtils.round(ArithUtils.mul(totalCpu, 100), 2));
|
||||
cpu.setSys(ArithUtils.round(ArithUtils.mul(cSys / cpu.getTotal(), 100), 2));
|
||||
cpu.setUsed(ArithUtils.round(ArithUtils.mul(user / cpu.getTotal(), 100), 2));
|
||||
cpu.setWait(ArithUtils.round(ArithUtils.mul(ioWait / cpu.getTotal(), 100), 2));
|
||||
cpu.setFree( ArithUtils.round(ArithUtils.mul(idle / cpu.getTotal(), 100), 2));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,10 +81,10 @@ public class ServerResult {
|
||||
*/
|
||||
private void setMemInfo(GlobalMemory memory) {
|
||||
int number = (1024 * 1024 * 1024);
|
||||
mem.setTotal(ArithUtil.div(memory.getTotal(), number, 2));
|
||||
mem.setUsed(ArithUtil.div(memory.getTotal() - memory.getAvailable(), number, 2));
|
||||
mem.setFree(ArithUtil.div(memory.getAvailable(), number, 2));
|
||||
mem.setUsage(ArithUtil.mul(ArithUtil.div(mem.getUsed(), memory.getTotal(), 4), 100));
|
||||
mem.setTotal(ArithUtils.div(memory.getTotal(), number, 2));
|
||||
mem.setUsed(ArithUtils.div(memory.getTotal() - memory.getAvailable(), number, 2));
|
||||
mem.setFree(ArithUtils.div(memory.getAvailable(), number, 2));
|
||||
mem.setUsage(ArithUtils.mul(ArithUtils.div(mem.getUsed(), memory.getTotal(), 4), 100));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,8 +92,8 @@ public class ServerResult {
|
||||
*/
|
||||
private void setSysInfo() {
|
||||
Properties props = System.getProperties();
|
||||
sys.setComputerName(IpUtil.getHostName());
|
||||
sys.setComputerIp(IpUtil.getHostIp());
|
||||
sys.setComputerName(IpUtils.getHostName());
|
||||
sys.setComputerIp(IpUtils.getHostIp());
|
||||
sys.setOsName(props.getProperty("os.name"));
|
||||
sys.setOsArch(props.getProperty("os.arch"));
|
||||
sys.setUserDir(props.getProperty("user.dir"));
|
||||
@@ -104,16 +104,16 @@ public class ServerResult {
|
||||
*/
|
||||
private void setJvmInfo() {
|
||||
Properties props = System.getProperties();
|
||||
jvm.setTotal(ArithUtil.div(Runtime.getRuntime().totalMemory(), (1024 * 1024), 2));
|
||||
jvm.setMax(ArithUtil.div(Runtime.getRuntime().maxMemory(), (1024 * 1024), 2));
|
||||
jvm.setFree(ArithUtil.div(Runtime.getRuntime().freeMemory(), (1024 * 1024), 2));
|
||||
jvm.setUsage(ArithUtil.mul(ArithUtil.div(jvm.getTotal() - jvm.getFree(), jvm.getTotal(), 4), 100));
|
||||
jvm.setTotal(ArithUtils.div(Runtime.getRuntime().totalMemory(), (1024 * 1024), 2));
|
||||
jvm.setMax(ArithUtils.div(Runtime.getRuntime().maxMemory(), (1024 * 1024), 2));
|
||||
jvm.setFree(ArithUtils.div(Runtime.getRuntime().freeMemory(), (1024 * 1024), 2));
|
||||
jvm.setUsage(ArithUtils.mul(ArithUtils.div(jvm.getTotal() - jvm.getFree(), jvm.getTotal(), 4), 100));
|
||||
jvm.setVersion(props.getProperty("java.version"));
|
||||
jvm.setHome(props.getProperty("java.home"));
|
||||
jvm.setName(ManagementFactory.getRuntimeMXBean().getVmName());
|
||||
jvm.setInputArgs(ManagementFactory.getRuntimeMXBean().getInputArguments().toString());
|
||||
jvm.setRunTime(TimeUtil.datePoor(TimeUtil.nowDate(), TimeUtil.serverStartDate()));
|
||||
jvm.setStartTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(TimeUtil.serverStartDate()));
|
||||
jvm.setRunTime(TimeUtils.datePoor(TimeUtils.nowDate(), TimeUtils.serverStartDate()));
|
||||
jvm.setStartTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(TimeUtils.serverStartDate()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +134,7 @@ public class ServerResult {
|
||||
sysFile.setTotal(convertFileSize(total));
|
||||
sysFile.setFree(convertFileSize(free));
|
||||
sysFile.setUsed(convertFileSize(used));
|
||||
sysFile.setUsage(ArithUtil.mul(ArithUtil.div(used, total, 4), 100));
|
||||
sysFile.setUsage(ArithUtils.mul(ArithUtils.div(used, total, 4), 100));
|
||||
disk.add(sysFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.github.yulichang.query.MPJQueryWrapper;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.mdd.common.utils.TimeUtil;
|
||||
import com.mdd.common.util.TimeUtils;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
@@ -168,8 +168,8 @@ public interface IBaseMapper<T> extends MPJBaseMapper<T> {
|
||||
if (!dateEnd.equals("")) { queryWrapper.le(field, Long.parseLong(dateEnd)); }
|
||||
if (!dateStart.equals("")) { queryWrapper.ge(field, Long.parseLong(dateStart)); }
|
||||
} else {
|
||||
if (!dateStart.equals("")) { queryWrapper.ge(field, TimeUtil.dateToTimestamp(dateStart)); }
|
||||
if (!dateEnd.equals("")) { queryWrapper.le(field, TimeUtil.dateToTimestamp(dateEnd)); }
|
||||
if (!dateStart.equals("")) { queryWrapper.ge(field, TimeUtils.dateToTimestamp(dateStart)); }
|
||||
if (!dateEnd.equals("")) { queryWrapper.le(field, TimeUtils.dateToTimestamp(dateEnd)); }
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -305,8 +305,8 @@ public interface IBaseMapper<T> extends MPJBaseMapper<T> {
|
||||
if (!dateStart.equals("")) { queryWrapper.ge(field, Long.parseLong(dateStart)); }
|
||||
if (!dateEnd.equals("")) { queryWrapper.le(field, Long.parseLong(dateEnd)); }
|
||||
} else {
|
||||
if (!dateStart.equals("")) { queryWrapper.ge(field, TimeUtil.dateToTimestamp(dateStart)); }
|
||||
if (!dateEnd.equals("")) { queryWrapper.le(field, TimeUtil.dateToTimestamp(dateEnd)); }
|
||||
if (!dateStart.equals("")) { queryWrapper.ge(field, TimeUtils.dateToTimestamp(dateStart)); }
|
||||
if (!dateEnd.equals("")) { queryWrapper.le(field, TimeUtils.dateToTimestamp(dateEnd)); }
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.mapper.notice.NoticeSettingMapper;
|
||||
import com.mdd.common.plugin.notice.engine.SmsNotice;
|
||||
import com.mdd.common.plugin.notice.template.SmsTemplate;
|
||||
import com.mdd.common.utils.SpringUtil;
|
||||
import com.mdd.common.utils.StringUtil;
|
||||
import com.mdd.common.util.SpringUtils;
|
||||
import com.mdd.common.util.StringUtils;
|
||||
|
||||
/**
|
||||
* 通知驱动
|
||||
@@ -16,14 +16,14 @@ public class NoticeDriver {
|
||||
|
||||
public void handle(NoticeParams noticeParams) {
|
||||
// 获取场景模板
|
||||
NoticeSettingMapper noticeSettingMapper = SpringUtil.getBean(NoticeSettingMapper.class);
|
||||
NoticeSettingMapper noticeSettingMapper = SpringUtils.getBean(NoticeSettingMapper.class);
|
||||
NoticeSetting noticeSetting = noticeSettingMapper.selectOne(
|
||||
new QueryWrapper<NoticeSetting>()
|
||||
.eq("scene", noticeParams.getScene())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
if (StringUtil.isNull(noticeSetting)) {
|
||||
if (StringUtils.isNull(noticeSetting)) {
|
||||
throw new OperateException("消息场景不存在!");
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class NoticeDriver {
|
||||
SmsTemplate smsTemplate = new SmsTemplate();
|
||||
smsTemplate.setType(noticeSetting.getType());
|
||||
smsTemplate.setParams(noticeSetting.getSmsNotice());
|
||||
if (StringUtil.isNotNull(smsTemplate.getStatus()) && smsTemplate.getStatus().equals(1)) {
|
||||
if (StringUtils.isNotNull(smsTemplate.getStatus()) && smsTemplate.getStatus().equals(1)) {
|
||||
(new SmsNotice()).send(noticeParams, smsTemplate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import com.mdd.common.config.GlobalConfig;
|
||||
import com.mdd.common.plugin.notice.NoticeParams;
|
||||
import com.mdd.common.plugin.notice.template.SmsTemplate;
|
||||
import com.mdd.common.plugin.sms.SmsDriver;
|
||||
import com.mdd.common.utils.ConfigUtil;
|
||||
import com.mdd.common.utils.RedisUtil;
|
||||
import com.mdd.common.utils.StringUtil;
|
||||
import com.mdd.common.util.ConfigUtils;
|
||||
import com.mdd.common.util.RedisUtils;
|
||||
import com.mdd.common.util.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class SmsNotice {
|
||||
Integer scene = noticeParams.getScene();
|
||||
|
||||
Map<String, String> params = new LinkedHashMap<>();
|
||||
if (StringUtil.isNotNull(noticeParams.getParams())) {
|
||||
if (StringUtils.isNotNull(noticeParams.getParams())) {
|
||||
for (String s : noticeParams.getParams()) {
|
||||
String[] arr = s.split(":");
|
||||
String key = arr[0].trim();
|
||||
@@ -36,7 +36,7 @@ public class SmsNotice {
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtil.isNotEmpty(mobile)) {
|
||||
if (StringUtils.isNotEmpty(mobile)) {
|
||||
(new SmsDriver())
|
||||
.setScene(scene)
|
||||
.setMobile(mobile)
|
||||
@@ -46,9 +46,9 @@ public class SmsNotice {
|
||||
.sendSms();
|
||||
|
||||
// 通知类型: [1=业务, 2=验证码]
|
||||
if (smsTemplate.getType().equals(2) && StringUtil.isNotNull(params.get("code"))) {
|
||||
if (smsTemplate.getType().equals(2) && StringUtils.isNotNull(params.get("code"))) {
|
||||
String code = params.get("code").toLowerCase();
|
||||
RedisUtil.set(GlobalConfig.redisSmsCode+scene+":"+mobile, code, 900);
|
||||
RedisUtils.set(GlobalConfig.redisSmsCode+scene+":"+mobile, code, 900);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public class SmsNotice {
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
private Map<String, String> getSmsParams(Map<String, String> params, String content) {
|
||||
String engine = ConfigUtil.get("sms", "default", "");
|
||||
String engine = ConfigUtils.get("sms", "default", "");
|
||||
if (!engine.equals("tencent")) {
|
||||
return params;
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public class SmsNotice {
|
||||
// 取变量对应值
|
||||
Map<String, String> arr4 = new LinkedHashMap<>();
|
||||
for (String v : arr3) {
|
||||
if (StringUtil.isNotNull(params.get(v))) {
|
||||
if (StringUtils.isNotNull(params.get(v))) {
|
||||
arr4.put(params.get(v), "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mdd.common.plugin.notice.template;
|
||||
|
||||
import com.mdd.common.utils.ToolsUtil;
|
||||
import com.mdd.common.util.ToolsUtils;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -24,7 +24,7 @@ public class SmsTemplate {
|
||||
* 设置参数
|
||||
*/
|
||||
public void setParams(String smsNotice) {
|
||||
Map<String, String> config = ToolsUtil.jsonToMap(smsNotice);
|
||||
Map<String, String> config = ToolsUtils.jsonToMap(smsNotice);
|
||||
this.setTemplateId(config.getOrDefault("templateId", ""));
|
||||
this.setContent(config.getOrDefault("content", ""));
|
||||
this.setStatus(Integer.parseInt(config.getOrDefault("status", "0")));
|
||||
|
||||
@@ -6,8 +6,8 @@ import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.mapper.system.SystemLogSmsMapper;
|
||||
import com.mdd.common.plugin.sms.engine.AliSms;
|
||||
import com.mdd.common.plugin.sms.engine.TencentSms;
|
||||
import com.mdd.common.utils.ConfigUtil;
|
||||
import com.mdd.common.utils.SpringUtil;
|
||||
import com.mdd.common.util.ConfigUtils;
|
||||
import com.mdd.common.util.SpringUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -27,9 +27,9 @@ public class SmsDriver {
|
||||
* 构造方法
|
||||
*/
|
||||
public SmsDriver() {
|
||||
this.engine = ConfigUtil.get("sms", "default", "");
|
||||
this.config = ConfigUtil.getMap("sms", this.engine);
|
||||
this.systemLogSmsMapper = SpringUtil.getBean(SystemLogSmsMapper.class);
|
||||
this.engine = ConfigUtils.get("sms", "default", "");
|
||||
this.config = ConfigUtils.getMap("sms", this.engine);
|
||||
this.systemLogSmsMapper = SpringUtils.getBean(SystemLogSmsMapper.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mdd.common.plugin.sms.engine;
|
||||
|
||||
import com.mdd.common.utils.ToolsUtil;
|
||||
import com.mdd.common.util.ToolsUtils;
|
||||
|
||||
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 = ToolsUtil.makeUUID().replace("-", "");
|
||||
String nonce = ToolsUtils.makeUUID().replace("-", "");
|
||||
|
||||
MessageDigest md;
|
||||
byte[] passwordDigest = null;
|
||||
|
||||
@@ -6,9 +6,9 @@ import com.mdd.common.plugin.storage.engine.AliyunStorage;
|
||||
import com.mdd.common.plugin.storage.engine.LocalStorage;
|
||||
import com.mdd.common.plugin.storage.engine.QcloudStorage;
|
||||
import com.mdd.common.plugin.storage.engine.QiniuStorage;
|
||||
import com.mdd.common.utils.ConfigUtil;
|
||||
import com.mdd.common.utils.TimeUtil;
|
||||
import com.mdd.common.utils.UrlUtil;
|
||||
import com.mdd.common.util.ConfigUtils;
|
||||
import com.mdd.common.util.TimeUtils;
|
||||
import com.mdd.common.util.UrlUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.*;
|
||||
@@ -29,10 +29,10 @@ public class StorageDriver {
|
||||
* 构造方法
|
||||
*/
|
||||
public StorageDriver() {
|
||||
this.engine = ConfigUtil.get("storage", "default", "local");
|
||||
this.engine = ConfigUtils.get("storage", "default", "local");
|
||||
|
||||
Map<String, String> config;
|
||||
config = ConfigUtil.getMap("storage", this.engine);
|
||||
config = ConfigUtils.getMap("storage", this.engine);
|
||||
if (config == null) {
|
||||
config = new HashMap<>();
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class StorageDriver {
|
||||
vo.setSize(multipartFile.getSize());
|
||||
vo.setExt(origFileExt.toLowerCase());
|
||||
vo.setUrl(newFileName);
|
||||
vo.setPath(UrlUtil.toAbsoluteUrl(newFileName));
|
||||
vo.setPath(UrlUtils.toAbsoluteUrl(newFileName));
|
||||
|
||||
// Map<String, Object> map = new LinkedHashMap<>();
|
||||
// map.put("id", 0);
|
||||
@@ -103,7 +103,7 @@ public class StorageDriver {
|
||||
private String buildSaveName(MultipartFile multipartFile) {
|
||||
String name = multipartFile.getOriginalFilename();
|
||||
String ext = Objects.requireNonNull(name).substring(name.lastIndexOf("."));
|
||||
String date = TimeUtil.timestampToDate(TimeUtil.timestamp(), "yyyyMMdd");
|
||||
String date = TimeUtils.timestampToDate(TimeUtils.timestamp(), "yyyyMMdd");
|
||||
return date + "/" + UUID.randomUUID() + ext.toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.mdd.common.plugin.storage.engine;
|
||||
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.utils.YmlUtil;
|
||||
import com.mdd.common.util.YmlUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
@@ -22,7 +21,7 @@ public class LocalStorage {
|
||||
*/
|
||||
public void upload(MultipartFile multipartFile, String key, String folder) {
|
||||
// 映射目录
|
||||
String directory = YmlUtil.get("like.upload-directory");
|
||||
String directory = YmlUtils.get("like.upload-directory");
|
||||
if (directory == null || directory.equals("")) {
|
||||
throw new OperateException("请配置上传目录like.upload-directory");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.common.utils;
|
||||
package com.mdd.common.util;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
@@ -6,13 +6,13 @@ import java.math.RoundingMode;
|
||||
/**
|
||||
* 算术运算工具
|
||||
*/
|
||||
public class ArithUtil {
|
||||
public class ArithUtils {
|
||||
|
||||
/** 默认除法运算精度 */
|
||||
private static final int DEF_DIV_SCALE = 10;
|
||||
|
||||
/** 这个类不能实例化 */
|
||||
private ArithUtil() {}
|
||||
private ArithUtils() {}
|
||||
|
||||
/**
|
||||
* 提供精确的加法运算
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.common.utils;
|
||||
package com.mdd.common.util;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
@@ -11,7 +11,7 @@ import java.util.*;
|
||||
/**
|
||||
* 数组工具类
|
||||
*/
|
||||
public class ArrayUtil {
|
||||
public class ArrayUtils {
|
||||
|
||||
/**
|
||||
* JSONArray转树形结构
|
||||
@@ -151,7 +151,7 @@ public class ArrayUtil {
|
||||
if (str.contains(regex)){
|
||||
String[] split = str.split(regex);
|
||||
for (String value : split) {
|
||||
if(!StringUtil.isBlank(value)){
|
||||
if(!StringUtils.isBlank(value)){
|
||||
list.add(Long.parseLong(value.trim()));
|
||||
}
|
||||
}
|
||||
@@ -177,7 +177,7 @@ public class ArrayUtil {
|
||||
if (str.contains(regex)){
|
||||
String[] split = str.split(regex);
|
||||
for (String value : split) {
|
||||
if(!StringUtil.isBlank(value)){
|
||||
if(!StringUtils.isBlank(value)){
|
||||
list.add(Integer.parseInt(value.trim()));
|
||||
}
|
||||
}
|
||||
@@ -200,7 +200,7 @@ public class ArrayUtil {
|
||||
if (str.contains(regex)){
|
||||
String[] split = str.split(regex);
|
||||
for (String value : split) {
|
||||
if(!StringUtil.isBlank(value)){
|
||||
if(!StringUtils.isBlank(value)){
|
||||
list.add(value.trim());
|
||||
}
|
||||
}
|
||||
@@ -242,7 +242,7 @@ public class ArrayUtil {
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
public static List<Map<String, Object>> stringToListAsMapObj(String s) {
|
||||
if (StringUtil.isEmpty(s)) {
|
||||
if (StringUtils.isEmpty(s)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Type type = new TypeToken<List<Map<String, Object>>>() {}.getType();
|
||||
@@ -257,7 +257,7 @@ public class ArrayUtil {
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
public static List<Map<String, String>> stringToListAsMapStr(String s) {
|
||||
if (StringUtil.isEmpty(s)) {
|
||||
if (StringUtils.isEmpty(s)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Type type = new TypeToken<List<Map<String, String>>>() {}.getType();
|
||||
@@ -272,7 +272,7 @@ public class ArrayUtil {
|
||||
* @return List<Long>
|
||||
*/
|
||||
public static List<Integer> objectToListAsLong(Object object) {
|
||||
if (StringUtil.isNull(object)) {
|
||||
if (StringUtils.isNull(object)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Type type = new TypeToken<List<Long>>() {}.getType();
|
||||
@@ -287,7 +287,7 @@ public class ArrayUtil {
|
||||
* @return List<Integer>
|
||||
*/
|
||||
public static List<Integer> objectToListAsInt(Object object) {
|
||||
if (StringUtil.isNull(object)) {
|
||||
if (StringUtils.isNull(object)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Type type = new TypeToken<List<Integer>>() {}.getType();
|
||||
@@ -302,7 +302,7 @@ public class ArrayUtil {
|
||||
* @return List<String>
|
||||
*/
|
||||
public static List<String> objectToListAsStr(Object object) {
|
||||
if (StringUtil.isNull(object)) {
|
||||
if (StringUtils.isNull(object)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Type type = new TypeToken<List<String>>() {}.getType();
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.common.utils;
|
||||
package com.mdd.common.util;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mdd.common.entity.system.SystemConfig;
|
||||
@@ -11,7 +11,7 @@ import java.util.Map;
|
||||
/**
|
||||
* 数据库配置操作工具
|
||||
*/
|
||||
public class ConfigUtil {
|
||||
public class ConfigUtils {
|
||||
|
||||
/**
|
||||
* 根据类型获取配置
|
||||
@@ -21,7 +21,7 @@ public class ConfigUtil {
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
public static Map<String, String> get(String type) {
|
||||
SystemConfigMapper model = SpringUtil.getBean(SystemConfigMapper.class);
|
||||
SystemConfigMapper model = SpringUtils.getBean(SystemConfigMapper.class);
|
||||
|
||||
List<SystemConfig> configs = model.selectList(
|
||||
new QueryWrapper<SystemConfig>()
|
||||
@@ -45,7 +45,7 @@ public class ConfigUtil {
|
||||
* @return String
|
||||
*/
|
||||
public static String get(String type, String name) {
|
||||
SystemConfigMapper model = SpringUtil.getBean(SystemConfigMapper.class);
|
||||
SystemConfigMapper model = SpringUtils.getBean(SystemConfigMapper.class);
|
||||
|
||||
SystemConfig config = model.selectOne(
|
||||
new QueryWrapper<SystemConfig>()
|
||||
@@ -65,7 +65,7 @@ public class ConfigUtil {
|
||||
* @return String
|
||||
*/
|
||||
public static String get(String type, String name, String defaults) {
|
||||
SystemConfigMapper model = SpringUtil.getBean(SystemConfigMapper.class);
|
||||
SystemConfigMapper model = SpringUtils.getBean(SystemConfigMapper.class);
|
||||
|
||||
SystemConfig config = model.selectOne(
|
||||
new QueryWrapper<SystemConfig>()
|
||||
@@ -89,7 +89,7 @@ public class ConfigUtil {
|
||||
* @return String
|
||||
*/
|
||||
public static Map<String, String> getMap(String type, String name) {
|
||||
SystemConfigMapper model = SpringUtil.getBean(SystemConfigMapper.class);
|
||||
SystemConfigMapper model = SpringUtils.getBean(SystemConfigMapper.class);
|
||||
|
||||
SystemConfig config = model.selectOne(
|
||||
new QueryWrapper<SystemConfig>()
|
||||
@@ -105,7 +105,7 @@ public class ConfigUtil {
|
||||
return new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
return ToolsUtil.jsonToMap(config.getValue());
|
||||
return ToolsUtils.jsonToMap(config.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,7 +117,7 @@ public class ConfigUtil {
|
||||
* @param val 值
|
||||
*/
|
||||
public static void set(String type, String name, String val) {
|
||||
SystemConfigMapper model = SpringUtil.getBean(SystemConfigMapper.class);
|
||||
SystemConfigMapper model = SpringUtils.getBean(SystemConfigMapper.class);
|
||||
|
||||
SystemConfig config = model.selectOne(
|
||||
new QueryWrapper<SystemConfig>()
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.common.utils;
|
||||
package com.mdd.common.util;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -12,9 +12,9 @@ import java.security.cert.X509Certificate;
|
||||
/**
|
||||
* HTTP工具类
|
||||
*/
|
||||
public class HttpUtil {
|
||||
public class HttpUtils {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(HttpUtil.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);
|
||||
|
||||
/**
|
||||
* 向指定URL发送GET方法的请求 (不带参)
|
||||
@@ -23,7 +23,7 @@ public class HttpUtil {
|
||||
* @return 所代表远程资源的响应结果
|
||||
*/
|
||||
public static String sendGet(String url) {
|
||||
return sendGet(url, StringUtil.EMPTY);
|
||||
return sendGet(url, StringUtils.EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,7 +49,7 @@ public class HttpUtil {
|
||||
StringBuilder result = new StringBuilder();
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
String urlNameString = StringUtil.isNotBlank(param) ? url + "?" + param : url;
|
||||
String urlNameString = StringUtils.isNotBlank(param) ? url + "?" + param : url;
|
||||
log.info("sendGet - {}", urlNameString);
|
||||
URL realUrl = new URL(urlNameString);
|
||||
URLConnection connection = realUrl.openConnection();
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.mdd.common.utils;
|
||||
package com.mdd.common.util;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -13,9 +12,9 @@ import java.net.UnknownHostException;
|
||||
/**
|
||||
* IP工具类
|
||||
*/
|
||||
public class IpUtil {
|
||||
public class IpUtils {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(IpUtil.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(IpUtils.class);
|
||||
|
||||
/**
|
||||
* 获取客户端IP
|
||||
@@ -24,7 +23,7 @@ public class IpUtil {
|
||||
* @return IP地址 (113.67.10.194)
|
||||
*/
|
||||
public static String getIpAddress() {
|
||||
HttpServletRequest request = RequestUtil.handler();
|
||||
HttpServletRequest request = RequestUtils.handler();
|
||||
if (request == null) {
|
||||
return "unknown";
|
||||
}
|
||||
@@ -61,13 +60,13 @@ public class IpUtil {
|
||||
String UNKNOWN = "XX XX";
|
||||
|
||||
// 内网不查询
|
||||
if (IpUtil.internalIp(ip)) {
|
||||
if (IpUtils.internalIp(ip)) {
|
||||
return "内网IP";
|
||||
}
|
||||
if (GlobalConfig.isAddressEnabled) {
|
||||
try {
|
||||
String rspStr = HttpUtil.sendGet(IP_URL, "ip=" + ip + "&json=true", "GBK");
|
||||
if (StringUtil.isEmpty(rspStr)) {
|
||||
String rspStr = HttpUtils.sendGet(IP_URL, "ip=" + ip + "&json=true", "GBK");
|
||||
if (StringUtils.isEmpty(rspStr)) {
|
||||
log.error("获取地理位置异常 {}", ip);
|
||||
return UNKNOWN;
|
||||
}
|
||||
@@ -263,7 +262,7 @@ public class IpUtil {
|
||||
* @return 是否未知
|
||||
*/
|
||||
public static boolean isUnknown(String checkString) {
|
||||
return StringUtils.isBlank(checkString) || "unknown".equalsIgnoreCase(checkString);
|
||||
return com.baomidou.mybatisplus.core.toolkit.StringUtils.isBlank(checkString) || "unknown".equalsIgnoreCase(checkString);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.common.utils;
|
||||
package com.mdd.common.util;
|
||||
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
@@ -14,7 +14,7 @@ import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component
|
||||
public class RedisUtil {
|
||||
public class RedisUtils {
|
||||
|
||||
private static RedisTemplate<String, Object> redisTemplate;
|
||||
private static final String redisPrefix = GlobalConfig.redisPrefix;
|
||||
@@ -27,7 +27,7 @@ public class RedisUtil {
|
||||
*/
|
||||
@Resource
|
||||
public void setRedisTemplate(RedisTemplate<String, Object> redisTemplate) {
|
||||
RedisUtil.redisTemplate = redisTemplate;
|
||||
RedisUtils.redisTemplate = redisTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,7 +190,7 @@ public class RedisUtil {
|
||||
*/
|
||||
public static Set<String> matchSet(String pattern) {
|
||||
Set<String> keys = new LinkedHashSet<>();
|
||||
RedisUtil.handler().execute((RedisConnection connection) -> {
|
||||
RedisUtils.handler().execute((RedisConnection connection) -> {
|
||||
try (Cursor<byte[]> cursor = connection.scan(
|
||||
ScanOptions.scanOptions()
|
||||
.count(Long.MAX_VALUE)
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.common.utils;
|
||||
package com.mdd.common.util;
|
||||
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
@@ -10,7 +10,7 @@ import java.util.List;
|
||||
/**
|
||||
* 请求工具类
|
||||
*/
|
||||
public class RequestUtil {
|
||||
public class RequestUtils {
|
||||
|
||||
/**
|
||||
* 获取请求对象
|
||||
@@ -34,7 +34,7 @@ public class RequestUtil {
|
||||
* @return String
|
||||
*/
|
||||
public static String url() {
|
||||
HttpServletRequest request = RequestUtil.handler();
|
||||
HttpServletRequest request = RequestUtils.handler();
|
||||
if (request != null) {
|
||||
return request.getRequestURL().toString();
|
||||
}
|
||||
@@ -49,9 +49,9 @@ public class RequestUtil {
|
||||
* @return String
|
||||
*/
|
||||
public static String uri() {
|
||||
String domain = RequestUtil.domain();
|
||||
if (!Arrays.asList(443,80,0).contains(RequestUtil.port())) {
|
||||
domain += ":" + RequestUtil.port();
|
||||
String domain = RequestUtils.domain();
|
||||
if (!Arrays.asList(443,80,0).contains(RequestUtils.port())) {
|
||||
domain += ":" + RequestUtils.port();
|
||||
}
|
||||
|
||||
return domain;
|
||||
@@ -65,7 +65,7 @@ public class RequestUtil {
|
||||
* @return String
|
||||
*/
|
||||
public static String route() {
|
||||
HttpServletRequest request = RequestUtil.handler();
|
||||
HttpServletRequest request = RequestUtils.handler();
|
||||
if (request != null) {
|
||||
return request.getRequestURI();
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public class RequestUtil {
|
||||
* @return Integer
|
||||
*/
|
||||
public static Integer port() {
|
||||
HttpServletRequest request = RequestUtil.handler();
|
||||
HttpServletRequest request = RequestUtils.handler();
|
||||
if (request != null) {
|
||||
return request.getServerPort();
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public class RequestUtil {
|
||||
* @return String
|
||||
*/
|
||||
public static String domain() {
|
||||
HttpServletRequest request = RequestUtil.handler();
|
||||
HttpServletRequest request = RequestUtils.handler();
|
||||
if (request != null) {
|
||||
String requestUrl = request.getRequestURL().toString();
|
||||
List<String> urls = Arrays.asList(requestUrl.split("/"));
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.common.utils;
|
||||
package com.mdd.common.util;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -6,7 +6,7 @@ import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class SpringUtil implements ApplicationContextAware {
|
||||
public class SpringUtils implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext applicationContext;
|
||||
|
||||
@@ -18,8 +18,8 @@ public class SpringUtil implements ApplicationContextAware {
|
||||
*/
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
if(SpringUtil.applicationContext == null) {
|
||||
SpringUtil.applicationContext = applicationContext;
|
||||
if(SpringUtils.applicationContext == null) {
|
||||
SpringUtils.applicationContext = applicationContext;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.common.utils;
|
||||
package com.mdd.common.util;
|
||||
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.*;
|
||||
/**
|
||||
* 字符串工具类
|
||||
*/
|
||||
public class StringUtil extends org.apache.commons.lang3.StringUtils {
|
||||
public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
/**
|
||||
* 空字符串
|
||||
*/
|
||||
@@ -235,18 +235,18 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
|
||||
*/
|
||||
public static List<String> str2List(String str, String sep, boolean filterBlank, boolean trim) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
if (StringUtil.isEmpty(str)) {
|
||||
if (StringUtils.isEmpty(str)) {
|
||||
return list;
|
||||
}
|
||||
|
||||
// 过滤空白字符串
|
||||
if (filterBlank && StringUtil.isBlank(str)) {
|
||||
if (filterBlank && StringUtils.isBlank(str)) {
|
||||
return list;
|
||||
}
|
||||
|
||||
String[] split = str.split(sep);
|
||||
for (String string : split) {
|
||||
if (filterBlank && StringUtil.isBlank(string)) {
|
||||
if (filterBlank && StringUtils.isBlank(string)) {
|
||||
continue;
|
||||
}
|
||||
if (trim) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.common.utils;
|
||||
package com.mdd.common.util;
|
||||
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
@@ -8,7 +8,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class TimeUtil {
|
||||
public class TimeUtils {
|
||||
|
||||
/**
|
||||
* 时间戳转日期(默认格式)
|
||||
@@ -69,7 +69,7 @@ public class TimeUtil {
|
||||
* @return Long
|
||||
*/
|
||||
public static Long dateToTimestamp(String date) {
|
||||
String dateTime = TimeUtil.formatDate(date);
|
||||
String dateTime = TimeUtils.formatDate(date);
|
||||
return (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).parse(dateTime, new ParsePosition(0)).getTime() / 1000;
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ public class TimeUtil {
|
||||
* @return List
|
||||
*/
|
||||
public static List<Long> yesterday() {
|
||||
List<Long> today = TimeUtil.today();
|
||||
List<Long> today = TimeUtils.today();
|
||||
List<Long> list = new ArrayList<>();
|
||||
list.add(today.get(0) - 86400);
|
||||
list.add(today.get(1) - 86400);
|
||||
@@ -266,7 +266,7 @@ public class TimeUtil {
|
||||
* @return List
|
||||
*/
|
||||
public static List<Long> lastWeek() {
|
||||
List<Long> week = TimeUtil.week();
|
||||
List<Long> week = TimeUtils.week();
|
||||
List<Long> list = new ArrayList<>();
|
||||
list.add(week.get(0) - 604800);
|
||||
list.add(week.get(1) - 604800);
|
||||
@@ -412,7 +412,7 @@ public class TimeUtil {
|
||||
* @return List
|
||||
*/
|
||||
public static List<Long> dayToNow(int day) {
|
||||
List<Long> today = TimeUtil.today();
|
||||
List<Long> today = TimeUtils.today();
|
||||
List<Long> list = new ArrayList<>();
|
||||
list.add(today.get(0) - day * 86400L);
|
||||
list.add(today.get(0) -1);
|
||||
@@ -464,7 +464,7 @@ public class TimeUtil {
|
||||
* @return [2022-03-29, 2022-03-30, 2022-03-31, 2022-04-01]
|
||||
*/
|
||||
public static List<String> daysAgoDate(Integer day) {
|
||||
long time = TimeUtil.today().get(0);
|
||||
long time = TimeUtils.today().get(0);
|
||||
|
||||
List<String> data = new ArrayList<>();
|
||||
for (int i=0; i<day; i++) {
|
||||
@@ -472,7 +472,7 @@ public class TimeUtil {
|
||||
time -= 86400;
|
||||
}
|
||||
|
||||
data.add(TimeUtil.timestampToDate(time, "yyyy-MM-dd"));
|
||||
data.add(TimeUtils.timestampToDate(time, "yyyy-MM-dd"));
|
||||
}
|
||||
|
||||
Collections.reverse(data);
|
||||
@@ -487,7 +487,7 @@ public class TimeUtil {
|
||||
* @return [1648483200, 1648569600, 1648656000, 1648742400]
|
||||
*/
|
||||
public static List<Long> daysAgoTime(Integer day) {
|
||||
long time = TimeUtil.today().get(0);
|
||||
long time = TimeUtils.today().get(0);
|
||||
|
||||
List<Long> data = new ArrayList<>();
|
||||
for (int i=0; i<day; i++) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.common.utils;
|
||||
package com.mdd.common.util;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
@@ -13,7 +13,7 @@ import java.util.*;
|
||||
/**
|
||||
* 常用工具集合
|
||||
*/
|
||||
public class ToolsUtil {
|
||||
public class ToolsUtils {
|
||||
|
||||
/**
|
||||
* 制作UUID
|
||||
@@ -55,10 +55,10 @@ public class ToolsUtil {
|
||||
*/
|
||||
public static String makeToken() {
|
||||
long millisecond = System.currentTimeMillis();
|
||||
String randStr = ToolsUtil.randomString(8);
|
||||
String randStr = ToolsUtils.randomString(8);
|
||||
String secret = GlobalConfig.secret;
|
||||
String token = ToolsUtil.makeMd5(ToolsUtil.makeUUID() + millisecond + randStr);
|
||||
return ToolsUtil.makeMd5(token + secret) + ToolsUtil.randomString(6);
|
||||
String token = ToolsUtils.makeMd5(ToolsUtils.makeUUID() + millisecond + randStr);
|
||||
return ToolsUtils.makeMd5(token + secret) + ToolsUtils.randomString(6);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.common.utils;
|
||||
package com.mdd.common.util;
|
||||
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.Map;
|
||||
/**
|
||||
* 文件路径处理工具
|
||||
*/
|
||||
public class UrlUtil {
|
||||
public class UrlUtils {
|
||||
|
||||
/**
|
||||
* 访问前缀
|
||||
@@ -33,16 +33,16 @@ public class UrlUtil {
|
||||
}
|
||||
|
||||
if (url.startsWith("/api/static/")) {
|
||||
return RequestUtil.uri() + url;
|
||||
return RequestUtils.uri() + url;
|
||||
}
|
||||
|
||||
String engine = ConfigUtil.get("storage", "default", "local");
|
||||
String engine = ConfigUtils.get("storage", "default", "local");
|
||||
engine = engine.equals("") ? "local" : engine;
|
||||
if (engine.equals("local")) {
|
||||
return RequestUtil.uri() + "/" + uploadPrefix + url;
|
||||
return RequestUtils.uri() + "/" + uploadPrefix + url;
|
||||
}
|
||||
|
||||
Map<String, String> config = ConfigUtil.getMap("storage", engine);
|
||||
Map<String, String> config = ConfigUtils.getMap("storage", engine);
|
||||
if (config != null) {
|
||||
return config.getOrDefault("domain", "") + url;
|
||||
}
|
||||
@@ -63,14 +63,14 @@ public class UrlUtil {
|
||||
return "";
|
||||
}
|
||||
|
||||
String engine = ConfigUtil.get("storage", "default", "local");
|
||||
String engine = ConfigUtils.get("storage", "default", "local");
|
||||
engine = engine.equals("") ? "local" : engine;
|
||||
if (engine.equals("local")) {
|
||||
return url.replace(RequestUtil.uri(), "")
|
||||
return url.replace(RequestUtils.uri(), "")
|
||||
.replace("/" + uploadPrefix + "/", "");
|
||||
}
|
||||
|
||||
Map<String, String> config = ConfigUtil.getMap("storage", engine);
|
||||
Map<String, String> config = ConfigUtils.getMap("storage", engine);
|
||||
if (config != null) {
|
||||
return url.replace(config.getOrDefault("domain", ""), "")
|
||||
.replace( "/" + uploadPrefix + "/", "");
|
||||
@@ -87,13 +87,13 @@ public class UrlUtil {
|
||||
* @return String
|
||||
*/
|
||||
public static String domain() {
|
||||
String engine = ConfigUtil.get("storage", "default", "local");
|
||||
String engine = ConfigUtils.get("storage", "default", "local");
|
||||
engine = engine.equals("") ? "local" : engine;
|
||||
if (engine.equals("local")) {
|
||||
return RequestUtil.uri() + "/";
|
||||
return RequestUtils.uri() + "/";
|
||||
}
|
||||
|
||||
Map<String, String> config = ConfigUtil.getMap("storage", engine);
|
||||
Map<String, String> config = ConfigUtils.getMap("storage", engine);
|
||||
if (config != null) {
|
||||
return config.getOrDefault("domain", "") + "/";
|
||||
}
|
||||
@@ -1,16 +1,15 @@
|
||||
package com.mdd.common.utils;
|
||||
package com.mdd.common.util;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
|
||||
import com.qcloud.cos.model.ciModel.auditing.Conf;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class WeChatUtil {
|
||||
public class WeChatUtils {
|
||||
|
||||
/**
|
||||
* 微信小程序
|
||||
@@ -19,7 +18,7 @@ public class WeChatUtil {
|
||||
* @return WxMaService
|
||||
*/
|
||||
public static WxMaService mnp() {
|
||||
Map<String, String> config = ConfigUtil.get("mp_channel");
|
||||
Map<String, String> config = ConfigUtils.get("mp_channel");
|
||||
|
||||
WxMaService service = new WxMaServiceImpl();
|
||||
WxMaDefaultConfigImpl wxConfig = new WxMaDefaultConfigImpl();
|
||||
@@ -37,7 +36,7 @@ public class WeChatUtil {
|
||||
* @return WxMpService
|
||||
*/
|
||||
public static WxMpService official() {
|
||||
Map<String, String> config = ConfigUtil.get("oa_channel");
|
||||
Map<String, String> config = ConfigUtils.get("oa_channel");
|
||||
|
||||
WxMpDefaultConfigImpl wxMpDefaultConfig = new WxMpDefaultConfigImpl();
|
||||
wxMpDefaultConfig.setAppId(config.getOrDefault("appId", "").trim());
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.common.utils;
|
||||
package com.mdd.common.util;
|
||||
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.core.env.Environment;
|
||||
@@ -8,7 +8,7 @@ import org.springframework.stereotype.Component;
|
||||
* 系统文件配置操作工具
|
||||
*/
|
||||
@Component
|
||||
public class YmlUtil implements EnvironmentAware {
|
||||
public class YmlUtils implements EnvironmentAware {
|
||||
|
||||
private static Environment env;
|
||||
|
||||
@@ -20,7 +20,7 @@ public class YmlUtil implements EnvironmentAware {
|
||||
*/
|
||||
@Override
|
||||
public void setEnvironment(Environment environment) {
|
||||
YmlUtil.env = environment;
|
||||
YmlUtils.env = environment;
|
||||
}
|
||||
|
||||
/**
|
||||
Reference in New Issue
Block a user