Merge branch 'r/paopao-ce-pro' into r/paopao-ce-xtra

r/paopao-ce-xtra
Michael Li 1 year ago
commit 7d461f88e4
No known key found for this signature in database

@ -49,24 +49,12 @@ func NewDataService() (core.DataService, core.VersionInfo) {
var ( var (
v core.VersionInfo v core.VersionInfo
cis core.CacheIndexService cis core.CacheIndexService
ips core.IndexPostsService
) )
db := pgxDB() db := pgxDB()
pvs := security.NewPhoneVerifyService() pvs := security.NewPhoneVerifyService()
ams := NewAuthorizationManageService() ams := NewAuthorizationManageService()
ths := newTweetHelpService(db) ths := newTweetHelpService(db)
ips := newShipIndexService(db, ams, ths)
// initialize core.IndexPostsService
if cfg.If("Friendship") {
ips = newFriendIndexService(db, ams, ths)
} else if cfg.If("Followship") {
ips = newFollowIndexService(db, ths)
} else if cfg.If("Lightship") {
ips = newLightIndexService(db, ths)
} else {
// default use lightship post index service
ips = newLightIndexService(db, ths)
}
// initialize core.CacheIndexService // initialize core.CacheIndexService
cfg.On(cfg.Actions{ cfg.On(cfg.Actions{

@ -13,62 +13,23 @@ import (
) )
var ( var (
_ core.IndexPostsService = (*friendIndexSrv)(nil) _ core.IndexPostsService = (*shipIndexSrv)(nil)
_ core.IndexPostsService = (*followIndexSrv)(nil)
_ core.IndexPostsService = (*lightIndexSrv)(nil)
_ core.IndexPostsService = (*simpleIndexPostsSrv)(nil) _ core.IndexPostsService = (*simpleIndexPostsSrv)(nil)
) )
type friendIndexSrv struct { type shipIndexSrv struct {
*pgxSrv *pgxSrv
ams core.AuthorizationManageService ams core.AuthorizationManageService
ths core.TweetHelpService ths core.TweetHelpService
} }
type followIndexSrv struct {
*pgxSrv
ths core.TweetHelpService
}
type lightIndexSrv struct {
*pgxSrv
ths core.TweetHelpService
}
type simpleIndexPostsSrv struct { type simpleIndexPostsSrv struct {
*pgxSrv *pgxSrv
ths core.TweetHelpService ths core.TweetHelpService
} }
// IndexPosts 根据userId查询广场推文列表简单做到不同用户的主页都是不同的 // IndexPosts 根据userId查询广场推文列表简单做到不同用户的主页都是不同的
func (s *friendIndexSrv) IndexPosts(user *ms.User, offset int, limit int) (*ms.IndexTweetList, error) { func (s *shipIndexSrv) IndexPosts(user *ms.User, offset int, limit int) (*ms.IndexTweetList, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *friendIndexSrv) TweetTimeline(userId int64, offset int, limit int) (*cs.TweetBox, error) {
// TODO
return nil, debug.ErrNotImplemented
}
// IndexPosts 根据userId查询广场推文列表简单做到不同用户的主页都是不同的
func (s *followIndexSrv) IndexPosts(user *ms.User, offset int, limit int) (*ms.IndexTweetList, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *followIndexSrv) TweetTimeline(userId int64, offset int, limit int) (*cs.TweetBox, error) {
// TODO
return nil, debug.ErrNotImplemented
}
// IndexPosts 根据userId查询广场推文列表简单做到不同用户的主页都是不同的
func (s *lightIndexSrv) IndexPosts(user *ms.User, offset int, limit int) (*ms.IndexTweetList, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *lightIndexSrv) TweetTimeline(userId int64, offset int, limit int) (*cs.TweetBox, error) {
// TODO // TODO
return nil, debug.ErrNotImplemented return nil, debug.ErrNotImplemented
} }
@ -84,27 +45,13 @@ func (s *simpleIndexPostsSrv) TweetTimeline(userId int64, offset int, limit int)
return nil, debug.ErrNotImplemented return nil, debug.ErrNotImplemented
} }
func newFriendIndexService(db *pgx.Conn, ams core.AuthorizationManageService, ths core.TweetHelpService) core.IndexPostsService { func newShipIndexService(db *pgx.Conn, ams core.AuthorizationManageService, ths core.TweetHelpService) core.IndexPostsService {
return &friendIndexSrv{ return &shipIndexSrv{
ams: ams, ams: ams,
pgxSrv: newPgxSrv(db), pgxSrv: newPgxSrv(db),
} }
} }
func newFollowIndexService(db *pgx.Conn, ths core.TweetHelpService) core.IndexPostsService {
return &followIndexSrv{
ths: ths,
pgxSrv: newPgxSrv(db),
}
}
func newLightIndexService(db *pgx.Conn, ths core.TweetHelpService) core.IndexPostsService {
return &lightIndexSrv{
ths: ths,
pgxSrv: newPgxSrv(db),
}
}
func newSimpleIndexPostsService(db *pgx.Conn, ths core.TweetHelpService) core.IndexPostsService { func newSimpleIndexPostsService(db *pgx.Conn, ths core.TweetHelpService) core.IndexPostsService {
return &simpleIndexPostsSrv{ return &simpleIndexPostsSrv{
ths: ths, ths: ths,

Loading…
Cancel
Save