修改依赖注入方式,改为构造函数注入;更新依赖;
This commit is contained in:
parent
8742e59ebe
commit
39e4e606b0
34
pom.xml
34
pom.xml
@ -14,7 +14,7 @@
|
||||
<name>LionWebsite</name>
|
||||
<description>LionWebsite</description>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<java.version>21</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -34,6 +34,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.30</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -57,7 +58,7 @@
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.11</version>
|
||||
<version>5.8.20</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -104,18 +105,35 @@
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>4.1.86.Final</version>
|
||||
<version>4.1.101.Final</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.pengrad</groupId>
|
||||
<artifactId>java-telegram-bot-api</artifactId>
|
||||
<version>6.7.0</version>
|
||||
<version>6.9.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.graalvm.buildtools</groupId>
|
||||
<artifactId>native-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<imageName>lionwebsite</imageName>
|
||||
<fallback>false</fallback>
|
||||
<verbose>true</verbose>
|
||||
<quickBuild>true</quickBuild>
|
||||
<buildArgs>
|
||||
<arg>-H:+ReportExceptionStackTraces</arg>
|
||||
<arg>--initialize-at-build-time=org.apache.commons.logging.LogFactory,org.apache.commons.logging.LogFactoryService</arg>
|
||||
</buildArgs>
|
||||
<metadataRepository>
|
||||
<enabled>true</enabled>
|
||||
</metadataRepository>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
@ -128,14 +146,6 @@
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@ -1,15 +1,26 @@
|
||||
package com.lion.lionwebsite.Configuration;
|
||||
|
||||
import com.lion.lionwebsite.Domain.*;
|
||||
import com.pengrad.telegrambot.TelegramBot;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import com.pengrad.telegrambot.model.Chat;
|
||||
import com.pengrad.telegrambot.model.Message;
|
||||
import com.pengrad.telegrambot.model.MessageEntity;
|
||||
import com.pengrad.telegrambot.response.SendResponse;
|
||||
import org.springframework.aot.hint.annotation.RegisterReflectionForBinding;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import com.pengrad.telegrambot.model.User;
|
||||
|
||||
@Configuration
|
||||
@RegisterReflectionForBinding(classes = {CRC32Cache.class, CustomConfiguration.class,
|
||||
GalleryForQuery.class, Gallery.class, GalleryTask.class, MaskDomain.class,
|
||||
PageNameCache.class, ShareFile.class, Tag.class, TagMark.class, User.class,
|
||||
SendResponse.class, Message.class, com.pengrad.telegrambot.model.User.class,
|
||||
Chat.class, MessageEntity.class})
|
||||
public class CustomBean {
|
||||
|
||||
@Bean
|
||||
public TelegramBot getTelegramBot(@Value("${bot.token}") String token){
|
||||
return new TelegramBot(token);
|
||||
public TelegramBot getTelegramBot(){
|
||||
return new TelegramBot("5222939329:AAHa6l9ZuVVdNSDLPI_H-c8O_VgeOEw5plA");
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,9 +14,12 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class InterceptorConfiguration implements WebMvcConfigurer {
|
||||
@Resource
|
||||
TaskHandlerInterceptor taskHandlerInterceptor;
|
||||
|
||||
public InterceptorConfiguration(TaskHandlerInterceptor taskHandlerInterceptor) {
|
||||
this.taskHandlerInterceptor = taskHandlerInterceptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(getPersonalInterceptor()).addPathPatterns("/personal/**", "/remote/**");
|
||||
|
||||
@ -0,0 +1,266 @@
|
||||
package com.lion.lionwebsite.Configuration;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.ibatis.annotations.DeleteProvider;
|
||||
import org.apache.ibatis.annotations.InsertProvider;
|
||||
import org.apache.ibatis.annotations.SelectProvider;
|
||||
import org.apache.ibatis.annotations.UpdateProvider;
|
||||
import org.apache.ibatis.cache.decorators.FifoCache;
|
||||
import org.apache.ibatis.cache.decorators.LruCache;
|
||||
import org.apache.ibatis.cache.decorators.SoftCache;
|
||||
import org.apache.ibatis.cache.decorators.WeakCache;
|
||||
import org.apache.ibatis.cache.impl.PerpetualCache;
|
||||
import org.apache.ibatis.javassist.util.proxy.ProxyFactory;
|
||||
import org.apache.ibatis.javassist.util.proxy.RuntimeSupport;
|
||||
import org.apache.ibatis.logging.Log;
|
||||
import org.apache.ibatis.logging.commons.JakartaCommonsLoggingImpl;
|
||||
import org.apache.ibatis.logging.jdk14.Jdk14LoggingImpl;
|
||||
import org.apache.ibatis.logging.log4j2.Log4j2Impl;
|
||||
import org.apache.ibatis.logging.nologging.NoLoggingImpl;
|
||||
import org.apache.ibatis.logging.slf4j.Slf4jImpl;
|
||||
import org.apache.ibatis.logging.stdout.StdOutImpl;
|
||||
import org.apache.ibatis.reflection.TypeParameterResolver;
|
||||
import org.apache.ibatis.scripting.defaults.RawLanguageDriver;
|
||||
import org.apache.ibatis.scripting.xmltags.XMLLanguageDriver;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.mapper.MapperFactoryBean;
|
||||
import org.mybatis.spring.mapper.MapperScannerConfigurer;
|
||||
import org.springframework.aot.hint.MemberCategory;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||
import org.springframework.beans.PropertyValue;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution;
|
||||
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor;
|
||||
import org.springframework.beans.factory.aot.BeanRegistrationExcludeFilter;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor;
|
||||
import org.springframework.beans.factory.support.RegisteredBean;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ImportRuntimeHints(MyBatisNativeConfiguration.MyBaitsRuntimeHintsRegistrar.class)
|
||||
public class MyBatisNativeConfiguration {
|
||||
|
||||
@Bean
|
||||
MyBatisBeanFactoryInitializationAotProcessor myBatisBeanFactoryInitializationAotProcessor() {
|
||||
return new MyBatisBeanFactoryInitializationAotProcessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
static MyBatisMapperFactoryBeanPostProcessor myBatisMapperFactoryBeanPostProcessor() {
|
||||
return new MyBatisMapperFactoryBeanPostProcessor();
|
||||
}
|
||||
|
||||
static class MyBaitsRuntimeHintsRegistrar implements RuntimeHintsRegistrar {
|
||||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
Stream.of(RawLanguageDriver.class,
|
||||
XMLLanguageDriver.class,
|
||||
RuntimeSupport.class,
|
||||
ProxyFactory.class,
|
||||
Slf4jImpl.class,
|
||||
Log.class,
|
||||
JakartaCommonsLoggingImpl.class,
|
||||
Log4j2Impl.class,
|
||||
Jdk14LoggingImpl.class,
|
||||
StdOutImpl.class,
|
||||
NoLoggingImpl.class,
|
||||
SqlSessionFactory.class,
|
||||
PerpetualCache.class,
|
||||
FifoCache.class,
|
||||
LruCache.class,
|
||||
SoftCache.class,
|
||||
WeakCache.class,
|
||||
SqlSessionFactoryBean.class,
|
||||
ArrayList.class,
|
||||
HashMap.class,
|
||||
TreeSet.class,
|
||||
HashSet.class
|
||||
).forEach(x -> hints.reflection().registerType(x, MemberCategory.values()));
|
||||
Stream.of(
|
||||
"org/apache/ibatis/builder/xml/*.dtd",
|
||||
"org/apache/ibatis/builder/xml/*.xsd"
|
||||
).forEach(hints.resources()::registerPattern);
|
||||
}
|
||||
}
|
||||
|
||||
static class MyBatisBeanFactoryInitializationAotProcessor
|
||||
implements BeanFactoryInitializationAotProcessor, BeanRegistrationExcludeFilter {
|
||||
|
||||
private final Set<Class<?>> excludeClasses = new HashSet<>();
|
||||
|
||||
MyBatisBeanFactoryInitializationAotProcessor() {
|
||||
excludeClasses.add(MapperScannerConfigurer.class);
|
||||
}
|
||||
|
||||
@Override public boolean isExcludedFromAotProcessing(RegisteredBean registeredBean) {
|
||||
return excludeClasses.contains(registeredBean.getBeanClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeanFactoryInitializationAotContribution processAheadOfTime(ConfigurableListableBeanFactory beanFactory) {
|
||||
String[] beanNames = beanFactory.getBeanNamesForType(MapperFactoryBean.class);
|
||||
if (beanNames.length == 0) {
|
||||
return null;
|
||||
}
|
||||
return (context, code) -> {
|
||||
RuntimeHints hints = context.getRuntimeHints();
|
||||
for (String beanName : beanNames) {
|
||||
BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName.substring(1));
|
||||
PropertyValue mapperInterface = beanDefinition.getPropertyValues().getPropertyValue("mapperInterface");
|
||||
if (mapperInterface != null && mapperInterface.getValue() != null) {
|
||||
Class<?> mapperInterfaceType = (Class<?>) mapperInterface.getValue();
|
||||
if (mapperInterfaceType != null) {
|
||||
registerReflectionTypeIfNecessary(mapperInterfaceType, hints);
|
||||
hints.proxies().registerJdkProxy(mapperInterfaceType);
|
||||
hints.resources()
|
||||
.registerPattern(mapperInterfaceType.getName().replace('.', '/').concat(".xml"));
|
||||
registerMapperRelationships(mapperInterfaceType, hints);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void registerMapperRelationships(Class<?> mapperInterfaceType, RuntimeHints hints) {
|
||||
Method[] methods = ReflectionUtils.getAllDeclaredMethods(mapperInterfaceType);
|
||||
for (Method method : methods) {
|
||||
if (method.getDeclaringClass() != Object.class) {
|
||||
ReflectionUtils.makeAccessible(method);
|
||||
registerSqlProviderTypes(method, hints, SelectProvider.class, SelectProvider::value, SelectProvider::type);
|
||||
registerSqlProviderTypes(method, hints, InsertProvider.class, InsertProvider::value, InsertProvider::type);
|
||||
registerSqlProviderTypes(method, hints, UpdateProvider.class, UpdateProvider::value, UpdateProvider::type);
|
||||
registerSqlProviderTypes(method, hints, DeleteProvider.class, DeleteProvider::value, DeleteProvider::type);
|
||||
Class<?> returnType = MyBatisMapperTypeUtils.resolveReturnClass(mapperInterfaceType, method);
|
||||
registerReflectionTypeIfNecessary(returnType, hints);
|
||||
MyBatisMapperTypeUtils.resolveParameterClasses(mapperInterfaceType, method)
|
||||
.forEach(x -> registerReflectionTypeIfNecessary(x, hints));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
private <T extends Annotation> void registerSqlProviderTypes(
|
||||
Method method, RuntimeHints hints, Class<T> annotationType, Function<T, Class<?>>... providerTypeResolvers) {
|
||||
for (T annotation : method.getAnnotationsByType(annotationType)) {
|
||||
for (Function<T, Class<?>> providerTypeResolver : providerTypeResolvers) {
|
||||
registerReflectionTypeIfNecessary(providerTypeResolver.apply(annotation), hints);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerReflectionTypeIfNecessary(Class<?> type, RuntimeHints hints) {
|
||||
if (!type.isPrimitive() && !type.getName().startsWith("java")) {
|
||||
hints.reflection().registerType(type, MemberCategory.values());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class MyBatisMapperTypeUtils {
|
||||
private MyBatisMapperTypeUtils() {
|
||||
// NOP
|
||||
}
|
||||
|
||||
static Class<?> resolveReturnClass(Class<?> mapperInterface, Method method) {
|
||||
Type resolvedReturnType = TypeParameterResolver.resolveReturnType(method, mapperInterface);
|
||||
return typeToClass(resolvedReturnType, method.getReturnType());
|
||||
}
|
||||
|
||||
static Set<Class<?>> resolveParameterClasses(Class<?> mapperInterface, Method method) {
|
||||
return Stream.of(TypeParameterResolver.resolveParamTypes(method, mapperInterface))
|
||||
.map(x -> typeToClass(x, x instanceof Class ? (Class<?>) x : Object.class)).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private static Class<?> typeToClass(Type src, Class<?> fallback) {
|
||||
Class<?> result = null;
|
||||
if (src instanceof Class<?>) {
|
||||
if (((Class<?>) src).isArray()) {
|
||||
result = ((Class<?>) src).getComponentType();
|
||||
} else {
|
||||
result = (Class<?>) src;
|
||||
}
|
||||
} else if (src instanceof ParameterizedType) {
|
||||
ParameterizedType parameterizedType = (ParameterizedType) src;
|
||||
int index = (parameterizedType.getRawType() instanceof Class
|
||||
&& Map.class.isAssignableFrom((Class<?>) parameterizedType.getRawType())
|
||||
&& parameterizedType.getActualTypeArguments().length > 1) ? 1 : 0;
|
||||
Type actualType = parameterizedType.getActualTypeArguments()[index];
|
||||
result = typeToClass(actualType, fallback);
|
||||
}
|
||||
if (result == null) {
|
||||
result = fallback;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class MyBatisMapperFactoryBeanPostProcessor implements MergedBeanDefinitionPostProcessor, BeanFactoryAware {
|
||||
|
||||
private static final org.apache.commons.logging.Log LOG = LogFactory.getLog(
|
||||
MyBatisMapperFactoryBeanPostProcessor.class);
|
||||
|
||||
private static final String MAPPER_FACTORY_BEAN = "org.mybatis.spring.mapper.MapperFactoryBean";
|
||||
|
||||
private ConfigurableBeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
this.beanFactory = (ConfigurableBeanFactory) beanFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
|
||||
if (ClassUtils.isPresent(MAPPER_FACTORY_BEAN, this.beanFactory.getBeanClassLoader())) {
|
||||
resolveMapperFactoryBeanTypeIfNecessary(beanDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
private void resolveMapperFactoryBeanTypeIfNecessary(RootBeanDefinition beanDefinition) {
|
||||
if (!beanDefinition.hasBeanClass() || !MapperFactoryBean.class.isAssignableFrom(beanDefinition.getBeanClass())) {
|
||||
return;
|
||||
}
|
||||
if (beanDefinition.getResolvableType().hasUnresolvableGenerics()) {
|
||||
Class<?> mapperInterface = getMapperInterface(beanDefinition);
|
||||
if (mapperInterface != null) {
|
||||
// Exposes a generic type information to context for prevent early initializing
|
||||
beanDefinition
|
||||
.setTargetType(ResolvableType.forClassWithGenerics(beanDefinition.getBeanClass(), mapperInterface));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Class<?> getMapperInterface(RootBeanDefinition beanDefinition) {
|
||||
try {
|
||||
return (Class<?>) beanDefinition.getPropertyValues().get("mapperInterface");
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.debug("Fail getting mapper interface type.", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -18,18 +18,21 @@ import java.util.List;
|
||||
@RequestMapping("/GalleryManage")
|
||||
@Slf4j
|
||||
public class GalleryManageController {
|
||||
@Resource
|
||||
GalleryManageService galleryManageService;
|
||||
|
||||
@Resource
|
||||
CollectService collectService;
|
||||
|
||||
@Resource
|
||||
CustomUtil customUtil;
|
||||
|
||||
@Resource
|
||||
UserServiceImpl userService;
|
||||
|
||||
public GalleryManageController(GalleryManageService galleryManageService, CollectService collectService, CustomUtil customUtil, UserServiceImpl userService) {
|
||||
this.galleryManageService = galleryManageService;
|
||||
this.collectService = collectService;
|
||||
this.customUtil = customUtil;
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@PostMapping("")
|
||||
public String create_task(String link, String targetResolution, String AuthCode,
|
||||
@RequestParam(value = "tags", required = false) List<Integer> tags,
|
||||
|
||||
@ -23,12 +23,15 @@ import java.io.IOException;
|
||||
@RequestMapping("/personal")
|
||||
public class PersonalController {
|
||||
|
||||
@Resource
|
||||
PersonalServiceImpl personalService;
|
||||
|
||||
@Resource
|
||||
LocalServiceImpl localService;
|
||||
|
||||
public PersonalController(PersonalServiceImpl personalService, LocalServiceImpl localService) {
|
||||
this.personalService = personalService;
|
||||
this.localService = localService;
|
||||
}
|
||||
|
||||
@GetMapping("/sub/self")
|
||||
public void sub(HttpServletResponse response, HttpServletRequest request){
|
||||
FileDownload.export(request, response, "sub/sub.txt");
|
||||
|
||||
@ -23,12 +23,15 @@ public class PublicController {
|
||||
|
||||
final List<String> black_share_codes = new LinkedList<>();
|
||||
|
||||
@Resource
|
||||
PublicServiceImpl publicService;
|
||||
|
||||
@Resource
|
||||
RemoteService remoteService;
|
||||
|
||||
public PublicController(PublicServiceImpl publicService, RemoteService remoteService) {
|
||||
this.publicService = publicService;
|
||||
this.remoteService = remoteService;
|
||||
}
|
||||
|
||||
@GetMapping("/ip")
|
||||
public void ip(HttpServletRequest request, String auth, HttpServletResponse response) throws IOException {
|
||||
String ip = request.getHeader("X-Forwarded-For");
|
||||
@ -52,8 +55,8 @@ public class PublicController {
|
||||
return;
|
||||
|
||||
switch (client){
|
||||
case "v2ray" -> FileDownload.export(request, response, "sub/DouNaiV2ray.txt");
|
||||
case "clash" -> FileDownload.export(request, response, "sub/DouNaiClash.txt");
|
||||
case "v2" -> FileDownload.export(request, response, "sub/DouNaiV2ray.txt");
|
||||
case "cat" -> FileDownload.export(request, response, "sub/DouNaiClash.txt");
|
||||
default -> response.getOutputStream().write("client error".getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
|
||||
@ -12,9 +12,11 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequestMapping("/query")
|
||||
public class QueryController {
|
||||
|
||||
@Resource
|
||||
QueryService queryService;
|
||||
|
||||
public QueryController(QueryService queryService) {
|
||||
this.queryService = queryService;
|
||||
}
|
||||
|
||||
@GetMapping("")
|
||||
public String query(String keyword, String prev, String next){
|
||||
|
||||
@ -9,9 +9,12 @@ import org.springframework.web.bind.annotation.*;
|
||||
@RequestMapping("/GalleryManage")
|
||||
public class TagController {
|
||||
|
||||
@Resource
|
||||
TagService tagService;
|
||||
|
||||
public TagController(TagService tagService) {
|
||||
this.tagService = tagService;
|
||||
}
|
||||
|
||||
@PostMapping("/tag")
|
||||
public String createTag(String tag){
|
||||
return tagService.createTag(tag);
|
||||
|
||||
@ -8,9 +8,12 @@ import org.springframework.web.bind.annotation.*;
|
||||
@RestController
|
||||
@RequestMapping("/personal/user")
|
||||
public class UserController {
|
||||
@Resource
|
||||
UserServiceImpl userService;
|
||||
|
||||
public UserController(UserServiceImpl userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@GetMapping("")
|
||||
public String getAllUser(){
|
||||
return userService.getAllUser();
|
||||
|
||||
@ -2,7 +2,6 @@ package com.lion.lionwebsite.Filter;
|
||||
|
||||
import com.lion.lionwebsite.Dao.UserMapper;
|
||||
import com.lion.lionwebsite.Util.CustomUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.*;
|
||||
import jakarta.servlet.annotation.WebFilter;
|
||||
|
||||
@ -11,9 +10,11 @@ import java.io.IOException;
|
||||
@WebFilter(filterName = "AccessFilter", urlPatterns = {"/validate"})
|
||||
public class AccessFilter implements Filter {
|
||||
|
||||
@Resource
|
||||
UserMapper userMapper;
|
||||
|
||||
public AccessFilter(UserMapper userMapper) {
|
||||
this.userMapper = userMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
|
||||
@ -15,11 +15,14 @@ public class TaskHandlerInterceptor implements HandlerInterceptor {
|
||||
UserMapper userMapper;
|
||||
|
||||
String[] AuthCodes = null;
|
||||
|
||||
public TaskHandlerInterceptor(UserMapper userMapper) {
|
||||
this.userMapper = userMapper;
|
||||
AuthCodes = userMapper.selectAllAuthCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler){
|
||||
if(AuthCodes == null)
|
||||
AuthCodes = userMapper.selectAllAuthCode();
|
||||
|
||||
String auth = request.getParameter("AuthCode");
|
||||
|
||||
if(auth != null)
|
||||
|
||||
@ -2,16 +2,18 @@ package com.lion.lionwebsite.Service;
|
||||
|
||||
import com.lion.lionwebsite.Dao.CollectMapper;
|
||||
import com.lion.lionwebsite.Util.Response;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.Data;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Data
|
||||
public class CollectService {
|
||||
@Resource
|
||||
CollectMapper collectMapper;
|
||||
|
||||
public CollectService(CollectMapper collectMapper){
|
||||
this.collectMapper = collectMapper;
|
||||
}
|
||||
|
||||
public String collectGallery(int gid, int collector){
|
||||
Response response = Response.generateResponse();
|
||||
if(collectMapper.isCollect(gid, collector) == 0) { //没有收藏
|
||||
|
||||
@ -11,7 +11,6 @@ import com.lion.lionwebsite.Util.FileDownload;
|
||||
import com.lion.lionwebsite.Util.GalleryUtil;
|
||||
import com.lion.lionwebsite.Util.Response;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.Data;
|
||||
@ -30,11 +29,10 @@ import static com.lion.lionwebsite.Util.CustomUtil.fourZeroFour;
|
||||
@Service
|
||||
@Data
|
||||
@Slf4j
|
||||
@ConfigurationProperties(prefix = "gallery-manage-service")
|
||||
public class GalleryManageService {
|
||||
String TargetPath;
|
||||
String TargetPath = "/root/gallery/";
|
||||
|
||||
int cacheSize;
|
||||
int cacheSize = 100;
|
||||
|
||||
Map<Integer, String> gid2name_cache = new HashMap<>();
|
||||
|
||||
@ -42,33 +40,37 @@ public class GalleryManageService {
|
||||
|
||||
Map<String, String> page2pageNameCache = new HashMap<>();
|
||||
|
||||
@Resource
|
||||
GalleryMapper galleryMapper;
|
||||
|
||||
@Resource
|
||||
CollectMapper collectMapper;
|
||||
|
||||
@Resource
|
||||
CustomConfigurationMapper configurationMapper;
|
||||
|
||||
@Resource
|
||||
UserMapper userMapper;
|
||||
|
||||
@Resource
|
||||
ShareFileMapper shareFileMapper;
|
||||
|
||||
@Resource
|
||||
TagMapper tagMapper;
|
||||
|
||||
@Resource
|
||||
PageNameCacheMapper pageNameCacheMapper;
|
||||
|
||||
@Resource
|
||||
RemoteService remoteService;
|
||||
|
||||
@Resource
|
||||
PushService pushService;
|
||||
|
||||
public GalleryManageService(GalleryMapper galleryMapper, CollectMapper collectMapper, CustomConfigurationMapper configurationMapper, UserMapper userMapper, ShareFileMapper shareFileMapper,
|
||||
TagMapper tagMapper, PageNameCacheMapper pageNameCacheMapper, RemoteService remoteService, PushService pushService){
|
||||
this.galleryMapper = galleryMapper;
|
||||
this.collectMapper = collectMapper;
|
||||
this.configurationMapper = configurationMapper;
|
||||
this.userMapper = userMapper;
|
||||
this.shareFileMapper = shareFileMapper;
|
||||
this.tagMapper = tagMapper;
|
||||
this.pageNameCacheMapper = pageNameCacheMapper;
|
||||
this.remoteService = remoteService;
|
||||
this.pushService = pushService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建任务
|
||||
* @param link 任务链接
|
||||
|
||||
@ -6,14 +6,12 @@ import com.lion.lionwebsite.Dao.ShareFileMapper;
|
||||
import com.lion.lionwebsite.Domain.CustomConfiguration;
|
||||
import com.lion.lionwebsite.Domain.ShareFile;
|
||||
import com.lion.lionwebsite.Util.CustomUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.Data;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -29,22 +27,26 @@ import java.util.*;
|
||||
import static java.nio.file.FileVisitResult.CONTINUE;
|
||||
|
||||
@Service
|
||||
@ConfigurationProperties(prefix = "local-service")
|
||||
@Data
|
||||
public class LocalServiceImpl{
|
||||
String fires;
|
||||
String DouNaiClash;
|
||||
String DouNaiV2ray;
|
||||
String fires = "https://api.dler.io/sub?target=clash&new_name=true&url=https%3A%2F%2Ffast.losadhwselfff2332dasd.xyz%2Flink%2Fz0pfwyTvC5naXkbb%3Fclash%3D1&insert=false&config=https%3A%2F%2Fraw.githubusercontent.com%2FACL4SSR%2FACL4SSR%2Fmaster%2FClash%2Fconfig%2FACL4SSR_Online.ini";
|
||||
|
||||
String DouNaiClash = "https://aaaa.gay/link/X7zEqkIx5gtIGugO?client=clashmeta";
|
||||
|
||||
String DouNaiV2ray = "https://aaaa.gay/link/X7zEqkIx5gtIGugO?client=v2";
|
||||
|
||||
@Resource
|
||||
CustomConfigurationMapper configurationMapper;
|
||||
|
||||
@Resource
|
||||
ShareFileMapper shareFIleMapper;
|
||||
|
||||
@Resource
|
||||
GalleryMapper galleryMapper;
|
||||
|
||||
public LocalServiceImpl(CustomConfigurationMapper configurationMapper, ShareFileMapper shareFileMapper, GalleryMapper galleryMapper){
|
||||
this.shareFIleMapper = shareFileMapper;
|
||||
this.configurationMapper = configurationMapper;
|
||||
this.galleryMapper = galleryMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 每周周一四点重置额度
|
||||
*/
|
||||
|
||||
@ -43,7 +43,6 @@ import java.util.concurrent.Executors;
|
||||
|
||||
@Service
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "personal-service")
|
||||
@Slf4j
|
||||
public class PersonalServiceImpl{
|
||||
@Resource
|
||||
@ -58,13 +57,17 @@ public class PersonalServiceImpl{
|
||||
@Resource
|
||||
TaskHandlerInterceptor taskHandlerInterceptor;
|
||||
|
||||
String StoragePath;
|
||||
String StoragePath = "/storage/";
|
||||
|
||||
DateTimeFormatter dateTimeFormatter = CustomUtil.dateTimeFormatter();
|
||||
|
||||
ExecutorService compressThreadPool;
|
||||
|
||||
PersonalServiceImpl(){
|
||||
public PersonalServiceImpl(CustomConfigurationMapper configurationMapper, UserMapper userMapper, ShareFileMapper shareFileMapper, TaskHandlerInterceptor taskHandlerInterceptor){
|
||||
this.configurationMapper = configurationMapper;
|
||||
this.userMapper = userMapper;
|
||||
this.shareFileMapper = shareFileMapper;
|
||||
this.taskHandlerInterceptor = taskHandlerInterceptor;
|
||||
compressThreadPool = Executors.newFixedThreadPool(1);
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ public class PublicServiceImpl {
|
||||
CustomConfigurationMapper configurationMapper;
|
||||
|
||||
@Resource
|
||||
ShareFileMapper shareFIleMapper;
|
||||
ShareFileMapper shareFileMapper;
|
||||
|
||||
@Resource
|
||||
UserMapper userMapper;
|
||||
@ -45,6 +45,13 @@ public class PublicServiceImpl {
|
||||
@Resource
|
||||
TaskHandlerInterceptor taskHandlerInterceptor;
|
||||
|
||||
public PublicServiceImpl(CustomConfigurationMapper configurationMapper, ShareFileMapper shareFileMapper, UserMapper userMapper, TaskHandlerInterceptor taskHandlerInterceptor) {
|
||||
this.configurationMapper = configurationMapper;
|
||||
this.shareFileMapper = shareFileMapper;
|
||||
this.userMapper = userMapper;
|
||||
this.taskHandlerInterceptor = taskHandlerInterceptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录家里ip地址
|
||||
* @param ip ip地址
|
||||
@ -68,7 +75,7 @@ public class PublicServiceImpl {
|
||||
if(ShareCode == null) {
|
||||
response.failure("ShareCode invalid");
|
||||
} else {
|
||||
ShareFile shareFile = shareFIleMapper.selectShareFileByShareCode(ShareCode);
|
||||
ShareFile shareFile = shareFileMapper.selectShareFileByShareCode(ShareCode);
|
||||
Calendar ExpireTime = Calendar.getInstance();
|
||||
Calendar now = Calendar.getInstance();
|
||||
|
||||
@ -78,7 +85,7 @@ public class PublicServiceImpl {
|
||||
FileDownload.export(httpRequest, httpResponse, shareFile.getFilePath());
|
||||
return true;
|
||||
} else {
|
||||
shareFIleMapper.deleteShareFile(shareFile.getShareCode());
|
||||
shareFileMapper.deleteShareFile(shareFile.getShareCode());
|
||||
response.failure("ShareCode is expired or File is not exist");
|
||||
}
|
||||
} else
|
||||
|
||||
@ -3,13 +3,16 @@ package com.lion.lionwebsite.Service;
|
||||
import com.lion.lionwebsite.Domain.Gallery;
|
||||
import com.lion.lionwebsite.Util.Response;
|
||||
import com.pengrad.telegrambot.TelegramBot;
|
||||
import com.pengrad.telegrambot.UpdatesListener;
|
||||
import com.pengrad.telegrambot.model.Update;
|
||||
import com.pengrad.telegrambot.request.SendMessage;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@ConfigurationProperties(prefix = "push-service")
|
||||
public class PushService {
|
||||
|
||||
long self = 686839482;
|
||||
@ -17,8 +20,11 @@ public class PushService {
|
||||
@Resource
|
||||
TelegramBot bot;
|
||||
|
||||
public PushService(TelegramBot bot) {
|
||||
this.bot = bot;
|
||||
}
|
||||
|
||||
public void taskCreateReport(String username, String link, Response response){
|
||||
System.out.println("task report");
|
||||
if(response.isSuccess())
|
||||
sendToMe(String.format("用户%s提交下载%s", username, link));
|
||||
else
|
||||
|
||||
@ -14,10 +14,8 @@ import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
|
||||
import io.netty.handler.logging.LoggingHandler;
|
||||
import io.netty.util.concurrent.DefaultPromise;
|
||||
import io.netty.util.concurrent.Promise;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
@ -37,7 +35,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
@Service
|
||||
@Data
|
||||
@Slf4j
|
||||
@ConfigurationProperties(prefix = "remote-service")
|
||||
public class RemoteService {
|
||||
|
||||
ChannelFuture channelFuture;
|
||||
@ -48,12 +45,8 @@ public class RemoteService {
|
||||
|
||||
short port = 26321;
|
||||
|
||||
String storagePath;
|
||||
|
||||
@Resource
|
||||
GalleryMapper galleryMapper;
|
||||
|
||||
@Resource
|
||||
PushService pushService;
|
||||
|
||||
HashMap<Integer, Promise<AbstractMessage>> promiseHashMap;
|
||||
@ -66,7 +59,9 @@ public class RemoteService {
|
||||
|
||||
AtomicInteger atomicInteger;
|
||||
|
||||
public RemoteService(){
|
||||
public RemoteService(GalleryMapper galleryMapper, PushService pushService){
|
||||
this.galleryMapper = galleryMapper;
|
||||
this.pushService = pushService;
|
||||
atomicInteger = new AtomicInteger(0);
|
||||
eventLoopGroup = new DefaultEventLoop();
|
||||
downloadThread = Executors.newCachedThreadPool();
|
||||
@ -100,6 +95,7 @@ public class RemoteService {
|
||||
channel.writeAndFlush(new IdentityMessage());
|
||||
return true;
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.info("connect node failed, wait for node back online");
|
||||
return false;
|
||||
}
|
||||
@ -330,6 +326,8 @@ public class RemoteService {
|
||||
|
||||
@Override
|
||||
public void channelUnregistered(ChannelHandlerContext ctx) {
|
||||
System.out.println(ctx.channel());
|
||||
System.out.println(channel);
|
||||
if(ctx.channel() != null && ctx.channel().remoteAddress().toString().equals(channel.remoteAddress().toString())){
|
||||
System.out.println("activate monitor thread, waiting for node back online");
|
||||
pushService.storageNodeOffline();
|
||||
|
||||
@ -14,12 +14,14 @@ import java.util.HashMap;
|
||||
|
||||
@Service
|
||||
public class TagService {
|
||||
@Resource
|
||||
TagMapper tagMapper;
|
||||
|
||||
@Resource
|
||||
GalleryMapper galleryMapper;
|
||||
|
||||
public TagService(TagMapper tagMapper, GalleryMapper galleryMapper) {
|
||||
this.tagMapper = tagMapper;
|
||||
this.galleryMapper = galleryMapper;
|
||||
}
|
||||
|
||||
public String createTag(String tagStr){
|
||||
Response response = Response.generateResponse();
|
||||
|
||||
@ -28,6 +28,13 @@ public class UserServiceImpl{
|
||||
@Resource
|
||||
TaskHandlerInterceptor taskHandlerInterceptor;
|
||||
|
||||
public UserServiceImpl(UserMapper userMapper, GalleryMapper galleryMapper, CollectMapper collectMapper, TaskHandlerInterceptor taskHandlerInterceptor) {
|
||||
this.userMapper = userMapper;
|
||||
this.galleryMapper = galleryMapper;
|
||||
this.collectMapper = collectMapper;
|
||||
this.taskHandlerInterceptor = taskHandlerInterceptor;
|
||||
}
|
||||
|
||||
public String addAuthCode(String targetAuthCode, String people) {
|
||||
Response response = Response.generateResponse();
|
||||
|
||||
|
||||
@ -2,6 +2,8 @@ server:
|
||||
port: 8888
|
||||
tomcat:
|
||||
max-swallow-size: 10000MB
|
||||
http2:
|
||||
enabled: true
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
@ -34,8 +36,8 @@ remote-service:
|
||||
|
||||
local-service:
|
||||
fires: https://api.dler.io/sub?target=clash&new_name=true&url=https%3A%2F%2Ffast.losadhwselfff2332dasd.xyz%2Flink%2Fz0pfwyTvC5naXkbb%3Fclash%3D1&insert=false&config=https%3A%2F%2Fraw.githubusercontent.com%2FACL4SSR%2FACL4SSR%2Fmaster%2FClash%2Fconfig%2FACL4SSR_Online.ini
|
||||
DouNaiClash: https://aaaa.gay/link/A5CXg2cJATerEEoe?client=clashv2
|
||||
DouNaiV2ray: https://aaaa.gay/link/A5CXg2cJATerEEoe?client=v2
|
||||
DouNaiClash: https://aaaa.gay/link/X7zEqkIx5gtIGugO?client=clashmeta
|
||||
DouNaiV2ray: https://aaaa.gay/link/X7zEqkIx5gtIGugO?client=v2
|
||||
|
||||
bot:
|
||||
token: 5222939329:AAHa6l9ZuVVdNSDLPI_H-c8O_VgeOEw5plA
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user