mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-09 05:00:30 +08:00
fix: fix project/list uids bug
This commit is contained in:
parent
d8208fbb5c
commit
19c826aa19
@ -248,12 +248,11 @@ class projectController extends baseController {
|
||||
let count = await this.Model.listCount(group_id);
|
||||
let uids = [];
|
||||
result.forEach( (item)=> {
|
||||
if(uids.indexOf(item.uid) !== -1){
|
||||
if(uids.indexOf(item.uid) === -1){
|
||||
uids.push(item.uid)
|
||||
}
|
||||
|
||||
} )
|
||||
|
||||
let _users = {}, users = await yapi.getInst(userModel).findByUids(uids);
|
||||
users.forEach((item)=> {
|
||||
_users[item._id] = item;
|
||||
@ -263,7 +262,7 @@ class projectController extends baseController {
|
||||
list: result,
|
||||
userinfo: _users
|
||||
})
|
||||
}catch(err){
|
||||
}catch(e){
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message)
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class userModel extends baseModel{
|
||||
}
|
||||
findByUids(uids){
|
||||
return this.model.find({
|
||||
_id: {$in: $uids}
|
||||
_id: {$in: uids}
|
||||
}).select("_id username email role add_time up_time").exec()
|
||||
}
|
||||
listWithPaging(page, limit) {
|
||||
|
@ -585,11 +585,10 @@ var projectController = function (_baseController) {
|
||||
uids = [];
|
||||
|
||||
result.forEach(function (item) {
|
||||
if (uids.indexOf(item.uid) !== -1) {
|
||||
if (uids.indexOf(item.uid) === -1) {
|
||||
uids.push(item.uid);
|
||||
}
|
||||
});
|
||||
|
||||
_users = {};
|
||||
_context6.next = 15;
|
||||
return _yapi2.default.getInst(_user2.default).findByUids(uids);
|
||||
@ -612,7 +611,7 @@ var projectController = function (_baseController) {
|
||||
_context6.prev = 20;
|
||||
_context6.t0 = _context6['catch'](3);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, e.message);
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context6.t0.message);
|
||||
|
||||
case 23:
|
||||
case 'end':
|
||||
|
@ -91,7 +91,7 @@ var userModel = function (_baseModel) {
|
||||
key: 'findByUids',
|
||||
value: function findByUids(uids) {
|
||||
return this.model.find({
|
||||
_id: { $in: $uids }
|
||||
_id: { $in: uids }
|
||||
}).select("_id username email role add_time up_time").exec();
|
||||
}
|
||||
}, {
|
||||
|
Loading…
Reference in New Issue
Block a user