12345678910111213141516171819202122232425262728293031323334 |
- 'use strict';
- const assert = require('assert');
- const _ = require('lodash');
- const { ObjectId } = require('mongoose').Types;
- const { CrudService } = require('naf-framework-mongoose/lib/service');
- const { BusinessError, ErrorCode } = require('naf-core').Error;
- class UtilService extends CrudService {
- constructor(ctx) {
- super(ctx);
- this.mq = this.ctx.mq;
- }
- async findModel({ model }) {
- const _model = _.capitalize(model);
- const data = this.ctx.model[_model].prototype.schema.obj;
- const keys = Object.keys(data);
- let res = [];
- for (const k of keys) {
- const obj = _.omit(data[k], [ 'type', 'required', 'maxLength', 'default', 'zh' ]);
- if (_.get(data[k], 'zh')) {
- obj.model = k;
- obj.label = _.get(data[k], 'zh');
- res.push(obj);
- }
- }
- res = _.orderBy(res, [ 'row' ], [ 'asc' ]);
- return res;
- }
- async utilMethod() {
- console.log('in function:');
- }
- }
- module.exports = UtilService;
|