gorm: optimize core interface define

x/wasm
Michael Li 1 year ago
parent 368eadf9e6
commit a101bcabc5
No known key found for this signature in database

@ -7,6 +7,7 @@ package core
import (
"context"
"github.com/rocboss/paopao-ce/internal/core/cs"
"github.com/rocboss/paopao-ce/internal/dao/jinzhu/dbr"
)
@ -26,6 +27,11 @@ type IndexAction struct {
Post *dbr.Post
}
type IndexActionA struct {
Act IdxAct
Tweet *cs.TweetInfo
}
func (a IdxAct) String() string {
switch a {
case IdxActNop:
@ -52,6 +58,13 @@ func NewIndexAction(act IdxAct, post *dbr.Post) *IndexAction {
}
}
func NewIndexActionA(act IdxAct, tweet *cs.TweetInfo) *IndexActionA {
return &IndexActionA{
Act: act,
Tweet: tweet,
}
}
// CacheIndexService cache index service interface
type CacheIndexService interface {
IndexPostsService
@ -59,6 +72,13 @@ type CacheIndexService interface {
SendAction(act IdxAct, post *dbr.Post)
}
// CacheIndexServantA cache index service interface
type CacheIndexServantA interface {
IndexPostsServantA
SendAction(act IdxAct, tweet *cs.TweetInfo)
}
// RedisCache memory cache by Redis
type RedisCache interface {
SetPushToSearchJob(ctx context.Context) error

@ -8,12 +8,17 @@ import (
"github.com/rocboss/paopao-ce/internal/core/cs"
)
// TweetTimelineService 广场首页推文时间线服务
type TweetTimelineService interface {
TweetTimeline(userId int64, offset int, limit int) (*cs.TweetBox, error)
type IndexTweetList struct {
Tweets []*PostFormated
Total int64
}
// TweetTimelineServantA 广场首页推文时间线服务(版本A)
type TweetTimelineServantA interface {
TweetTimeline(userId int64, offset int, limit int) (*cs.TweetBox, error)
// IndexPostsService 广场首页推文列表服务
type IndexPostsService interface {
IndexPosts(user *User, offset int, limit int) (*IndexTweetList, error)
}
// IndexPostsServantA 广场首页推文列表服务(版本A)
type IndexPostsServantA interface {
IndexPosts(user *User, limit int, offset int) (*cs.TweetBox, error)
}

@ -33,11 +33,6 @@ type (
Attachment = dbr.Attachment
AttachmentType = dbr.AttachmentType
PostContentT = dbr.PostContentT
IndexTweetList struct {
Tweets []*PostFormated
Total int64
}
)
// TweetService 推文检索服务
@ -78,20 +73,15 @@ type TweetHelpService interface {
MergePosts(posts []*Post) ([]*PostFormated, error)
}
// IndexPostsService 广场首页推文列表服务
type IndexPostsService interface {
IndexPosts(user *User, offset int, limit int) (*IndexTweetList, error)
}
// TweetServantA 推文检索服务(版本A)
type TweetServantA interface {
TweetInfoById(id int64) (*cs.TweetInfo, error)
TweetItemById(id int64) (*cs.TweetItem, error)
UserTweets(visitorId, userId int64) (cs.TweetList, error)
ReactionByTweetId(userId int64, tweetId int64) (*cs.ReactionItem, error)
UserReactions(userId int64, offset int, limit int) (cs.ReactionList, error)
UserReactions(userId int64, limit int, offset int) (cs.ReactionList, error)
FavoriteByTweetId(userId int64, tweetId int64) (*cs.FavoriteItem, error)
UserFavorites(userId int64, offset int, limit int) (cs.FavoriteList, error)
UserFavorites(userId int64, limit int, offset int) (cs.FavoriteList, error)
AttachmentByTweetId(userId int64, tweetId int64) (*cs.AttachmentBill, error)
}

@ -257,6 +257,7 @@ func (s *DaoServant) GetTweetList(conditions *core.ConditionsT, offset, limit in
func NewDaoServant() *DaoServant {
return &DaoServant{
Redis: cache.NewRedisCache(),
Dsa: dao.WebDataServantA(),
Ds: dao.DataService(),
Ts: dao.TweetSearchService(),
}

Loading…
Cancel
Save