|
@@ -17,6 +17,23 @@ class InstallService extends CrudService {
|
|
|
await this.initAdmin();
|
|
|
await this.initSelfShop();
|
|
|
await this.initTestCustomer();
|
|
|
+ await this.initGoodsTags();
|
|
|
+ }
|
|
|
+
|
|
|
+ async initGoodsTags() {
|
|
|
+ const model = this.ctx.model.System.GoodsTags;
|
|
|
+ const p = path.resolve(this.dataIndex, 'goodsTags.js');
|
|
|
+ const data = require(p);
|
|
|
+ const loop = async (list, pid) => {
|
|
|
+ for (const i of list) {
|
|
|
+ const { children = [], label, code } = i;
|
|
|
+ let pdata;
|
|
|
+ pdata = await model.findOne({ code });
|
|
|
+ if (!pdata) pdata = await model.create({ label, code, pid });
|
|
|
+ if (children.length > 0) loop(children, pdata._id);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ await loop(data);
|
|
|
}
|
|
|
|
|
|
/**
|