1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- '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 BuffService extends CrudService {
- constructor(ctx) {
- super(ctx, 'user');
- this.umodel = this.ctx.model.User;
- this.emodel = this.ctx.model.Expertsuser;
- }
- async userlist(info) {
- const { pid, code, skip, limit } = info;
- let url = this.ctx.app.config.axios.auth.baseUrl + '/finduserlist?skip=' + skip + '&limit=' + limit;
- if (pid) {
- url = url + '&pid=' + pid;
- }
- if (code) {
- url = url + '&code=' + code;
- }
- const res = await this.ctx.curl(url, {
- method: 'get',
- headers: {
- 'content-type': 'application/json',
- },
- dataType: 'json',
- });
- const resdata = res.data.data;
- const data = [];
- for (const elm of resdata) {
- const newdata = { ...JSON.parse(JSON.stringify(elm)) };
- if (elm.role === '4' || elm.role === '5') {
- const user = await this.umodel.findById(elm.uid);
- if (user) {
- newdata.status = user.status;
- }
- } else if (elm.role === '6') {
- const user = await this.emodel.findById(elm.uid);
- if (user) {
- newdata.status = user.status;
- }
- }
- data.push(newdata);
- }
- return { data, total: res.data.total };
- }
- }
- module.exports = BuffService;
|