1
This commit is contained in:
parent
8fd77fd8dc
commit
ddba7238ac
@ -25,50 +25,56 @@ function registerMetaClass(fileName, primKey, wrapClass, aliseName = '') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function load() {
|
function onAllLoadPost(classList) {
|
||||||
metaClassList.forEach((metaClass) => {
|
for (let i = 0; i < 3; ++i) {
|
||||||
const json = utils.readJsonFromFile(metaClass['fileName']);
|
classList.forEach((metaClass) => {
|
||||||
if (!json) {
|
|
||||||
throw new Error('读取配置' + metaClass['fileName'] + '失败');
|
|
||||||
}
|
|
||||||
if (Array.isArray(json)) {
|
|
||||||
metaClass['rawList'] = json;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
metaClass['rawList'].push(json);
|
|
||||||
}
|
|
||||||
let idx = 0;
|
|
||||||
metaClass['rawList'].forEach(function (item) {
|
|
||||||
const wrapOjb = new metaClass['wrapClass'](item, metaClass);
|
|
||||||
const wrapProxy = new Proxy(wrapOjb, wrapOjb._getHandler());
|
|
||||||
metaClass['wrapList'].push(wrapProxy);
|
|
||||||
if (metaClass['primKey'] == '') {
|
|
||||||
metaClass['rawHash'][idx] = item;
|
|
||||||
metaClass['wrapHash'][idx] = wrapProxy;
|
|
||||||
} else {
|
|
||||||
metaClass['rawHash'][item[metaClass['primKey']]] = item;
|
|
||||||
metaClass['wrapHash'][item[metaClass['primKey']]] = wrapProxy;
|
|
||||||
}
|
|
||||||
++idx;
|
|
||||||
});
|
|
||||||
//log.debug(utils.jsonEncode(metaClass));
|
|
||||||
});
|
|
||||||
{
|
|
||||||
for (let i = 0; i < 3; ++i) {
|
|
||||||
metaClassList.forEach((metaClass) => {
|
|
||||||
metaClass['wrapList'].forEach((item) => {
|
|
||||||
if (item['_init' + i]) {
|
|
||||||
item['_init' + i](exports);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
metaClassList.forEach((metaClass) => {
|
|
||||||
metaClass['wrapList'].forEach((item) => {
|
metaClass['wrapList'].forEach((item) => {
|
||||||
item.lock();
|
if (item['_init' + i]) {
|
||||||
|
item['_init' + i](exports);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
classList.forEach((metaClass) => {
|
||||||
|
metaClass['wrapList'].forEach((item) => {
|
||||||
|
item.lock();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadMeta(metaClass) {
|
||||||
|
const json = utils.readJsonFromFile(metaClass['fileName']);
|
||||||
|
if (!json) {
|
||||||
|
throw new Error('读取配置' + metaClass['fileName'] + '失败');
|
||||||
|
}
|
||||||
|
if (Array.isArray(json)) {
|
||||||
|
metaClass['rawList'] = json;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
metaClass['rawList'].push(json);
|
||||||
|
}
|
||||||
|
let idx = 0;
|
||||||
|
metaClass['rawList'].forEach(function (item) {
|
||||||
|
const wrapOjb = new metaClass['wrapClass'](item, metaClass);
|
||||||
|
const wrapProxy = new Proxy(wrapOjb, wrapOjb._getHandler());
|
||||||
|
metaClass['wrapList'].push(wrapProxy);
|
||||||
|
if (metaClass['primKey'] == '') {
|
||||||
|
metaClass['rawHash'][idx] = item;
|
||||||
|
metaClass['wrapHash'][idx] = wrapProxy;
|
||||||
|
} else {
|
||||||
|
metaClass['rawHash'][item[metaClass['primKey']]] = item;
|
||||||
|
metaClass['wrapHash'][item[metaClass['primKey']]] = wrapProxy;
|
||||||
|
}
|
||||||
|
++idx;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function load() {
|
||||||
|
metaClassList.forEach((metaClass) => {
|
||||||
|
loadMeta(metaClass);
|
||||||
|
//log.debug(utils.jsonEncode(metaClass));
|
||||||
|
});
|
||||||
|
onAllLoadPost(metaClassList);
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
@ -115,13 +121,18 @@ function init() {
|
|||||||
|
|
||||||
load();
|
load();
|
||||||
{
|
{
|
||||||
|
const classList = [];
|
||||||
getMetaByKey('PresentList', '0')['list'].forEach((item) => {
|
getMetaByKey('PresentList', '0')['list'].forEach((item) => {
|
||||||
registerMetaClass(resDir + item + '@present.json',
|
registerMetaClass(resDir + item + '@present.json',
|
||||||
'id',
|
'id',
|
||||||
'Present',
|
'Present',
|
||||||
'Present' + item
|
'Present' + item
|
||||||
);
|
);
|
||||||
|
const metaClass = getMetaClass('Present' + item);
|
||||||
|
loadMeta(metaClass);
|
||||||
|
classList.push(metaClass);
|
||||||
});
|
});
|
||||||
|
onAllLoadPost(classList);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
traverseMetaList('MarketDb', (dbConf, idx) => {
|
traverseMetaList('MarketDb', (dbConf, idx) => {
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
const BaseService = require('./baseservice');
|
const BaseService = require('./baseservice');
|
||||||
|
const metaFactory = require('../metadata/factory');
|
||||||
|
|
||||||
class Present extends BaseService {
|
class Present extends BaseService {
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
|
const presentList = metaFactory.getMetaByKey('PresentList', '0')['list'];
|
||||||
|
for (let i in presentList) {
|
||||||
|
const name = presentList[i];
|
||||||
|
metaFactory.traverseMetaList('Present' + name, (item) => {
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user