完善功能
This commit is contained in:
27
internal/controller/author/author_v1_unfollow.go
Normal file
27
internal/controller/author/author_v1_unfollow.go
Normal file
@ -0,0 +1,27 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user