|
@@ -1,7 +1,7 @@
|
|
'use strict';
|
|
'use strict';
|
|
const _ = require('lodash');
|
|
const _ = require('lodash');
|
|
|
|
|
|
-module.exports = data => {
|
|
|
|
|
|
+module.exports = (data) => {
|
|
const { name, name_zh, columns } = data;
|
|
const { name, name_zh, columns } = data;
|
|
let columnStr = `const ${name} = { \n`;
|
|
let columnStr = `const ${name} = { \n`;
|
|
let indexStr = '';
|
|
let indexStr = '';
|
|
@@ -11,7 +11,7 @@ module.exports = data => {
|
|
let configSearchStr = '';
|
|
let configSearchStr = '';
|
|
for (let i = 0; i < columns.length; i++) {
|
|
for (let i = 0; i < columns.length; i++) {
|
|
const { title, type, required = false, remark, index, def } = columns[i];
|
|
const { title, type, required = false, remark, index, def } = columns[i];
|
|
- const str = ` ${title}: { type: ${type || 'String'}, required: ${required} ${type === 'Secret' ? ', select: false' : ''} ${def ? `, default: '${def}'` : ''}, ${
|
|
|
|
|
|
+ const str = ` ${title}: { type: ${type || 'String'}, required: ${required} ${type === 'Secret' ? ', select: false' : ''} ${def ? `, default: '${def}'` : ''}${
|
|
remark ? `, zh: '${remark}'` : ''
|
|
remark ? `, zh: '${remark}'` : ''
|
|
} }, // ${remark || ''} \n`;
|
|
} }, // ${remark || ''} \n`;
|
|
columnStr += str;
|
|
columnStr += str;
|
|
@@ -25,7 +25,7 @@ module.exports = data => {
|
|
}
|
|
}
|
|
columnStr += '}';
|
|
columnStr += '}';
|
|
const nameList = name.split('_');
|
|
const nameList = name.split('_');
|
|
- const modelName = nameList.map(i => _.capitalize(i)).join('_');
|
|
|
|
|
|
+ const modelName = nameList.map((i) => _.capitalize(i)).join('_');
|
|
return `'use strict';
|
|
return `'use strict';
|
|
const Schema = require('mongoose').Schema;
|
|
const Schema = require('mongoose').Schema;
|
|
const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
|
|
const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
|