|
@@ -8,14 +8,27 @@ module.exports = (data) => {
|
|
|
let has_ObjectId = false;
|
|
|
let has_Secret = false;
|
|
|
const configArr = [];
|
|
|
+ const updateArr = [];
|
|
|
let configSearchStr = '';
|
|
|
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, zh, ref, getProp } = columns[i];
|
|
|
+ let refStr;
|
|
|
+ if (ref) {
|
|
|
+ const propList = getProp.split(';');
|
|
|
+ let propStr = '[';
|
|
|
+ for (const p of propList) {
|
|
|
+ if (p !== _.head(propList)) propStr = `${propStr}, `;
|
|
|
+ propStr = `${propStr}'${p}'`;
|
|
|
+ }
|
|
|
+ propStr += ']';
|
|
|
+ refStr = `ref: '${_.capitalize(ref)}', getProp: ${propStr}`;
|
|
|
+ }
|
|
|
const str = ` ${title}: { type: ${type || 'String'}, required: ${required} ${type === 'Secret' ? ', select: false' : ''} ${def ? `, default: '${def}'` : ''}${
|
|
|
- remark ? `, zh: '${remark}'` : ''
|
|
|
- } }, // ${remark || ''} \n`;
|
|
|
+ zh ? `, zh: '${zh}'` : ''
|
|
|
+ }${refStr ? `,${refStr}` : ''} }, // ${remark || ''} \n`;
|
|
|
columnStr += str;
|
|
|
configArr.push(`'${required ? '!' : ''}${title}'`);
|
|
|
+ updateArr.push(`'${title}'`);
|
|
|
if (index) {
|
|
|
indexStr += `schema.index({ '${title}': 1 });\n`;
|
|
|
configSearchStr += `'${title}': '${title}' ,\n`;
|
|
@@ -53,7 +66,7 @@ module.exports = {
|
|
|
},
|
|
|
update: {
|
|
|
params: ["!id"],
|
|
|
- requestBody: [${configArr.join(',')}],
|
|
|
+ requestBody: [${updateArr.join(',')}],
|
|
|
},
|
|
|
show: {
|
|
|
parameters: {
|