MCPcopy
hub / github.com/YMFE/yapi / del

Method del

server/controllers/user.js:452–474  ·  view source on GitHub ↗

* 删除用户,只有admin用户才有此权限 * @interface /user/del * @method POST * @param id 用户uid * @category user * @foldnumber 10 * @returns {Object} * @example

(ctx)

Source from the content-addressed store, hash-verified

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 * 更新用户个人信息

Callers 3

delColMethod · 0.45
delCaseMethod · 0.45

Calls 2

getRoleMethod · 0.80
getUidMethod · 0.45

Tested by

no test coverage detected