feat: 迁移plant
This commit is contained in:
@@ -5,9 +5,11 @@ package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -28,7 +30,12 @@ func NewCommentPostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Comme
|
||||
}
|
||||
|
||||
func (l *CommentPostLogic) CommentPost(req *types.PostCommentReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
|
||||
_, err := l.svcCtx.PlantRpc.CommentPost(l.ctx, &plant.CommentPostReq{
|
||||
PostId: req.PostId,
|
||||
UserId: userId,
|
||||
Content: req.Content,
|
||||
ParentId: req.ParentId,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -5,9 +5,11 @@ package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -28,7 +30,14 @@ func NewCreatePostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Create
|
||||
}
|
||||
|
||||
func (l *CreatePostLogic) CreatePost(req *types.CreatePostReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
|
||||
_, err := l.svcCtx.PlantRpc.CreatePost(l.ctx, &plant.CreatePostReq{
|
||||
UserId: userId,
|
||||
Title: req.Title,
|
||||
Content: req.Content,
|
||||
Location: req.Location,
|
||||
ImgIds: req.ImgIds,
|
||||
TopicId: req.TopicId,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -28,7 +29,6 @@ func NewDeletePostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Delete
|
||||
}
|
||||
|
||||
func (l *DeletePostLogic) DeletePost(req *types.IdsReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
_, err := l.svcCtx.PlantRpc.DeletePost(l.ctx, &plant.IdsReq{Ids: req.Ids})
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -27,8 +28,10 @@ func NewGetPostDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Get
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetPostDetailLogic) GetPostDetail(req *types.IdPathReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
func (l *GetPostDetailLogic) GetPostDetail(req *types.IdPathReq) (interface{}, error) {
|
||||
result, err := l.svcCtx.PlantRpc.GetPostDetail(l.ctx, &plant.IdReq{Id: req.Id})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -27,8 +28,15 @@ func NewGetPostListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPo
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetPostListLogic) GetPostList(req *types.PostListReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
func (l *GetPostListLogic) GetPostList(req *types.PostListReq) (interface{}, error) {
|
||||
result, err := l.svcCtx.PlantRpc.GetPostList(l.ctx, &plant.PostListReq{
|
||||
Current: int32(req.Current),
|
||||
PageSize: int32(req.PageSize),
|
||||
Keyword: req.Keyword,
|
||||
TopicId: req.TopicId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return map[string]interface{}{"list": result.List, "total": result.Total}, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
plantPb "sundynix-micro-go/app/plant/rpc/plant"
|
||||
)
|
||||
|
||||
type GetMyPostListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetMyPostListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetMyPostListLogic {
|
||||
return &GetMyPostListLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *GetMyPostListLogic) GetMyPostList(req *types.PostListReq) (*plantPb.PostListResp, error) {
|
||||
userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
|
||||
return l.svcCtx.PlantRpc.GetPostList(l.ctx, &plantPb.PostListReq{
|
||||
UserId: userId, Current: int32(req.Current), PageSize: int32(req.PageSize),
|
||||
})
|
||||
}
|
||||
@@ -5,9 +5,11 @@ package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -18,7 +20,7 @@ type LikePostLogic struct {
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 点赞帖子
|
||||
// 点赞/取消点赞帖子
|
||||
func NewLikePostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LikePostLogic {
|
||||
return &LikePostLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
@@ -28,7 +30,10 @@ func NewLikePostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LikePost
|
||||
}
|
||||
|
||||
func (l *LikePostLogic) LikePost(req *types.IdReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
|
||||
_, err := l.svcCtx.PlantRpc.LikePost(l.ctx, &plant.LikePostReq{
|
||||
PostId: req.Id,
|
||||
UserId: userId,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
plantPb "sundynix-micro-go/app/plant/rpc/plant"
|
||||
)
|
||||
|
||||
type StarPostLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewStarPostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StarPostLogic {
|
||||
return &StarPostLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *StarPostLogic) StarPost(req *types.IdReq) error {
|
||||
userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
|
||||
_, err := l.svcCtx.PlantRpc.StarPost(l.ctx, &plantPb.LikePostReq{UserId: userId, PostId: req.Id})
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user