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

update:更新

上级 e0cc3ec1
import { OpenViewService } from "@/utils";
import { AppBase, IParam, ViewDetail, IApp, IOpenViewService, deepCopy } from "@core";
import { AppFuncConfig } from './app-func-config';
import { AppViewConfig } from './app-view-config';
import { AppBase, IParam, ViewDetail, IApp, IOpenViewService, deepCopy, IUIServiceRegister, IDataServiceRegister } from "@core";
import { AppFuncConfig, AppViewConfig } from './config';
import { DataServiceRegister, UIServiceRegister } from "./register";
export class App extends AppBase implements IApp {
......@@ -45,6 +45,30 @@ export class App extends AppBase implements IApp {
return OpenViewService.getInstance();
}
/**
* 获取UI服务
*
* @param {string} entityKey 应用实体名小写
* @param {*} context 应用上下文
* @return {Promise<any>}
* @memberof App
*/
public getUIService(entityKey: string, context?: IParam): Promise<any> {
return UIServiceRegister.getInstance().getService(entityKey, context);
}
/**
* 获取数据服务
*
* @param {string} entityKey 应用实体名小写
* @param {*} context 应用上下文
* @return {Promise<any>}
* @memberof App
*/
public getDataService(entityKey: string, context?: IParam): Promise<any> {
return DataServiceRegister.getInstance().getService(entityKey, context);
}
/**
* 获取视图信息
*
......
export { AppFuncConfig } from './app-func-config';
export { AppViewConfig } from './app-view-config';
\ No newline at end of file
import { IDataServiceRegister, IParam } from '@core';
/**
* 数据服务注册中心
*
* @export
* @class DataServiceRegister
*/
export class DataServiceRegister implements IDataServiceRegister {
/**
* DataServiceRegister 单例对象
*
* @private
* @static
* @memberof DataServiceRegister
*/
private static DataServiceRegister: DataServiceRegister;
/**
* 所有数据服务 Map对象
*
* @private
* @static
* @memberof DataServiceRegister
*/
private static allDataServiceMap: Map<string, any> = new Map();
/**
* Creates an instance of DataServiceRegister.
* @memberof DataServiceRegister
*/
constructor() {
this.init();
}
/**
* 获取DataServiceRegister 单例对象
*
* @public
* @static
* @memberof DataServiceRegister
*/
public static getInstance() {
if (!this.DataServiceRegister) {
this.DataServiceRegister = new DataServiceRegister();
}
return this.DataServiceRegister;
}
/**
* 初始化
*
* @protected
* @memberof DataServiceRegister
*/
protected init(): void {
{{#each app.appEntities as |appEntity|}}
DataServiceRegister.allDataServiceMap.set('{{lowerCase appEntity.codeName}}', () => import('@api/{{spinalCase appEntity.codeName}}/{{spinalCase appEntity.codeName}}-service'));
{{/each}}
}
/**
* 获取指定数据服务
*
* @param {string} entityKey 应用实体名小写
* @param {*} context 应用上下文
* @return {*}
* @memberof DataServiceRegister
*/
public async getService(entityKey: string, context: IParam = {}) {
const importService = DataServiceRegister.allDataServiceMap.get(entityKey);
if (importService) {
const importModule = await importService();
return importModule.default.getInstance(context);
}
}
}
\ No newline at end of file
export { DataServiceRegister } from './data-service-register';
export { UIServiceRegister } from './ui-service-register';
\ No newline at end of file
import { IParam, IUIServiceRegister } from '@core';
/**
* UI服务注册中心
*
* @export
* @class UIServiceRegister
*/
export class UIServiceRegister implements IUIServiceRegister {
/**
* UIServiceRegister 单例对象
*
* @private
* @static
* @memberof UIServiceRegister
*/
private static UIServiceRegister: UIServiceRegister;
/**
* 所有UIService Map对象
*
* @private
* @static
* @memberof UIServiceRegister
*/
private static allUIServiceMap: Map<string, any> = new Map();
/**
* Creates an instance of UIServiceRegister.
* @memberof UIServiceRegister
*/
constructor() {
this.init();
}
/**
* 获取UIServiceRegister 单例对象
*
* @public
* @static
* @memberof UIServiceRegister
*/
public static getInstance() {
if (!this.UIServiceRegister) {
this.UIServiceRegister = new UIServiceRegister();
}
return this.UIServiceRegister;
}
/**
* 初始化
*
* @protected
* @memberof UIServiceRegister
*/
protected init(): void {
{{#each app.appEntities as |appEntity|}}
UIServiceRegister.allUIServiceMap.set('{{lowerCase appEntity.codeName}}', () => import('@ui-service/{{spinalCase appEntity.codeName}}/{{spinalCase appEntity.codeName}}-ui-service'));
{{/each}}
}
/**
* 获取指定UIService
*
* @param {string} entityKey 应用实体名小写
* @param {*} context 应用上下文
* @return {*}
* @memberof UIServiceRegister
*/
public async getService(entityKey: string, context: IParam = {}) {
const importService = UIServiceRegister.allUIServiceMap.get(entityKey);
if (importService) {
const importModule = await importService();
return importModule.default.getInstance(context);
}
}
}
\ No newline at end of file
import { IParam, ViewDetail } from "../common";
import { IAppFuncService, IOpenViewService } from "../logic";
import { IAppFuncService, IDataServiceRegister, IOpenViewService, IUIServiceRegister } from "../service";
/**
......@@ -21,7 +21,7 @@ export interface IApp {
/**
* 获取应用功能服务
*
* @return {*} {AppFuncService}
* @return {*} {IAppFuncService}
* @memberof IApp
*/
getAppFuncService(): IAppFuncService;
......@@ -29,11 +29,31 @@ export interface IApp {
/**
* 获取打开视图服务
*
* @return {*} {IParam}
* @return {*} {IOpenViewService}
* @memberof IApp
*/
getOpenViewService(): IOpenViewService;
/**
* 获取UI服务
*
* @param {string} entityKey 应用实体名小写
* @param {*} context 应用上下文
* @return {Promise<any>}
* @memberof IApp
*/
getUIService(entityKey: string, context?: IParam): Promise<any>;
/**
* 获取全局数据服务
*
* @param {string} entityKey 应用实体名小写
* @param {*} context 应用上下文
* @return {Promise<any>}
* @memberof IApp
*/
getDataService(entityKey: string, context?: IParam): Promise<any>;
/**
* 获取指定视图信息
*
......@@ -41,6 +61,6 @@ export interface IApp {
* @return {*} {(ViewDetail | undefined)}
* @memberof IApp
*/
getViewInfo(codeName: string): ViewDetail | undefined
getViewInfo(codeName: string): ViewDetail | undefined;
}
\ No newline at end of file
export * from './app';
export * from './common';
export * from './logic';
\ No newline at end of file
export * from './service';
\ No newline at end of file
export * from './i-app-func-service';
export * from './i-open-view-service';
\ No newline at end of file
/**
* @description 数据服务注册中心
* @export
* @interface IDataServiceRegister
*/
export interface IDataServiceRegister {
/**
* 获取指定数据服务
*
* @param {string} entityKey 应用实体名小写
* @param {*} context 应用上下文
* @return {*}
* @memberof DataServiceRegister
*/
getService(entityKey: string, context?: any): Promise<any>;
}
\ No newline at end of file
/**
* @description UI服务注册中心
* @export
* @interface IUIServiceRegister
*/
export interface IUIServiceRegister {
/**
* 获取指定UI服务
*
* @param {string} entityKey 应用实体名小写
* @param {*} context 应用上下文
* @return {*}
* @memberof IUIServiceRegister
*/
getService(entityKey: string, context: any): Promise<any>;
}
\ No newline at end of file
export * from './i-app-func-service';
export * from './i-open-view-service';
export * from './i-data-service-register';
export * from './i-ui-service-register';
\ No newline at end of file
import { AppFuncService, IApp, IAppFuncService, IOpenViewService, ViewDetail } from "@core";
import { IParam } from "@core/interface";
import { IDataServiceRegister, IParam, IUIServiceRegister } from "@core/interface";
/**
* 应用基类
......@@ -38,6 +38,30 @@ export abstract class AppBase implements IApp {
throw new Error("Method not implemented.");
}
/**
* 获取UI服务
*
* @param {string} entityKey 应用实体名小写
* @param {*} context 应用上下文
* @return {Promise<any>}
* @memberof AppBase
*/
public getUIService(entityKey: string, context?: IParam): Promise<any> {
throw new Error("Method not implemented.");
}
/**
* 获取数据服务
*
* @param {string} entityKey 应用实体名小写
* @param {*} context 应用上下文
* @return {Promise<any>}
* @memberof AppBase
*/
public getDataService(entityKey: string, context?: IParam): Promise<any> {
throw new Error("Method not implemented.");
}
/**
* 获取所有应用功能
*
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册