package author import ( "context" v1 "server/api/author/v1" "server/internal/service" "server/utility/ecode" "github.com/gogf/gf/v2/frame/g" ) func (c *ControllerV1) Unfollow(ctx context.Context, req *v1.UnfollowReq) (res *v1.UnfollowRes, err error) { // 从 ctx 获取用户ID userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64() if userId == 0 { return nil, ecode.Logout } out, err := service.UserFollowAuthor().Unfollow(ctx, userId, req.AuthorId) if err != nil { return nil, err } return &v1.UnfollowRes{ Success: out.Success, }, nil }