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

Method list

server/controllers/user.js:380–396  ·  view source on GitHub ↗

* 获取用户列表 * @interface /user/list * @method GET * @category user * @foldnumber 10 * @param {Number} [page] 分页页码 * @param {Number} [limit] 分页大小,默认为10条 * @returns {Object} * @example

(ctx)

Source from the content-addressed store, hash-verified

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 * 获取用户个人信息

Callers

nothing calls this directly

Calls 2

listWithPagingMethod · 0.45
listCountMethod · 0.45

Tested by

no test coverage detected