add timeline service
This commit is contained in:
parent
68cf992930
commit
c9a0926495
|
@ -1,5 +1,2 @@
|
|||
use digimon_tweeting;
|
||||
db.comment.createIndex({ "post_id": 1,"createAt":1});
|
||||
|
||||
|
||||
// TODO 看是否有要刪除過多的索引,要在測試一下
|
|
@ -181,4 +181,35 @@ service CommentService
|
|||
rpc DeleteComment(DeleteCommentReq) returns (OKResp);
|
||||
// UpdateComment 更新評論
|
||||
rpc UpdateComment(UpdateCommentReq) returns (OKResp);
|
||||
}
|
||||
|
||||
// ========== TimeLineService (個人動態時報) ==========
|
||||
|
||||
message GetTimelineReq
|
||||
{
|
||||
string uid = 1; // 用户ID
|
||||
int32 pageIndex = 2; // 頁碼
|
||||
int32 pageSize = 3; // 每一頁大小
|
||||
}
|
||||
|
||||
message GetTimelineResp
|
||||
{
|
||||
repeated PostDetailItem posts = 1; // 貼文列表
|
||||
Pager page = 2; // 分頁訊息
|
||||
}
|
||||
|
||||
message AddPostToTimelineReq
|
||||
{
|
||||
string uid = 1; // key
|
||||
repeated PostDetailItem posts = 2;
|
||||
}
|
||||
// TimelineService 業務邏輯在外面組合
|
||||
service TimelineService
|
||||
{
|
||||
// AddPostToTimeline 加入貼文,只管一股腦全塞,這裡會自動判斷
|
||||
// 誰要砍誰不砍,處理排序,上限是 1000 筆(超過1000 請他回資料庫拿)
|
||||
// 只存活躍用戶的,不活躍不浪費快取的空間
|
||||
rpc AddPostToTimeline(GetTimelineReq) returns (OKResp);
|
||||
// GetTimeline 取得這個人的動態時報
|
||||
rpc GetTimeline(GetTimelineReq) returns (GetTimelineResp);
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package timelineservicelogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"app-cloudep-tweeting-service/gen_result/pb/tweeting"
|
||||
"app-cloudep-tweeting-service/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AddPostToTimelineLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewAddPostToTimelineLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddPostToTimelineLogic {
|
||||
return &AddPostToTimelineLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// AddPostToTimeline 加入貼文,只管一股腦全塞,這裡會自動判斷
|
||||
func (l *AddPostToTimelineLogic) AddPostToTimeline(in *tweeting.GetTimelineReq) (*tweeting.OKResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &tweeting.OKResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package timelineservicelogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"app-cloudep-tweeting-service/gen_result/pb/tweeting"
|
||||
"app-cloudep-tweeting-service/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetTimelineLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetTimelineLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTimelineLogic {
|
||||
return &GetTimelineLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// GetTimeline 取得這個人的動態時報
|
||||
func (l *GetTimelineLogic) GetTimeline(in *tweeting.GetTimelineReq) (*tweeting.GetTimelineResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &tweeting.GetTimelineResp{}, nil
|
||||
}
|
|
@ -7,7 +7,7 @@ import (
|
|||
"context"
|
||||
|
||||
"app-cloudep-tweeting-service/gen_result/pb/tweeting"
|
||||
commentservicelogic "app-cloudep-tweeting-service/internal/logic/commentservice"
|
||||
"app-cloudep-tweeting-service/internal/logic/commentservice"
|
||||
"app-cloudep-tweeting-service/internal/svc"
|
||||
)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"context"
|
||||
|
||||
"app-cloudep-tweeting-service/gen_result/pb/tweeting"
|
||||
postservicelogic "app-cloudep-tweeting-service/internal/logic/postservice"
|
||||
"app-cloudep-tweeting-service/internal/logic/postservice"
|
||||
"app-cloudep-tweeting-service/internal/svc"
|
||||
)
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
// Source: tweeting.proto
|
||||
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"app-cloudep-tweeting-service/gen_result/pb/tweeting"
|
||||
"app-cloudep-tweeting-service/internal/logic/timelineservice"
|
||||
"app-cloudep-tweeting-service/internal/svc"
|
||||
)
|
||||
|
||||
type TimelineServiceServer struct {
|
||||
svcCtx *svc.ServiceContext
|
||||
tweeting.UnimplementedTimelineServiceServer
|
||||
}
|
||||
|
||||
func NewTimelineServiceServer(svcCtx *svc.ServiceContext) *TimelineServiceServer {
|
||||
return &TimelineServiceServer{
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
// AddPostToTimeline 加入貼文,只管一股腦全塞,這裡會自動判斷
|
||||
func (s *TimelineServiceServer) AddPostToTimeline(ctx context.Context, in *tweeting.GetTimelineReq) (*tweeting.OKResp, error) {
|
||||
l := timelineservicelogic.NewAddPostToTimelineLogic(ctx, s.svcCtx)
|
||||
return l.AddPostToTimeline(in)
|
||||
}
|
||||
|
||||
// GetTimeline 取得這個人的動態時報
|
||||
func (s *TimelineServiceServer) GetTimeline(ctx context.Context, in *tweeting.GetTimelineReq) (*tweeting.GetTimelineResp, error) {
|
||||
l := timelineservicelogic.NewGetTimelineLogic(ctx, s.svcCtx)
|
||||
return l.GetTimeline(in)
|
||||
}
|
Loading…
Reference in New Issue