fix: log group bug

This commit is contained in:
suxiaoxin 2017-10-10 11:34:33 +08:00
parent 375a4d7822
commit 0aa0598926
2 changed files with 13 additions and 4 deletions

View File

@ -39,11 +39,20 @@ class logController extends baseController {
try {
if(type === "group"){
let projectList = await this.projectModel.list(typeid);
let projectIds = [], projectDatas = {};
for(let i in projectList){
projectList[i] = projectList[i]._id;
projectDatas[projectList[i]._id] = projectList[i];
projectIds[i] = projectList[i]._id;
}
let projectLogList = await this.Model.listWithPagingByGroup(typeid,projectList,page,limit);
let total = await this.Model.listCountByGroup(typeid,projectList);
let projectLogList = await this.Model.listWithPagingByGroup(typeid,projectIds,page,limit);
projectLogList.forEach((item, index)=>{
item = item.toObject();
if(item.type === 'project'){
item.content = `${projectDatas[item.typeid].name} 项目: ` + item.content;
}
projectLogList[index] = item;
})
let total = await this.Model.listCountByGroup(typeid,projectIds);
ctx.body = yapi.commons.resReturn({
list: projectLogList,
total: Math.ceil(total / limit)

View File

@ -135,7 +135,7 @@ class projectController extends baseController {
let username = this.getUsername();
yapi.commons.saveLog({
content: `用户 "${username}" 添加了项目 "${params.name}"`,
type: 'project',
type: 'group',
uid: this.getUid(),
username: username,
typeid: params.group_id