We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
是这样的,我在 go-cqhttp 看到的一些 request 发现在 ActionPathEnum 没有提供 (例如群精华消息,我找不到) ,于是便打算自行调用 ActionHandler 去做自定义的 API 请求。
但我发现 Enum 是没办法自行使用反射创建的,而且你的 ActionHandler 的 doActionRequest 方法中只能放入 ActionPathEnum 作为请求,因此我现在无法做自定义的 API 请求。如果要在不修改API源代码的前提下做,我只能重新实作一个新的 ActionHandler ,并使用反射获取现有 ActionHandler 的所有实例,极其麻烦。
如果此API会持续更新的话,我就需要每次有新的更新都要修改本API源代码一次,很麻烦。因此我希望你能接受 pull request ? 或者由作者本人去修改。
为 ActionPathEnum 提供可扩展方式很简单,只要创建一个 interface 去定义 enum 的方法 然后由 ActionPathEnum 去继承,最后 ActionHandler 的 doActionRequest 方法 接收 该 Interface 作为参数而不是 ActionPathEnum 就可以了。
public interface ActionPath { String getDesc(); String getPath(); }
public enum ActionPathEnum implements ActionPath { SOME_ACTION("do_action", "某个请求"); // 更多如此类推 private final String path; private final String desc; @Override public String getPath() { return this.path; } @Override public String getDesc() { return this.desc; } private ActionPathEnum(String path, String desc) { this.path = path; this.desc = desc; } }
@Component public class ActionHandler { // .... public JSONObject doActionRequest(WebSocketSession session, ActionPath action, JSONObject params) { // .... String path = action.getPath(); String desc = action.getDesc(); // ..... } // ..... }
The text was updated successfully, but these errors were encountered:
非常感谢提出建议,目前已支持 ActionPathEnum 的拓展与 CustomRequest 方法,请等待 Maven Repo 的同步,对应版本为 v1.1.2
ActionPathEnum
CustomRequest
v1.1.2
Sorry, something went wrong.
十分感謝!
No branches or pull requests
是这样的,我在 go-cqhttp 看到的一些 request 发现在 ActionPathEnum 没有提供 (例如群精华消息,我找不到) ,于是便打算自行调用 ActionHandler 去做自定义的 API 请求。
但我发现 Enum 是没办法自行使用反射创建的,而且你的 ActionHandler 的 doActionRequest 方法中只能放入 ActionPathEnum 作为请求,因此我现在无法做自定义的 API 请求。如果要在不修改API源代码的前提下做,我只能重新实作一个新的 ActionHandler ,并使用反射获取现有 ActionHandler 的所有实例,极其麻烦。
如果此API会持续更新的话,我就需要每次有新的更新都要修改本API源代码一次,很麻烦。因此我希望你能接受 pull request ? 或者由作者本人去修改。
为 ActionPathEnum 提供可扩展方式很简单,只要创建一个 interface 去定义 enum 的方法 然后由 ActionPathEnum 去继承,最后 ActionHandler 的 doActionRequest 方法 接收 该 Interface 作为参数而不是 ActionPathEnum 就可以了。
The text was updated successfully, but these errors were encountered: