Skip to content

Commit

Permalink
修正api-web代码生成模板
Browse files Browse the repository at this point in the history
  • Loading branch information
entropy-cloud committed Sep 3, 2023
1 parent de6548e commit bbe822a
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<gen:DefineLoop xpl:lib="/nop/codegen/xlib/gen.xlib">
<c:script><![CDATA[
let apiModel = codeGenModel;
let appName = ormModel['ext:appName'];
let appName = apiModel['ext:appName'];
let apiModuleName = apiModel['ext:apiModuleName'];
let apiPackageName = apiModel['ext:apiPackageName'];
let serviceModuleName = apiModel['ext:serviceModuleName'];
let servicePackageName = apiModel['ext:servicePackageName'];

let moduleId = ormModel['ext:moduleId'] || appName.replace('-','/');
let moduleId = apiModel['ext:moduleId'] || appName.replace('-','/');

let apiModelName = apiModel.resourcePath.$fullFileName().$firstPart('.')
let apiModelName = appName;

builder.defineGlobalVar("apiModel",apiModel);
builder.defineGlobalVar("apiModelName",apiModelName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@
<forms>
<c:script><![CDATA[
let formNames = new Set();
service.methods.forEach(method=>{
serviceModel.methods.forEach(method=>{
formNames.add(method.requestMessage.$simpleClassName())
});
]]></c:script>
<c:for var="formName" items="${formNames}">
<form name="${formName}" editMode="add">
<form id="${formName}" editMode="edit">
<c:script>
let message = apiModel.messages.getByKey(formName);
</c:script>

<c:for var="field" items="${message?.fields}">
${field.name}
</c:for>
<layout>
<c:for var="field" items="${message?.fields}">
${field.name}
</c:for>
</layout>
</form>
</c:for>
</forms>
Expand Down
24 changes: 24 additions & 0 deletions nop-commons/src/main/java/io/nop/commons/type/StdDataType.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,30 @@ public Object convert(Object value) {
return convert(value, NopException::new);
}

public String getJsonType() {
switch (this) {
case BOOLEAN:
return "boolean";
case INT:
case LONG:
case SHORT:
case BYTE:
case FLOAT:
case DOUBLE:
case DECIMAL:
return "number";
case NULL:
return "null";
case MAP:
return "object";
case LIST:
return "array";
case STRING:
default:
return "string";
}
}

public String getDemoJsonValue() {
switch (this) {
case STRING: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25468,6 +25468,10 @@
"name": "getBizObjName",
"parameterTypes": []
},
{
"name": "getFieldName",
"parameterTypes": []
},
{
"name": "getFileExt",
"parameterTypes": []
Expand Down Expand Up @@ -25498,6 +25502,12 @@
"java.lang.String"
]
},
{
"name": "setFieldName",
"parameterTypes": [
"java.lang.String"
]
},
{
"name": "setFileName",
"parameterTypes": [
Expand Down Expand Up @@ -26019,6 +26029,15 @@
"java.lang.String"
]
},
{
"name": "getFileResource",
"parameterTypes": [
"java.lang.String",
"java.lang.String",
"java.lang.String",
"java.lang.String"
]
},
{
"name": "init",
"parameterTypes": []
Expand Down Expand Up @@ -35371,6 +35390,12 @@
"name": "orm_fullyLoaded",
"parameterTypes": []
},
{
"name": "orm_getBean",
"parameterTypes": [
"java.lang.String"
]
},
{
"name": "orm_inited",
"parameterTypes": []
Expand Down Expand Up @@ -36345,6 +36370,10 @@
"java.lang.String"
]
},
{
"name": "getRuleType",
"parameterTypes": []
},
{
"name": "init",
"parameterTypes": []
Expand Down Expand Up @@ -38344,6 +38373,20 @@
}
],
"methods": [
{
"name": "defaultPrepareSave",
"parameterTypes": [
"io.nop.biz.crud.EntityData",
"io.nop.core.context.IServiceContext"
]
},
{
"name": "defaultPrepareUpdate",
"parameterTypes": [
"io.nop.biz.crud.EntityData",
"io.nop.core.context.IServiceContext"
]
},
{
"name": "getConditionFields",
"parameterTypes": [
Expand All @@ -38357,6 +38400,12 @@
"java.lang.String",
"io.nop.core.context.IServiceContext"
]
},
{
"name": "importExcelFile",
"parameterTypes": [
"io.nop.biz.crud.EntityData"
]
}
],
"name": "io.nop.rule.service.entity.NopRuleDefinitionBizModel",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,6 @@
/nop/templates/orm/{appName}-meta/postcompile/gen-i18n.xgen.xgen
/nop/templates/orm/{appName}-meta/precompile/gen-meta.xgen.xgen
/nop/templates/orm/{appName}-meta/src/main/resources/_vfs/dict/{dict.name}.dict.yaml.xgen
/nop/templates/orm/{appName}-meta/src/resources/_vfs/dict/{dict.name}.dict.yaml.xgen
/nop/templates/orm/{appName}-service/impl.xrun
/nop/templates/orm/{appName}-service/pom.xml.xgen
/nop/templates/orm/{appName}-service/src/main/java/{basePackagePath}/service/entity/{!entityModel.notGenCode}{entityModel.shortName}BizModel.java.xgen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.nop.api.core.util.ISourceLocationGetter;
import io.nop.commons.cache.ICache;
import io.nop.commons.cache.LocalCache;
import io.nop.commons.collections.KeyedList;
import io.nop.commons.util.CollectionHelper;
import io.nop.core.lang.eval.IEvalScope;
import io.nop.core.model.object.DynamicObject;
Expand Down Expand Up @@ -157,7 +158,8 @@ DynamicObject newObject(ISourceLocationGetter wk) {
}

private void parseSheets(ImportSheetModel sheetModel, List<ExcelSheet> sheets, DynamicObject obj, IEvalScope scope) {
List<Object> list = new ArrayList<>();
List<Object> list = sheetModel.getKeyProp() == null ? new ArrayList<>() :
new KeyedList<>(o -> BeanTool.instance().getProperty(o, sheetModel.getKeyProp()));
ImportDataCollector builder = new ImportDataCollector(scope, cache, compileTool, obj, list);

for (ExcelSheet sheet : sheets) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<schema stdDomain="string"/>
</field>

<field name="methods" displayName="方法列表" list="true">
<field name="methods" displayName="方法列表" list="true" keyProp="name">
<normalizeFieldsExpr>
<c:script><![CDATA[
const beanPackage = rootRecord['ext:apiPackageName']+'.beans';
Expand Down
2 changes: 2 additions & 0 deletions nop-rule/nop-rule-web/precompile/gen-page.xgen
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
<c:script>
// 根据xmeta生成页面文件view.xml/page.yaml
codeGenerator.withTplDir('/nop/templates/orm-web').execute("/",{ moduleId: "nop/rule" },$scope);

codeGenerator.renderModel('../../model/nop-rule.api.xlsx','/nop/templates/api-web', '/',$scope);
</c:script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<auth x:schema="/nop/schema/action-auth.xdef" xmlns:x="/nop/schema/xdsl.xdef" xmlns:i18n-en="i18n-en">

<site id="main">
<resource id="test-api-nop-rule" displayName="测试nop-rule" icon="ion:grid-outline" resourceType="TOPM"
routePath="/test-api-nop-rule" component="layouts/default/index">
<children>
<resource id="RuleService-main" displayName="规则引擎服务" i18n-en:displayName="Rule Service"
icon="ant-design:appstore-twotone" component="AMIS" resourceType="SUBM"
url="/nop/rule/pages/RuleService/main.page.yaml"/>
</children>
</resource>
</site>
</auth>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<view x:extends="_RuleService.view.xml" x:schema="/nop/schema/xui/xview.xdef" xmlns:x="/nop/schema/xdsl.xdef">

<pages>
<tabs name="main"/>
</pages>
</view>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" ?>
<view x:schema="/nop/schema/xui/xview.xdef" xmlns:x="/nop/schema/xdsl.xdef">

<controlLib>/nop/web/xlib/control.xlib</controlLib>

<forms>
<form id="RuleRequestBean" editMode="edit">
<layout>
ruleName

ruleVersion

inputs
</layout>
</form>
<form id="RuleKeyBean" editMode="edit">
<layout>
ruleName

ruleVersion
</layout>
</form>
</forms>

<pages>
<simple name="executeRule" form="RuleRequestBean">
<api url="/r/RuleService__executeRule"/>
</simple>
<simple name="getRuleMeta" form="RuleKeyBean">
<api url="/r/RuleService__getRuleMeta"/>
</simple>
<tabs name="main" tabsMode="vertical" mountOnEnter="true" unmountOnExit="true">
<tab name="executeRule" page="executeRule" title="执行规则"/>
<tab name="getRuleMeta" page="getRuleMeta" title="得到规则元数据"/>
</tabs>
</pages>
</view>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

x:gen-extends: |
<web:GenPage view="RuleService.view.xml" page="main" xpl:lib="/nop/web/xlib/web.xlib" />

0 comments on commit bbe822a

Please sign in to comment.