@farris/bef
Advanced tools
Comparing version 0.0.11-201901031330 to 0.0.11-201901171630
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@farris/devkit'), require('@ecp-caf/caf-common'), require('@angular/common/http'), require('rxjs/observable/of'), require('rxjs/operators/tap'), require('rxjs/operators/switchMap'), require('rxjs/observable/zip'), require('rxjs/operators/map')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@farris/devkit', '@ecp-caf/caf-common', '@angular/common/http', 'rxjs/observable/of', 'rxjs/operators/tap', 'rxjs/operators/switchMap', 'rxjs/observable/zip', 'rxjs/operators/map'], factory) : | ||
(factory((global['farris-bef'] = {}),global.core,global.devkit,global.cafCommon,global.http,global.of,global.tap,global.switchMap,global.zip,global.map)); | ||
}(this, (function (exports,core,devkit,cafCommon,http,of,tap,switchMap,zip,map) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@farris/devkit'), require('@ecp-caf/caf-common'), require('@angular/common/http'), require('rxjs/observable/of'), require('rxjs/operators/tap'), require('rxjs/observable/zip'), require('rxjs/operators/map'), require('rxjs/operators/switchMap')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@farris/devkit', '@ecp-caf/caf-common', '@angular/common/http', 'rxjs/observable/of', 'rxjs/operators/tap', 'rxjs/observable/zip', 'rxjs/operators/map', 'rxjs/operators/switchMap'], factory) : | ||
(factory((global['farris-bef'] = {}),global.core,global.devkit,global.cafCommon,global.http,global.of,global.tap,global.zip,global.map,global.switchMap)); | ||
}(this, (function (exports,core,devkit,cafCommon,http,of,tap,zip,map,switchMap) { 'use strict'; | ||
@@ -101,3 +101,8 @@ /* | ||
var primaryNgFiledProp = devkit.FieldMetadataUtil.getPrimaryFieldMetadata(entityType); | ||
return primaryNgFiledProp.dataField; | ||
if (primaryNgFiledProp) { | ||
return primaryNgFiledProp.dataField; | ||
} | ||
else { | ||
return ''; | ||
} | ||
}; | ||
@@ -153,3 +158,3 @@ /** | ||
}); | ||
console.log(this.changeDetail); | ||
// console.log(this.changeDetail); | ||
return this.changeDetail; | ||
@@ -170,2 +175,3 @@ }; | ||
var _loop_1 = function (i) { | ||
var parentChangeInfo = this_1.getChangeInfo(parentChangeDetail); | ||
var propName = paths[i]; | ||
@@ -183,3 +189,3 @@ var _a = EntityUtil.getPropInfo(parentEntityType, propName), propType = _a.propType, propEntityType = _a.propEntityType; | ||
// NgField类型:说明是最后一级 | ||
parentChangeDetail.ChangeInfo[propName] = modification.value; | ||
parentChangeInfo[propName] = modification.value; | ||
parentChangeDetail = null; | ||
@@ -189,8 +195,7 @@ } | ||
// NgObject属性本身无法触发变更,只有它的子节点才能触发,所以它上边的变更永远是Modify类型的。 | ||
var childPropName = paths[i + 2]; | ||
var childId = paths[i + 1].split(':')[1]; | ||
var childIdName = paths[i + 1].split(':')[0]; | ||
if (childIdName) { | ||
// 没有主键(关联对象):是一个普通的对象 | ||
var changeObject = parentChangeDetail.ChangeInfo[propName]; | ||
// 有主键(关联对象):是一个普通的对象 | ||
var changeObject = parentChangeInfo[propName]; | ||
if (!changeObject) { | ||
@@ -200,8 +205,8 @@ changeObject = {}; | ||
} | ||
changeObject[childPropName] = modification.value; | ||
parentChangeDetail.ChangeInfo[propName] = changeObject; | ||
parentChangeInfo[propName] = changeObject; | ||
parentChangeDetail = changeObject; | ||
} | ||
else { | ||
// 有主键(值对象):是一个完整的ChangeDetail | ||
var changeDetail = parentChangeDetail.ChangeInfo[propName]; | ||
// 没有主键(值对象):是一个完整的ChangeDetail | ||
var changeDetail = parentChangeInfo[propName]; | ||
if (!changeDetail) { | ||
@@ -213,8 +218,6 @@ changeDetail = { | ||
} | ||
changeDetail.ChangeInfo[childPropName] = modification.value; | ||
parentChangeDetail.ChangeInfo[propName] = changeDetail; | ||
parentChangeInfo[propName] = changeDetail; | ||
parentChangeDetail = changeDetail; | ||
} | ||
// BE中关联对象、值对象已经是最后一级,不需要再往后遍历 | ||
parentChangeDetail = null; | ||
parentEntityType = null; | ||
parentEntityType = propEntityType; | ||
} | ||
@@ -329,2 +332,19 @@ else if (propType === 'NgList') { | ||
/** | ||
* 获取变更信息 | ||
* 在整个ChangeDetail树上,存在两种类型的节点 | ||
* ChangeDetail:实体变更、值对象变更(没有DataID) | ||
* PlainObject: 关联对象的变更 | ||
* 从这两种节点上拿具体变更信息的时候,需要统一处理,屏蔽这个差异。 | ||
* @todo:为这两种节点封装ChangeNode基类来解决这个差异。 | ||
*/ | ||
BefChangeBuilder.prototype.getChangeInfo = function (changeDetail) { | ||
// @todo:可能存在同名属性 | ||
if (changeDetail.hasOwnProperty('ChangeInfo')) { | ||
return changeDetail.ChangeInfo; | ||
} | ||
else { | ||
return changeDetail; | ||
} | ||
}; | ||
/** | ||
* 创建ChangeDetail | ||
@@ -490,254 +510,2 @@ * @param type BEF变更类型 | ||
/* | ||
* @Author: Witt | ||
* @Date: 2018-10-12 14:43:49 | ||
* @Last Modified by: Witt | ||
* @Last Modified time: 2018-11-15 16:08:42 | ||
*/ | ||
var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata$2 = (undefined && undefined.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
/** | ||
* BEF取数服务 | ||
* 该服务由BefRepository实例化,不做注入,每个BefRepository拥有一个BefRestService实例。 | ||
*/ | ||
var BefRestService = /** @class */ (function () { | ||
/** | ||
* 构造函数 | ||
* @param httpClient http服务 | ||
* @param serverUri 应用服务器地址 | ||
* @param beUri BE API地址 | ||
*/ | ||
function BefRestService(httpClient, baseUri, frmSessionService) { | ||
this.httpClient = httpClient; | ||
this.baseUri = baseUri; | ||
this.sessionService = new BefSessionService(httpClient, baseUri, frmSessionService); | ||
} | ||
/** | ||
* 列表查询 | ||
* @return 数据数组 | ||
* @todo | ||
* 1、目前仅支持查询全部数据 | ||
*/ | ||
BefRestService.prototype.query = function (entityFilter) { | ||
var url = this.baseUri; | ||
if (entityFilter) { | ||
var entityFilterJson = JSON.stringify(entityFilter); | ||
url = url + "?entityFilter=" + entityFilterJson; | ||
} | ||
return this.request(url, 'GET'); | ||
}; | ||
/** | ||
* 数据检索 | ||
* @param id 单据内码 | ||
* @return 数据对象 | ||
*/ | ||
BefRestService.prototype.retrieve = function (id) { | ||
var url = this.baseUri + "/" + id; | ||
return this.request(url, 'GET'); | ||
}; | ||
/** | ||
* 创建一条数据 | ||
* @summary | ||
* 返回带默认值的空数据,服务器端该数据在BE缓存中,尚未保存到数据库 | ||
*/ | ||
BefRestService.prototype.create = function () { | ||
return this.request(this.baseUri, 'POST'); | ||
}; | ||
/** | ||
* 从表新增 | ||
* @path 新增路径(从表形如:/1/edus,从从表形如:/1/edus/11/grades) | ||
* @return | ||
*/ | ||
BefRestService.prototype.createByPath = function (fpath) { | ||
var pathUrl = this.convertPathToUrl(fpath); | ||
var url = "" + this.baseUri + pathUrl; | ||
return this.request(url, 'POST'); | ||
}; | ||
/** | ||
* 提交变更 | ||
* @summary | ||
* 此时变更提交的BE缓存中,等待保存,服务器端不返回任何数据 | ||
*/ | ||
BefRestService.prototype.update = function (changeDetail) { | ||
var optionsWithBody = this.addBody({}, changeDetail); | ||
return this.request(this.baseUri, 'PATCH', null, optionsWithBody); | ||
}; | ||
/** | ||
* 保存 | ||
* @summary | ||
* 通过此地方将BEF中的变更缓存应用到数据库中,服务器端不返回任何数据 | ||
*/ | ||
BefRestService.prototype.save = function () { | ||
return this.request(this.baseUri, 'PUT'); | ||
}; | ||
/** | ||
* 删除 | ||
*/ | ||
BefRestService.prototype.delete = function (id) { | ||
var url = this.baseUri + "/" + id; | ||
return this.request(url, 'DELETE'); | ||
}; | ||
/** | ||
* 删除后代 | ||
* @param fpath 父路径(从表形如:/1/edus,从从表形如:/1/edus/11/grades) | ||
*/ | ||
BefRestService.prototype.deletByPath = function (fpath, id) { | ||
var pathUrl = this.convertPathToUrl(fpath); | ||
var url = "" + this.baseUri + pathUrl + "/" + id; | ||
return this.request(url, 'DELETE'); | ||
}; | ||
/** | ||
* 批量删除 | ||
* @param ids 待删除的id数组 | ||
*/ | ||
BefRestService.prototype.batchDelete = function (ids) { | ||
var params = { | ||
ids: ids.join(',') | ||
}; | ||
return this.request(this.baseUri, 'DELETE', params); | ||
}; | ||
/** | ||
* 批量删除子表记录 | ||
* @param fpath 父路径 | ||
* @param ids 待删除的id数组 | ||
*/ | ||
BefRestService.prototype.batchDeleteByPath = function (fpath, ids) { | ||
throw new Error('Not Implemented'); | ||
}; | ||
/** | ||
* 取消 | ||
*/ | ||
BefRestService.prototype.cancel = function () { | ||
var url = this.baseUri + "/service/cancel"; | ||
return this.request(url, 'POST'); | ||
}; | ||
/** | ||
* 发送http请求 | ||
*/ | ||
BefRestService.prototype.request = function (url, method, params, options) { | ||
var _this = this; | ||
options = options || {}; | ||
// params | ||
if (params) { | ||
var httpParams = this.buildParams(params); | ||
options.params = httpParams; | ||
} | ||
// 串联session流和http流 | ||
return this.sessionService.getBeSessionId().pipe(switchMap.switchMap(function (sessionId) { | ||
if (options.headers) { | ||
options.headers = options.headers.append('SessionId', sessionId); | ||
} | ||
else { | ||
options.headers = new http.HttpHeaders({ 'SessionId': sessionId }); | ||
} | ||
return _this.httpClient.request(method, url, options); | ||
})); | ||
}; | ||
/** | ||
* 构造HttpParams对象 | ||
* @param params 请求参数 | ||
*/ | ||
BefRestService.prototype.buildParams = function (params) { | ||
var httpParams = new http.HttpParams(); | ||
for (var key in params) { | ||
if (params.hasOwnProperty(key)) { | ||
var value = params[key].toString(); | ||
httpParams = httpParams.append(key, value); | ||
} | ||
} | ||
return httpParams; | ||
}; | ||
/** | ||
* 向HttpOptions对象中添加body | ||
* @param options 原来的options | ||
* @param body body内容 | ||
*/ | ||
BefRestService.prototype.addBody = function (options, body) { | ||
options = options || {}; | ||
var mergedOptions = Object.assign(options, { body: body }); | ||
return mergedOptions; | ||
}; | ||
/** | ||
* 在devkit的路径中表名是属性名,是复数,在url中表名是单数 | ||
* 在此做兼容 | ||
* @todo:临时支持子表,应该支持无限层级 | ||
* fixed by justin: 每级属性名都去掉s | ||
*/ | ||
BefRestService.prototype.convertPathToUrl = function (path) { | ||
// return path.substring(0, path.length - 1); | ||
var subPaths = path.split('/'); | ||
for (var i = subPaths.length - 1; i > 0; i--) { | ||
if (subPaths[i] && subPaths[i].endsWith('s')) { | ||
subPaths[i] = subPaths[i].substr(0, subPaths[i].length - 1); | ||
} | ||
} | ||
return subPaths.join('/'); | ||
}; | ||
BefRestService = __decorate$2([ | ||
core.Injectable(), | ||
__metadata$2("design:paramtypes", [http.HttpClient, String, FrameworkSessionService]) | ||
], BefRestService); | ||
return BefRestService; | ||
}()); | ||
var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata$3 = (undefined && undefined.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
/** | ||
* 帮助Rest取数服务 | ||
*/ | ||
var BefLookupRestService = /** @class */ (function () { | ||
function BefLookupRestService(repository) { | ||
this.befRepository = repository; | ||
} | ||
BefLookupRestService.prototype.getData = function (helpMetadataId, data) { | ||
var tableName = helpMetadataId.split('.')[0]; | ||
var labelId = helpMetadataId.split('.')[1]; | ||
var url = this.befRepository.restService.baseUri + "/elementhelps/" + labelId; | ||
data = data || {}; | ||
return this.befRepository.restService.request(url, 'GET', { nodeCode: tableName, queryParam: JSON.stringify(data) }); | ||
}; | ||
BefLookupRestService.prototype.convert2TreeDataWithPathCode = function (data, layer, parentPathCode) { | ||
var _this = this; | ||
if (layer === void 0) { layer = 1; } | ||
if (parentPathCode === void 0) { parentPathCode = '01'; } | ||
var nodes = data.filter(function (d) { return d.layer === layer && d.pathcode === parentPathCode; }); | ||
if (layer > 1) { | ||
nodes = data.filter(function (d) { return d.layer === layer && d.pathcode.substr(0, (layer - 1) * 2) === parentPathCode; }); | ||
} | ||
if (nodes.length) { | ||
var treeNodes = nodes.map(function (n) { | ||
return { | ||
data: n, | ||
children: [] | ||
}; | ||
}); | ||
treeNodes.forEach(function (tn) { | ||
var _a; | ||
var _tns = _this.convert2TreeDataWithPathCode(data, tn.data.layer + 1, tn.data.pathcode); | ||
(_a = tn.children).push.apply(_a, _tns); | ||
}); | ||
return treeNodes; | ||
} | ||
}; | ||
BefLookupRestService = __decorate$3([ | ||
core.Injectable(), | ||
__metadata$3("design:paramtypes", [devkit.Repository]) | ||
], BefLookupRestService); | ||
return BefLookupRestService; | ||
}()); | ||
/* | ||
* @Author: Sagi, Lucas, Witt | ||
@@ -766,3 +534,3 @@ * @Date: 2018-10-11 17:34:26 | ||
})(); | ||
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
@@ -773,3 +541,3 @@ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
}; | ||
var __metadata$4 = (undefined && undefined.__metadata) || function (k, v) { | ||
var __metadata$2 = (undefined && undefined.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
@@ -793,3 +561,3 @@ }; | ||
var restBaseUri = serverUri + "/" + _this.apiUri; | ||
_this.restService = new BefRestService(httpClient, restBaseUri, frmSessionService); | ||
_this.restService = new BefRestService(httpClient, restBaseUri, frmSessionService, _this); | ||
// 创建BefChangeBuilder实例 | ||
@@ -891,14 +659,2 @@ _this.changeBuilder = new BefChangeBuilder(_this.entityType); | ||
BefRepository.prototype.lockById = function (id) { | ||
// const entity = this.entityCollection.getEntityById(id); | ||
// // 组织一个空变更 | ||
// const changeDetail = this.changeBuilder.build([]); | ||
// changeDetail.ChangeInfo.DataId = id; | ||
// // 提交变更 | ||
// const update$ = this.restService.update(changeDetail); | ||
// const result$ = update$.pipe( | ||
// map(() => { | ||
// return true; | ||
// }) | ||
// ); | ||
// return result$; | ||
return of.of(true); | ||
@@ -1184,5 +940,5 @@ }; | ||
}; | ||
BefRepository = __decorate$4([ | ||
BefRepository = __decorate$2([ | ||
core.Injectable(), | ||
__metadata$4("design:paramtypes", [core.Injector]) | ||
__metadata$2("design:paramtypes", [core.Injector]) | ||
], BefRepository); | ||
@@ -1192,2 +948,271 @@ return BefRepository; | ||
/* | ||
* @Author: Witt | ||
* @Date: 2018-10-12 14:43:49 | ||
* @Last Modified by: Witt | ||
* @Last Modified time: 2018-11-15 16:08:42 | ||
*/ | ||
var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata$3 = (undefined && undefined.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
/** | ||
* BEF取数服务 | ||
* 该服务由BefRepository实例化,不做注入,每个BefRepository拥有一个BefRestService实例。 | ||
*/ | ||
var BefRestService = /** @class */ (function () { | ||
/** | ||
* 构造函数 | ||
* @param httpClient http服务 | ||
* @param serverUri 应用服务器地址 | ||
* @param beUri BE API地址 | ||
*/ | ||
function BefRestService(httpClient, baseUri, frmSessionService, repository) { | ||
this.httpClient = httpClient; | ||
this.baseUri = baseUri; | ||
this.sessionService = new BefSessionService(httpClient, baseUri, frmSessionService); | ||
this.repository = repository; | ||
} | ||
/** | ||
* 列表查询 | ||
* @return 数据数组 | ||
* @todo | ||
* 1、目前仅支持查询全部数据 | ||
*/ | ||
BefRestService.prototype.query = function (entityFilter) { | ||
var url = this.baseUri; | ||
if (entityFilter) { | ||
var entityFilterJson = JSON.stringify(entityFilter); | ||
url = url + "?entityFilter=" + entityFilterJson; | ||
} | ||
return this.request(url, 'GET'); | ||
}; | ||
/** | ||
* 数据检索 | ||
* @param id 单据内码 | ||
* @return 数据对象 | ||
*/ | ||
BefRestService.prototype.retrieve = function (id) { | ||
var url = this.baseUri + "/" + id; | ||
return this.request(url, 'GET'); | ||
}; | ||
/** | ||
* 创建一条数据 | ||
* @summary | ||
* 返回带默认值的空数据,服务器端该数据在BE缓存中,尚未保存到数据库 | ||
*/ | ||
BefRestService.prototype.create = function () { | ||
return this.request(this.baseUri, 'POST'); | ||
}; | ||
/** | ||
* 从表新增 | ||
* @path 新增路径(从表形如:/1/edus,从从表形如:/1/edus/11/grades) | ||
* @return | ||
*/ | ||
BefRestService.prototype.createByPath = function (fpath) { | ||
var pathUrl = this.convertPathToUrl(fpath); | ||
var url = "" + this.baseUri + pathUrl; | ||
return this.request(url, 'POST'); | ||
}; | ||
/** | ||
* 提交变更 | ||
* @summary | ||
* 此时变更提交的BE缓存中,等待保存,服务器端不返回任何数据 | ||
*/ | ||
BefRestService.prototype.update = function (changeDetail) { | ||
var optionsWithBody = this.addBody({}, changeDetail); | ||
return this.innerRequest(this.baseUri, 'PATCH', null, optionsWithBody); | ||
}; | ||
/** | ||
* 保存 | ||
* @summary | ||
* 通过此地方将BEF中的变更缓存应用到数据库中,服务器端不返回任何数据 | ||
*/ | ||
BefRestService.prototype.save = function () { | ||
return this.innerRequest(this.baseUri, 'PUT'); | ||
}; | ||
/** | ||
* 删除 | ||
*/ | ||
BefRestService.prototype.delete = function (id) { | ||
var url = this.baseUri + "/" + id; | ||
return this.request(url, 'DELETE'); | ||
}; | ||
/** | ||
* 删除后代 | ||
* @param fpath 父路径(从表形如:/1/edus,从从表形如:/1/edus/11/grades) | ||
*/ | ||
BefRestService.prototype.deletByPath = function (fpath, id) { | ||
var pathUrl = this.convertPathToUrl(fpath); | ||
var url = "" + this.baseUri + pathUrl + "/" + id; | ||
return this.request(url, 'DELETE'); | ||
}; | ||
/** | ||
* 批量删除 | ||
* @param ids 待删除的id数组 | ||
*/ | ||
BefRestService.prototype.batchDelete = function (ids) { | ||
var params = { | ||
ids: ids.join(',') | ||
}; | ||
return this.request(this.baseUri, 'DELETE', params); | ||
}; | ||
/** | ||
* 批量删除子表记录 | ||
* @param fpath 父路径 | ||
* @param ids 待删除的id数组 | ||
*/ | ||
BefRestService.prototype.batchDeleteByPath = function (fpath, ids) { | ||
throw new Error('Not Implemented'); | ||
}; | ||
/** | ||
* 取消 | ||
*/ | ||
BefRestService.prototype.cancel = function () { | ||
var url = this.baseUri + "/service/cancel"; | ||
return this.request(url, 'POST'); | ||
}; | ||
/** | ||
* 发送http请求 | ||
*/ | ||
BefRestService.prototype.request = function (url, method, params, options) { | ||
var _this = this; | ||
if (method !== 'GET') { | ||
return this.repository.updateAllChanges().pipe(switchMap.switchMap(function () { | ||
return _this.innerRequest(url, method, params, options); | ||
})); | ||
} | ||
else { | ||
return this.innerRequest(url, method, params, options); | ||
} | ||
}; | ||
/** | ||
* 发送http请求(请勿使用) | ||
* @internal | ||
*/ | ||
BefRestService.prototype.innerRequest = function (url, method, params, options) { | ||
var _this = this; | ||
options = options || {}; | ||
// params | ||
if (params) { | ||
var httpParams = this.buildParams(params); | ||
options.params = httpParams; | ||
} | ||
// 串联session流和http流 | ||
return this.sessionService.getBeSessionId().pipe(switchMap.switchMap(function (sessionId) { | ||
if (options.headers) { | ||
options.headers = options.headers.append('SessionId', sessionId); | ||
} | ||
else { | ||
options.headers = new http.HttpHeaders({ 'SessionId': sessionId }); | ||
} | ||
return _this.httpClient.request(method, url, options); | ||
})); | ||
}; | ||
/** | ||
* 构造HttpParams对象 | ||
* @param params 请求参数 | ||
*/ | ||
BefRestService.prototype.buildParams = function (params) { | ||
var httpParams = new http.HttpParams(); | ||
for (var key in params) { | ||
if (params.hasOwnProperty(key)) { | ||
var value = params[key].toString(); | ||
httpParams = httpParams.append(key, value); | ||
} | ||
} | ||
return httpParams; | ||
}; | ||
/** | ||
* 向HttpOptions对象中添加body | ||
* @param options 原来的options | ||
* @param body body内容 | ||
*/ | ||
BefRestService.prototype.addBody = function (options, body) { | ||
options = options || {}; | ||
var mergedOptions = Object.assign(options, { body: body }); | ||
return mergedOptions; | ||
}; | ||
/** | ||
* 在devkit的路径中表名是属性名,是复数,在url中表名是单数 | ||
* 在此做兼容 | ||
* @todo:临时支持子表,应该支持无限层级 | ||
* fixed by justin: 每级属性名都去掉s | ||
*/ | ||
BefRestService.prototype.convertPathToUrl = function (path) { | ||
// return path.substring(0, path.length - 1); | ||
var subPaths = path.split('/'); | ||
for (var i = subPaths.length - 1; i > 0; i--) { | ||
if (subPaths[i] && subPaths[i].endsWith('s')) { | ||
subPaths[i] = subPaths[i].substr(0, subPaths[i].length - 1); | ||
} | ||
} | ||
return subPaths.join('/'); | ||
}; | ||
BefRestService = __decorate$3([ | ||
core.Injectable(), | ||
__metadata$3("design:paramtypes", [http.HttpClient, String, FrameworkSessionService, | ||
BefRepository]) | ||
], BefRestService); | ||
return BefRestService; | ||
}()); | ||
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata$4 = (undefined && undefined.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
/** | ||
* 帮助Rest取数服务 | ||
*/ | ||
var BefLookupRestService = /** @class */ (function () { | ||
function BefLookupRestService(repository) { | ||
this.befRepository = repository; | ||
} | ||
BefLookupRestService.prototype.getData = function (helpMetadataId, data) { | ||
var tableName = helpMetadataId.split('.')[0]; | ||
var labelId = helpMetadataId.split('.')[1]; | ||
var url = this.befRepository.restService.baseUri + "/elementhelps/" + labelId; | ||
data = data || {}; | ||
return this.befRepository.restService.request(url, 'GET', { nodeCode: tableName, queryParam: JSON.stringify(data) }); | ||
}; | ||
BefLookupRestService.prototype.convert2TreeDataWithPathCode = function (data, layer, parentPathCode) { | ||
var _this = this; | ||
if (layer === void 0) { layer = 1; } | ||
if (parentPathCode === void 0) { parentPathCode = '01'; } | ||
var nodes = data.filter(function (d) { return d.layer === layer && d.pathcode === parentPathCode; }); | ||
if (layer > 1) { | ||
nodes = data.filter(function (d) { return d.layer === layer && d.pathcode.substr(0, (layer - 1) * 2) === parentPathCode; }); | ||
} | ||
if (nodes.length) { | ||
var treeNodes = nodes.map(function (n) { | ||
return { | ||
data: n, | ||
children: [] | ||
}; | ||
}); | ||
treeNodes.forEach(function (tn) { | ||
var _a; | ||
var _tns = _this.convert2TreeDataWithPathCode(data, tn.data.layer + 1, tn.data.pathcode); | ||
(_a = tn.children).push.apply(_a, _tns); | ||
}); | ||
return treeNodes; | ||
} | ||
}; | ||
BefLookupRestService = __decorate$4([ | ||
core.Injectable(), | ||
__metadata$4("design:paramtypes", [devkit.Repository]) | ||
], BefLookupRestService); | ||
return BefLookupRestService; | ||
}()); | ||
exports.ChangeDetail = ChangeDetail; | ||
@@ -1194,0 +1219,0 @@ exports.BE_SERVER_URI_TOKEN = BE_SERVER_URI_TOKEN; |
import { InjectionToken, Injectable, Injector } from '@angular/core'; | ||
import { FieldMetadataUtil, ModifyType, Repository, EntityFactory } from '@farris/devkit'; | ||
import { FieldMetadataUtil, ModifyType, EntityFactory, Repository } from '@farris/devkit'; | ||
import { CacheService } from '@ecp-caf/caf-common'; | ||
@@ -7,5 +7,5 @@ import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; | ||
import { tap } from 'rxjs/operators/tap'; | ||
import { switchMap } from 'rxjs/operators/switchMap'; | ||
import { zip } from 'rxjs/observable/zip'; | ||
import { map } from 'rxjs/operators/map'; | ||
import { switchMap } from 'rxjs/operators/switchMap'; | ||
@@ -101,3 +101,8 @@ /* | ||
const primaryNgFiledProp = FieldMetadataUtil.getPrimaryFieldMetadata(entityType); | ||
return primaryNgFiledProp.dataField; | ||
if (primaryNgFiledProp) { | ||
return primaryNgFiledProp.dataField; | ||
} | ||
else { | ||
return ''; | ||
} | ||
} | ||
@@ -151,3 +156,3 @@ /** | ||
}); | ||
console.log(this.changeDetail); | ||
// console.log(this.changeDetail); | ||
return this.changeDetail; | ||
@@ -167,2 +172,3 @@ } | ||
for (let i = 1; i < paths.length && parentChangeDetail; i = i + 2) { | ||
const parentChangeInfo = this.getChangeInfo(parentChangeDetail); | ||
const propName = paths[i]; | ||
@@ -180,3 +186,3 @@ const { propType, propEntityType } = EntityUtil.getPropInfo(parentEntityType, propName); | ||
// NgField类型:说明是最后一级 | ||
parentChangeDetail.ChangeInfo[propName] = modification.value; | ||
parentChangeInfo[propName] = modification.value; | ||
parentChangeDetail = null; | ||
@@ -186,8 +192,7 @@ } | ||
// NgObject属性本身无法触发变更,只有它的子节点才能触发,所以它上边的变更永远是Modify类型的。 | ||
const childPropName = paths[i + 2]; | ||
const childId = paths[i + 1].split(':')[1]; | ||
const childIdName = paths[i + 1].split(':')[0]; | ||
if (childIdName) { | ||
// 没有主键(关联对象):是一个普通的对象 | ||
let changeObject = parentChangeDetail.ChangeInfo[propName]; | ||
// 有主键(关联对象):是一个普通的对象 | ||
let changeObject = parentChangeInfo[propName]; | ||
if (!changeObject) { | ||
@@ -197,8 +202,8 @@ changeObject = {}; | ||
} | ||
changeObject[childPropName] = modification.value; | ||
parentChangeDetail.ChangeInfo[propName] = changeObject; | ||
parentChangeInfo[propName] = changeObject; | ||
parentChangeDetail = changeObject; | ||
} | ||
else { | ||
// 有主键(值对象):是一个完整的ChangeDetail | ||
let changeDetail = parentChangeDetail.ChangeInfo[propName]; | ||
// 没有主键(值对象):是一个完整的ChangeDetail | ||
let changeDetail = parentChangeInfo[propName]; | ||
if (!changeDetail) { | ||
@@ -210,8 +215,6 @@ changeDetail = { | ||
} | ||
changeDetail.ChangeInfo[childPropName] = modification.value; | ||
parentChangeDetail.ChangeInfo[propName] = changeDetail; | ||
parentChangeInfo[propName] = changeDetail; | ||
parentChangeDetail = changeDetail; | ||
} | ||
// BE中关联对象、值对象已经是最后一级,不需要再往后遍历 | ||
parentChangeDetail = null; | ||
parentEntityType = null; | ||
parentEntityType = propEntityType; | ||
} | ||
@@ -322,2 +325,19 @@ else if (propType === 'NgList') { | ||
/** | ||
* 获取变更信息 | ||
* 在整个ChangeDetail树上,存在两种类型的节点 | ||
* ChangeDetail:实体变更、值对象变更(没有DataID) | ||
* PlainObject: 关联对象的变更 | ||
* 从这两种节点上拿具体变更信息的时候,需要统一处理,屏蔽这个差异。 | ||
* @todo:为这两种节点封装ChangeNode基类来解决这个差异。 | ||
*/ | ||
getChangeInfo(changeDetail) { | ||
// @todo:可能存在同名属性 | ||
if (changeDetail.hasOwnProperty('ChangeInfo')) { | ||
return changeDetail.ChangeInfo; | ||
} | ||
else { | ||
return changeDetail; | ||
} | ||
} | ||
/** | ||
* 创建ChangeDetail | ||
@@ -479,247 +499,2 @@ * @param type BEF变更类型 | ||
/* | ||
* @Author: Witt | ||
* @Date: 2018-10-12 14:43:49 | ||
* @Last Modified by: Witt | ||
* @Last Modified time: 2018-11-15 16:08:42 | ||
*/ | ||
var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata$2 = (undefined && undefined.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
/** | ||
* BEF取数服务 | ||
* 该服务由BefRepository实例化,不做注入,每个BefRepository拥有一个BefRestService实例。 | ||
*/ | ||
let BefRestService = class BefRestService { | ||
/** | ||
* 构造函数 | ||
* @param httpClient http服务 | ||
* @param serverUri 应用服务器地址 | ||
* @param beUri BE API地址 | ||
*/ | ||
constructor(httpClient, baseUri, frmSessionService) { | ||
this.httpClient = httpClient; | ||
this.baseUri = baseUri; | ||
this.sessionService = new BefSessionService(httpClient, baseUri, frmSessionService); | ||
} | ||
/** | ||
* 列表查询 | ||
* @return 数据数组 | ||
* @todo | ||
* 1、目前仅支持查询全部数据 | ||
*/ | ||
query(entityFilter) { | ||
let url = this.baseUri; | ||
if (entityFilter) { | ||
const entityFilterJson = JSON.stringify(entityFilter); | ||
url = `${url}?entityFilter=${entityFilterJson}`; | ||
} | ||
return this.request(url, 'GET'); | ||
} | ||
/** | ||
* 数据检索 | ||
* @param id 单据内码 | ||
* @return 数据对象 | ||
*/ | ||
retrieve(id) { | ||
const url = `${this.baseUri}/${id}`; | ||
return this.request(url, 'GET'); | ||
} | ||
/** | ||
* 创建一条数据 | ||
* @summary | ||
* 返回带默认值的空数据,服务器端该数据在BE缓存中,尚未保存到数据库 | ||
*/ | ||
create() { | ||
return this.request(this.baseUri, 'POST'); | ||
} | ||
/** | ||
* 从表新增 | ||
* @path 新增路径(从表形如:/1/edus,从从表形如:/1/edus/11/grades) | ||
* @return | ||
*/ | ||
createByPath(fpath) { | ||
const pathUrl = this.convertPathToUrl(fpath); | ||
const url = `${this.baseUri}${pathUrl}`; | ||
return this.request(url, 'POST'); | ||
} | ||
/** | ||
* 提交变更 | ||
* @summary | ||
* 此时变更提交的BE缓存中,等待保存,服务器端不返回任何数据 | ||
*/ | ||
update(changeDetail) { | ||
const optionsWithBody = this.addBody({}, changeDetail); | ||
return this.request(this.baseUri, 'PATCH', null, optionsWithBody); | ||
} | ||
/** | ||
* 保存 | ||
* @summary | ||
* 通过此地方将BEF中的变更缓存应用到数据库中,服务器端不返回任何数据 | ||
*/ | ||
save() { | ||
return this.request(this.baseUri, 'PUT'); | ||
} | ||
/** | ||
* 删除 | ||
*/ | ||
delete(id) { | ||
const url = `${this.baseUri}/${id}`; | ||
return this.request(url, 'DELETE'); | ||
} | ||
/** | ||
* 删除后代 | ||
* @param fpath 父路径(从表形如:/1/edus,从从表形如:/1/edus/11/grades) | ||
*/ | ||
deletByPath(fpath, id) { | ||
const pathUrl = this.convertPathToUrl(fpath); | ||
const url = `${this.baseUri}${pathUrl}/${id}`; | ||
return this.request(url, 'DELETE'); | ||
} | ||
/** | ||
* 批量删除 | ||
* @param ids 待删除的id数组 | ||
*/ | ||
batchDelete(ids) { | ||
const params = { | ||
ids: ids.join(',') | ||
}; | ||
return this.request(this.baseUri, 'DELETE', params); | ||
} | ||
/** | ||
* 批量删除子表记录 | ||
* @param fpath 父路径 | ||
* @param ids 待删除的id数组 | ||
*/ | ||
batchDeleteByPath(fpath, ids) { | ||
throw new Error('Not Implemented'); | ||
} | ||
/** | ||
* 取消 | ||
*/ | ||
cancel() { | ||
const url = `${this.baseUri}/service/cancel`; | ||
return this.request(url, 'POST'); | ||
} | ||
/** | ||
* 发送http请求 | ||
*/ | ||
request(url, method, params, options) { | ||
options = options || {}; | ||
// params | ||
if (params) { | ||
const httpParams = this.buildParams(params); | ||
options.params = httpParams; | ||
} | ||
// 串联session流和http流 | ||
return this.sessionService.getBeSessionId().pipe(switchMap((sessionId) => { | ||
if (options.headers) { | ||
options.headers = options.headers.append('SessionId', sessionId); | ||
} | ||
else { | ||
options.headers = new HttpHeaders({ 'SessionId': sessionId }); | ||
} | ||
return this.httpClient.request(method, url, options); | ||
})); | ||
} | ||
/** | ||
* 构造HttpParams对象 | ||
* @param params 请求参数 | ||
*/ | ||
buildParams(params) { | ||
let httpParams = new HttpParams(); | ||
for (const key in params) { | ||
if (params.hasOwnProperty(key)) { | ||
const value = params[key].toString(); | ||
httpParams = httpParams.append(key, value); | ||
} | ||
} | ||
return httpParams; | ||
} | ||
/** | ||
* 向HttpOptions对象中添加body | ||
* @param options 原来的options | ||
* @param body body内容 | ||
*/ | ||
addBody(options, body) { | ||
options = options || {}; | ||
const mergedOptions = Object.assign(options, { body: body }); | ||
return mergedOptions; | ||
} | ||
/** | ||
* 在devkit的路径中表名是属性名,是复数,在url中表名是单数 | ||
* 在此做兼容 | ||
* @todo:临时支持子表,应该支持无限层级 | ||
* fixed by justin: 每级属性名都去掉s | ||
*/ | ||
convertPathToUrl(path) { | ||
// return path.substring(0, path.length - 1); | ||
const subPaths = path.split('/'); | ||
for (let i = subPaths.length - 1; i > 0; i--) { | ||
if (subPaths[i] && subPaths[i].endsWith('s')) { | ||
subPaths[i] = subPaths[i].substr(0, subPaths[i].length - 1); | ||
} | ||
} | ||
return subPaths.join('/'); | ||
} | ||
}; | ||
BefRestService = __decorate$2([ | ||
Injectable(), | ||
__metadata$2("design:paramtypes", [HttpClient, String, FrameworkSessionService]) | ||
], BefRestService); | ||
var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata$3 = (undefined && undefined.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
/** | ||
* 帮助Rest取数服务 | ||
*/ | ||
let BefLookupRestService = class BefLookupRestService { | ||
constructor(repository) { | ||
this.befRepository = repository; | ||
} | ||
getData(helpMetadataId, data) { | ||
const tableName = helpMetadataId.split('.')[0]; | ||
const labelId = helpMetadataId.split('.')[1]; | ||
const url = `${this.befRepository.restService.baseUri}/elementhelps/${labelId}`; | ||
data = data || {}; | ||
return this.befRepository.restService.request(url, 'GET', { nodeCode: tableName, queryParam: JSON.stringify(data) }); | ||
} | ||
convert2TreeDataWithPathCode(data, layer = 1, parentPathCode = '01') { | ||
let nodes = data.filter(d => d.layer === layer && d.pathcode === parentPathCode); | ||
if (layer > 1) { | ||
nodes = data.filter(d => d.layer === layer && d.pathcode.substr(0, (layer - 1) * 2) === parentPathCode); | ||
} | ||
if (nodes.length) { | ||
const treeNodes = nodes.map(n => { | ||
return { | ||
data: n, | ||
children: [] | ||
}; | ||
}); | ||
treeNodes.forEach(tn => { | ||
const _tns = this.convert2TreeDataWithPathCode(data, tn.data.layer + 1, tn.data.pathcode); | ||
tn.children.push(..._tns); | ||
}); | ||
return treeNodes; | ||
} | ||
} | ||
}; | ||
BefLookupRestService = __decorate$3([ | ||
Injectable(), | ||
__metadata$3("design:paramtypes", [Repository]) | ||
], BefLookupRestService); | ||
/* | ||
* @Author: Sagi, Lucas, Witt | ||
@@ -738,3 +513,3 @@ * @Date: 2018-10-11 17:34:26 | ||
*/ | ||
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
@@ -745,3 +520,3 @@ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
}; | ||
var __metadata$4 = (undefined && undefined.__metadata) || function (k, v) { | ||
var __metadata$2 = (undefined && undefined.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
@@ -764,3 +539,3 @@ }; | ||
const restBaseUri = `${serverUri}/${this.apiUri}`; | ||
this.restService = new BefRestService(httpClient, restBaseUri, frmSessionService); | ||
this.restService = new BefRestService(httpClient, restBaseUri, frmSessionService, this); | ||
// 创建BefChangeBuilder实例 | ||
@@ -857,14 +632,2 @@ this.changeBuilder = new BefChangeBuilder(this.entityType); | ||
lockById(id) { | ||
// const entity = this.entityCollection.getEntityById(id); | ||
// // 组织一个空变更 | ||
// const changeDetail = this.changeBuilder.build([]); | ||
// changeDetail.ChangeInfo.DataId = id; | ||
// // 提交变更 | ||
// const update$ = this.restService.update(changeDetail); | ||
// const result$ = update$.pipe( | ||
// map(() => { | ||
// return true; | ||
// }) | ||
// ); | ||
// return result$; | ||
return of(true); | ||
@@ -1142,8 +905,269 @@ } | ||
}; | ||
BefRepository = __decorate$4([ | ||
BefRepository = __decorate$2([ | ||
Injectable(), | ||
__metadata$4("design:paramtypes", [Injector]) | ||
__metadata$2("design:paramtypes", [Injector]) | ||
], BefRepository); | ||
/* | ||
* @Author: Witt | ||
* @Date: 2018-10-12 14:43:49 | ||
* @Last Modified by: Witt | ||
* @Last Modified time: 2018-11-15 16:08:42 | ||
*/ | ||
var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata$3 = (undefined && undefined.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
/** | ||
* BEF取数服务 | ||
* 该服务由BefRepository实例化,不做注入,每个BefRepository拥有一个BefRestService实例。 | ||
*/ | ||
let BefRestService = class BefRestService { | ||
/** | ||
* 构造函数 | ||
* @param httpClient http服务 | ||
* @param serverUri 应用服务器地址 | ||
* @param beUri BE API地址 | ||
*/ | ||
constructor(httpClient, baseUri, frmSessionService, repository) { | ||
this.httpClient = httpClient; | ||
this.baseUri = baseUri; | ||
this.sessionService = new BefSessionService(httpClient, baseUri, frmSessionService); | ||
this.repository = repository; | ||
} | ||
/** | ||
* 列表查询 | ||
* @return 数据数组 | ||
* @todo | ||
* 1、目前仅支持查询全部数据 | ||
*/ | ||
query(entityFilter) { | ||
let url = this.baseUri; | ||
if (entityFilter) { | ||
const entityFilterJson = JSON.stringify(entityFilter); | ||
url = `${url}?entityFilter=${entityFilterJson}`; | ||
} | ||
return this.request(url, 'GET'); | ||
} | ||
/** | ||
* 数据检索 | ||
* @param id 单据内码 | ||
* @return 数据对象 | ||
*/ | ||
retrieve(id) { | ||
const url = `${this.baseUri}/${id}`; | ||
return this.request(url, 'GET'); | ||
} | ||
/** | ||
* 创建一条数据 | ||
* @summary | ||
* 返回带默认值的空数据,服务器端该数据在BE缓存中,尚未保存到数据库 | ||
*/ | ||
create() { | ||
return this.request(this.baseUri, 'POST'); | ||
} | ||
/** | ||
* 从表新增 | ||
* @path 新增路径(从表形如:/1/edus,从从表形如:/1/edus/11/grades) | ||
* @return | ||
*/ | ||
createByPath(fpath) { | ||
const pathUrl = this.convertPathToUrl(fpath); | ||
const url = `${this.baseUri}${pathUrl}`; | ||
return this.request(url, 'POST'); | ||
} | ||
/** | ||
* 提交变更 | ||
* @summary | ||
* 此时变更提交的BE缓存中,等待保存,服务器端不返回任何数据 | ||
*/ | ||
update(changeDetail) { | ||
const optionsWithBody = this.addBody({}, changeDetail); | ||
return this.innerRequest(this.baseUri, 'PATCH', null, optionsWithBody); | ||
} | ||
/** | ||
* 保存 | ||
* @summary | ||
* 通过此地方将BEF中的变更缓存应用到数据库中,服务器端不返回任何数据 | ||
*/ | ||
save() { | ||
return this.innerRequest(this.baseUri, 'PUT'); | ||
} | ||
/** | ||
* 删除 | ||
*/ | ||
delete(id) { | ||
const url = `${this.baseUri}/${id}`; | ||
return this.request(url, 'DELETE'); | ||
} | ||
/** | ||
* 删除后代 | ||
* @param fpath 父路径(从表形如:/1/edus,从从表形如:/1/edus/11/grades) | ||
*/ | ||
deletByPath(fpath, id) { | ||
const pathUrl = this.convertPathToUrl(fpath); | ||
const url = `${this.baseUri}${pathUrl}/${id}`; | ||
return this.request(url, 'DELETE'); | ||
} | ||
/** | ||
* 批量删除 | ||
* @param ids 待删除的id数组 | ||
*/ | ||
batchDelete(ids) { | ||
const params = { | ||
ids: ids.join(',') | ||
}; | ||
return this.request(this.baseUri, 'DELETE', params); | ||
} | ||
/** | ||
* 批量删除子表记录 | ||
* @param fpath 父路径 | ||
* @param ids 待删除的id数组 | ||
*/ | ||
batchDeleteByPath(fpath, ids) { | ||
throw new Error('Not Implemented'); | ||
} | ||
/** | ||
* 取消 | ||
*/ | ||
cancel() { | ||
const url = `${this.baseUri}/service/cancel`; | ||
return this.request(url, 'POST'); | ||
} | ||
/** | ||
* 发送http请求 | ||
*/ | ||
request(url, method, params, options) { | ||
if (method !== 'GET') { | ||
return this.repository.updateAllChanges().pipe(switchMap(() => { | ||
return this.innerRequest(url, method, params, options); | ||
})); | ||
} | ||
else { | ||
return this.innerRequest(url, method, params, options); | ||
} | ||
} | ||
/** | ||
* 发送http请求(请勿使用) | ||
* @internal | ||
*/ | ||
innerRequest(url, method, params, options) { | ||
options = options || {}; | ||
// params | ||
if (params) { | ||
const httpParams = this.buildParams(params); | ||
options.params = httpParams; | ||
} | ||
// 串联session流和http流 | ||
return this.sessionService.getBeSessionId().pipe(switchMap((sessionId) => { | ||
if (options.headers) { | ||
options.headers = options.headers.append('SessionId', sessionId); | ||
} | ||
else { | ||
options.headers = new HttpHeaders({ 'SessionId': sessionId }); | ||
} | ||
return this.httpClient.request(method, url, options); | ||
})); | ||
} | ||
/** | ||
* 构造HttpParams对象 | ||
* @param params 请求参数 | ||
*/ | ||
buildParams(params) { | ||
let httpParams = new HttpParams(); | ||
for (const key in params) { | ||
if (params.hasOwnProperty(key)) { | ||
const value = params[key].toString(); | ||
httpParams = httpParams.append(key, value); | ||
} | ||
} | ||
return httpParams; | ||
} | ||
/** | ||
* 向HttpOptions对象中添加body | ||
* @param options 原来的options | ||
* @param body body内容 | ||
*/ | ||
addBody(options, body) { | ||
options = options || {}; | ||
const mergedOptions = Object.assign(options, { body: body }); | ||
return mergedOptions; | ||
} | ||
/** | ||
* 在devkit的路径中表名是属性名,是复数,在url中表名是单数 | ||
* 在此做兼容 | ||
* @todo:临时支持子表,应该支持无限层级 | ||
* fixed by justin: 每级属性名都去掉s | ||
*/ | ||
convertPathToUrl(path) { | ||
// return path.substring(0, path.length - 1); | ||
const subPaths = path.split('/'); | ||
for (let i = subPaths.length - 1; i > 0; i--) { | ||
if (subPaths[i] && subPaths[i].endsWith('s')) { | ||
subPaths[i] = subPaths[i].substr(0, subPaths[i].length - 1); | ||
} | ||
} | ||
return subPaths.join('/'); | ||
} | ||
}; | ||
BefRestService = __decorate$3([ | ||
Injectable(), | ||
__metadata$3("design:paramtypes", [HttpClient, String, FrameworkSessionService, | ||
BefRepository]) | ||
], BefRestService); | ||
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata$4 = (undefined && undefined.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
/** | ||
* 帮助Rest取数服务 | ||
*/ | ||
let BefLookupRestService = class BefLookupRestService { | ||
constructor(repository) { | ||
this.befRepository = repository; | ||
} | ||
getData(helpMetadataId, data) { | ||
const tableName = helpMetadataId.split('.')[0]; | ||
const labelId = helpMetadataId.split('.')[1]; | ||
const url = `${this.befRepository.restService.baseUri}/elementhelps/${labelId}`; | ||
data = data || {}; | ||
return this.befRepository.restService.request(url, 'GET', { nodeCode: tableName, queryParam: JSON.stringify(data) }); | ||
} | ||
convert2TreeDataWithPathCode(data, layer = 1, parentPathCode = '01') { | ||
let nodes = data.filter(d => d.layer === layer && d.pathcode === parentPathCode); | ||
if (layer > 1) { | ||
nodes = data.filter(d => d.layer === layer && d.pathcode.substr(0, (layer - 1) * 2) === parentPathCode); | ||
} | ||
if (nodes.length) { | ||
const treeNodes = nodes.map(n => { | ||
return { | ||
data: n, | ||
children: [] | ||
}; | ||
}); | ||
treeNodes.forEach(tn => { | ||
const _tns = this.convert2TreeDataWithPathCode(data, tn.data.layer + 1, tn.data.pathcode); | ||
tn.children.push(..._tns); | ||
}); | ||
return treeNodes; | ||
} | ||
} | ||
}; | ||
BefLookupRestService = __decorate$4([ | ||
Injectable(), | ||
__metadata$4("design:paramtypes", [Repository]) | ||
], BefLookupRestService); | ||
export { ChangeDetailType, ChangeDetail, BE_SERVER_URI_TOKEN, BefChangeBuilder, BefSessionService, BefRestService, BefLookupRestService, BefRepository, FrameworkSessionService }; | ||
//# sourceMappingURL=index.bundle.js.map |
import { InjectionToken, Injectable, Injector } from '@angular/core'; | ||
import { FieldMetadataUtil, ModifyType, Repository, EntityFactory } from '@farris/devkit'; | ||
import { FieldMetadataUtil, ModifyType, EntityFactory, Repository } from '@farris/devkit'; | ||
import { CacheService } from '@ecp-caf/caf-common'; | ||
@@ -7,5 +7,5 @@ import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; | ||
import { tap } from 'rxjs/operators/tap'; | ||
import { switchMap } from 'rxjs/operators/switchMap'; | ||
import { zip } from 'rxjs/observable/zip'; | ||
import { map } from 'rxjs/operators/map'; | ||
import { switchMap } from 'rxjs/operators/switchMap'; | ||
@@ -106,3 +106,8 @@ /* | ||
var primaryNgFiledProp = FieldMetadataUtil.getPrimaryFieldMetadata(entityType); | ||
return primaryNgFiledProp.dataField; | ||
if (primaryNgFiledProp) { | ||
return primaryNgFiledProp.dataField; | ||
} | ||
else { | ||
return ''; | ||
} | ||
}; | ||
@@ -158,3 +163,3 @@ /** | ||
}); | ||
console.log(this.changeDetail); | ||
// console.log(this.changeDetail); | ||
return this.changeDetail; | ||
@@ -175,2 +180,3 @@ }; | ||
var _loop_1 = function (i) { | ||
var parentChangeInfo = this_1.getChangeInfo(parentChangeDetail); | ||
var propName = paths[i]; | ||
@@ -188,3 +194,3 @@ var _a = EntityUtil.getPropInfo(parentEntityType, propName), propType = _a.propType, propEntityType = _a.propEntityType; | ||
// NgField类型:说明是最后一级 | ||
parentChangeDetail.ChangeInfo[propName] = modification.value; | ||
parentChangeInfo[propName] = modification.value; | ||
parentChangeDetail = null; | ||
@@ -194,8 +200,7 @@ } | ||
// NgObject属性本身无法触发变更,只有它的子节点才能触发,所以它上边的变更永远是Modify类型的。 | ||
var childPropName = paths[i + 2]; | ||
var childId = paths[i + 1].split(':')[1]; | ||
var childIdName = paths[i + 1].split(':')[0]; | ||
if (childIdName) { | ||
// 没有主键(关联对象):是一个普通的对象 | ||
var changeObject = parentChangeDetail.ChangeInfo[propName]; | ||
// 有主键(关联对象):是一个普通的对象 | ||
var changeObject = parentChangeInfo[propName]; | ||
if (!changeObject) { | ||
@@ -205,8 +210,8 @@ changeObject = {}; | ||
} | ||
changeObject[childPropName] = modification.value; | ||
parentChangeDetail.ChangeInfo[propName] = changeObject; | ||
parentChangeInfo[propName] = changeObject; | ||
parentChangeDetail = changeObject; | ||
} | ||
else { | ||
// 有主键(值对象):是一个完整的ChangeDetail | ||
var changeDetail = parentChangeDetail.ChangeInfo[propName]; | ||
// 没有主键(值对象):是一个完整的ChangeDetail | ||
var changeDetail = parentChangeInfo[propName]; | ||
if (!changeDetail) { | ||
@@ -218,8 +223,6 @@ changeDetail = { | ||
} | ||
changeDetail.ChangeInfo[childPropName] = modification.value; | ||
parentChangeDetail.ChangeInfo[propName] = changeDetail; | ||
parentChangeInfo[propName] = changeDetail; | ||
parentChangeDetail = changeDetail; | ||
} | ||
// BE中关联对象、值对象已经是最后一级,不需要再往后遍历 | ||
parentChangeDetail = null; | ||
parentEntityType = null; | ||
parentEntityType = propEntityType; | ||
} | ||
@@ -334,2 +337,19 @@ else if (propType === 'NgList') { | ||
/** | ||
* 获取变更信息 | ||
* 在整个ChangeDetail树上,存在两种类型的节点 | ||
* ChangeDetail:实体变更、值对象变更(没有DataID) | ||
* PlainObject: 关联对象的变更 | ||
* 从这两种节点上拿具体变更信息的时候,需要统一处理,屏蔽这个差异。 | ||
* @todo:为这两种节点封装ChangeNode基类来解决这个差异。 | ||
*/ | ||
BefChangeBuilder.prototype.getChangeInfo = function (changeDetail) { | ||
// @todo:可能存在同名属性 | ||
if (changeDetail.hasOwnProperty('ChangeInfo')) { | ||
return changeDetail.ChangeInfo; | ||
} | ||
else { | ||
return changeDetail; | ||
} | ||
}; | ||
/** | ||
* 创建ChangeDetail | ||
@@ -495,254 +515,2 @@ * @param type BEF变更类型 | ||
/* | ||
* @Author: Witt | ||
* @Date: 2018-10-12 14:43:49 | ||
* @Last Modified by: Witt | ||
* @Last Modified time: 2018-11-15 16:08:42 | ||
*/ | ||
var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata$2 = (undefined && undefined.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
/** | ||
* BEF取数服务 | ||
* 该服务由BefRepository实例化,不做注入,每个BefRepository拥有一个BefRestService实例。 | ||
*/ | ||
var BefRestService = /** @class */ (function () { | ||
/** | ||
* 构造函数 | ||
* @param httpClient http服务 | ||
* @param serverUri 应用服务器地址 | ||
* @param beUri BE API地址 | ||
*/ | ||
function BefRestService(httpClient, baseUri, frmSessionService) { | ||
this.httpClient = httpClient; | ||
this.baseUri = baseUri; | ||
this.sessionService = new BefSessionService(httpClient, baseUri, frmSessionService); | ||
} | ||
/** | ||
* 列表查询 | ||
* @return 数据数组 | ||
* @todo | ||
* 1、目前仅支持查询全部数据 | ||
*/ | ||
BefRestService.prototype.query = function (entityFilter) { | ||
var url = this.baseUri; | ||
if (entityFilter) { | ||
var entityFilterJson = JSON.stringify(entityFilter); | ||
url = url + "?entityFilter=" + entityFilterJson; | ||
} | ||
return this.request(url, 'GET'); | ||
}; | ||
/** | ||
* 数据检索 | ||
* @param id 单据内码 | ||
* @return 数据对象 | ||
*/ | ||
BefRestService.prototype.retrieve = function (id) { | ||
var url = this.baseUri + "/" + id; | ||
return this.request(url, 'GET'); | ||
}; | ||
/** | ||
* 创建一条数据 | ||
* @summary | ||
* 返回带默认值的空数据,服务器端该数据在BE缓存中,尚未保存到数据库 | ||
*/ | ||
BefRestService.prototype.create = function () { | ||
return this.request(this.baseUri, 'POST'); | ||
}; | ||
/** | ||
* 从表新增 | ||
* @path 新增路径(从表形如:/1/edus,从从表形如:/1/edus/11/grades) | ||
* @return | ||
*/ | ||
BefRestService.prototype.createByPath = function (fpath) { | ||
var pathUrl = this.convertPathToUrl(fpath); | ||
var url = "" + this.baseUri + pathUrl; | ||
return this.request(url, 'POST'); | ||
}; | ||
/** | ||
* 提交变更 | ||
* @summary | ||
* 此时变更提交的BE缓存中,等待保存,服务器端不返回任何数据 | ||
*/ | ||
BefRestService.prototype.update = function (changeDetail) { | ||
var optionsWithBody = this.addBody({}, changeDetail); | ||
return this.request(this.baseUri, 'PATCH', null, optionsWithBody); | ||
}; | ||
/** | ||
* 保存 | ||
* @summary | ||
* 通过此地方将BEF中的变更缓存应用到数据库中,服务器端不返回任何数据 | ||
*/ | ||
BefRestService.prototype.save = function () { | ||
return this.request(this.baseUri, 'PUT'); | ||
}; | ||
/** | ||
* 删除 | ||
*/ | ||
BefRestService.prototype.delete = function (id) { | ||
var url = this.baseUri + "/" + id; | ||
return this.request(url, 'DELETE'); | ||
}; | ||
/** | ||
* 删除后代 | ||
* @param fpath 父路径(从表形如:/1/edus,从从表形如:/1/edus/11/grades) | ||
*/ | ||
BefRestService.prototype.deletByPath = function (fpath, id) { | ||
var pathUrl = this.convertPathToUrl(fpath); | ||
var url = "" + this.baseUri + pathUrl + "/" + id; | ||
return this.request(url, 'DELETE'); | ||
}; | ||
/** | ||
* 批量删除 | ||
* @param ids 待删除的id数组 | ||
*/ | ||
BefRestService.prototype.batchDelete = function (ids) { | ||
var params = { | ||
ids: ids.join(',') | ||
}; | ||
return this.request(this.baseUri, 'DELETE', params); | ||
}; | ||
/** | ||
* 批量删除子表记录 | ||
* @param fpath 父路径 | ||
* @param ids 待删除的id数组 | ||
*/ | ||
BefRestService.prototype.batchDeleteByPath = function (fpath, ids) { | ||
throw new Error('Not Implemented'); | ||
}; | ||
/** | ||
* 取消 | ||
*/ | ||
BefRestService.prototype.cancel = function () { | ||
var url = this.baseUri + "/service/cancel"; | ||
return this.request(url, 'POST'); | ||
}; | ||
/** | ||
* 发送http请求 | ||
*/ | ||
BefRestService.prototype.request = function (url, method, params, options) { | ||
var _this = this; | ||
options = options || {}; | ||
// params | ||
if (params) { | ||
var httpParams = this.buildParams(params); | ||
options.params = httpParams; | ||
} | ||
// 串联session流和http流 | ||
return this.sessionService.getBeSessionId().pipe(switchMap(function (sessionId) { | ||
if (options.headers) { | ||
options.headers = options.headers.append('SessionId', sessionId); | ||
} | ||
else { | ||
options.headers = new HttpHeaders({ 'SessionId': sessionId }); | ||
} | ||
return _this.httpClient.request(method, url, options); | ||
})); | ||
}; | ||
/** | ||
* 构造HttpParams对象 | ||
* @param params 请求参数 | ||
*/ | ||
BefRestService.prototype.buildParams = function (params) { | ||
var httpParams = new HttpParams(); | ||
for (var key in params) { | ||
if (params.hasOwnProperty(key)) { | ||
var value = params[key].toString(); | ||
httpParams = httpParams.append(key, value); | ||
} | ||
} | ||
return httpParams; | ||
}; | ||
/** | ||
* 向HttpOptions对象中添加body | ||
* @param options 原来的options | ||
* @param body body内容 | ||
*/ | ||
BefRestService.prototype.addBody = function (options, body) { | ||
options = options || {}; | ||
var mergedOptions = Object.assign(options, { body: body }); | ||
return mergedOptions; | ||
}; | ||
/** | ||
* 在devkit的路径中表名是属性名,是复数,在url中表名是单数 | ||
* 在此做兼容 | ||
* @todo:临时支持子表,应该支持无限层级 | ||
* fixed by justin: 每级属性名都去掉s | ||
*/ | ||
BefRestService.prototype.convertPathToUrl = function (path) { | ||
// return path.substring(0, path.length - 1); | ||
var subPaths = path.split('/'); | ||
for (var i = subPaths.length - 1; i > 0; i--) { | ||
if (subPaths[i] && subPaths[i].endsWith('s')) { | ||
subPaths[i] = subPaths[i].substr(0, subPaths[i].length - 1); | ||
} | ||
} | ||
return subPaths.join('/'); | ||
}; | ||
BefRestService = __decorate$2([ | ||
Injectable(), | ||
__metadata$2("design:paramtypes", [HttpClient, String, FrameworkSessionService]) | ||
], BefRestService); | ||
return BefRestService; | ||
}()); | ||
var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata$3 = (undefined && undefined.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
/** | ||
* 帮助Rest取数服务 | ||
*/ | ||
var BefLookupRestService = /** @class */ (function () { | ||
function BefLookupRestService(repository) { | ||
this.befRepository = repository; | ||
} | ||
BefLookupRestService.prototype.getData = function (helpMetadataId, data) { | ||
var tableName = helpMetadataId.split('.')[0]; | ||
var labelId = helpMetadataId.split('.')[1]; | ||
var url = this.befRepository.restService.baseUri + "/elementhelps/" + labelId; | ||
data = data || {}; | ||
return this.befRepository.restService.request(url, 'GET', { nodeCode: tableName, queryParam: JSON.stringify(data) }); | ||
}; | ||
BefLookupRestService.prototype.convert2TreeDataWithPathCode = function (data, layer, parentPathCode) { | ||
var _this = this; | ||
if (layer === void 0) { layer = 1; } | ||
if (parentPathCode === void 0) { parentPathCode = '01'; } | ||
var nodes = data.filter(function (d) { return d.layer === layer && d.pathcode === parentPathCode; }); | ||
if (layer > 1) { | ||
nodes = data.filter(function (d) { return d.layer === layer && d.pathcode.substr(0, (layer - 1) * 2) === parentPathCode; }); | ||
} | ||
if (nodes.length) { | ||
var treeNodes = nodes.map(function (n) { | ||
return { | ||
data: n, | ||
children: [] | ||
}; | ||
}); | ||
treeNodes.forEach(function (tn) { | ||
var _a; | ||
var _tns = _this.convert2TreeDataWithPathCode(data, tn.data.layer + 1, tn.data.pathcode); | ||
(_a = tn.children).push.apply(_a, _tns); | ||
}); | ||
return treeNodes; | ||
} | ||
}; | ||
BefLookupRestService = __decorate$3([ | ||
Injectable(), | ||
__metadata$3("design:paramtypes", [Repository]) | ||
], BefLookupRestService); | ||
return BefLookupRestService; | ||
}()); | ||
/* | ||
* @Author: Sagi, Lucas, Witt | ||
@@ -771,3 +539,3 @@ * @Date: 2018-10-11 17:34:26 | ||
})(); | ||
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
@@ -778,3 +546,3 @@ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
}; | ||
var __metadata$4 = (undefined && undefined.__metadata) || function (k, v) { | ||
var __metadata$2 = (undefined && undefined.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
@@ -798,3 +566,3 @@ }; | ||
var restBaseUri = serverUri + "/" + _this.apiUri; | ||
_this.restService = new BefRestService(httpClient, restBaseUri, frmSessionService); | ||
_this.restService = new BefRestService(httpClient, restBaseUri, frmSessionService, _this); | ||
// 创建BefChangeBuilder实例 | ||
@@ -896,14 +664,2 @@ _this.changeBuilder = new BefChangeBuilder(_this.entityType); | ||
BefRepository.prototype.lockById = function (id) { | ||
// const entity = this.entityCollection.getEntityById(id); | ||
// // 组织一个空变更 | ||
// const changeDetail = this.changeBuilder.build([]); | ||
// changeDetail.ChangeInfo.DataId = id; | ||
// // 提交变更 | ||
// const update$ = this.restService.update(changeDetail); | ||
// const result$ = update$.pipe( | ||
// map(() => { | ||
// return true; | ||
// }) | ||
// ); | ||
// return result$; | ||
return of(true); | ||
@@ -1189,5 +945,5 @@ }; | ||
}; | ||
BefRepository = __decorate$4([ | ||
BefRepository = __decorate$2([ | ||
Injectable(), | ||
__metadata$4("design:paramtypes", [Injector]) | ||
__metadata$2("design:paramtypes", [Injector]) | ||
], BefRepository); | ||
@@ -1197,3 +953,272 @@ return BefRepository; | ||
/* | ||
* @Author: Witt | ||
* @Date: 2018-10-12 14:43:49 | ||
* @Last Modified by: Witt | ||
* @Last Modified time: 2018-11-15 16:08:42 | ||
*/ | ||
var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata$3 = (undefined && undefined.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
/** | ||
* BEF取数服务 | ||
* 该服务由BefRepository实例化,不做注入,每个BefRepository拥有一个BefRestService实例。 | ||
*/ | ||
var BefRestService = /** @class */ (function () { | ||
/** | ||
* 构造函数 | ||
* @param httpClient http服务 | ||
* @param serverUri 应用服务器地址 | ||
* @param beUri BE API地址 | ||
*/ | ||
function BefRestService(httpClient, baseUri, frmSessionService, repository) { | ||
this.httpClient = httpClient; | ||
this.baseUri = baseUri; | ||
this.sessionService = new BefSessionService(httpClient, baseUri, frmSessionService); | ||
this.repository = repository; | ||
} | ||
/** | ||
* 列表查询 | ||
* @return 数据数组 | ||
* @todo | ||
* 1、目前仅支持查询全部数据 | ||
*/ | ||
BefRestService.prototype.query = function (entityFilter) { | ||
var url = this.baseUri; | ||
if (entityFilter) { | ||
var entityFilterJson = JSON.stringify(entityFilter); | ||
url = url + "?entityFilter=" + entityFilterJson; | ||
} | ||
return this.request(url, 'GET'); | ||
}; | ||
/** | ||
* 数据检索 | ||
* @param id 单据内码 | ||
* @return 数据对象 | ||
*/ | ||
BefRestService.prototype.retrieve = function (id) { | ||
var url = this.baseUri + "/" + id; | ||
return this.request(url, 'GET'); | ||
}; | ||
/** | ||
* 创建一条数据 | ||
* @summary | ||
* 返回带默认值的空数据,服务器端该数据在BE缓存中,尚未保存到数据库 | ||
*/ | ||
BefRestService.prototype.create = function () { | ||
return this.request(this.baseUri, 'POST'); | ||
}; | ||
/** | ||
* 从表新增 | ||
* @path 新增路径(从表形如:/1/edus,从从表形如:/1/edus/11/grades) | ||
* @return | ||
*/ | ||
BefRestService.prototype.createByPath = function (fpath) { | ||
var pathUrl = this.convertPathToUrl(fpath); | ||
var url = "" + this.baseUri + pathUrl; | ||
return this.request(url, 'POST'); | ||
}; | ||
/** | ||
* 提交变更 | ||
* @summary | ||
* 此时变更提交的BE缓存中,等待保存,服务器端不返回任何数据 | ||
*/ | ||
BefRestService.prototype.update = function (changeDetail) { | ||
var optionsWithBody = this.addBody({}, changeDetail); | ||
return this.innerRequest(this.baseUri, 'PATCH', null, optionsWithBody); | ||
}; | ||
/** | ||
* 保存 | ||
* @summary | ||
* 通过此地方将BEF中的变更缓存应用到数据库中,服务器端不返回任何数据 | ||
*/ | ||
BefRestService.prototype.save = function () { | ||
return this.innerRequest(this.baseUri, 'PUT'); | ||
}; | ||
/** | ||
* 删除 | ||
*/ | ||
BefRestService.prototype.delete = function (id) { | ||
var url = this.baseUri + "/" + id; | ||
return this.request(url, 'DELETE'); | ||
}; | ||
/** | ||
* 删除后代 | ||
* @param fpath 父路径(从表形如:/1/edus,从从表形如:/1/edus/11/grades) | ||
*/ | ||
BefRestService.prototype.deletByPath = function (fpath, id) { | ||
var pathUrl = this.convertPathToUrl(fpath); | ||
var url = "" + this.baseUri + pathUrl + "/" + id; | ||
return this.request(url, 'DELETE'); | ||
}; | ||
/** | ||
* 批量删除 | ||
* @param ids 待删除的id数组 | ||
*/ | ||
BefRestService.prototype.batchDelete = function (ids) { | ||
var params = { | ||
ids: ids.join(',') | ||
}; | ||
return this.request(this.baseUri, 'DELETE', params); | ||
}; | ||
/** | ||
* 批量删除子表记录 | ||
* @param fpath 父路径 | ||
* @param ids 待删除的id数组 | ||
*/ | ||
BefRestService.prototype.batchDeleteByPath = function (fpath, ids) { | ||
throw new Error('Not Implemented'); | ||
}; | ||
/** | ||
* 取消 | ||
*/ | ||
BefRestService.prototype.cancel = function () { | ||
var url = this.baseUri + "/service/cancel"; | ||
return this.request(url, 'POST'); | ||
}; | ||
/** | ||
* 发送http请求 | ||
*/ | ||
BefRestService.prototype.request = function (url, method, params, options) { | ||
var _this = this; | ||
if (method !== 'GET') { | ||
return this.repository.updateAllChanges().pipe(switchMap(function () { | ||
return _this.innerRequest(url, method, params, options); | ||
})); | ||
} | ||
else { | ||
return this.innerRequest(url, method, params, options); | ||
} | ||
}; | ||
/** | ||
* 发送http请求(请勿使用) | ||
* @internal | ||
*/ | ||
BefRestService.prototype.innerRequest = function (url, method, params, options) { | ||
var _this = this; | ||
options = options || {}; | ||
// params | ||
if (params) { | ||
var httpParams = this.buildParams(params); | ||
options.params = httpParams; | ||
} | ||
// 串联session流和http流 | ||
return this.sessionService.getBeSessionId().pipe(switchMap(function (sessionId) { | ||
if (options.headers) { | ||
options.headers = options.headers.append('SessionId', sessionId); | ||
} | ||
else { | ||
options.headers = new HttpHeaders({ 'SessionId': sessionId }); | ||
} | ||
return _this.httpClient.request(method, url, options); | ||
})); | ||
}; | ||
/** | ||
* 构造HttpParams对象 | ||
* @param params 请求参数 | ||
*/ | ||
BefRestService.prototype.buildParams = function (params) { | ||
var httpParams = new HttpParams(); | ||
for (var key in params) { | ||
if (params.hasOwnProperty(key)) { | ||
var value = params[key].toString(); | ||
httpParams = httpParams.append(key, value); | ||
} | ||
} | ||
return httpParams; | ||
}; | ||
/** | ||
* 向HttpOptions对象中添加body | ||
* @param options 原来的options | ||
* @param body body内容 | ||
*/ | ||
BefRestService.prototype.addBody = function (options, body) { | ||
options = options || {}; | ||
var mergedOptions = Object.assign(options, { body: body }); | ||
return mergedOptions; | ||
}; | ||
/** | ||
* 在devkit的路径中表名是属性名,是复数,在url中表名是单数 | ||
* 在此做兼容 | ||
* @todo:临时支持子表,应该支持无限层级 | ||
* fixed by justin: 每级属性名都去掉s | ||
*/ | ||
BefRestService.prototype.convertPathToUrl = function (path) { | ||
// return path.substring(0, path.length - 1); | ||
var subPaths = path.split('/'); | ||
for (var i = subPaths.length - 1; i > 0; i--) { | ||
if (subPaths[i] && subPaths[i].endsWith('s')) { | ||
subPaths[i] = subPaths[i].substr(0, subPaths[i].length - 1); | ||
} | ||
} | ||
return subPaths.join('/'); | ||
}; | ||
BefRestService = __decorate$3([ | ||
Injectable(), | ||
__metadata$3("design:paramtypes", [HttpClient, String, FrameworkSessionService, | ||
BefRepository]) | ||
], BefRestService); | ||
return BefRestService; | ||
}()); | ||
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata$4 = (undefined && undefined.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
/** | ||
* 帮助Rest取数服务 | ||
*/ | ||
var BefLookupRestService = /** @class */ (function () { | ||
function BefLookupRestService(repository) { | ||
this.befRepository = repository; | ||
} | ||
BefLookupRestService.prototype.getData = function (helpMetadataId, data) { | ||
var tableName = helpMetadataId.split('.')[0]; | ||
var labelId = helpMetadataId.split('.')[1]; | ||
var url = this.befRepository.restService.baseUri + "/elementhelps/" + labelId; | ||
data = data || {}; | ||
return this.befRepository.restService.request(url, 'GET', { nodeCode: tableName, queryParam: JSON.stringify(data) }); | ||
}; | ||
BefLookupRestService.prototype.convert2TreeDataWithPathCode = function (data, layer, parentPathCode) { | ||
var _this = this; | ||
if (layer === void 0) { layer = 1; } | ||
if (parentPathCode === void 0) { parentPathCode = '01'; } | ||
var nodes = data.filter(function (d) { return d.layer === layer && d.pathcode === parentPathCode; }); | ||
if (layer > 1) { | ||
nodes = data.filter(function (d) { return d.layer === layer && d.pathcode.substr(0, (layer - 1) * 2) === parentPathCode; }); | ||
} | ||
if (nodes.length) { | ||
var treeNodes = nodes.map(function (n) { | ||
return { | ||
data: n, | ||
children: [] | ||
}; | ||
}); | ||
treeNodes.forEach(function (tn) { | ||
var _a; | ||
var _tns = _this.convert2TreeDataWithPathCode(data, tn.data.layer + 1, tn.data.pathcode); | ||
(_a = tn.children).push.apply(_a, _tns); | ||
}); | ||
return treeNodes; | ||
} | ||
}; | ||
BefLookupRestService = __decorate$4([ | ||
Injectable(), | ||
__metadata$4("design:paramtypes", [Repository]) | ||
], BefLookupRestService); | ||
return BefLookupRestService; | ||
}()); | ||
export { ChangeDetailType, ChangeDetail, BE_SERVER_URI_TOKEN, BefChangeBuilder, BefSessionService, BefRestService, BefLookupRestService, BefRepository, FrameworkSessionService }; | ||
//# sourceMappingURL=index.bundle.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":4,"metadata":{"ChangeDetailType":{"Added":"Added","Modify":"Modify","Deleted":"Deleted"},"ChangeDetailInfo":{"__symbolic":"interface"},"ChangeDetail":{"__symbolic":"class","members":{}},"BE_SERVER_URI_TOKEN":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":9,"character":32},"arguments":["@farris/be BE_SERVER_URL"]},"BefChangeBuilder":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Type","module":"@angular/core","arguments":[{"__symbolic":"reference","module":"@farris/devkit","name":"Entity","line":27,"character":39}]}]}],"build":[{"__symbolic":"method"}],"buildChangeDetail":[{"__symbolic":"method"}],"addAddChangeDetail":[{"__symbolic":"method"}],"addRemoveChangeDetail":[{"__symbolic":"method"}],"createEmptyChangeDetail":[{"__symbolic":"method"}]}},"BefSessionService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":28,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/common/http","name":"HttpClient","line":59,"character":26},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"FrameworkSessionService"}]}],"getBeSessionId":[{"__symbolic":"method"}],"setBeSessionId":[{"__symbolic":"method"}],"createBeSession":[{"__symbolic":"method"}],"clearBeSessionId":[{"__symbolic":"method"}]}},"BefRestService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":21,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/common/http","name":"HttpClient","line":45,"character":26},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"FrameworkSessionService"}]}],"query":[{"__symbolic":"method"}],"retrieve":[{"__symbolic":"method"}],"create":[{"__symbolic":"method"}],"createByPath":[{"__symbolic":"method"}],"update":[{"__symbolic":"method"}],"save":[{"__symbolic":"method"}],"delete":[{"__symbolic":"method"}],"deletByPath":[{"__symbolic":"method"}],"batchDelete":[{"__symbolic":"method"}],"batchDeleteByPath":[{"__symbolic":"method"}],"cancel":[{"__symbolic":"method"}],"request":[{"__symbolic":"method"}],"buildParams":[{"__symbolic":"method"}],"addBody":[{"__symbolic":"method"}],"convertPathToUrl":[{"__symbolic":"method"}]}},"BefLookupRestService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":9,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Repository","module":"@farris/devkit","arguments":[{"__symbolic":"reference","name":"any"}]}]}],"getData":[{"__symbolic":"method"}],"convert2TreeDataWithPathCode":[{"__symbolic":"method"}]}},"BefRepository":{"__symbolic":"class","arity":1,"extends":{"__symbolic":"reference","module":"@farris/devkit","name":"Repository","line":38,"character":55},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":37,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":53,"character":24}]}],"getEntities":[{"__symbolic":"method"}],"getList":[{"__symbolic":"method"}],"getById":[{"__symbolic":"method"}],"updateById":[{"__symbolic":"method"}],"lockById":[{"__symbolic":"method"}],"create":[{"__symbolic":"method"}],"createByPath":[{"__symbolic":"method"}],"append":[{"__symbolic":"method"}],"appendByPath":[{"__symbolic":"method"}],"appendEntityByPath":[{"__symbolic":"method"}],"removeById":[{"__symbolic":"method"}],"removeByIds":[{"__symbolic":"method"}],"removeByPath":[{"__symbolic":"method"}],"removeEntityByPath":[{"__symbolic":"method"}],"updateChangesById":[{"__symbolic":"method"}],"updateChangesByPath":[{"__symbolic":"method"}],"updateAllChanges":[{"__symbolic":"method"}],"applyChanges":[{"__symbolic":"method"}],"applyChangesById":[{"__symbolic":"method"}],"cancelChanges":[{"__symbolic":"method"}]}},"FrameworkSessionService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":10,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@ecp-caf/caf-common","name":"CacheService","line":13,"character":36}]}],"getUserSessionId":[{"__symbolic":"method"}]}}},"origins":{"ChangeDetailType":"./src/types","ChangeDetailInfo":"./src/types","ChangeDetail":"./src/types","BE_SERVER_URI_TOKEN":"./src/tokens","BefChangeBuilder":"./src/bef_change_builder","BefSessionService":"./src/bef_session.service","BefRestService":"./src/bef_rest_service","BefLookupRestService":"./src/bef_lookup.service","BefRepository":"./src/bef_repository","FrameworkSessionService":"./src/framework_session.service"},"importAs":"@farris/bef"} | ||
{"__symbolic":"module","version":4,"metadata":{"ChangeDetailType":{"Added":"Added","Modify":"Modify","Deleted":"Deleted"},"ChangeDetailInfo":{"__symbolic":"interface"},"ChangeDetail":{"__symbolic":"class","members":{}},"BE_SERVER_URI_TOKEN":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":9,"character":32},"arguments":["@farris/be BE_SERVER_URL"]},"BefChangeBuilder":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Type","module":"@angular/core","arguments":[{"__symbolic":"reference","module":"@farris/devkit","name":"Entity","line":27,"character":39}]}]}],"build":[{"__symbolic":"method"}],"buildChangeDetail":[{"__symbolic":"method"}],"addAddChangeDetail":[{"__symbolic":"method"}],"addRemoveChangeDetail":[{"__symbolic":"method"}],"getChangeInfo":[{"__symbolic":"method"}],"createEmptyChangeDetail":[{"__symbolic":"method"}]}},"BefSessionService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":28,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/common/http","name":"HttpClient","line":59,"character":26},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"FrameworkSessionService"}]}],"getBeSessionId":[{"__symbolic":"method"}],"setBeSessionId":[{"__symbolic":"method"}],"createBeSession":[{"__symbolic":"method"}],"clearBeSessionId":[{"__symbolic":"method"}]}},"BefRestService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":23,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/common/http","name":"HttpClient","line":50,"character":16},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"FrameworkSessionService"},{"__symbolic":"reference","name":"BefRepository"}]}],"query":[{"__symbolic":"method"}],"retrieve":[{"__symbolic":"method"}],"create":[{"__symbolic":"method"}],"createByPath":[{"__symbolic":"method"}],"update":[{"__symbolic":"method"}],"save":[{"__symbolic":"method"}],"delete":[{"__symbolic":"method"}],"deletByPath":[{"__symbolic":"method"}],"batchDelete":[{"__symbolic":"method"}],"batchDeleteByPath":[{"__symbolic":"method"}],"cancel":[{"__symbolic":"method"}],"request":[{"__symbolic":"method"}],"innerRequest":[{"__symbolic":"method"}],"buildParams":[{"__symbolic":"method"}],"addBody":[{"__symbolic":"method"}],"convertPathToUrl":[{"__symbolic":"method"}]}},"BefLookupRestService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":9,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Repository","module":"@farris/devkit","arguments":[{"__symbolic":"reference","name":"any"}]}]}],"getData":[{"__symbolic":"method"}],"convert2TreeDataWithPathCode":[{"__symbolic":"method"}]}},"BefRepository":{"__symbolic":"class","arity":1,"extends":{"__symbolic":"reference","module":"@farris/devkit","name":"Repository","line":38,"character":55},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":37,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":53,"character":24}]}],"getEntities":[{"__symbolic":"method"}],"getList":[{"__symbolic":"method"}],"getById":[{"__symbolic":"method"}],"updateById":[{"__symbolic":"method"}],"lockById":[{"__symbolic":"method"}],"create":[{"__symbolic":"method"}],"createByPath":[{"__symbolic":"method"}],"append":[{"__symbolic":"method"}],"appendByPath":[{"__symbolic":"method"}],"appendEntityByPath":[{"__symbolic":"method"}],"removeById":[{"__symbolic":"method"}],"removeByIds":[{"__symbolic":"method"}],"removeByPath":[{"__symbolic":"method"}],"removeEntityByPath":[{"__symbolic":"method"}],"updateChangesById":[{"__symbolic":"method"}],"updateChangesByPath":[{"__symbolic":"method"}],"updateAllChanges":[{"__symbolic":"method"}],"applyChanges":[{"__symbolic":"method"}],"applyChangesById":[{"__symbolic":"method"}],"cancelChanges":[{"__symbolic":"method"}]}},"FrameworkSessionService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":10,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@ecp-caf/caf-common","name":"CacheService","line":13,"character":36}]}],"getUserSessionId":[{"__symbolic":"method"}]}}},"origins":{"ChangeDetailType":"./src/types","ChangeDetailInfo":"./src/types","ChangeDetail":"./src/types","BE_SERVER_URI_TOKEN":"./src/tokens","BefChangeBuilder":"./src/bef_change_builder","BefSessionService":"./src/bef_session.service","BefRestService":"./src/bef_rest_service","BefLookupRestService":"./src/bef_lookup.service","BefRepository":"./src/bef_repository","FrameworkSessionService":"./src/framework_session.service"},"importAs":"@farris/bef"} |
{ | ||
"name": "@farris/bef", | ||
"version": "0.0.11-201901031330", | ||
"version": "0.0.11-201901171630", | ||
"description": "Farris Bef", | ||
@@ -5,0 +5,0 @@ "main": "./bundles/index.umd.js", |
@@ -43,2 +43,11 @@ import { Type } from '@angular/core'; | ||
/** | ||
* 获取变更信息 | ||
* 在整个ChangeDetail树上,存在两种类型的节点 | ||
* ChangeDetail:实体变更、值对象变更(没有DataID) | ||
* PlainObject: 关联对象的变更 | ||
* 从这两种节点上拿具体变更信息的时候,需要统一处理,屏蔽这个差异。 | ||
* @todo:为这两种节点封装ChangeNode基类来解决这个差异。 | ||
*/ | ||
private getChangeInfo; | ||
/** | ||
* 创建ChangeDetail | ||
@@ -45,0 +54,0 @@ * @param type BEF变更类型 |
import { HttpClient } from '@angular/common/http'; | ||
import { Observable } from 'rxjs/Observable'; | ||
import { Entity } from '@farris/devkit'; | ||
import { BefRepository } from './bef_repository'; | ||
import { FrameworkSessionService } from './framework_session.service'; | ||
@@ -11,2 +13,3 @@ import { BefSessionService } from './bef_session.service'; | ||
declare class BefRestService { | ||
private repository; | ||
/** | ||
@@ -30,3 +33,3 @@ * httpClient | ||
*/ | ||
constructor(httpClient: HttpClient, baseUri: string, frmSessionService: FrameworkSessionService); | ||
constructor(httpClient: HttpClient, baseUri: string, frmSessionService: FrameworkSessionService, repository: BefRepository<Entity>); | ||
/** | ||
@@ -33,0 +36,0 @@ * 列表查询 |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
396749
4006