-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
增加nop.biz.use-dict-service开关,开启后字典获取将使用RPC服务
- Loading branch information
1 parent
f7ca6fe
commit 6673d47
Showing
9 changed files
with
102 additions
and
15 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
nop-biz/src/main/resources/_vfs/nop/core/model/DictProvider/DictProvider.xbiz
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,20 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<biz x:schema="/nop/schema/biz/xbiz.xdef" xmlns:x="/nop/schema/xdsl.xdef" xmlns:feature="feature"> | ||
|
||
<actions> | ||
<query name="getDict" feature:on="nop.biz.use-dict-service"> | ||
<arg name="dictName" type="String" mandatory="true"/> | ||
<arg name="svcCtx" kind="ServiceContext"/> | ||
|
||
<return type="io.nop.api.core.beans.DictBean"/> | ||
|
||
<source> | ||
<c:script> | ||
const dictServiceName = $config.var('nop.biz.dict-service.name','nop-sys-service') | ||
</c:script> | ||
<rpc:invoke serviceName="${dictServiceName}" serviceMethod="DictProvider__getDict" | ||
data="${ {dictName}}" cancelToken="${svcCtx}"/> | ||
</source> | ||
</query> | ||
</actions> | ||
</biz> |
27 changes: 27 additions & 0 deletions
27
nop-rpc/nop-rpc-api/src/main/java/io/nop/rpc/api/IDynamicRpcService.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,27 @@ | ||
package io.nop.rpc.api; | ||
|
||
import io.nop.api.core.beans.ApiRequest; | ||
import io.nop.api.core.beans.ApiResponse; | ||
import io.nop.api.core.beans.FieldSelectionBean; | ||
import io.nop.api.core.util.ApiHeaders; | ||
import io.nop.api.core.util.ICancelToken; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.CompletionStage; | ||
|
||
public interface IDynamicRpcService { | ||
CompletionStage<ApiResponse<?>> dynamicInvokeAsync(ApiRequest<?> request, ICancelToken cancelToken); | ||
|
||
default CompletionStage<ApiResponse<?>> dynamicInvokeWithArgs( | ||
String serviceName, String serviceMethod, Map<String, Object> headers, | ||
Object data, FieldSelectionBean selection, ICancelToken cancelToken) { | ||
ApiRequest<Object> request = new ApiRequest<>(); | ||
request.setHeaders(headers); | ||
request.setSelection(selection); | ||
request.setData(data); | ||
|
||
ApiHeaders.setSvcName(request, serviceName); | ||
ApiHeaders.setSvcAction(request, serviceMethod); | ||
return dynamicInvokeAsync(request, cancelToken); | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
nop-rpc/nop-rpc-cluster/src/main/resources/_vfs/nop/rpc/xlib/rpc.xlib
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,23 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<lib x:schema="/nop/schema/xlib.xdef" xmlns:x="/nop/schema/xdsl.xdef"> | ||
|
||
<tags> | ||
<invoke> | ||
<attr name="serviceName" type="String" mandatory="true"/> | ||
<attr name="serviceMethod" type="String" mandatory="true"/> | ||
<attr name="data" optional="true"/> | ||
<attr name="headers" type="Map" optional="true"/> | ||
<attr name="selection" type="io.nop.api.core.beans.FieldSelectionBean" | ||
stdDomain="field-selection" optional="true"/> | ||
<attr name="cancelToken" type="io.nop.api.core.util.ICancelToken" optional="true"/> | ||
|
||
<source> | ||
<c:script><![CDATA[ | ||
const rpcService = inject('nopDynamicRpcService'); | ||
return rpcService.dynamicInvokeWithArgs(serviceName, serviceMethod, | ||
headers, data, selection, cancelToken); | ||
]]></c:script> | ||
</source> | ||
</invoke> | ||
</tags> | ||
</lib> |
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