On this page
我的粉丝列表
控制器:app/controller/user.js
js
// 我的粉丝列表
async fens() {
const { ctx, service, app } = this;
let currentUser = ctx.authUser;
let rows = await ctx.page(app.model.Follow, {
follow_id: currentUser.id
}, {
include: [{
model: app.model.User,
as: "user_fen",
attributes: ['id', 'username', 'nickname', 'avatar']
}]
});
rows = rows.map(item => {
return {
id: item.user_fen.id,
name: item.user_fen.nickname || item.user_fen.username,
avatar: item.user_fen.avatar
}
});
ctx.apiSuccess(rows);
}
路由:app/router.js
js
// 我的粉丝列表
router.get("/user/fens/:page", controller.user.fens);