From 1ef4286b6eb072e7c4512bcf657cc808f42d9298 Mon Sep 17 00:00:00 2001 From: "Nicholas.Jee" Date: Mon, 15 Nov 2021 17:37:49 +0800 Subject: [PATCH] update Readme --- README.md | 219 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 217 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 10da083..e788ba0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,218 @@ -# open-client-demo -开放平台子插件demo \ No newline at end of file +# 开放平台子插件demo + +``` txt +api接口,分三级结构(类似httpHandlerProvider)  +分组类(CallerProvider)———API描述类(Loader)——API执行逻辑(Caller)                                                                                              +       └——额外Caller(指不希望默认添加到面板但添加菜单里可以看到) + ``` + + +#### PluginAPICallerProvider 提供方法registerCallers注册具体API + +``` java +package com.tptj.plugin.hg.client.open.fun; + +import com.fr.stable.fun.mark.Mutable; + +public interface APICallerProvider extends Mutable { + String XML_TAG = "OpenClientAPIProvider"; + int CURRENT_LEVEL = 1; + + /** + * API列表 + * @return + */ + PluginAPICaller[] registerCallers(); + + /** + * 希望读取到可添加项但不希望直接导入到面板的Caller + * @return + */ + APICaller[] extraCaller(); + + /** + * 分组显示名 要求唯一 + * @return + */ + String groupName(); + + /** + * 分组描述 + * @return + */ + String groupDescription(); + +} +``` + +#### PluginAPICaller提供具体api参数 + + +``` java +package com.tptj.plugin.hg.client.open.fun; + +import com.tptj.plugin.hg.client.center.core.store.api.APIEntity; + +import java.util.Map; + +public interface APILoader { + + + /** + * @return 显示名 唯一 + */ + String APIName(); + + /** + * 插件逻辑类 + * @return APICallerProvider + */ + APICaller APICaller(); + /** + * @return 默认参数 + */ + Map defaultParameters(); + + /** + * + * @return 请求路径 不含/webroot/decision/sp/client/api/ + */ + String path(); + + /** + * 插件ID 统一分配 + * @return ID + */ + String getApiId(); + + /** + * @return 配置 + */ + Map config(); + + /** + * @return 是否公开 + */ + boolean isPublic(); + + /** + * @return 描述 + */ + String Description(); + + /** + * @return 请求类型 GET/POST/DELETE/PUT + */ + String RequestType(); + APIEntity toAPIEntity(); + +} + +``` + +``` java + +package com.tptj.plugin.hg.client.open.fun; + +import com.fr.decision.webservice.Response; +import com.tptj.plugin.hg.client.open.exception.CodeException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +/** + * @author 秃破天际 + * @version 10.0 + * Created by 秃破天际 on 2020-04-30 + **/ +public interface APICaller { + /** + * 传入请求和配置的默认参数,执行API,并给出响应 + * @param req + * @param defaultParameters + * @param config + * @return + * @throws CodeException + */ + Response call(HttpServletRequest req, Map defaultParameters,Map config)throws CodeException; + + + Response call(HttpServletRequest req, HttpServletResponse res, Map defaultParameters, Map config)throws CodeException; + + /** + * @return 描述 尽量简短 + */ + String Description(); +} + +``` + +#### 认证器,类似 但是只有一级 + +``` java +package com.tptj.plugin.hg.client.open.fun; + +import com.fr.stable.fun.mark.Mutable; +import com.tptj.plugin.hg.client.center.core.store.authentication.AuthEntity; + +import java.util.Map; + +public interface PluginAuthProvider extends AuthenticationProvider , Mutable { + String XML_TAG = "PluginAuthProvider"; + int CURRENT_LEVEL = 1; + + /** + * @return ID 唯一 + */ + String AuthId(); + + /** + * @return 显示名 唯一 + */ + String AuthName(); + + /** + * @return 描述 + */ + String Description(); + + /** + * @return 默认参数 + */ + Map defaultParameters(); + + /** + * @return 配置 + */ + Map config(); + + AuthEntity toAuthEntity(); + + /** + * 根据请求和配置进行自定义的权限验证 + * @param req + * @param defaultParameters + * @param config + * @return 是否通过 + * @throws CodeException + */ + boolean auth(HttpServletRequest req, Map defaultParameters,Map config)throws CodeException; + +} + +``` + +注入点 + +``` xml + + + + + + + + +``` \ No newline at end of file