提交 58356594 编写于 作者: Mosher's avatar Mosher

update:更新实体行为发布逻辑,支持脚本、实体处理逻辑类型

上级 c1ca690c
/**
* {{singleAppMethod.codeName}}
*
* @param {IContext} [context={}]
* @param {IParam} [data = {}]
* @returns {Promise<any>}
* @memberof {{pascalCase appEntity.codeName}}ServiceBase
*/
public async {{singleAppMethod.codeName}}(context: IContext = {}, data: IParam = {}): Promise<any> {
try {
// data = await this.executeAppDELogic('{{singleAppMethod.psDEAction.psDELogic.codeName}}', context, data);
const res = {
ok: true,
status: 200,
data: data
};
return res;
} catch (error: any) {
const res = {
ok: false,
status: 500,
message: error?.message
}
return res;
}
}
/** /**
* {{singleAppMethod.codeName}} * {{singleAppMethod.codeName}}
* *
* @param {IContext} [context={}] * @param {IContext} [context={}]
* @param {IParam} [data = {}] * @param {IParam} [data = {}]
* @returns {Promise<any>} * @returns {Promise<any>}
* @memberof {{pascalCase appEntity.codeName}}ServiceBase * @memberof {{pascalCase appEntity.codeName}}ServiceBase
*/ */
public async {{singleAppMethod.codeName}}(context: IContext = {}, data: IParam = {}): Promise<any> { public async {{singleAppMethod.codeName}}(context: IContext = {}, data: IParam = {}): Promise<any> {
{{! 方法路径是否带资源主键 }} {{! 方法路径是否带资源主键 }}
const deResPath = this.buildDeResPath(context, {{singleAppMethod.psDEServiceAPIMethod.needResourceKey}}); const deResPath = this.buildDeResPath(context, {{singleAppMethod.psDEServiceAPIMethod.needResourceKey}});
{{#if (eq singleAppMethod.methodType "SELECT")}} {{#if (eq singleAppMethod.methodType "SELECT")}}
{{! 方法类型为SELECT }} {{! 方法类型为SELECT }}
{{#if (or (eq singleAppMethod.psDEServiceAPIMethod.requestMethod "PUT") (eq singleAppMethod.psDEServiceAPIMethod.requestMethod "POST") )}} {{#if (or (eq singleAppMethod.psDEServiceAPIMethod.requestMethod "PUT") (eq singleAppMethod.psDEServiceAPIMethod.requestMethod "POST") )}}
const res = await this.http.{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestMethod }}(`${deResPath}{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestPath}}`,data); const res = await this.http.{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestMethod }}(`${deResPath}{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestPath}}`,data);
{{else}}
const res = await this.http.{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestMethod }}(`${deResPath}{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestPath}}`);
{{/if}}
{{else if (eq singleAppMethod.methodType "FETCHTEMP")}}
{{! 方法类型为FETCHTEMP }}
const res = await this.http.{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestMethod }}(`${deResPath}{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestPath}}`);
{{else if (eq singleAppMethod.methodType "FETCH")}}
{{! 方法类型为FETCH }}
const res = await this.http.{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestMethod }}(`${deResPath}{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestPath}}`,data);
{{else}} {{else}}
{{! 方法类型为DEACTION }} const res = await this.http.{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestMethod }}(`${deResPath}{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestPath}}`);
this.beforeExecuteAction(context,data,'{{singleAppMethod.codeName}}'); {{/if}}
{{#if (eq singleAppMethod.psDEServiceAPIMethod.requestParamType "NONE")}} {{else if (eq singleAppMethod.methodType "FETCHTEMP")}}
{{! 参数类型为NONE,包含GetDraft }} {{! 方法类型为FETCHTEMP }}
{{#if (neq singleAppMethod.codeName 'GetDraft')}} const res = await this.http.{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestMethod }}(`${deResPath}{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestPath}}`);
const res = await this.http.{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestMethod }}(`${deResPath}{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestPath}}`); {{else if (eq singleAppMethod.methodType "FETCH")}}
{{else}} {{! 方法类型为FETCH }}
const res = await this.http.{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestMethod }}(`${deResPath}{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestPath}}`,data); const res = await this.http.{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestMethod }}(`${deResPath}{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestPath}}`,data);
{{/if}} {{else}}
{{else if (eq singleAppMethod.psDEServiceAPIMethod.requestParamType "FIELD")}} {{! 方法类型为DEACTION }}
{{! 参数类型为FIELD,包含Get,Remove }} this.beforeExecuteAction(context,data,'{{singleAppMethod.codeName}}');
const res = await this.http.{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestMethod }}(`${deResPath}{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestPath}}`); {{#if (eq singleAppMethod.psDEServiceAPIMethod.requestParamType "NONE")}}
{{else if (eq singleAppMethod.psDEServiceAPIMethod.requestParamType "ENTITY")}} {{! 参数类型为NONE,包含GetDraft }}
{{! 参数类型为ENTITY,包含CheckKey,Create,Save,Update }} {{#if (neq singleAppMethod.codeName 'GetDraft')}}
const res = await this.http.{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestMethod }}(`${deResPath}{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestPath}}`,data); const res = await this.http.{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestMethod }}(`${deResPath}{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestPath}}`);
{{else}} {{else}}
{{! 参数类型为URIPARAM }} const res = await this.http.{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestMethod }}(`${deResPath}{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestPath}}`,data);
const res = await this.http.{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestMethod }}(`${deResPath}{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestPath}}`,data);
{{/if}} {{/if}}
this.afterExecuteAction(context,data,'{{singleAppMethod.codeName}}'); {{else if (eq singleAppMethod.psDEServiceAPIMethod.requestParamType "FIELD")}}
{{! 参数类型为FIELD,包含Get,Remove }}
const res = await this.http.{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestMethod }}(`${deResPath}{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestPath}}`);
{{else if (eq singleAppMethod.psDEServiceAPIMethod.requestParamType "ENTITY")}}
{{! 参数类型为ENTITY,包含CheckKey,Create,Save,Update }}
const res = await this.http.{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestMethod }}(`${deResPath}{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestPath}}`,data);
{{else}}
{{! 参数类型为URIPARAM }}
const res = await this.http.{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestMethod }}(`${deResPath}{{lowerCase singleAppMethod.psDEServiceAPIMethod.requestPath}}`,data);
{{/if}} {{/if}}
return res; this.afterExecuteAction(context,data,'{{singleAppMethod.codeName}}');
} {{/if}}
\ No newline at end of file return res;
}
/**
* {{singleAppMethod.codeName}}
*
* @param {IContext} [context={}]
* @param {IParam} [data = {}]
* @returns {Promise<any>}
* @memberof {{pascalCase appEntity.codeName}}ServiceBase
*/
public async {{singleAppMethod.codeName}}(context: IContext = {}, data: IParam = {}): Promise<any> {
{{#if singleAppMethod.psDEAction.scriptCode}}
eval(`{{singleAppMethod.psDEAction.scriptCode}}`);
{{/if}}
const res = {
ok: true,
status: 200,
data: data
}
return res;
}
...@@ -43,14 +43,26 @@ export class {{pascalCase appEntity.codeName}}ServiceBase extends EntityService ...@@ -43,14 +43,26 @@ export class {{pascalCase appEntity.codeName}}ServiceBase extends EntityService
} }
{{#each appEntity.allPSAppDEMethods as |singleAppMethod| }} {{#each appEntity.allPSAppDEMethods as |singleAppMethod| }}
{{! 非内置行为才输出 }} {{! 非内置行为和非临时数据方法才输出 }}
{{#if (eq isBuiltinMethod false)}} {{#if (and (eq builtinMethod false) (eq tempDataMode 0))}}
{{! 存在接口方法才输出 }} {{#if (eq appEntity.psDEServiceAPI.nested true)}}
{{#if singleAppMethod.psDEServiceAPIMethod}} {{!-- todo嵌套行为补充 --}}
{{! 远端接口 }} {{else}}
{{!-- todo 插件 --}}
{{#if (and (eq methodType 'DEACTION') psDEAction (eq psDEAction.actionType 'DELOGIC'))}}
{{!-- 实体处理逻辑 --}}
{{> @macro/front-end/entity/service-delogic-method.hbs singleAppMethod=singleAppMethod}}
{{else if (and (eq methodType 'DEACTION') psDEAction (eq psDEAction.actionType 'SCRIPT'))}}
{{!-- 脚本代码 --}}
{{> @macro/front-end/entity/service-script-method.hbs singleAppMethod=singleAppMethod}}
{{else if (and singleAppMethod.psDEServiceAPIMethod appEntity.major)}}
{{!-- 远程接口 --}}
{{> @macro/front-end/entity/service-remote-method.hbs singleAppMethod=singleAppMethod}} {{> @macro/front-end/entity/service-remote-method.hbs singleAppMethod=singleAppMethod}}
{{/if}}
{{/if}}
{{/if}}
{{/if}} {{/if}}
{{/each}} {{/each}}
} }
\ No newline at end of file
...@@ -204,7 +204,7 @@ export class AppSysAction { ...@@ -204,7 +204,7 @@ export class AppSysAction {
public static newRow(params: IUIActionParams) { public static newRow(params: IUIActionParams) {
const { actionEnvironment } = params; const { actionEnvironment } = params;
// 视图里获取多数据部件 // 视图里获取多数据部件
if (hasFunction(actionEnvironment.xDataControl, "newRow")) { if (actionEnvironment.xDataControl && hasFunction(actionEnvironment.xDataControl, "newRow")) {
actionEnvironment.xDataControl.newRow(); actionEnvironment.xDataControl.newRow();
} else if (isExist(actionEnvironment.newRow)) { } else if (isExist(actionEnvironment.newRow)) {
actionEnvironment.newRow(); actionEnvironment.newRow();
...@@ -220,7 +220,7 @@ export class AppSysAction { ...@@ -220,7 +220,7 @@ export class AppSysAction {
public static save(params: IUIActionParams) { public static save(params: IUIActionParams) {
const { actionEnvironment } = params; const { actionEnvironment } = params;
// 视图里获取多数据部件 // 视图里获取多数据部件
if (hasFunction(actionEnvironment.xDataControl, "save")) { if (actionEnvironment.xDataControl && hasFunction(actionEnvironment.xDataControl, "save")) {
actionEnvironment.xDataControl.save(); actionEnvironment.xDataControl.save();
} else if (isExist(actionEnvironment.save)) { } else if (isExist(actionEnvironment.save)) {
actionEnvironment.save(); actionEnvironment.save();
...@@ -236,7 +236,7 @@ export class AppSysAction { ...@@ -236,7 +236,7 @@ export class AppSysAction {
public static saveRow(params: IUIActionParams) { public static saveRow(params: IUIActionParams) {
const { actionEnvironment } = params; const { actionEnvironment } = params;
// 视图里获取多数据部件 // 视图里获取多数据部件
if (hasFunction(actionEnvironment.xDataControl, "save")) { if (actionEnvironment.xDataControl && hasFunction(actionEnvironment.xDataControl, "save")) {
actionEnvironment.xDataControl.save(); actionEnvironment.xDataControl.save();
} else if (isExist(actionEnvironment.save)) { } else if (isExist(actionEnvironment.save)) {
actionEnvironment.save(); actionEnvironment.save();
...@@ -252,10 +252,10 @@ export class AppSysAction { ...@@ -252,10 +252,10 @@ export class AppSysAction {
public static remove(params: IUIActionParams) { public static remove(params: IUIActionParams) {
const { actionEnvironment, data } = params; const { actionEnvironment, data } = params;
// 视图里获取多数据部件 // 视图里获取多数据部件
if (hasFunction(actionEnvironment.xDataControl, "remove")) { if (actionEnvironment.xDataControl && hasFunction(actionEnvironment.xDataControl, "remove")) {
actionEnvironment.xDataControl.remove(data); actionEnvironment.xDataControl.remove(data);
} else if (isExist(actionEnvironment.remove)) { } else if (isExist(actionEnvironment.remove)) {
actionEnvironment.remove(); actionEnvironment.remove(data);
} }
} }
...@@ -268,7 +268,7 @@ export class AppSysAction { ...@@ -268,7 +268,7 @@ export class AppSysAction {
public static refresh(params: IUIActionParams) { public static refresh(params: IUIActionParams) {
const { actionEnvironment } = params; const { actionEnvironment } = params;
// 视图里获取多数据部件 // 视图里获取多数据部件
if (hasFunction(actionEnvironment.xDataControl, "refresh")) { if (actionEnvironment.xDataControl && hasFunction(actionEnvironment.xDataControl, "refresh")) {
actionEnvironment.xDataControl.refresh(); actionEnvironment.xDataControl.refresh();
} else if (isExist(actionEnvironment.refresh)) { } else if (isExist(actionEnvironment.refresh)) {
actionEnvironment.refresh(); actionEnvironment.refresh();
...@@ -296,7 +296,7 @@ export class AppSysAction { ...@@ -296,7 +296,7 @@ export class AppSysAction {
*/ */
public static async saveAndExit(params: IUIActionParams) { public static async saveAndExit(params: IUIActionParams) {
const { actionEnvironment } = params; const { actionEnvironment } = params;
if (hasFunction(actionEnvironment.xDataControl, "save")) { if (actionEnvironment.xDataControl && hasFunction(actionEnvironment.xDataControl, "save")) {
await actionEnvironment.xDataControl.save(); await actionEnvironment.xDataControl.save();
} else if (isExist(actionEnvironment.save)) { } else if (isExist(actionEnvironment.save)) {
await actionEnvironment.save(); await actionEnvironment.save();
...@@ -314,7 +314,7 @@ export class AppSysAction { ...@@ -314,7 +314,7 @@ export class AppSysAction {
*/ */
public static async saveAndNew(params: IUIActionParams) { public static async saveAndNew(params: IUIActionParams) {
const { actionEnvironment } = params; const { actionEnvironment } = params;
if (hasFunction(actionEnvironment.xDataControl, "save")) { if (actionEnvironment.xDataControl && hasFunction(actionEnvironment.xDataControl, "save")) {
await actionEnvironment.xDataControl.save(); await actionEnvironment.xDataControl.save();
} else if (isExist(actionEnvironment.save)) { } else if (isExist(actionEnvironment.save)) {
await actionEnvironment.save(); await actionEnvironment.save();
...@@ -338,7 +338,7 @@ export class AppSysAction { ...@@ -338,7 +338,7 @@ export class AppSysAction {
public static async removeAndExit(params: IUIActionParams) { public static async removeAndExit(params: IUIActionParams) {
const { actionEnvironment } = params; const { actionEnvironment } = params;
// 视图里获取多数据部件 // 视图里获取多数据部件
if (hasFunction(actionEnvironment.xDataControl, "remove")) { if (actionEnvironment.xDataControl && hasFunction(actionEnvironment.xDataControl, "remove")) {
await actionEnvironment.xDataControl.remove(); await actionEnvironment.xDataControl.remove();
} else if (isExist(actionEnvironment.remove)) { } else if (isExist(actionEnvironment.remove)) {
await actionEnvironment.remove(); await actionEnvironment.remove();
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册