commit
d2977a0767
|
@ -59,5 +59,11 @@
|
|||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper</artifactId>
|
||||
</dependency>
|
||||
<!-- 查询ip地址 -->
|
||||
<dependency>
|
||||
<groupId>org.lionsoul</groupId>
|
||||
<artifactId>ip2region</artifactId>
|
||||
<version>2.6.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
package cn.bunny.common.service.utils;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class FileUtil {
|
||||
/**
|
||||
* * 获取文件大小字符串
|
||||
*/
|
||||
public static String getSize(Long fileSize) {
|
||||
double fileSizeInKB = fileSize / 1024.00;
|
||||
double fileSizeInMB = fileSizeInKB / 1024;
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
package cn.bunny.common.service.utils;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import org.lionsoul.ip2region.xdb.Searcher;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class IpUtil {
|
||||
private static Searcher searcher;
|
||||
|
||||
/**
|
||||
* 判断是否为合法 IP
|
||||
*/
|
||||
public static boolean checkIp(String ipAddress) {
|
||||
String ip = "([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}";
|
||||
Pattern pattern = Pattern.compile(ip);
|
||||
Matcher matcher = pattern.matcher(ipAddress);
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 在服务启动时,将 ip2region 加载到内存中
|
||||
*/
|
||||
@PostConstruct
|
||||
private static void initIp2Region() {
|
||||
try {
|
||||
InputStream inputStream = new ClassPathResource("/ipdb/ip2region.xdb").getInputStream();
|
||||
byte[] bytes = FileCopyUtils.copyToByteArray(inputStream);
|
||||
searcher = Searcher.newWithBuffer(bytes);
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 ip 所属地址
|
||||
*
|
||||
* @param ip ip
|
||||
*/
|
||||
public static String getIpRegion(String ip) {
|
||||
if (ip.equals("0:0:0:0:0:0:0:1")) ip = "127.0.0.1";
|
||||
boolean isIp = checkIp(ip);
|
||||
if (isIp) {
|
||||
initIp2Region();
|
||||
try {
|
||||
// searchIpInfo 的数据格式: 国家|区域|省份|城市|ISP
|
||||
String searchIpInfo = searcher.search(ip);
|
||||
String[] splitIpInfo = searchIpInfo.split("\\|");
|
||||
if (splitIpInfo.length > 0) {
|
||||
if ("中国".equals(splitIpInfo[0])) {
|
||||
// 国内属地返回省份
|
||||
return splitIpInfo[2];
|
||||
} else if ("0".equals(splitIpInfo[0])) {
|
||||
if ("内网IP".equals(splitIpInfo[4])) {
|
||||
// 内网 IP
|
||||
return splitIpInfo[4];
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
} else {
|
||||
// 国外属地返回国家
|
||||
return splitIpInfo[0];
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
} else {
|
||||
throw new IllegalArgumentException("非法的IP地址");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package cn.bunny.common.service.utils;
|
||||
|
||||
import cn.bunny.pojo.result.Result;
|
||||
import cn.bunny.pojo.result.ResultCodeEnum;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
public class ResponseHandlerUtil {
|
||||
public static boolean loginAuthHandler(HttpServletResponse response, ResultCodeEnum loginAuth) {
|
||||
ResponseUtil.out(response, Result.error(loginAuth));
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package cn.bunny.pojo.file;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class MinioFIlePath {
|
||||
private String filename;
|
||||
private String uuidFilename;
|
||||
private String timeUuidFilename;
|
||||
private String filepath;
|
||||
private String bucketNameFilepath;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package cn.bunny.pojo.result.constant;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class MinioConstant {
|
||||
public static final String favicon = "favicon";
|
||||
public static final String avatar = "avatar";
|
||||
public static final String article = "article";
|
||||
public static final String carousel = "carousel";
|
||||
public static final String feedback = "feedback";
|
||||
public static final String articleCovers = "articleCovers";
|
||||
public static final String articleAttachment = "articleAttachment";
|
||||
private static final Map<String, String> typeMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
typeMap.put(favicon, "/favicon/");
|
||||
typeMap.put(avatar, "/avatar/");
|
||||
typeMap.put(article, "/article/");
|
||||
typeMap.put(carousel, "/carousel/");
|
||||
typeMap.put(feedback, "/feedback/");
|
||||
typeMap.put("articleImages", "/articleImages/");
|
||||
typeMap.put("articleVideo", "/articleVideo/");
|
||||
typeMap.put(articleCovers, "/articleCovers/");
|
||||
typeMap.put(articleAttachment, "/articleAttachment/");
|
||||
typeMap.put("images", "/images/");
|
||||
typeMap.put("video", "/video/");
|
||||
typeMap.put("default", "/default/");
|
||||
}
|
||||
|
||||
public static String getType(String type) {
|
||||
String value = typeMap.get(type);
|
||||
if (value != null) return value;
|
||||
throw new RuntimeException(FileMessageConstant.COMPOSE_OBJECT_EXCEPTION);
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
2024-05-10 15:13:33.089 INFO [CommandCenter] Begin listening at port 8719
|
|
@ -1,91 +0,0 @@
|
|||
2024-05-10 15:13:33.055 INFO Add child <sentinel_default_context> to node <machine-root>
|
||||
2024-05-10 15:13:33.055 INFO Add child <sentinel_spring_webflux_context> to node <machine-root>
|
||||
2024-05-10 15:13:33.059 INFO App name resolved from property csp.sentinel.app.name: service-gateway
|
||||
2024-05-10 15:13:33.060 INFO [SentinelConfig] Application type resolved: 0
|
||||
2024-05-10 15:13:33.061 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.init.InitFunc, provider=com.alibaba.csp.sentinel.transport.init.CommandCenterInitFunc, aliasName=com.alibaba.csp.sentinel.transport.init.CommandCenterInitFunc, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.061 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.init.InitFunc, provider=com.alibaba.csp.sentinel.transport.init.HeartbeatSenderInitFunc, aliasName=com.alibaba.csp.sentinel.transport.init.HeartbeatSenderInitFunc, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.063 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.init.InitFunc, provider=com.alibaba.csp.sentinel.metric.extension.MetricCallbackInit, aliasName=com.alibaba.csp.sentinel.metric.extension.MetricCallbackInit, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.063 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.init.InitFunc, provider=com.alibaba.csp.sentinel.init.ParamFlowStatisticSlotCallbackInit, aliasName=com.alibaba.csp.sentinel.init.ParamFlowStatisticSlotCallbackInit, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.064 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.init.InitFunc, provider=com.alibaba.csp.sentinel.cluster.server.init.DefaultClusterServerInitFunc, aliasName=com.alibaba.csp.sentinel.cluster.server.init.DefaultClusterServerInitFunc, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.065 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.init.InitFunc, provider=com.alibaba.csp.sentinel.cluster.client.init.DefaultClusterClientInitFunc, aliasName=com.alibaba.csp.sentinel.cluster.client.init.DefaultClusterClientInitFunc, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.066 INFO [InitExecutor] Found init func: com.alibaba.csp.sentinel.transport.init.CommandCenterInitFunc
|
||||
2024-05-10 15:13:33.066 INFO [InitExecutor] Found init func: com.alibaba.csp.sentinel.transport.init.HeartbeatSenderInitFunc
|
||||
2024-05-10 15:13:33.066 INFO [InitExecutor] Found init func: com.alibaba.csp.sentinel.metric.extension.MetricCallbackInit
|
||||
2024-05-10 15:13:33.067 INFO [InitExecutor] Found init func: com.alibaba.csp.sentinel.init.ParamFlowStatisticSlotCallbackInit
|
||||
2024-05-10 15:13:33.067 INFO [InitExecutor] Found init func: com.alibaba.csp.sentinel.cluster.server.init.DefaultClusterServerInitFunc
|
||||
2024-05-10 15:13:33.067 INFO [InitExecutor] Found init func: com.alibaba.csp.sentinel.cluster.client.init.DefaultClusterClientInitFunc
|
||||
2024-05-10 15:13:33.068 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.transport.CommandCenter, provider=com.alibaba.csp.sentinel.transport.command.SimpleHttpCommandCenter, aliasName=com.alibaba.csp.sentinel.transport.command.SimpleHttpCommandCenter, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.068 INFO [CommandCenterProvider] CommandCenter resolved: com.alibaba.csp.sentinel.transport.command.SimpleHttpCommandCenter
|
||||
2024-05-10 15:13:33.070 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.BasicInfoCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.BasicInfoCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.071 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.FetchActiveRuleCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.FetchActiveRuleCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.071 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.FetchClusterNodeByIdCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.FetchClusterNodeByIdCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.071 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.FetchClusterNodeHumanCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.FetchClusterNodeHumanCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.071 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.FetchJsonTreeCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.FetchJsonTreeCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.073 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.FetchOriginCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.FetchOriginCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.073 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.FetchSimpleClusterNodeCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.FetchSimpleClusterNodeCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.074 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.FetchSystemStatusCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.FetchSystemStatusCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.074 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.FetchTreeCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.FetchTreeCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.074 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.ModifyRulesCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.ModifyRulesCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.075 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.OnOffGetCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.OnOffGetCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.075 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.OnOffSetCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.OnOffSetCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.075 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.SendMetricCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.SendMetricCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.076 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.VersionCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.VersionCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.076 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.cluster.FetchClusterModeCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.cluster.FetchClusterModeCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.076 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.cluster.ModifyClusterModeCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.cluster.ModifyClusterModeCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.077 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.ApiCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.ApiCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.077 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.GetParamFlowRulesCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.GetParamFlowRulesCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.078 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.ModifyParamFlowRulesCommandHandler, aliasName=com.alibaba.csp.sentinel.command.handler.ModifyParamFlowRulesCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.078 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.cluster.server.command.handler.ModifyClusterServerFlowConfigHandler, aliasName=com.alibaba.csp.sentinel.cluster.server.command.handler.ModifyClusterServerFlowConfigHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.079 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.cluster.server.command.handler.FetchClusterFlowRulesCommandHandler, aliasName=com.alibaba.csp.sentinel.cluster.server.command.handler.FetchClusterFlowRulesCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.079 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.cluster.server.command.handler.FetchClusterParamFlowRulesCommandHandler, aliasName=com.alibaba.csp.sentinel.cluster.server.command.handler.FetchClusterParamFlowRulesCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.080 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.cluster.server.command.handler.FetchClusterServerConfigHandler, aliasName=com.alibaba.csp.sentinel.cluster.server.command.handler.FetchClusterServerConfigHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.081 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.cluster.server.command.handler.ModifyClusterServerTransportConfigHandler, aliasName=com.alibaba.csp.sentinel.cluster.server.command.handler.ModifyClusterServerTransportConfigHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.081 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.cluster.server.command.handler.ModifyServerNamespaceSetHandler, aliasName=com.alibaba.csp.sentinel.cluster.server.command.handler.ModifyServerNamespaceSetHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.081 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.cluster.server.command.handler.ModifyClusterFlowRulesCommandHandler, aliasName=com.alibaba.csp.sentinel.cluster.server.command.handler.ModifyClusterFlowRulesCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.082 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.cluster.server.command.handler.ModifyClusterParamFlowRulesCommandHandler, aliasName=com.alibaba.csp.sentinel.cluster.server.command.handler.ModifyClusterParamFlowRulesCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.082 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.cluster.server.command.handler.FetchClusterServerInfoCommandHandler, aliasName=com.alibaba.csp.sentinel.cluster.server.command.handler.FetchClusterServerInfoCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.083 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.cluster.server.command.handler.FetchClusterMetricCommandHandler, aliasName=com.alibaba.csp.sentinel.cluster.server.command.handler.FetchClusterMetricCommandHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.083 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.ModifyClusterClientConfigHandler, aliasName=com.alibaba.csp.sentinel.command.handler.ModifyClusterClientConfigHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.084 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.command.CommandHandler, provider=com.alibaba.csp.sentinel.command.handler.FetchClusterClientConfigHandler, aliasName=com.alibaba.csp.sentinel.command.handler.FetchClusterClientConfigHandler, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.086 WARNING No SPI configuration file, filename=META-INF/services/com.alibaba.csp.sentinel.command.CommandHandlerInterceptor, classloader=jdk.internal.loader.ClassLoaders$AppClassLoader@36baf30c
|
||||
2024-05-10 15:13:33.087 INFO [CommandCenterInit] Starting command center: com.alibaba.csp.sentinel.transport.command.SimpleHttpCommandCenter
|
||||
2024-05-10 15:13:33.087 INFO [InitExecutor] Executing com.alibaba.csp.sentinel.transport.init.CommandCenterInitFunc with order -1
|
||||
2024-05-10 15:13:33.088 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.transport.HeartbeatSender, provider=com.alibaba.csp.sentinel.transport.heartbeat.SimpleHttpHeartbeatSender, aliasName=com.alibaba.csp.sentinel.transport.heartbeat.SimpleHttpHeartbeatSender, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.090 WARNING [SimpleHttpHeartbeatSender] Dashboard server address not configured or not available
|
||||
2024-05-10 15:13:33.090 INFO [HeartbeatSenderProvider] HeartbeatSender activated: com.alibaba.csp.sentinel.transport.heartbeat.SimpleHttpHeartbeatSender
|
||||
2024-05-10 15:13:33.090 INFO [HeartbeatSenderInit] Heartbeat interval not configured in config property or invalid, using sender default: 10000
|
||||
2024-05-10 15:13:33.091 INFO [HeartbeatSenderInit] HeartbeatSender started: com.alibaba.csp.sentinel.transport.heartbeat.SimpleHttpHeartbeatSender
|
||||
2024-05-10 15:13:33.091 INFO [InitExecutor] Executing com.alibaba.csp.sentinel.transport.init.HeartbeatSenderInitFunc with order -1
|
||||
2024-05-10 15:13:33.093 INFO [InitExecutor] Executing com.alibaba.csp.sentinel.cluster.client.init.DefaultClusterClientInitFunc with order 0
|
||||
2024-05-10 15:13:33.094 INFO [InitExecutor] Executing com.alibaba.csp.sentinel.metric.extension.MetricCallbackInit with order 2147483647
|
||||
2024-05-10 15:13:33.095 INFO [InitExecutor] Executing com.alibaba.csp.sentinel.init.ParamFlowStatisticSlotCallbackInit with order 2147483647
|
||||
2024-05-10 15:13:33.099 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.cluster.server.processor.RequestProcessor, provider=com.alibaba.csp.sentinel.cluster.server.processor.FlowRequestProcessor, aliasName=com.alibaba.csp.sentinel.cluster.server.processor.FlowRequestProcessor, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.100 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.cluster.server.processor.RequestProcessor, provider=com.alibaba.csp.sentinel.cluster.server.processor.ParamFlowRequestProcessor, aliasName=com.alibaba.csp.sentinel.cluster.server.processor.ParamFlowRequestProcessor, isSingleton=true, isDefault=false, order=0
|
||||
2024-05-10 15:13:33.101 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.cluster.TokenService, provider=com.alibaba.csp.sentinel.cluster.flow.DefaultTokenService, aliasName=com.alibaba.csp.sentinel.cluster.flow.DefaultTokenService, isSingleton=true, isDefault=true, order=0
|
||||
2024-05-10 15:13:33.101 INFO [TokenServiceProvider] Global token service resolved: com.alibaba.csp.sentinel.cluster.flow.DefaultTokenService
|
||||
2024-05-10 15:13:33.101 INFO [DefaultClusterServerInitFunc] Default entity codec and processors registered
|
||||
2024-05-10 15:13:33.101 INFO [InitExecutor] Executing com.alibaba.csp.sentinel.cluster.server.init.DefaultClusterServerInitFunc with order 2147483647
|
||||
2024-05-10 15:13:33.104 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.slotchain.SlotChainBuilder, provider=com.alibaba.csp.sentinel.slots.DefaultSlotChainBuilder, aliasName=com.alibaba.csp.sentinel.slots.DefaultSlotChainBuilder, isSingleton=true, isDefault=true, order=0
|
||||
2024-05-10 15:13:33.105 INFO [SlotChainProvider] Global slot chain builder resolved: com.alibaba.csp.sentinel.slots.DefaultSlotChainBuilder
|
||||
2024-05-10 15:13:33.105 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.slotchain.ProcessorSlot, provider=com.alibaba.csp.sentinel.slots.nodeselector.NodeSelectorSlot, aliasName=com.alibaba.csp.sentinel.slots.nodeselector.NodeSelectorSlot, isSingleton=false, isDefault=false, order=-10000
|
||||
2024-05-10 15:13:33.106 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.slotchain.ProcessorSlot, provider=com.alibaba.csp.sentinel.slots.clusterbuilder.ClusterBuilderSlot, aliasName=com.alibaba.csp.sentinel.slots.clusterbuilder.ClusterBuilderSlot, isSingleton=false, isDefault=false, order=-9000
|
||||
2024-05-10 15:13:33.106 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.slotchain.ProcessorSlot, provider=com.alibaba.csp.sentinel.slots.logger.LogSlot, aliasName=com.alibaba.csp.sentinel.slots.logger.LogSlot, isSingleton=true, isDefault=false, order=-8000
|
||||
2024-05-10 15:13:33.106 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.slotchain.ProcessorSlot, provider=com.alibaba.csp.sentinel.slots.statistic.StatisticSlot, aliasName=com.alibaba.csp.sentinel.slots.statistic.StatisticSlot, isSingleton=true, isDefault=false, order=-7000
|
||||
2024-05-10 15:13:33.107 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.slotchain.ProcessorSlot, provider=com.alibaba.csp.sentinel.slots.block.authority.AuthoritySlot, aliasName=com.alibaba.csp.sentinel.slots.block.authority.AuthoritySlot, isSingleton=true, isDefault=false, order=-6000
|
||||
2024-05-10 15:13:33.107 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.slotchain.ProcessorSlot, provider=com.alibaba.csp.sentinel.slots.system.SystemSlot, aliasName=com.alibaba.csp.sentinel.slots.system.SystemSlot, isSingleton=true, isDefault=false, order=-5000
|
||||
2024-05-10 15:13:33.107 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.slotchain.ProcessorSlot, provider=com.alibaba.csp.sentinel.slots.block.flow.FlowSlot, aliasName=com.alibaba.csp.sentinel.slots.block.flow.FlowSlot, isSingleton=true, isDefault=false, order=-2000
|
||||
2024-05-10 15:13:33.108 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.slotchain.ProcessorSlot, provider=com.alibaba.csp.sentinel.slots.block.degrade.DegradeSlot, aliasName=com.alibaba.csp.sentinel.slots.block.degrade.DegradeSlot, isSingleton=true, isDefault=false, order=-1000
|
||||
2024-05-10 15:13:33.108 INFO [SpiLoader] Found SPI implementation for SPI com.alibaba.csp.sentinel.slotchain.ProcessorSlot, provider=com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowSlot, aliasName=com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowSlot, isSingleton=true, isDefault=false, order=-3000
|
||||
2024-05-10 15:13:33.112 INFO Add child </> to node <sentinel_spring_webflux_context>
|
||||
2024-05-10 15:13:33.113 INFO [AuthorityRuleManager] Authority rules loaded: {}
|
||||
2024-05-10 15:13:33.115 INFO [SystemRuleManager] Current system check status: false, highestSystemLoad: 1.797693e+308, highestCpuUsage: 1.797693e+308, maxRt: 9223372036854775807, maxThread: 9223372036854775807, maxQps: 1.797693e+308
|
||||
2024-05-10 15:13:33.117 INFO [ParamFlowRuleManager] No parameter flow rules, clearing all parameter metrics
|
||||
2024-05-10 15:13:33.117 INFO [ParamFlowRuleManager] Parameter flow rules received: {}
|
||||
2024-05-10 15:13:33.118 INFO [FlowRuleManager] Flow rules loaded: {}
|
||||
2024-05-10 15:13:33.120 INFO [MetricWriter] Creating new MetricWriter, singleFileSize=52428800, totalFileCount=6
|
||||
2024-05-10 15:13:33.121 INFO [DegradeRuleManager] Degrade rules loaded: {}
|
||||
2024-05-10 15:13:33.123 WARNING No SPI configuration file, filename=META-INF/services/com.alibaba.csp.sentinel.metric.extension.MetricExtension, classloader=jdk.internal.loader.ClassLoaders$AppClassLoader@36baf30c
|
||||
2024-05-10 15:13:33.123 INFO [MetricExtensionProvider] No existing MetricExtension found
|
||||
2024-05-10 15:13:33.470 INFO Add child </favicon.ico> to node <sentinel_spring_webflux_context>
|
||||
2024-05-10 15:13:34.123 INFO [MetricWriter] New metric file created: logs/service-gateway/sentinel\service-gateway-metrics.log.2024-05-10
|
||||
2024-05-10 15:13:34.124 INFO [MetricWriter] New metric index file created: logs/service-gateway/sentinel\service-gateway-metrics.log.2024-05-10.idx
|
|
@ -2,16 +2,23 @@ package cn.bunny.module.minio.utils;
|
|||
|
||||
import cn.bunny.common.service.exception.BunnyException;
|
||||
import cn.bunny.module.minio.properties.MinioProperties;
|
||||
import cn.bunny.pojo.file.MinioFIlePath;
|
||||
import cn.bunny.pojo.result.constant.FileMessageConstant;
|
||||
import cn.bunny.pojo.result.constant.MinioConstant;
|
||||
import io.minio.*;
|
||||
import io.minio.messages.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Minio操作工具类 简化操作步骤
|
||||
|
@ -26,18 +33,118 @@ public class MinioUtil {
|
|||
private MinioClient minioClient;
|
||||
|
||||
/**
|
||||
* 获取Minio全路径名
|
||||
*
|
||||
* @param objectName 对象名称
|
||||
* @return 全路径
|
||||
* 获取Minio文件路径
|
||||
*/
|
||||
public String getFullPath(String objectName) {
|
||||
String url = properties.getEndpointUrl();
|
||||
public static MinioFIlePath getMinioFilePath(String buckName, String minioPreType, MultipartFile file) {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
// 定义日期时间格式
|
||||
LocalDateTime currentDateTime = LocalDateTime.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM-dd");
|
||||
String extension = "";
|
||||
|
||||
// 原始文件名
|
||||
String filename = file.getOriginalFilename();
|
||||
if (filename.contains(".")) {
|
||||
extension = "." + filename.substring(filename.lastIndexOf(".") + 1);
|
||||
}
|
||||
|
||||
// UUID防止重名
|
||||
String uuidFilename = uuid + extension;
|
||||
|
||||
// 拼接时间+UUID文件名
|
||||
String timeUuidFilename = currentDateTime.format(formatter) + "/" + uuidFilename;// 加上时间路径
|
||||
|
||||
// 上传根文件夹+拼接时间+UUID文件名
|
||||
String filepath = MinioConstant.getType(minioPreType) + timeUuidFilename;
|
||||
|
||||
// 桶名称+上传根文件夹+拼接时间+UUID文件名
|
||||
String buckNameFilepath = "/" + buckName + MinioConstant.getType(minioPreType) + timeUuidFilename;
|
||||
|
||||
// 设置及Minio基础信息
|
||||
MinioFIlePath minioFIlePath = new MinioFIlePath();
|
||||
minioFIlePath.setFilename(filename);
|
||||
minioFIlePath.setUuidFilename(uuidFilename);
|
||||
minioFIlePath.setTimeUuidFilename(timeUuidFilename);
|
||||
minioFIlePath.setFilepath(filepath);
|
||||
minioFIlePath.setBucketNameFilepath(buckNameFilepath);
|
||||
|
||||
return minioFIlePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* * 获取上传路径
|
||||
*/
|
||||
public MinioFIlePath getUploadMinioObjectFilePath(MultipartFile file, String bucketName, String minioPreType) throws IOException {
|
||||
if (file != null) {
|
||||
MinioFIlePath minioFile = getMinioFilePath(bucketName, minioPreType, file);
|
||||
String filepath = minioFile.getFilepath();
|
||||
|
||||
// 上传对象
|
||||
putObject(bucketName, filepath, file.getInputStream(), file.getSize());
|
||||
|
||||
// 设置图片地址
|
||||
return minioFile;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* * 上传文件并返回处理信息
|
||||
*/
|
||||
public MinioFIlePath getUploadMinioObjectFilePath(MultipartFile file, String minioPreType) throws IOException {
|
||||
// 如果buckName为空,设置为默认的桶
|
||||
String bucketName = properties.getBucketName();
|
||||
if (file != null) {
|
||||
MinioFIlePath minioFile = getMinioFilePath(bucketName, minioPreType, file);
|
||||
String filepath = minioFile.getFilepath();
|
||||
|
||||
// 上传对象
|
||||
putObject(bucketName, filepath, file.getInputStream(), file.getSize());
|
||||
|
||||
// 设置图片地址
|
||||
return minioFile;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动上传文件
|
||||
*/
|
||||
public String uploadFile(MultipartFile file, String bucketName, String minioPreType) throws IOException {
|
||||
// 准备上传路径
|
||||
return getUploadFIlePath(file, bucketName, minioPreType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动上传文件
|
||||
*/
|
||||
public String uploadFile(MultipartFile file, String minioPreType) throws IOException {
|
||||
// 如果buckName为空,设置为默认的桶
|
||||
String bucketName = properties.getBucketName();
|
||||
|
||||
return url + "/" + bucketName + objectName;
|
||||
// 准备上传路径
|
||||
return getUploadFIlePath(file, bucketName, minioPreType);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 获取上传路径
|
||||
*/
|
||||
private String getUploadFIlePath(MultipartFile file, String bucketName, String minioPreType) throws IOException {
|
||||
if (file != null) {
|
||||
MinioFIlePath minioFile = getMinioFilePath(bucketName, minioPreType, file);
|
||||
String bucketNameFilepath = minioFile.getBucketNameFilepath();
|
||||
String filepath = minioFile.getFilepath();
|
||||
|
||||
// 上传对象
|
||||
putObject(bucketName, filepath, file.getInputStream(), file.getSize());
|
||||
|
||||
// 设置图片地址
|
||||
return bucketNameFilepath;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件并返回字节数组
|
||||
*
|
||||
|
@ -57,6 +164,64 @@ public class MinioUtil {
|
|||
throw new BunnyException(FileMessageConstant.GET_BUCKET_EXCEPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认bucket文件,并返回字节数组
|
||||
*
|
||||
* @param objectName 对象名称
|
||||
* @return 文件流对象
|
||||
*/
|
||||
public byte[] getBucketObjectByte(String objectName) {
|
||||
// 如果buckName为空,设置为默认的桶
|
||||
String bucketName = properties.getBucketName();
|
||||
|
||||
try {
|
||||
objectName = objectName.replace("/" + bucketName, "");
|
||||
GetObjectResponse getObjectResponse = minioClient.getObject(GetObjectArgs.builder().bucket(bucketName).object(objectName).build());
|
||||
|
||||
return getObjectResponse.readAllBytes();
|
||||
} catch (Exception exception) {
|
||||
exception.getStackTrace();
|
||||
}
|
||||
throw new BunnyException(FileMessageConstant.GET_BUCKET_EXCEPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Minio全路径名,Object带有桶名称
|
||||
*
|
||||
* @param objectName 对象名称
|
||||
* @return 全路径
|
||||
*/
|
||||
public String getObjectNameFullPath(String objectName) {
|
||||
String url = properties.getEndpointUrl();
|
||||
|
||||
return url + objectName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Minio全路径名-默认桶名称
|
||||
*
|
||||
* @param objectName 对象名称
|
||||
* @return 全路径
|
||||
*/
|
||||
public String getDefaultBuckNameFullPath(String objectName) {
|
||||
String url = properties.getEndpointUrl();
|
||||
String bucketName = properties.getBucketName();
|
||||
|
||||
return url + "/" + bucketName + objectName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Minio全路径名,自定义桶名称
|
||||
*
|
||||
* @param objectName 对象名称
|
||||
* @return 全路径
|
||||
*/
|
||||
public String getBuckNameFullPath(String bucketName, String objectName) {
|
||||
String url = properties.getEndpointUrl();
|
||||
|
||||
return url + "/" + bucketName + objectName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断桶是否存在
|
||||
*
|
||||
|
|
27
pom.xml
27
pom.xml
|
@ -185,4 +185,31 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<profiles>
|
||||
<!--dev环境-->
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
<properties>
|
||||
<profiles.active>dev</profiles.active>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
</profile>
|
||||
<!--test环境-->
|
||||
<profile>
|
||||
<id>test</id>
|
||||
<properties>
|
||||
<profiles.active>test</profiles.active>
|
||||
</properties>
|
||||
</profile>
|
||||
<!--prod环境-->
|
||||
<profile>
|
||||
<id>prod</id>
|
||||
<properties>
|
||||
<profiles.active>prod</profiles.active>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
bunny:
|
||||
nacos:
|
||||
server-addr: 192.168.3.98:8848
|
||||
discovery:
|
||||
namespace: bunnyBBS
|
||||
username: nacos
|
||||
password: "02120212"
|
||||
|
||||
redis:
|
||||
host: 192.168.3.98
|
||||
port: 6379
|
||||
database: 1
|
||||
password: "123456"
|
|
@ -2,7 +2,7 @@ server:
|
|||
port: 8800
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
active: @profiles.active@
|
||||
application:
|
||||
name: service-gateway
|
||||
main:
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
bunny:
|
||||
datasource:
|
||||
host: 192.168.3.98
|
||||
port: 3306
|
||||
sqlData: bunny_docs
|
||||
username: root
|
||||
password: "02120212"
|
||||
|
||||
redis:
|
||||
host: 192.168.3.98
|
||||
port: 6379
|
||||
database: 1
|
||||
password: "123456"
|
||||
|
||||
minio:
|
||||
endpointUrl: "http://192.168.3.98:9000"
|
||||
accessKey: bunny
|
||||
secretKey: "02120212"
|
||||
bucket-name: bunny-bbs
|
||||
|
||||
nacos:
|
||||
server-addr: 192.168.3.98:8848
|
||||
discovery:
|
||||
namespace: bunnyBBS
|
||||
username: nacos
|
||||
password: "02120212"
|
|
@ -3,7 +3,7 @@ server:
|
|||
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
active: @profiles.active@
|
||||
application:
|
||||
name: service-admin
|
||||
main:
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,26 @@
|
|||
bunny:
|
||||
datasource:
|
||||
host: 192.168.3.98
|
||||
port: 3306
|
||||
sqlData: bunny_docs
|
||||
username: root
|
||||
password: "02120212"
|
||||
|
||||
redis:
|
||||
host: 192.168.3.98
|
||||
port: 6379
|
||||
database: 1
|
||||
password: "123456"
|
||||
|
||||
minio:
|
||||
endpointUrl: "http://192.168.3.98:9000"
|
||||
accessKey: bunny
|
||||
secretKey: "02120212"
|
||||
bucket-name: bunny-bbs
|
||||
|
||||
nacos:
|
||||
server-addr: 192.168.3.98:8848
|
||||
discovery:
|
||||
namespace: bunnyBBS
|
||||
username: nacos
|
||||
password: "02120212"
|
|
@ -3,7 +3,7 @@ server:
|
|||
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
active: @profiles.active@
|
||||
application:
|
||||
name: service-web
|
||||
main:
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,16 @@
|
|||
package cn.bunny.ipdb;
|
||||
|
||||
import cn.bunny.common.service.utils.IpUtil;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class IpDbTest {
|
||||
@Test
|
||||
public void test() {
|
||||
String ip = "220.248.12.158"; // IpRegion:上海
|
||||
// String ip = "47.52.236.180"; // IpRegion:香港
|
||||
// String ip = "172.22.12.123"; // IpRegion:内网IP
|
||||
// String ip = "164.114.53.60"; // IpRegion:美国
|
||||
String ipRegion = IpUtil.getIpRegion(ip);
|
||||
System.out.println(ipRegion);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue