From 208705074c1158dffcc937592c454ce75308956a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=94=E6=B0=91=E5=B0=8F=E9=95=87?= <262610965@qq.com> Date: Tue, 12 Nov 2024 15:01:56 +0800 Subject: [PATCH] :whale: feat(GenerateDoc): 1. Add DocumentMethod annotation : Action supports generating documentation method names through annotations. 2. BroadcastDebug enhancements. --- .../core/doc/ActionMethodDocument.java | 8 +++- .../skeleton/core/doc/DocumentMethod.java | 40 +++++++++++++++++++ .../broker/core/client/BroadcastDebug.java | 4 ++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 common/common-core/src/main/java/com/iohao/game/action/skeleton/core/doc/DocumentMethod.java diff --git a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/doc/ActionMethodDocument.java b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/doc/ActionMethodDocument.java index 1432877f0..3d25d086b 100644 --- a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/doc/ActionMethodDocument.java +++ b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/doc/ActionMethodDocument.java @@ -88,7 +88,13 @@ public ActionMethodDocument(ActionCommandDoc actionCommandDoc, TypeMappingDocume this.actionSimpleName = actionCommand.getActionControllerClazz().getSimpleName(); // 方法名 - this.actionMethodName = StrKit.firstCharToUpperCase(actionCommand.getActionMethodName()); + var documentMethod = actionCommand.getAnnotation(DocumentMethod.class); + if (Objects.nonNull(documentMethod)) { + this.actionMethodName = StrKit.firstCharToUpperCase(documentMethod.value()); + } else { + this.actionMethodName = StrKit.firstCharToUpperCase(actionCommand.getActionMethodName()); + } + // 方法注释 this.methodComment = this.actionCommandDoc.getComment(); diff --git a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/doc/DocumentMethod.java b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/doc/DocumentMethod.java new file mode 100644 index 000000000..8bfea1a99 --- /dev/null +++ b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/doc/DocumentMethod.java @@ -0,0 +1,40 @@ +/* + * ioGame + * Copyright (C) 2021 - present 渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved. + * # iohao.com . 渔民小镇 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package com.iohao.game.action.skeleton.core.doc; + +import java.lang.annotation.*; + +/** + * Generates the document action method name. By default, the action method name is used. + * + * @author 渔民小镇 + * @date 2024-11-12 + * @since 21.20 + */ +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface DocumentMethod { + /** + * The method name of the document action + * + * @return method name + */ + String value(); +} diff --git a/net-bolt/bolt-core/src/main/java/com/iohao/game/bolt/broker/core/client/BroadcastDebug.java b/net-bolt/bolt-core/src/main/java/com/iohao/game/bolt/broker/core/client/BroadcastDebug.java index 9b66e1b79..85bbacd78 100644 --- a/net-bolt/bolt-core/src/main/java/com/iohao/game/bolt/broker/core/client/BroadcastDebug.java +++ b/net-bolt/bolt-core/src/main/java/com/iohao/game/bolt/broker/core/client/BroadcastDebug.java @@ -152,6 +152,10 @@ private int lookBusinessCodeInTrace(StackTraceElement[] traces) { if (RangeBroadcast.class.getName().equals(name)) { return index + 1; } + + if ("com.iohao.game.action.skeleton.core.flow.SimpleCommunicationBroadcast".equals(name)) { + return index + 1; + } } return 2;