Skip to content

Commit b9b0d2a

Browse files
@initial fix bug
1 parent 4397720 commit b9b0d2a

177 files changed

Lines changed: 9521 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.talexframe.frame;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.cache.annotation.EnableCaching;
6+
import org.springframework.context.ConfigurableApplicationContext;
7+
import org.springframework.scheduling.annotation.EnableAsync;
8+
import org.springframework.scheduling.annotation.EnableScheduling;
9+
10+
/**
11+
* @author TalexDreamSoul
12+
*/
13+
@SpringBootApplication
14+
@EnableAsync
15+
@EnableScheduling
16+
@EnableCaching
17+
public class TalexFrameApplication {
18+
19+
public static final long startedTimeStamp = System.nanoTime();
20+
public static ConfigurableApplicationContext context;
21+
22+
public static void start(String[] args) {
23+
24+
context = SpringApplication.run(TalexFrameApplication.class, args);
25+
26+
}
27+
28+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* TalexFrame # 系统暴露接口 <br /> {@link com.talexframe.frame.api Package }
3+
*
4+
* @author TalexDreamSoul
5+
* @date 22/03/05 上午 10:04 <br /> Project: TalexFrame <br />
6+
*/
7+
package com.talexframe.frame.api;
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package com.talexframe.frame.config;
2+
3+
import com.talexframe.frame.core.talex.TFrame;
4+
import lombok.extern.slf4j.Slf4j;
5+
import org.apache.catalina.Context;
6+
import org.apache.catalina.connector.Connector;
7+
import org.apache.tomcat.util.descriptor.web.SecurityCollection;
8+
import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
9+
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
10+
import org.springframework.context.annotation.Bean;
11+
import org.springframework.context.annotation.Configuration;
12+
13+
import java.io.File;
14+
15+
/**
16+
* SSL (HTTP & HTTPS) <br /> {@link com.talexframe.frame.config Package }
17+
*
18+
* @author TalexDreamSoul
19+
* @date 2022/1/24 16:48 <br /> Project: TalexFrame <br />
20+
*/
21+
@Configuration
22+
@Slf4j
23+
public class ConnectorConfig {
24+
25+
private static boolean HTTPS = false;
26+
27+
static {
28+
29+
if ( !new File(TFrame.getMainFile() + "/config/keystore.p12").exists() ) {
30+
31+
log.info("[Connector] 未检测到 keystore -> 启动 HTTP 服务");
32+
33+
} else {
34+
35+
HTTPS = true;
36+
37+
log.info("[Connector] 已检测到 keystore -> 启动 HTTPS 服务");
38+
39+
}
40+
41+
}
42+
43+
@Bean
44+
public TomcatServletWebServerFactory servletContainer() { //springboot2 新变化
45+
46+
if ( HTTPS ) {
47+
48+
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory() {
49+
50+
@Override
51+
protected void postProcessContext(Context context) {
52+
53+
SecurityConstraint securityConstraint = new SecurityConstraint();
54+
securityConstraint.setUserConstraint("CONFIDENTIAL");
55+
SecurityCollection collection = new SecurityCollection();
56+
collection.addPattern("/*");
57+
securityConstraint.addCollection(collection);
58+
context.addConstraint(securityConstraint);
59+
}
60+
};
61+
tomcat.addAdditionalTomcatConnectors(initiateHttpConnector());
62+
return tomcat;
63+
64+
} else {
65+
66+
return new TomcatServletWebServerFactory();
67+
68+
}
69+
70+
71+
}
72+
73+
private Connector initiateHttpConnector() {
74+
75+
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
76+
connector.setScheme("http");
77+
connector.setPort(8080);//http端口
78+
connector.setSecure(true);//设置为false重定向容易出错,建议设置为true
79+
connector.setRedirectPort(443);
80+
return connector;
81+
}
82+
83+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.talexframe.frame.config;
2+
3+
import lombok.Getter;
4+
import org.springframework.beans.factory.annotation.Value;
5+
import org.springframework.context.annotation.Configuration;
6+
7+
/**
8+
* <br /> {@link com.talexframe.frame.config Package }
9+
*
10+
* @author TalexDreamSoul
11+
* @date 2022/1/29 1:05 <br /> Project: TalexFrame <br />
12+
*/
13+
@Configuration
14+
@Getter
15+
public class ElasticConfig {
16+
17+
public static ElasticConfig INSTANCE;
18+
/**
19+
* 协议
20+
*/
21+
@Value( "${elasticsearch.schema:http}" )
22+
private String schema;
23+
/**
24+
* 集群地址,如果有多个用“,”隔开
25+
*/
26+
@Value( "${elasticsearch.address}" )
27+
private String address;
28+
/**
29+
* 连接超时时间
30+
*/
31+
@Value( "${elasticsearch.connectTimeout:5000}" )
32+
private int connectTimeout;
33+
/**
34+
* Socket 连接超时时间
35+
*/
36+
@Value( "${elasticsearch.socketTimeout:10000}" )
37+
private int socketTimeout;
38+
/**
39+
* 获取连接的超时时间
40+
*/
41+
@Value( "${elasticsearch.connectionRequestTimeout:5000}" )
42+
private int connectionRequestTimeout;
43+
/**
44+
* 最大连接数
45+
*/
46+
@Value( "${elasticsearch.maxConnectNum:100}" )
47+
private int maxConnectNum;
48+
/**
49+
* 最大路由连接数
50+
*/
51+
@Value( "${elasticsearch.maxConnectPerRoute:100}" )
52+
private int maxConnectPerRoute;
53+
54+
public ElasticConfig() {
55+
56+
INSTANCE = this;
57+
58+
}
59+
60+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.talexframe.frame.config;
2+
3+
/**
4+
* Redis 容器注入 <br /> {@link com.talexframe.frame.config Package }
5+
*
6+
* @author TalexDreamSoul
7+
* @date 2022/1/15 23:18 <br /> Project: TalexFrame <br />
8+
*/
9+
// @Configuration
10+
@Deprecated
11+
public class RedisConfig {
12+
13+
// @Bean
14+
// @ConditionalOnMissingBean
15+
// public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
16+
//
17+
// RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
18+
//
19+
// redisTemplate.setConnectionFactory(connectionFactory);
20+
//
21+
// Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
22+
//
23+
// ObjectMapper objectMapper = new ObjectMapper();
24+
// objectMapper.setVisibility(PropertyAccessor.ALL, com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY);
25+
// objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
26+
//
27+
// jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
28+
// redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
29+
// redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);
30+
//
31+
// RedisSerializer<?> redisSerializer = new StringRedisSerializer();
32+
//
33+
// redisTemplate.setKeySerializer(redisSerializer);
34+
// redisTemplate.setHashKeySerializer(redisSerializer);
35+
//
36+
// redisTemplate.afterPropertiesSet();
37+
//
38+
// return redisTemplate;
39+
//
40+
// }
41+
42+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.talexframe.frame.config;
2+
3+
import com.talexframe.frame.core.modules.network.interceptor.TimeConsumingInterceptor;
4+
import com.talexframe.frame.core.modules.network.interceptor.request.RequestInterceptor;
5+
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
7+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
8+
9+
/**
10+
* <br /> {@link com.talexframe.frame.config Package }
11+
*
12+
* @author TalexDreamSoul
13+
* @date 2022/1/16 11:07 <br /> Project: TalexFrame <br />
14+
*/
15+
@Configuration
16+
public class WebConfig implements WebMvcConfigurer {
17+
18+
@Override
19+
public void addInterceptors(InterceptorRegistry registry) {
20+
21+
registry.addInterceptor(new RequestInterceptor()).addPathPatterns("/**");
22+
registry.addInterceptor(new TimeConsumingInterceptor()).addPathPatterns("/**");
23+
24+
}
25+
26+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* TalexFrame # 自定义配置 <br /> {@link com.talexframe.frame.config Package }
3+
*
4+
* @author TalexDreamSoul
5+
* @date 2022/1/15 23:18 <br /> Project: TalexFrame <br />
6+
*/
7+
package com.talexframe.frame.config;
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.talexframe.frame.core.function.command;
2+
3+
import com.talexframe.frame.core.pojo.mapper.frame.FrameSender;
4+
import com.talexframe.frame.core.talex.FrameCreator;
5+
import com.talexframe.frame.core.talex.TFrame;
6+
import lombok.Getter;
7+
8+
/**
9+
* <br /> {@link com.talexframe.frame.function.command Package }
10+
*
11+
* @author TalexDreamSoul
12+
* @date 2022/1/20 10:56 <br /> Project: TalexFrame <br />
13+
*/
14+
@Getter
15+
public abstract class BaseCommand implements ICommand {
16+
17+
public static final String DIVIDER = "---------------------------";
18+
protected final TFrame tframe = TFrame.tframe;
19+
private final FrameCreator owner;
20+
private final String label;
21+
private final String[] alias;
22+
private final String description;
23+
protected FrameSender frameSender = tframe.getFrameSender();
24+
25+
/**
26+
* 指令 init
27+
*
28+
* @param creator 指令拥有者
29+
* @param label 指令Label
30+
* @param alias 指令别称
31+
* @param description 指令描述
32+
*/
33+
public BaseCommand(FrameCreator creator, String label, String[] alias, String description) {
34+
35+
this.owner = creator;
36+
37+
this.label = label;
38+
this.alias = alias;
39+
this.description = description;
40+
41+
}
42+
43+
/**
44+
* 当扫描到这个类但是没有任何相关匹配的时候,执行操作 (@Override 重写)
45+
*
46+
* @param sender 命令发出者
47+
*/
48+
@Deprecated
49+
public void onDisMatched(ISender sender) {
50+
51+
sender.sendMessage("命令参数错误!");
52+
53+
}
54+
55+
/**
56+
* 减少冗杂代码
57+
*/
58+
@Override
59+
public boolean executeCommand(ISender sender, String wholeCommand, String matchedLabel, String[] args) {
60+
61+
return false;
62+
}
63+
64+
}

0 commit comments

Comments
 (0)