* 删除项目成员 * @interface /project/del_member * @method POST * @category project * @foldnumber 10 * @param {Number} id 项目id,不能为空 * @param {member_uid} uid 项目成员uid,不能为空 * @returns {Object} * @example ./api/project/del_member.json
(ctx)
| 450 | */ |
| 451 | |
| 452 | async delMember(ctx) { |
| 453 | try { |
| 454 | let params = ctx.params; |
| 455 | |
| 456 | var check = await this.Model.checkMemberRepeat(params.id, params.member_uid); |
| 457 | if (check === 0) { |
| 458 | return (ctx.body = yapi.commons.resReturn(null, 400, '项目成员不存在')); |
| 459 | } |
| 460 | |
| 461 | if ((await this.checkAuth(params.id, 'project', 'danger')) !== true) { |
| 462 | return (ctx.body = yapi.commons.resReturn(null, 405, '没有权限')); |
| 463 | } |
| 464 | |
| 465 | let result = await this.Model.delMember(params.id, params.member_uid); |
| 466 | let username = this.getUsername(); |
| 467 | yapi |
| 468 | .getInst(userModel) |
| 469 | .findById(params.member_uid) |
| 470 | .then(member => { |
| 471 | yapi.commons.saveLog({ |
| 472 | content: `<a href="/user/profile/${this.getUid()}">${username}</a> 删除了项目中的成员 <a href="/user/profile/${ |
| 473 | params.member_uid |
| 474 | }">${member ? member.username : ''}</a>`, |
| 475 | type: 'project', |
| 476 | uid: this.getUid(), |
| 477 | username: username, |
| 478 | typeid: params.id |
| 479 | }); |
| 480 | }); |
| 481 | ctx.body = yapi.commons.resReturn(result); |
| 482 | } catch (e) { |
| 483 | ctx.body = yapi.commons.resReturn(null, 402, e.message); |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | /** |
| 488 | * 获取项目成员列表 |
nothing calls this directly
no test coverage detected