提交 d2544b9f 编写于 作者: tony001's avatar tony001

update:更新数据服务和UI服务

上级 1f0f3a30
import { Http, EntityService } from '@core';
import { Http, IParam, EntityService } from '@core';
/**
* {{appEntity.logicName}}服务对象基类
......@@ -9,8 +9,14 @@ import { Http, EntityService } from '@core';
*/
export class {{pascalCase appEntity.codeName}}ServiceBase extends EntityService {
constructor(opts?: any) {
super(opts);
/**
* Creates an instance of {{pascalCase appEntity.codeName}}ServiceBase.
*
* @param {*} [opts={}]
* @memberof {{pascalCase appEntity.codeName}}ServiceBase
*/
constructor(opts: IParam = {}) {
super(opts,'{{pascalCase appEntity.codeName}}');
// 初始化关系实体路径集合
this.deResPaths = [
{{#each appEntity.appEntityResources as |appEntityResource| }}
......
import { IParam } from '@core';
import { {{pascalCase appEntity.codeName}}ServiceBase } from './{{spinalCase appEntity.codeName}}-service-base';
/**
* ${appEntity.getLogicName()}服务
* {{appEntity.logicName}}服务
*
* @export
* @class {{pascalCase appEntity.codeName}}Service
* @extends {{pascalCase appEntity.codeName}}ServiceBase
*/
export class {{pascalCase appEntity.codeName}}Service extends {{pascalCase appEntity.codeName}}ServiceBase {
/**
* 基础数据服务实例
*
* @private
* @type { {{pascalCase appEntity.codeName}}Service }
* @memberof {{pascalCase appEntity.codeName}}Service
*/
private static basicDataServiceInstance: {{pascalCase appEntity.codeName}}Service;
/**
* 数据服务存储Map对象
*
* @private
* @type {Map<string, any>}
* @memberof {{pascalCase appEntity.codeName}}Service
*/
private static dataServiceMap: Map<string, any> = new Map();
/**
* Creates an instance of {{pascalCase appEntity.codeName}}Service.
* @memberof {{pascalCase appEntity.codeName}}Service
*/
constructor(opts?: any) {
{{!-- const { context: context, tag: cacheKey } = opts; --}}
constructor(opts?: IParam) {
super(opts);
}
......@@ -25,8 +44,18 @@ export class {{pascalCase appEntity.codeName}}Service extends {{pascalCase appEn
* @return {*} { {{pascalCase appEntity.codeName}}Service }
* @memberof {{pascalCase appEntity.codeName}}Service
*/
static getInstance(context?: any): {{pascalCase appEntity.codeName}}Service {
return new {{pascalCase appEntity.codeName}}Service({ context: context });
static getInstance(opts?: IParam): {{pascalCase appEntity.codeName}}Service {
if (!this.basicDataServiceInstance) {
this.basicDataServiceInstance = new {{pascalCase appEntity.codeName}}Service(opts);
}
if (!opts || !opts.srfdynainstid) {
return this.basicDataServiceInstance;
} else {
if (!{{pascalCase appEntity.codeName}}Service.dataServiceMap.get(opts.srfdynainstid)) {
{{pascalCase appEntity.codeName}}Service.dataServiceMap.set(opts.srfdynainstid, new {{pascalCase appEntity.codeName}}Service(opts));
}
return {{pascalCase appEntity.codeName}}Service.dataServiceMap.get(opts.srfdynainstid);
}
}
}
export default {{pascalCase appEntity.codeName}}Service;
\ No newline at end of file
import { Http, RouteUtil } from '@core';
import { Http, IParam, RouteUtil } from '@core';
/**
* 实体服务基类
* @export
* @class EntityService
*/
export class EntityService{
export class EntityService {
constructor(opts?: any) {
}
/**
* 应用上下文
*
* @protected
* @type {*}
* @memberof EntityService
*/
protected context: any;
/**
* 实体关系路径集合
* 实体关系路径集合
*
* @protected
* @type {any[]}
* @memberof EntityService
*/
protected deResPaths: any[] = []
/**
* HTTP服务类
*
* @protected
* @memberof EntityService
*/
protected http = Http.getInstance();
/**
* 计算请求的实体关系路径
* Creates an instance of EntityService.
* @param {IParam} [opts] 应用上下文
* @param {string} [dbName] 本地存储表
* @param {(0 | 1 | 3)} [storageMode] 存储模式
* @memberof EntityService
*/
constructor(opts: IParam = {}, dbName?: string, storageMode?: 0 | 1 | 3) {
this.context = opts;
}
/**
* 计算请求的实体关系路径
*
* @protected
* @param context 视图上下文
* @param isSelfAppend 是否拼接实体自身的主键值。
* @param {*} context 视图上下文
* @param {boolean} isSelfAppend 是否拼接实体自身的主键值
* @return {*}
* @memberof EntityService
*/
protected buildDeResPath(context: any, isSelfAppend: boolean){
let deResPath = RouteUtil.buildDeResRequestPath(context,this.deResPaths);
protected buildDeResPath(context: any, isSelfAppend: boolean) {
let deResPath = RouteUtil.buildDeResRequestPath(context, this.deResPaths);
// 不需要自身的主键值的删除末尾/xxxx
if(!isSelfAppend){
deResPath = deResPath.substring(0,deResPath.lastIndexOf("/"))
if (!isSelfAppend) {
deResPath = deResPath.substring(0, deResPath.lastIndexOf("/"))
}
return deResPath;
}
// TODO 预置方法
public GET(){}
}
\ No newline at end of file
......@@ -15,7 +15,7 @@ export class {{pascalCase appEntity.codeName}}UIServiceBase extends UIServiceBas
* @param {*} [opts={}]
* @memberof {{pascalCase appEntity.codeName}}UIServiceBase
*/
constructor(opts: any = {}) {
constructor(opts: IParam = {}) {
super(opts);
}
......
import { IParam } from '@core';
import { {{pascalCase appEntity.codeName}}UIServiceBase } from './{{spinalCase appEntity.codeName}}-ui-service-base';
/**
......@@ -31,7 +32,7 @@ export class {{pascalCase appEntity.codeName}}UIService extends {{pascalCase app
* Creates an instance of {{pascalCase appEntity.codeName}}UIService.
* @memberof {{pascalCase appEntity.codeName}}UIService
*/
constructor(opts?: any) {
constructor(opts?: IParam) {
super(opts);
}
......@@ -43,17 +44,17 @@ export class {{pascalCase appEntity.codeName}}UIService extends {{pascalCase app
* @return {*} { {{pascalCase appEntity.codeName}}UIService }
* @memberof {{pascalCase appEntity.codeName}}UIService
*/
static getInstance(context?: any): {{pascalCase appEntity.codeName}}UIService {
static getInstance(opts?: IParam): {{pascalCase appEntity.codeName}}UIService {
if (!this.basicUIServiceInstance) {
this.basicUIServiceInstance = new {{pascalCase appEntity.codeName}}UIService(context);
this.basicUIServiceInstance = new {{pascalCase appEntity.codeName}}UIService(opts);
}
if (!context || !context.srfdynainstid) {
if (!opts || !opts.srfdynainstid) {
return this.basicUIServiceInstance;
} else {
if (!{{pascalCase appEntity.codeName}}UIService.UIServiceMap.get(context.srfdynainstid)) {
{{pascalCase appEntity.codeName}}UIService.UIServiceMap.set(context.srfdynainstid, new {{pascalCase appEntity.codeName}}UIService(context));
if (!{{pascalCase appEntity.codeName}}UIService.UIServiceMap.get(opts.srfdynainstid)) {
{{pascalCase appEntity.codeName}}UIService.UIServiceMap.set(opts.srfdynainstid, new {{pascalCase appEntity.codeName}}UIService(opts));
}
return {{pascalCase appEntity.codeName}}UIService.UIServiceMap.get(context.srfdynainstid);
return {{pascalCase appEntity.codeName}}UIService.UIServiceMap.get(opts.srfdynainstid);
}
}
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册