* 删除用户,只有admin用户才有此权限 * @interface /user/del * @method POST * @param id 用户uid * @category user * @foldnumber 10 * @returns {Object} * @example
(ctx)
| 450 | * @example |
| 451 | */ |
| 452 | async del(ctx) { |
| 453 | //根据id删除一个用户 |
| 454 | try { |
| 455 | if (this.getRole() !== 'admin') { |
| 456 | return (ctx.body = yapi.commons.resReturn(null, 402, 'Without permission.')); |
| 457 | } |
| 458 | |
| 459 | let userInst = yapi.getInst(userModel); |
| 460 | let id = ctx.request.body.id; |
| 461 | if (id == this.getUid()) { |
| 462 | return (ctx.body = yapi.commons.resReturn(null, 403, '禁止删除管理员')); |
| 463 | } |
| 464 | if (!id) { |
| 465 | return (ctx.body = yapi.commons.resReturn(null, 400, 'uid不能为空')); |
| 466 | } |
| 467 | |
| 468 | let result = await userInst.del(id); |
| 469 | |
| 470 | ctx.body = yapi.commons.resReturn(result); |
| 471 | } catch (e) { |
| 472 | ctx.body = yapi.commons.resReturn(null, 402, e.message); |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | /** |
| 477 | * 更新用户个人信息 |
no test coverage detected