xzqh.js 726 B

123456789101112131415161718192021222324
  1. 'use strict';
  2. const { CrudService } = require('naf-framework-mongoose/lib/service');
  3. const _ = require('lodash');
  4. // 行政区划
  5. class XzqhService extends CrudService {
  6. constructor(ctx) {
  7. super(ctx, 'xzqh');
  8. this.model = this.ctx.model.Xzqh;
  9. this.util = this.ctx.service.util;
  10. }
  11. async query(query, opts) {
  12. const condition = this.util.queryReset(query, opts);
  13. const { filter, options } = condition;
  14. const { skip, limit, sort, projection } = options;
  15. filter.disabled = false;
  16. if (!_.get(filter, 'pcode')) {
  17. filter.pcode = { $exists: false };
  18. }
  19. const res = await this.model.find(filter, projection, { skip, limit, sort });
  20. return res;
  21. }
  22. }
  23. module.exports = XzqhService;