Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat jdk21 #1180

Merged
merged 11 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions laokou-cloud/laokou-register/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ db:
# see DataSourcePoolProperties 与 ExternalDataSourceProperties
pool:
config:
# see DataSourcePoolProperties
# see HikariConfig
minimum-idle: 2
idle-timeout: 10000
# 连接时间
connection-timeout: 30000
# 超时时间
validation-timeout: 10000
# 最优最大连接数
maximum-pool-size: 20
# 数据库驱动
driver-class-name: @DATASOURCE-DRIVER-CLASS-NAME@
management:
metrics:
Expand Down
5 changes: 5 additions & 0 deletions laokou-common/laokou-common-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@
<!-- 定义全局jar版本,模块使用需要再次引入但不用写版本号 -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.laokou</groupId>
<artifactId>laokou-common-domain</artifactId>
<version>${laokou.version}</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-mysql</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@

package org.laokou.common.core.annotation;

import org.laokou.common.core.config.TaskPoolExecutorConfig;
import org.laokou.common.core.config.TaskExecutorConfig;
import org.springframework.context.annotation.Import;

import java.lang.annotation.*;

@Documented
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Import(TaskPoolExecutorConfig.class)
public @interface EnableTask {
@Import(TaskExecutorConfig.class)
public @interface EnableTaskExecutor {

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
@EnableAsync
@AutoConfiguration
@RequiredArgsConstructor
public class TaskPoolExecutorConfig {
public class TaskExecutorConfig {

@Bean(THREAD_POOL_TASK_EXECUTOR_NAME)
public Executor ttlTaskExecutor(SpringTaskExecutionProperties springTaskExecutionProperties, Environment environment) {
public Executor executor(SpringTaskExecutionProperties springTaskExecutionProperties, Environment environment) {
String threadNamePrefix = springTaskExecutionProperties.getThreadNamePrefix();
String enabled = environment.getProperty("spring.threads.virtual.enabled");
if (ObjectUtil.equals(TRUE, enabled)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class GlobalExceptionHandler {
* @return 响应结果
*/
@ExceptionHandler({ FeignException.class, SystemException.class, ApiException.class, FlowException.class,
DataSourceException.class, GatewayException.class })
DataSourceException.class, GatewayException.class, AuthException.class })
public Result<?> handle(GlobalException ex) {
// log.error("错误码:{},错误信息:{}", ex.getCode(), ex.getMsg());
return Result.fail(ex.getCode(), ex.getMsg());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
package org.laokou.common.core.holder;

import com.alibaba.ttl.TransmittableThreadLocal;
import lombok.Data;
import lombok.NoArgsConstructor;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.util.Optional;

import static lombok.AccessLevel.PRIVATE;

/**
* 用户上下文.
*
Expand Down Expand Up @@ -55,44 +57,32 @@ public static User get() {
* @param user 用户
*/
public static void set(User user) {
clear();
USER_LOCAL.remove();
USER_LOCAL.set(user);
}

@Data
@NoArgsConstructor
@Builder
@AllArgsConstructor(access = PRIVATE)
@NoArgsConstructor(access = PRIVATE)
@Schema(name = "User", description = "用户")
public static class User {

/**
* ID.
*/
@Schema(name = "id", description = "ID")
private Long id;

/**
* 租户ID.
*/
@Schema(name = "tenantId", description = "租户ID")
private Long tenantId;

/**
* 部门PATH.
*/
@Schema(name = "deptPath", description = "部门PATH")
private String deptPath;

/**
* 部门ID.
*/
@Schema(name = "deptId", description = "部门ID")
private Long deptId;

/**
* 数据源名称.
*/
@Schema(name = "sourceName", description = "数据源名称")
private String sourceName;

public User(Long tenantId, String sourceName) {
this.tenantId = tenantId;
this.sourceName = sourceName;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public class AesUtil {

private final static byte[] SECRET_KEY;

private final static String KEY;
private final static String SECRET_KEY_STRING;

static {
try (InputStream inputStream = ResourceUtil.getResource("conf/secretKey.b16").getInputStream()) {
SECRET_KEY = inputStream.readAllBytes();
Assert.isTrue(SECRET_KEY.length == 16, "密钥长度必须16位");
KEY = new String(SECRET_KEY, StandardCharsets.UTF_8);
SECRET_KEY_STRING = new String(SECRET_KEY, StandardCharsets.UTF_8);
}
catch (IOException e) {
throw new RuntimeException(e);
Expand All @@ -60,8 +60,8 @@ public class AesUtil {
* 获取加密密钥.
* @return 加密密钥
*/
public static String getKey() {
return KEY;
public static String getSecretKeyStr() {
return SECRET_KEY_STRING;
}

/**
Expand Down
24 changes: 24 additions & 0 deletions laokou-common/laokou-common-domain/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.laokou</groupId>
<artifactId>laokou-common</artifactId>
<version>3.2.2</version>
</parent>
<artifactId>laokou-common-domain</artifactId>

<dependencies>
<dependency>
<groupId>org.laokou</groupId>
<artifactId>laokou-common-core</artifactId>
</dependency>
<dependency>
<groupId>org.laokou</groupId>
<artifactId>laokou-common-rocketmq</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,25 @@
*
*/

package org.laokou.auth.common.event;
package org.laokou.common.domain.publish;

import lombok.extern.slf4j.Slf4j;
import org.laokou.common.core.utils.SpringContextUtil;
import lombok.RequiredArgsConstructor;
import org.laokou.common.rocketmq.template.RocketMqTemplate;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.ApplicationEvent;
import org.springframework.stereotype.Component;

/**
* 领域事件推送器.
*
* @author laokou
*/
@Component
@Slf4j
public class DomainEventPublisher {
@AutoConfiguration
@RequiredArgsConstructor
public class AsyncDomainEventPublisher implements DomainEventPublisher {

private final RocketMqTemplate rocketMqTemplate;

/**
* 推送事件.
* @param event 事件
*/
@Override
public void publish(ApplicationEvent event) {
SpringContextUtil.publishEvent(event);
// rocketMqTemplate.sendAsyncOrderlyMessage();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2022-2024 KCloud-Platform-Alibaba Author or Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.laokou.common.domain.publish;

import org.springframework.context.ApplicationEvent;

/**
* 领域事件推送器.
*
* @author laokou
*/
public interface DomainEventPublisher {

/**
* 推送事件.
* @param event 事件
*/
void publish(ApplicationEvent event);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2022-2024 KCloud-Platform-Alibaba Author or Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.laokou.common.i18n.common;

import io.swagger.v3.oas.annotations.media.Schema;

/**
* @author laokou
*/
@Schema(name = "EventStatusEnums", description = "事件状态枚举")
public enum EventStatusEnums {

@Schema(name = "CREATED", description = "创建")
CREATED,

@Schema(name = "PUBLISH_SUCCEED", description = "发布成功")
PUBLISH_SUCCEED,

@Schema(name = "PUBLISH_FAILED", description = "发布失败")
PUBLISH_FAILED,

@Schema(name = "CONSUME_SUCCEED", description = "消费成功")
CONSUME_SUCCEED,

@Schema(name = "CONSUME_FAILED", description = "消费失败")
CONSUME_FAILED

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@
*
*/

package org.laokou.common.i18n.common;

import io.swagger.v3.oas.annotations.media.Schema;

/**
* @author laokou
*/
package org.laokou.common.security.domain;
@Schema(name = "EventTypeEnums", description = "事件类型枚举")
public enum EventTypeEnums {

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ private MybatisPlusConstants() {
@Schema(name = "PLACE_HOLDER", description = "分表标识符")
public static final String PLACE_HOLDER = "$$";

@Schema(name = "ID", description = "ID")
public static final String ID = "id";
@Schema(name = "PRIMARY_KEY", description = "ID")
public static final String PRIMARY_KEY = "id";

@Schema(name = "CREATOR", description = "创建人")
public static final String CREATOR = "creator";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ private SysConstants() {
public static final String WEBSOCKET_PATH = "/ws";

@Schema(name = "THREAD_POOL_TASK_EXECUTOR_NAME", description = "线程池名称")
public static final String THREAD_POOL_TASK_EXECUTOR_NAME = "ttlTaskExecutor";
public static final String THREAD_POOL_TASK_EXECUTOR_NAME = "executor";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2022-2024 KCloud-Platform-Alibaba Author or Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.laokou.common.i18n.common.exception;

import io.swagger.v3.oas.annotations.media.Schema;

/**
* @author laokou
*/
@Schema(name = "AuthException", description = "认证异常")
public final class AuthException extends GlobalException {

public AuthException(int code) {
super(code);
}

public AuthException(int code, String msg) {
super(code, msg);
}

public AuthException(String msg) {
super(msg);
}

}
Loading
Loading