1
This commit is contained in:
parent
8fd77fd8dc
commit
ddba7238ac
@ -25,50 +25,56 @@ function registerMetaClass(fileName, primKey, wrapClass, aliseName = '') {
|
||||
}
|
||||
}
|
||||
|
||||
function load() {
|
||||
metaClassList.forEach((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;
|
||||
});
|
||||
//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) => {
|
||||
function onAllLoadPost(classList) {
|
||||
for (let i = 0; i < 3; ++i) {
|
||||
classList.forEach((metaClass) => {
|
||||
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() {
|
||||
@ -115,13 +121,18 @@ function init() {
|
||||
|
||||
load();
|
||||
{
|
||||
const classList = [];
|
||||
getMetaByKey('PresentList', '0')['list'].forEach((item) => {
|
||||
registerMetaClass(resDir + item + '@present.json',
|
||||
'id',
|
||||
'Present',
|
||||
'Present' + item
|
||||
);
|
||||
const metaClass = getMetaClass('Present' + item);
|
||||
loadMeta(metaClass);
|
||||
classList.push(metaClass);
|
||||
});
|
||||
onAllLoadPost(classList);
|
||||
}
|
||||
{
|
||||
traverseMetaList('MarketDb', (dbConf, idx) => {
|
||||
|
@ -1,9 +1,15 @@
|
||||
const BaseService = require('./baseservice');
|
||||
const metaFactory = require('../metadata/factory');
|
||||
|
||||
class Present extends BaseService {
|
||||
|
||||
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