Skip to content
关注公众号,获取新课通知

我的关注列表


控制器:app/controller/user.js

js
	// 我的关注列表
    async follows() {
        const { ctx, service, app } = this;
        let currentUser = ctx.authUser;

        let rows = await ctx.page(app.model.Follow, {
            user_id: currentUser.id
        }, {
            include: [{
                model: app.model.User,
                as: "user_follow",
                attributes: ['id', 'username', 'nickname', 'avatar']
            }]
        });

        rows = rows.map(item => {
            return {
                id: item.user_follow.id,
                name: item.user_follow.nickname || item.user_follow.username,
                avatar: item.user_follow.avatar
            }
        });

        ctx.apiSuccess(rows);
    }

路由:app/router.js

js
// 我的关注列表
router.get("/user/follows/:page", controller.user.follows);