规范命名.

This commit is contained in:
lijiahang
2023-10-09 16:25:19 +08:00
parent 7a26e6f89c
commit 890afa093c
13 changed files with 40 additions and 67 deletions

View File

@@ -11,8 +11,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @since 2023/7/10 15:49 * @since 2023/7/10 15:49
*/ */
@Data @Data
@ConfigurationProperties(prefix = "orion.thread.pool") @ConfigurationProperties(prefix = "orion.async.executor")
public class ThreadPoolConfig { public class AsyncExecutorConfig {
/** /**
* 核心线程数量 * 核心线程数量
@@ -34,7 +34,7 @@ public class ThreadPoolConfig {
*/ */
private int keepAliveSeconds; private int keepAliveSeconds;
public ThreadPoolConfig() { public AsyncExecutorConfig() {
this.corePoolSize = 8; this.corePoolSize = 8;
this.maxPoolSize = 16; this.maxPoolSize = 16;
this.queueCapacity = 200; this.queueCapacity = 200;

View File

@@ -23,7 +23,7 @@ import java.util.concurrent.ThreadPoolExecutor;
@EnableAsync @EnableAsync
@AutoConfiguration @AutoConfiguration
@AutoConfigureOrder(AutoConfigureOrderConst.FRAMEWORK_COMMON) @AutoConfigureOrder(AutoConfigureOrderConst.FRAMEWORK_COMMON)
@EnableConfigurationProperties(ThreadPoolConfig.class) @EnableConfigurationProperties(AsyncExecutorConfig.class)
public class OrionCommonAutoConfiguration { public class OrionCommonAutoConfiguration {
/** /**
@@ -43,7 +43,7 @@ public class OrionCommonAutoConfiguration {
*/ */
@Primary @Primary
@Bean(name = "asyncExecutor") @Bean(name = "asyncExecutor")
public TaskExecutor asyncExecutor(ThreadPoolConfig config) { public TaskExecutor asyncExecutor(AsyncExecutorConfig config) {
ThreadPoolMdcTaskExecutor executor = new ThreadPoolMdcTaskExecutor(); ThreadPoolMdcTaskExecutor executor = new ThreadPoolMdcTaskExecutor();
executor.setCorePoolSize(config.getCorePoolSize()); executor.setCorePoolSize(config.getCorePoolSize());
executor.setMaxPoolSize(config.getMaxPoolSize()); executor.setMaxPoolSize(config.getMaxPoolSize());

View File

@@ -1,34 +0,0 @@
package com.orion.ops.framework.common.utils;
import com.orion.lang.utils.Strings;
import com.orion.ops.framework.common.constant.Const;
/**
* 工具类
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023/7/14 16:34
*/
public class Kits {
private Kits() {
}
/**
* 获取登陆凭证
*
* @param authorization authorization
* @return token
*/
public static String getAuthorization(String authorization) {
if (Strings.isEmpty(authorization)) {
return null;
}
if (!authorization.contains(Const.BEARER) || authorization.length() <= Const.BEARER_PREFIX_LEN) {
return null;
}
return authorization.substring(Const.BEARER_PREFIX_LEN).trim();
}
}

View File

@@ -1,32 +1,32 @@
{ {
"groups": [ "groups": [
{ {
"name": "orion.thread.pool", "name": "orion.async.executor",
"type": "com.orion.ops.framework.common.config.ThreadPoolConfig", "type": "com.orion.ops.framework.common.config.AsyncExecutorConfig",
"sourceType": "com.orion.ops.framework.common.config.ThreadPoolConfig" "sourceType": "com.orion.ops.framework.common.config.AsyncExecutorConfig"
} }
], ],
"properties": [ "properties": [
{ {
"name": "orion.thread.pool.core-pool-size", "name": "orion.async.executor.core-pool-size",
"type": "java.lang.Integer", "type": "java.lang.Integer",
"description": "核心线程数量", "description": "核心线程数量",
"defaultValue": "8" "defaultValue": "8"
}, },
{ {
"name": "orion.thread.pool.max-pool-size", "name": "orion.async.executor.max-pool-size",
"type": "java.lang.Integer", "type": "java.lang.Integer",
"description": "最大线程数量.", "description": "最大线程数量.",
"defaultValue": "16" "defaultValue": "16"
}, },
{ {
"name": "orion.thread.pool.queue-capacity", "name": "orion.async.executor.queue-capacity",
"type": "java.lang.Integer", "type": "java.lang.Integer",
"description": "队列容量.", "description": "队列容量.",
"defaultValue": "200" "defaultValue": "200"
}, },
{ {
"name": "orion.thread.pool.keep-alive-seconds", "name": "orion.async.executor.keep-alive-seconds",
"type": "java.lang.Integer", "type": "java.lang.Integer",
"description": "活跃时间.", "description": "活跃时间.",
"defaultValue": "300" "defaultValue": "300"

View File

@@ -1,8 +1,9 @@
package com.orion.ops.framework.security.core.utils; package com.orion.ops.framework.security.core.utils;
import com.orion.lang.constant.StandardHttpHeader; import com.orion.lang.constant.StandardHttpHeader;
import com.orion.lang.utils.Strings;
import com.orion.ops.framework.common.constant.Const;
import com.orion.ops.framework.common.security.LoginUser; import com.orion.ops.framework.common.security.LoginUser;
import com.orion.ops.framework.common.utils.Kits;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContext;
@@ -31,7 +32,14 @@ public class SecurityUtils {
* @return token * @return token
*/ */
public static String obtainAuthorization(HttpServletRequest request) { public static String obtainAuthorization(HttpServletRequest request) {
return Kits.getAuthorization(request.getHeader(StandardHttpHeader.AUTHORIZATION)); String authorization = request.getHeader(StandardHttpHeader.AUTHORIZATION);
if (Strings.isEmpty(authorization)) {
return null;
}
if (!authorization.contains(Const.BEARER) || authorization.length() <= Const.BEARER_PREFIX_LEN) {
return null;
}
return authorization.substring(Const.BEARER_PREFIX_LEN).trim();
} }
/** /**

View File

@@ -45,9 +45,9 @@ public enum WsCloseCode {
VALID(4150, WsCloseReason.AUTHENTICATION_FAILURE), VALID(4150, WsCloseReason.AUTHENTICATION_FAILURE),
/** /**
* 机不合法 * 机不合法
*/ */
INVALID_MACHINE(4200, WsCloseReason.CLOSED_CONNECTION), INVALID_HOST(4200, WsCloseReason.CLOSED_CONNECTION),
/** /**
* 连接远程服务器连接超时 * 连接远程服务器连接超时
@@ -70,9 +70,9 @@ public enum WsCloseCode {
CONNECTION_EXCEPTION(4210, WsCloseReason.UNABLE_TO_CONNECT_REMOTE_SERVER), CONNECTION_EXCEPTION(4210, WsCloseReason.UNABLE_TO_CONNECT_REMOTE_SERVER),
/** /**
* 机未启用 * 机未启用
*/ */
MACHINE_DISABLED(4215, WsCloseReason.MACHINE_DISABLED), HOST_DISABLED(4215, WsCloseReason.HOST_DISABLED),
/** /**
* 打开shell出现异常 * 打开shell出现异常

View File

@@ -21,7 +21,7 @@ public interface WsCloseReason {
String REMOTE_SERVER_AUTHENTICATION_FAILURE = "remote server authentication failure..."; String REMOTE_SERVER_AUTHENTICATION_FAILURE = "remote server authentication failure...";
String MACHINE_DISABLED = "machine disabled..."; String HOST_DISABLED = "host disabled...";
String UNABLE_TO_CONNECT_REMOTE_SERVER = "unable to connect remote server..."; String UNABLE_TO_CONNECT_REMOTE_SERVER = "unable to connect remote server...";

View File

@@ -101,7 +101,7 @@ public class WebSockets {
} else if (Exceptions.isCausedBy(e, AuthenticationException.class)) { } else if (Exceptions.isCausedBy(e, AuthenticationException.class)) {
close(session, WsCloseCode.CONNECTION_AUTH_FAILURE); close(session, WsCloseCode.CONNECTION_AUTH_FAILURE);
} else if (Exceptions.isCausedBy(e, DisabledException.class)) { } else if (Exceptions.isCausedBy(e, DisabledException.class)) {
close(session, WsCloseCode.MACHINE_DISABLED); close(session, WsCloseCode.HOST_DISABLED);
} else { } else {
close(session, WsCloseCode.CONNECTION_EXCEPTION); close(session, WsCloseCode.CONNECTION_EXCEPTION);
} }

View File

@@ -41,8 +41,8 @@ orion:
aes: aes:
# 加密秘钥 # 加密秘钥
secret-key: uQeacXV8b3isvKLK secret-key: uQeacXV8b3isvKLK
thread: async:
pool: executor:
core-pool-size: 8 core-pool-size: 8
max-pool-size: 16 max-pool-size: 16
queue-capacity: 200 queue-capacity: 200

View File

@@ -146,9 +146,9 @@ orion:
infra: infra:
group: "infra - 基建模块" group: "infra - 基建模块"
path: "infra" path: "infra"
machine: asset:
group: "machine - 机器资源模块" group: "asset - 资产模块"
path: "machine" path: "asset"
logging: logging:
# 全局日志打印 # 全局日志打印
@@ -189,10 +189,10 @@ orion:
secret-key: I66AndrKWrwXjtBL secret-key: I66AndrKWrwXjtBL
use-generator-key: true use-generator-key: true
generator-key-length: 128 generator-key-length: 128
thread: async:
# 线程池配置 # 线程池配置
pool: executor:
core-pool-size: 2 core-pool-size: 2
max-pool-size: 4 max-pool-size: 4
keep-alive-seconds: 180
queue-capacity: 30 queue-capacity: 30
keep-alive-seconds: 180

View File

@@ -105,7 +105,7 @@
}; };
</script> </script>
<script setup lang="ts"> <script lang="ts" setup>
import { usePagination, useColLayout } from '@/types/card'; import { usePagination, useColLayout } from '@/types/card';
import { computed, reactive, ref } from 'vue'; import { computed, reactive, ref } from 'vue';
import useLoading from '@/hooks/loading'; import useLoading from '@/hooks/loading';

View File

@@ -28,7 +28,7 @@
<version>${revision}</version> <version>${revision}</version>
</dependency> </dependency>
<!-- machine provider --> <!-- asset provider -->
<dependency> <dependency>
<groupId>com.orion.ops</groupId> <groupId>com.orion.ops</groupId>
<artifactId>orion-ops-module-asset-provider</artifactId> <artifactId>orion-ops-module-asset-provider</artifactId>

View File

@@ -2,7 +2,6 @@ package com.orion.ops.module.infra.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.orion.lang.constant.StandardHttpHeader;
import com.orion.lang.define.wrapper.Pair; import com.orion.lang.define.wrapper.Pair;
import com.orion.lang.utils.Exceptions; import com.orion.lang.utils.Exceptions;
import com.orion.lang.utils.collect.Lists; import com.orion.lang.utils.collect.Lists;
@@ -12,10 +11,10 @@ import com.orion.ops.framework.common.constant.ErrorMessage;
import com.orion.ops.framework.common.security.LoginUser; import com.orion.ops.framework.common.security.LoginUser;
import com.orion.ops.framework.common.utils.CryptoUtils; import com.orion.ops.framework.common.utils.CryptoUtils;
import com.orion.ops.framework.common.utils.IpUtils; import com.orion.ops.framework.common.utils.IpUtils;
import com.orion.ops.framework.common.utils.Kits;
import com.orion.ops.framework.common.utils.Valid; import com.orion.ops.framework.common.utils.Valid;
import com.orion.ops.framework.redis.core.utils.RedisStrings; import com.orion.ops.framework.redis.core.utils.RedisStrings;
import com.orion.ops.framework.redis.core.utils.RedisUtils; import com.orion.ops.framework.redis.core.utils.RedisUtils;
import com.orion.ops.framework.security.core.utils.SecurityUtils;
import com.orion.ops.module.infra.convert.SystemUserConvert; import com.orion.ops.module.infra.convert.SystemUserConvert;
import com.orion.ops.module.infra.dao.SystemUserDAO; import com.orion.ops.module.infra.dao.SystemUserDAO;
import com.orion.ops.module.infra.dao.SystemUserRoleDAO; import com.orion.ops.module.infra.dao.SystemUserRoleDAO;
@@ -97,7 +96,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
@Override @Override
public void logout(HttpServletRequest request) { public void logout(HttpServletRequest request) {
// 获取登陆 token // 获取登陆 token
String loginToken = Kits.getAuthorization(request.getHeader(StandardHttpHeader.AUTHORIZATION)); String loginToken = SecurityUtils.obtainAuthorization(request);
if (loginToken == null) { if (loginToken == null) {
return; return;
} }