|
@@ -0,0 +1,56 @@
|
|
|
+'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 + '?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 === '2' || elm.role === '3') {
|
|
|
+ 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;
|