Compare commits
2 Commits
4cab0a0475
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 32304cdca0 | |||
| 53f1af64bd |
@@ -9,12 +9,15 @@ import org.springframework.cache.annotation.EnableCaching;
|
|||||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
|
||||||
@MapperScan("me.qwq.doghouse.dao")
|
@MapperScan("me.qwq.doghouse.dao")
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableAsync(proxyTargetClass=true)
|
@EnableAsync(proxyTargetClass=true)
|
||||||
@EnableCaching(proxyTargetClass=true)
|
@EnableCaching(proxyTargetClass=true)
|
||||||
@EnableAspectJAutoProxy(exposeProxy = true)
|
@EnableAspectJAutoProxy(exposeProxy = true)
|
||||||
|
@Slf4j
|
||||||
public class BlogApplication {
|
public class BlogApplication {
|
||||||
|
|
||||||
static Boolean isDebug = null;
|
static Boolean isDebug = null;
|
||||||
@@ -23,7 +26,9 @@ public class BlogApplication {
|
|||||||
|
|
||||||
if (isDebug == null) {
|
if (isDebug == null) {
|
||||||
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
|
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
|
||||||
isDebug = runtimeMXBean.getInputArguments().toString().contains("-agentlib:jdwp");
|
String runtimeMXBeanInputArguments = runtimeMXBean.getInputArguments().toString();
|
||||||
|
log.debug("Runtime MXBean input arguments: {}", runtimeMXBeanInputArguments);
|
||||||
|
isDebug = runtimeMXBeanInputArguments.contains("-agentlib:jdwp");
|
||||||
}
|
}
|
||||||
return isDebug;
|
return isDebug;
|
||||||
}
|
}
|
||||||
@@ -33,8 +38,9 @@ public class BlogApplication {
|
|||||||
|
|
||||||
// 根据是否调试加载额外的 application-*.yml
|
// 根据是否调试加载额外的 application-*.yml
|
||||||
SpringApplication app = new SpringApplication(BlogApplication.class);
|
SpringApplication app = new SpringApplication(BlogApplication.class);
|
||||||
app.setAdditionalProfiles(isDebug ? "debug" : "prod");
|
String additionalProfiles = isDebug ? "debug" : "prod";
|
||||||
|
app.setAdditionalProfiles(additionalProfiles);
|
||||||
|
log.info("Current is {}debug, set additional profiles: {}", isDebug ? "" : "not ", additionalProfiles);
|
||||||
app.run(args);
|
app.run(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package me.qwq.doghouse.controller.api.v1;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.jdom2.DocType;
|
import org.jdom2.DocType;
|
||||||
@@ -71,7 +71,7 @@ public class ApiControllerV1 {
|
|||||||
@RequestParam(required=false) String nocache) {
|
@RequestParam(required=false) String nocache) {
|
||||||
|
|
||||||
if (size == null || size <= 0) size = 36;
|
if (size == null || size <= 0) size = 36;
|
||||||
CompletableFuture<byte[]> future =
|
Future<byte[]> future =
|
||||||
gravatarUtils.getReversedProxyGravatarAsync(hash, size, StringUtils.isBlank(nocache));
|
gravatarUtils.getReversedProxyGravatarAsync(hash, size, StringUtils.isBlank(nocache));
|
||||||
|
|
||||||
byte[] avatar;
|
byte[] avatar;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package me.qwq.doghouse.controller.api.v2;
|
package me.qwq.doghouse.controller.api.v2;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -49,7 +49,7 @@ public class GravatarApiControllerV2 extends BaseController {
|
|||||||
@RequestParam(required=false) String nocache) {
|
@RequestParam(required=false) String nocache) {
|
||||||
|
|
||||||
if (size == null || size <= 0) size = 36;
|
if (size == null || size <= 0) size = 36;
|
||||||
CompletableFuture<byte[]> future =
|
Future<byte[]> future =
|
||||||
gravatarUtils.getReversedProxyGravatarAsync(hash, size, StringUtils.isBlank(nocache));
|
gravatarUtils.getReversedProxyGravatarAsync(hash, size, StringUtils.isBlank(nocache));
|
||||||
|
|
||||||
byte[] avatar;
|
byte[] avatar;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package me.qwq.doghouse.util;
|
package me.qwq.doghouse.util;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -34,4 +35,24 @@ public final class DateUtils {
|
|||||||
|
|
||||||
return dateTime.format(formatter);
|
return dateTime.format(formatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将给定字符串转换成 LocalDate
|
||||||
|
* @param value 如 "20260101"
|
||||||
|
* @param pattern 日期格式,如 yyyyMMdd
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static LocalDate parse(String value, String pattern) {
|
||||||
|
if (value == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (pattern == null || pattern.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("pattern must not be null or empty");
|
||||||
|
}
|
||||||
|
DateTimeFormatter formatter =
|
||||||
|
FORMATTER_CACHE.computeIfAbsent(pattern, DateTimeFormatter::ofPattern);
|
||||||
|
|
||||||
|
LocalDate date = LocalDate.parse(value, formatter);
|
||||||
|
return date;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.net.Proxy;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@ public class GravatarUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
public CompletableFuture<byte[]> getReversedProxyGravatarAsync(String privateHash, int size, boolean fromCache) {
|
public Future<byte[]> getReversedProxyGravatarAsync(String privateHash, int size, boolean fromCache) {
|
||||||
return CompletableFuture.completedFuture(getProxyGravatar(privateHash, size, fromCache));
|
return CompletableFuture.completedFuture(getProxyGravatar(privateHash, size, fromCache));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ spring:
|
|||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
'[me.qwq.doghouse]': debug
|
'[me.qwq.doghouse]': info
|
||||||
'[me.qwq.doghouse.dao]': warn
|
'[me.qwq.doghouse.dao]': warn
|
||||||
'[me.qwq.doghouse.interceptor.BlogInterceptor]': warn
|
'[me.qwq.doghouse.interceptor.BlogInterceptor]': warn
|
||||||
'[org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver]': error
|
'[org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver]': error
|
||||||
|
|||||||
Reference in New Issue
Block a user