* 获取用户列表 * @interface /user/list * @method GET * @category user * @foldnumber 10 * @param {Number} [page] 分页页码 * @param {Number} [limit] 分页大小,默认为10条 * @returns {Object} * @example
(ctx)
| 378 | * @example |
| 379 | */ |
| 380 | async list(ctx) { |
| 381 | let page = ctx.request.query.page || 1, |
| 382 | limit = ctx.request.query.limit || 10; |
| 383 | |
| 384 | const userInst = yapi.getInst(userModel); |
| 385 | try { |
| 386 | let user = await userInst.listWithPaging(page, limit); |
| 387 | let count = await userInst.listCount(); |
| 388 | return (ctx.body = yapi.commons.resReturn({ |
| 389 | count: count, |
| 390 | total: Math.ceil(count / limit), |
| 391 | list: user |
| 392 | })); |
| 393 | } catch (e) { |
| 394 | return (ctx.body = yapi.commons.resReturn(null, 402, e.message)); |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | /** |
| 399 | * 获取用户个人信息 |
nothing calls this directly
no test coverage detected