-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐳 #290 [对接文档] - 新增广播文档构建器,简化生成广播对接文档
Banner News 补充
- Loading branch information
Showing
18 changed files
with
240 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
common/common-core/src/main/java/com/iohao/game/action/skeleton/core/doc/BroadcastDoc.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* ioGame | ||
* Copyright (C) 2021 - present 渔民小镇 ([email protected]、[email protected]) . 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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
package com.iohao.game.action.skeleton.core.doc; | ||
|
||
import com.iohao.game.action.skeleton.core.CmdInfo; | ||
|
||
/** | ||
* @author 渔民小镇 | ||
* @date 2024-05-18 | ||
* @since 21.8 | ||
*/ | ||
public interface BroadcastDoc { | ||
static BroadcastDocBuilder newBuilder(CmdInfo cmdInfo) { | ||
return new BroadcastDocBuilder(cmdInfo); | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
...ommon-core/src/main/java/com/iohao/game/action/skeleton/core/doc/BroadcastDocBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* ioGame | ||
* Copyright (C) 2021 - present 渔民小镇 ([email protected]、[email protected]) . 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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
package com.iohao.game.action.skeleton.core.doc; | ||
|
||
import com.iohao.game.action.skeleton.core.CmdInfo; | ||
import com.iohao.game.action.skeleton.protocol.wrapper.ByteValueList; | ||
import com.iohao.game.action.skeleton.protocol.wrapper.WrapperKit; | ||
import lombok.AccessLevel; | ||
import lombok.Setter; | ||
import lombok.experimental.Accessors; | ||
import lombok.experimental.FieldDefaults; | ||
|
||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
/** | ||
* 广播文档构建器 | ||
* | ||
* @author 渔民小镇 | ||
* @date 2024-05-18 | ||
* @since 21.8 | ||
*/ | ||
@Setter | ||
@Accessors(chain = true) | ||
@FieldDefaults(level = AccessLevel.PACKAGE) | ||
public final class BroadcastDocBuilder { | ||
/** 路由 */ | ||
final CmdInfo cmdInfo; | ||
/** 广播(推送)描述 */ | ||
String description; | ||
@Setter(AccessLevel.PRIVATE) | ||
String dataClassName; | ||
|
||
BroadcastDocBuilder(CmdInfo cmdInfo) { | ||
this.cmdInfo = cmdInfo; | ||
} | ||
|
||
/** | ||
* set 推送的数据类型 List dataClass,ByteValueList dataClass。 | ||
* | ||
* @param dataClass 数据类型 | ||
* @return this | ||
*/ | ||
public BroadcastDocBuilder setDataClassList(Class<?> dataClass) { | ||
String simpleName = ByteValueList.class.getSimpleName(); | ||
String simpleNameActualClazz = dataClass.getSimpleName(); | ||
dataClassName = String.format("%s<%s>", simpleName, simpleNameActualClazz); | ||
return this; | ||
} | ||
|
||
/** | ||
* set 推送的数据类型 | ||
* | ||
* @param dataClass 推送的数据类型 | ||
* @return this | ||
*/ | ||
public BroadcastDocBuilder setDataClass(Class<?> dataClass) { | ||
|
||
dataClassName = WrapperKit.optionalRefType(dataClass) | ||
.map(Class::getSimpleName) | ||
.orElse(dataClass.getSimpleName()); | ||
|
||
return this; | ||
} | ||
|
||
/** | ||
* 构建广播文档 | ||
* | ||
* @return 广播文档 | ||
*/ | ||
public ActionSendDoc build() { | ||
|
||
Objects.requireNonNull(this.description); | ||
|
||
this.dataClassName = Optional.ofNullable(this.dataClassName).orElse("none"); | ||
|
||
ActionSendDoc actionSendDoc = new ActionSendDoc(this.cmdInfo); | ||
actionSendDoc.setDescription(this.description); | ||
actionSendDoc.setDataClassName(this.dataClassName); | ||
|
||
return actionSendDoc; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,6 +94,5 @@ List<String> listData() { | |
bannerList.add(banner); | ||
|
||
return bannerList; | ||
|
||
} | ||
} |
Oops, something went wrong.