diff --git a/internal/dao/slonik/authority.go b/internal/dao/slonik/authority.go index cb08e465..0981489d 100644 --- a/internal/dao/slonik/authority.go +++ b/internal/dao/slonik/authority.go @@ -11,45 +11,45 @@ import ( ) var ( - _ core.AuthorizationManageService = (*authorizationManageServant)(nil) + _ core.AuthorizationManageService = (*authorizationManageSrv)(nil) ) -type authorizationManageServant struct { - *pgxServant +type authorizationManageSrv struct { + *pgxSrv } -func (s *authorizationManageServant) IsAllow(user *core.User, action *core.Action) bool { +func (s *authorizationManageSrv) IsAllow(user *core.User, action *core.Action) bool { // TODO debug.NotImplemented() return false } -func (s *authorizationManageServant) MyFriendSet(userId int64) core.FriendSet { +func (s *authorizationManageSrv) MyFriendSet(userId int64) core.FriendSet { // TODO debug.NotImplemented() return nil } -func (s *authorizationManageServant) BeFriendFilter(userId int64) core.FriendFilter { +func (s *authorizationManageSrv) BeFriendFilter(userId int64) core.FriendFilter { // TODO debug.NotImplemented() return nil } -func (s *authorizationManageServant) BeFriendIds(userId int64) ([]int64, error) { +func (s *authorizationManageSrv) BeFriendIds(userId int64) ([]int64, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *authorizationManageServant) isFriend(userId int64, friendId int64) bool { +func (s *authorizationManageSrv) isFriend(userId int64, friendId int64) bool { // TODO debug.NotImplemented() return false } func newAuthorizationManageService(db *pgx.Conn) core.AuthorizationManageService { - return &authorizationManageServant{ - pgxServant: newPgxServant(db), + return &authorizationManageSrv{ + pgxSrv: newPgxSrv(db), } } diff --git a/internal/dao/slonik/comments.go b/internal/dao/slonik/comments.go index d4c0ece8..25cff917 100644 --- a/internal/dao/slonik/comments.go +++ b/internal/dao/slonik/comments.go @@ -11,92 +11,92 @@ import ( ) var ( - _ core.CommentService = (*commentServant)(nil) - _ core.CommentManageService = (*commentManageServant)(nil) + _ core.CommentService = (*commentSrv)(nil) + _ core.CommentManageService = (*commentManageSrv)(nil) ) -type commentServant struct { - *pgxServant +type commentSrv struct { + *pgxSrv } -type commentManageServant struct { - *pgxServant +type commentManageSrv struct { + *pgxSrv } -func (s *commentServant) GetComments(conditions *core.ConditionsT, offset, limit int) ([]*core.Comment, error) { +func (s *commentSrv) GetComments(conditions *core.ConditionsT, offset, limit int) ([]*core.Comment, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *commentServant) GetCommentByID(id int64) (*core.Comment, error) { +func (s *commentSrv) GetCommentByID(id int64) (*core.Comment, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *commentServant) GetCommentReplyByID(id int64) (*core.CommentReply, error) { +func (s *commentSrv) GetCommentReplyByID(id int64) (*core.CommentReply, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *commentServant) GetCommentCount(conditions *core.ConditionsT) (int64, error) { +func (s *commentSrv) GetCommentCount(conditions *core.ConditionsT) (int64, error) { // TODO debug.NotImplemented() return 0, nil } -func (s *commentServant) GetCommentContentsByIDs(ids []int64) ([]*core.CommentContent, error) { +func (s *commentSrv) GetCommentContentsByIDs(ids []int64) ([]*core.CommentContent, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *commentServant) GetCommentRepliesByID(ids []int64) ([]*core.CommentReplyFormated, error) { +func (s *commentSrv) GetCommentRepliesByID(ids []int64) ([]*core.CommentReplyFormated, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *commentManageServant) DeleteComment(comment *core.Comment) error { +func (s *commentManageSrv) DeleteComment(comment *core.Comment) error { // TODO debug.NotImplemented() return nil } -func (s *commentManageServant) CreateComment(comment *core.Comment) (*core.Comment, error) { +func (s *commentManageSrv) CreateComment(comment *core.Comment) (*core.Comment, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *commentManageServant) CreateCommentReply(reply *core.CommentReply) (*core.CommentReply, error) { +func (s *commentManageSrv) CreateCommentReply(reply *core.CommentReply) (*core.CommentReply, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *commentManageServant) DeleteCommentReply(reply *core.CommentReply) error { +func (s *commentManageSrv) DeleteCommentReply(reply *core.CommentReply) error { // TODO debug.NotImplemented() return nil } -func (s *commentManageServant) CreateCommentContent(content *core.CommentContent) (*core.CommentContent, error) { +func (s *commentManageSrv) CreateCommentContent(content *core.CommentContent) (*core.CommentContent, error) { // TODO debug.NotImplemented() return nil, nil } func newCommentService(db *pgx.Conn) core.CommentService { - return &commentServant{ - pgxServant: newPgxServant(db), + return &commentSrv{ + pgxSrv: newPgxSrv(db), } } func newCommentManageService(db *pgx.Conn) core.CommentManageService { - return &commentManageServant{ - pgxServant: newPgxServant(db), + return &commentManageSrv{ + pgxSrv: newPgxSrv(db), } } diff --git a/internal/dao/slonik/contacts.go b/internal/dao/slonik/contacts.go index a03a9519..393c9671 100644 --- a/internal/dao/slonik/contacts.go +++ b/internal/dao/slonik/contacts.go @@ -11,51 +11,51 @@ import ( ) var ( - _ core.ContactManageService = (*contactManageServant)(nil) + _ core.ContactManageService = (*contactManageSrv)(nil) ) -type contactManageServant struct { - *pgxServant +type contactManageSrv struct { + *pgxSrv } -func (s *contactManageServant) RequestingFriend(userId int64, friendId int64, greetings string) (err error) { +func (s *contactManageSrv) RequestingFriend(userId int64, friendId int64, greetings string) (err error) { // TODO debug.NotImplemented() return nil } -func (s *contactManageServant) AddFriend(userId int64, friendId int64) (err error) { +func (s *contactManageSrv) AddFriend(userId int64, friendId int64) (err error) { // TODO debug.NotImplemented() return nil } -func (s *contactManageServant) RejectFriend(userId int64, friendId int64) (err error) { +func (s *contactManageSrv) RejectFriend(userId int64, friendId int64) (err error) { // TODO debug.NotImplemented() return nil } -func (s *contactManageServant) DeleteFriend(userId int64, friendId int64) (err error) { +func (s *contactManageSrv) DeleteFriend(userId int64, friendId int64) (err error) { // TODO debug.NotImplemented() return nil } -func (s *contactManageServant) GetContacts(userId int64, offset int, limit int) (*core.ContactList, error) { +func (s *contactManageSrv) GetContacts(userId int64, offset int, limit int) (*core.ContactList, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *contactManageServant) IsFriend(userId int64, friendId int64) bool { +func (s *contactManageSrv) IsFriend(userId int64, friendId int64) bool { // TODO debug.NotImplemented() return false } func newContactManageService(db *pgx.Conn) core.ContactManageService { - return &contactManageServant{ - pgxServant: newPgxServant(db), + return &contactManageSrv{ + pgxSrv: newPgxSrv(db), } } diff --git a/internal/dao/slonik/messages.go b/internal/dao/slonik/messages.go index 51742aca..1aa2ca19 100644 --- a/internal/dao/slonik/messages.go +++ b/internal/dao/slonik/messages.go @@ -11,51 +11,51 @@ import ( ) var ( - _ core.MessageService = (*messageServant)(nil) + _ core.MessageService = (*messageSrv)(nil) ) -type messageServant struct { - *pgxServant +type messageSrv struct { + *pgxSrv } -func (s *messageServant) CreateMessage(msg *core.Message) (*core.Message, error) { +func (s *messageSrv) CreateMessage(msg *core.Message) (*core.Message, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *messageServant) GetUnreadCount(userID int64) (int64, error) { +func (s *messageSrv) GetUnreadCount(userID int64) (int64, error) { // TODO debug.NotImplemented() return 0, nil } -func (s *messageServant) GetMessageByID(id int64) (*core.Message, error) { +func (s *messageSrv) GetMessageByID(id int64) (*core.Message, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *messageServant) ReadMessage(message *core.Message) error { +func (s *messageSrv) ReadMessage(message *core.Message) error { // TODO debug.NotImplemented() return nil } -func (s *messageServant) GetMessages(conditions *core.ConditionsT, offset, limit int) ([]*core.MessageFormated, error) { +func (s *messageSrv) GetMessages(conditions *core.ConditionsT, offset, limit int) ([]*core.MessageFormated, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *messageServant) GetMessageCount(conditions *core.ConditionsT) (int64, error) { +func (s *messageSrv) GetMessageCount(conditions *core.ConditionsT) (int64, error) { // TODO debug.NotImplemented() return 0, nil } func newMessageService(db *pgx.Conn) core.MessageService { - return &messageServant{ - pgxServant: newPgxServant(db), + return &messageSrv{ + pgxSrv: newPgxSrv(db), } } diff --git a/internal/dao/slonik/pgx.go b/internal/dao/slonik/pgx.go index 54ece04a..32dea035 100644 --- a/internal/dao/slonik/pgx.go +++ b/internal/dao/slonik/pgx.go @@ -18,12 +18,12 @@ var ( _oncePgx sync.Once ) -type pgxServant struct { +type pgxSrv struct { db *pgx.Conn q dbr.Querier } -func (s *pgxServant) begin(ctx context.Context) (pgx.Tx, dbr.Querier, error) { +func (s *pgxSrv) begin(ctx context.Context) (pgx.Tx, dbr.Querier, error) { tx, err := s.db.Begin(ctx) if err != nil { return nil, nil, err @@ -31,7 +31,7 @@ func (s *pgxServant) begin(ctx context.Context) (pgx.Tx, dbr.Querier, error) { return tx, dbr.New(tx), nil } -func (s *pgxServant) beingTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, dbr.Querier, error) { +func (s *pgxSrv) beingTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, dbr.Querier, error) { tx, err := s.db.BeginTx(ctx, txOptions) if err != nil { return nil, nil, err @@ -39,7 +39,7 @@ func (s *pgxServant) beingTx(ctx context.Context, txOptions pgx.TxOptions) (pgx. return tx, dbr.New(tx), nil } -func (s *pgxServant) with(handle func(c context.Context, q dbr.Querier) error) error { +func (s *pgxSrv) with(handle func(c context.Context, q dbr.Querier) error) error { ctx := context.Background() tx, err := s.db.Begin(ctx) if err != nil { @@ -52,7 +52,7 @@ func (s *pgxServant) with(handle func(c context.Context, q dbr.Querier) error) e return tx.Commit(ctx) } -func (s *pgxServant) withTx(txOptions pgx.TxOptions, handle func(ctx context.Context, q dbr.Querier) error) error { +func (s *pgxSrv) withTx(txOptions pgx.TxOptions, handle func(ctx context.Context, q dbr.Querier) error) error { ctx := context.Background() tx, err := s.db.BeginTx(ctx, txOptions) if err != nil { @@ -65,7 +65,7 @@ func (s *pgxServant) withTx(txOptions pgx.TxOptions, handle func(ctx context.Con return tx.Commit(ctx) } -func (s *pgxServant) withCtx(ctx context.Context, handle func(dbr.Querier) error) error { +func (s *pgxSrv) withCtx(ctx context.Context, handle func(dbr.Querier) error) error { tx, err := s.db.Begin(ctx) if err != nil { return err @@ -77,7 +77,7 @@ func (s *pgxServant) withCtx(ctx context.Context, handle func(dbr.Querier) error return tx.Commit(ctx) } -func (s *pgxServant) withTxCtx(ctx context.Context, txOptions pgx.TxOptions, handle func(dbr.Querier) error) error { +func (s *pgxSrv) withTxCtx(ctx context.Context, txOptions pgx.TxOptions, handle func(dbr.Querier) error) error { tx, err := s.db.BeginTx(ctx, txOptions) if err != nil { return err @@ -89,8 +89,8 @@ func (s *pgxServant) withTxCtx(ctx context.Context, txOptions pgx.TxOptions, han return tx.Commit(ctx) } -func newPgxServant(db *pgx.Conn) *pgxServant { - return &pgxServant{ +func newPgxSrv(db *pgx.Conn) *pgxSrv { + return &pgxSrv{ db: db, q: dbr.New(db), } diff --git a/internal/dao/slonik/security.go b/internal/dao/slonik/security.go index 00281421..8d3aff80 100644 --- a/internal/dao/slonik/security.go +++ b/internal/dao/slonik/security.go @@ -11,36 +11,36 @@ import ( ) var ( - _ core.SecurityService = (*securityServant)(nil) + _ core.SecurityService = (*securitySrv)(nil) ) -type securityServant struct { - *pgxServant +type securitySrv struct { + *pgxSrv } // GetLatestPhoneCaptcha 获取最新短信验证码 -func (s *securityServant) GetLatestPhoneCaptcha(phone string) (*core.Captcha, error) { +func (s *securitySrv) GetLatestPhoneCaptcha(phone string) (*core.Captcha, error) { // TODO debug.NotImplemented() return nil, nil } // UsePhoneCaptcha 更新短信验证码 -func (s *securityServant) UsePhoneCaptcha(captcha *core.Captcha) error { +func (s *securitySrv) UsePhoneCaptcha(captcha *core.Captcha) error { // TODO debug.NotImplemented() return nil } // SendPhoneCaptcha 发送短信验证码 -func (s *securityServant) SendPhoneCaptcha(phone string) error { +func (s *securitySrv) SendPhoneCaptcha(phone string) error { // TODO debug.NotImplemented() return nil } func newSecurityService(db *pgx.Conn, phoneVerify core.PhoneVerifyService) core.SecurityService { - return &securityServant{ - pgxServant: newPgxServant(db), + return &securitySrv{ + pgxSrv: newPgxSrv(db), } } diff --git a/internal/dao/slonik/slonik.go b/internal/dao/slonik/slonik.go index aa0aef65..b3b27e53 100644 --- a/internal/dao/slonik/slonik.go +++ b/internal/dao/slonik/slonik.go @@ -14,11 +14,14 @@ import ( ) var ( - _ core.DataService = (*dataServant)(nil) - _ core.VersionInfo = (*dataServant)(nil) + _ core.DataService = (*dataSrv)(nil) + _ core.VersionInfo = (*dataSrv)(nil) + + _ core.DataServantA = (*dataSrvA)(nil) + _ core.VersionInfo = (*dataSrvA)(nil) ) -type dataServant struct { +type dataSrv struct { core.IndexPostsService core.WalletService core.MessageService @@ -34,6 +37,13 @@ type dataServant struct { core.AttachmentCheckService } +type dataSrvA struct { + core.TopicServantA + core.TweetServantA + core.TweetManageServantA + core.TweetHelpServantA +} + func NewDataService() (core.DataService, core.VersionInfo) { var ( v core.VersionInfo @@ -70,7 +80,7 @@ func NewDataService() (core.DataService, core.VersionInfo) { } logrus.Infof("use %s as cache index service by version: %s", v.Name(), v.Version()) - ds := &dataServant{ + ds := &dataSrv{ IndexPostsService: cis, WalletService: newWalletService(db), MessageService: newMessageService(db), @@ -97,10 +107,18 @@ func NewAuthorizationManageService() core.AuthorizationManageService { return newAuthorizationManageService(pgxDB()) } -func (s *dataServant) Name() string { +func (s *dataSrv) Name() string { + return "sqlc/pgx" +} + +func (s *dataSrv) Version() *semver.Version { + return semver.MustParse("v0.1.0") +} + +func (s *dataSrvA) Name() string { return "sqlc/pgx" } -func (s *dataServant) Version() *semver.Version { +func (s *dataSrvA) Version() *semver.Version { return semver.MustParse("v0.1.0") } diff --git a/internal/dao/slonik/timeline.go b/internal/dao/slonik/timeline.go index e6b9eeb6..f5c9fb3a 100644 --- a/internal/dao/slonik/timeline.go +++ b/internal/dao/slonik/timeline.go @@ -12,101 +12,101 @@ import ( ) var ( - _ core.IndexPostsService = (*friendIndexServant)(nil) - _ core.IndexPostsService = (*followIndexServant)(nil) - _ core.IndexPostsService = (*lightIndexServant)(nil) - _ core.IndexPostsService = (*simpleIndexPostsServant)(nil) + _ core.IndexPostsService = (*friendIndexSrv)(nil) + _ core.IndexPostsService = (*followIndexSrv)(nil) + _ core.IndexPostsService = (*lightIndexSrv)(nil) + _ core.IndexPostsService = (*simpleIndexPostsSrv)(nil) ) -type friendIndexServant struct { - *pgxServant +type friendIndexSrv struct { + *pgxSrv ams core.AuthorizationManageService ths core.TweetHelpService } -type followIndexServant struct { - *pgxServant +type followIndexSrv struct { + *pgxSrv ths core.TweetHelpService } -type lightIndexServant struct { - *pgxServant +type lightIndexSrv struct { + *pgxSrv ths core.TweetHelpService } -type simpleIndexPostsServant struct { - *pgxServant +type simpleIndexPostsSrv struct { + *pgxSrv ths core.TweetHelpService } // IndexPosts 根据userId查询广场推文列表,简单做到不同用户的主页都是不同的; -func (s *friendIndexServant) IndexPosts(user *core.User, offset int, limit int) (*core.IndexTweetList, error) { +func (s *friendIndexSrv) IndexPosts(user *core.User, offset int, limit int) (*core.IndexTweetList, error) { // TODO return nil, debug.ErrNotImplemented } -func (s *friendIndexServant) TweetTimeline(userId int64, offset int, limit int) (*cs.TweetBox, error) { +func (s *friendIndexSrv) TweetTimeline(userId int64, offset int, limit int) (*cs.TweetBox, error) { // TODO return nil, debug.ErrNotImplemented } // IndexPosts 根据userId查询广场推文列表,简单做到不同用户的主页都是不同的; -func (s *followIndexServant) IndexPosts(user *core.User, offset int, limit int) (*core.IndexTweetList, error) { +func (s *followIndexSrv) IndexPosts(user *core.User, offset int, limit int) (*core.IndexTweetList, error) { // TODO return nil, debug.ErrNotImplemented } -func (s *followIndexServant) TweetTimeline(userId int64, offset int, limit int) (*cs.TweetBox, error) { +func (s *followIndexSrv) TweetTimeline(userId int64, offset int, limit int) (*cs.TweetBox, error) { // TODO return nil, debug.ErrNotImplemented } // IndexPosts 根据userId查询广场推文列表,简单做到不同用户的主页都是不同的; -func (s *lightIndexServant) IndexPosts(user *core.User, offset int, limit int) (*core.IndexTweetList, error) { +func (s *lightIndexSrv) IndexPosts(user *core.User, offset int, limit int) (*core.IndexTweetList, error) { // TODO return nil, debug.ErrNotImplemented } -func (s *lightIndexServant) TweetTimeline(userId int64, offset int, limit int) (*cs.TweetBox, error) { +func (s *lightIndexSrv) TweetTimeline(userId int64, offset int, limit int) (*cs.TweetBox, error) { // TODO return nil, debug.ErrNotImplemented } // simpleCacheIndexGetPosts simpleCacheIndex 专属获取广场推文列表函数 -func (s *simpleIndexPostsServant) IndexPosts(_user *core.User, offset int, limit int) (*core.IndexTweetList, error) { +func (s *simpleIndexPostsSrv) IndexPosts(_user *core.User, offset int, limit int) (*core.IndexTweetList, error) { // TODO return nil, debug.ErrNotImplemented } -func (s *simpleIndexPostsServant) TweetTimeline(userId int64, offset int, limit int) (*cs.TweetBox, error) { +func (s *simpleIndexPostsSrv) TweetTimeline(userId int64, offset int, limit int) (*cs.TweetBox, error) { // TODO return nil, debug.ErrNotImplemented } func newFriendIndexService(db *pgx.Conn, ams core.AuthorizationManageService, ths core.TweetHelpService) core.IndexPostsService { - return &friendIndexServant{ - ams: ams, - pgxServant: newPgxServant(db), + return &friendIndexSrv{ + ams: ams, + pgxSrv: newPgxSrv(db), } } func newFollowIndexService(db *pgx.Conn, ths core.TweetHelpService) core.IndexPostsService { - return &followIndexServant{ - ths: ths, - pgxServant: newPgxServant(db), + return &followIndexSrv{ + ths: ths, + pgxSrv: newPgxSrv(db), } } func newLightIndexService(db *pgx.Conn, ths core.TweetHelpService) core.IndexPostsService { - return &lightIndexServant{ - ths: ths, - pgxServant: newPgxServant(db), + return &lightIndexSrv{ + ths: ths, + pgxSrv: newPgxSrv(db), } } func newSimpleIndexPostsService(db *pgx.Conn, ths core.TweetHelpService) core.IndexPostsService { - return &simpleIndexPostsServant{ - ths: ths, - pgxServant: newPgxServant(db), + return &simpleIndexPostsSrv{ + ths: ths, + pgxSrv: newPgxSrv(db), } } diff --git a/internal/dao/slonik/topics.go b/internal/dao/slonik/topics.go index a1ce3d7d..e6640e09 100644 --- a/internal/dao/slonik/topics.go +++ b/internal/dao/slonik/topics.go @@ -16,16 +16,16 @@ import ( ) var ( - _ core.TopicService = (*topicServant)(nil) + _ core.TopicService = (*topicSrv)(nil) ) -type topicServant struct { - *pgxServant +type topicSrv struct { + *pgxSrv } // UpsertTags update/insert tags info. // Assume tags slice is distinct elements. -func (s *topicServant) UpsertTags(userId int64, tags []string) (res cs.TagInfoList, err error) { +func (s *topicSrv) UpsertTags(userId int64, tags []string) (res cs.TagInfoList, err error) { err = s.with(func(c context.Context, q dbr.Querier) error { now := time.Now().Unix() upTags, err := q.IncrTags(c, &dbr.IncrTagsParams{ @@ -74,14 +74,14 @@ func (s *topicServant) UpsertTags(userId int64, tags []string) (res cs.TagInfoLi return } -func (s *topicServant) DecrTagsById(ids []int64) error { +func (s *topicSrv) DecrTagsById(ids []int64) error { return s.q.DecrTagsById(context.Background(), &dbr.DecrTagsByIdParams{ Ids: ids, ModifiedOn: time.Now().Unix(), }) } -func (s *topicServant) ListTags(typ cs.TagType, limit int, offset int) (res cs.TagList, _ error) { +func (s *topicSrv) ListTags(typ cs.TagType, limit int, offset int) (res cs.TagList, _ error) { ctx := context.Background() switch typ { case cs.TagTypeHot: @@ -130,7 +130,7 @@ func (s *topicServant) ListTags(typ cs.TagType, limit int, offset int) (res cs.T return } -func (s *topicServant) TagsByKeyword(keyword string) (res cs.TagInfoList, _ error) { +func (s *topicSrv) TagsByKeyword(keyword string) (res cs.TagInfoList, _ error) { ctx := context.Background() keyword = "%" + strings.Trim(keyword, " ") + "%" if keyword == "%%" { @@ -164,7 +164,7 @@ func (s *topicServant) TagsByKeyword(keyword string) (res cs.TagInfoList, _ erro } func newTopicService(db *pgx.Conn) core.TopicService { - return &topicServant{ - pgxServant: newPgxServant(db), + return &topicSrv{ + pgxSrv: newPgxSrv(db), } } diff --git a/internal/dao/slonik/tweets.go b/internal/dao/slonik/tweets.go index 4cdd2526..fe3a535f 100644 --- a/internal/dao/slonik/tweets.go +++ b/internal/dao/slonik/tweets.go @@ -13,319 +13,319 @@ import ( ) var ( - _ core.TweetService = (*tweetServant)(nil) - _ core.TweetManageService = (*tweetManageServant)(nil) - _ core.TweetHelpService = (*tweetHelpServant)(nil) + _ core.TweetService = (*tweetSrv)(nil) + _ core.TweetManageService = (*tweetManageSrv)(nil) + _ core.TweetHelpService = (*tweetHelpSrv)(nil) ) -type tweetServant struct { - *pgxServant +type tweetSrv struct { + *pgxSrv } -type tweetManageServant struct { - *pgxServant +type tweetManageSrv struct { + *pgxSrv } -type tweetHelpServant struct { - *pgxServant +type tweetHelpSrv struct { + *pgxSrv } // MergePosts post数据整合 -func (s *tweetHelpServant) MergePosts(posts []*core.Post) ([]*core.PostFormated, error) { +func (s *tweetHelpSrv) MergePosts(posts []*core.Post) ([]*core.PostFormated, error) { // TODO debug.NotImplemented() return nil, nil } // RevampPosts post数据整形修复 -func (s *tweetHelpServant) RevampPosts(posts []*core.PostFormated) ([]*core.PostFormated, error) { +func (s *tweetHelpSrv) RevampPosts(posts []*core.PostFormated) ([]*core.PostFormated, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetHelpServant) RevampTweets(tweets cs.TweetList) (cs.TweetList, error) { +func (s *tweetHelpSrv) RevampTweets(tweets cs.TweetList) (cs.TweetList, error) { // TODO return nil, debug.ErrNotImplemented } -func (s *tweetHelpServant) MergeTweets(tweets cs.TweetInfo) (cs.TweetList, error) { +func (s *tweetHelpSrv) MergeTweets(tweets cs.TweetInfo) (cs.TweetList, error) { // TODO return nil, debug.ErrNotImplemented } -func (s *tweetHelpServant) getPostContentsByIDs(ids []int64) ([]*core.PostContent, error) { +func (s *tweetHelpSrv) getPostContentsByIDs(ids []int64) ([]*core.PostContent, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetHelpServant) getUsersByIDs(ids []int64) ([]*core.User, error) { +func (s *tweetHelpSrv) getUsersByIDs(ids []int64) ([]*core.User, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetManageServant) CreatePostCollection(postID, userID int64) (*core.PostCollection, error) { +func (s *tweetManageSrv) CreatePostCollection(postID, userID int64) (*core.PostCollection, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetManageServant) DeletePostCollection(p *core.PostCollection) error { +func (s *tweetManageSrv) DeletePostCollection(p *core.PostCollection) error { // TODO debug.NotImplemented() return nil } -func (s *tweetManageServant) CreatePostContent(content *core.PostContent) (*core.PostContent, error) { +func (s *tweetManageSrv) CreatePostContent(content *core.PostContent) (*core.PostContent, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetManageServant) CreatePost(post *core.Post) (*core.Post, error) { +func (s *tweetManageSrv) CreatePost(post *core.Post) (*core.Post, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetManageServant) DeletePost(post *core.Post) ([]string, error) { +func (s *tweetManageSrv) DeletePost(post *core.Post) ([]string, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetManageServant) deleteCommentByPostId(db *gorm.DB, postId int64) ([]string, error) { +func (s *tweetManageSrv) deleteCommentByPostId(db *gorm.DB, postId int64) ([]string, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetManageServant) LockPost(post *core.Post) error { +func (s *tweetManageSrv) LockPost(post *core.Post) error { // TODO debug.NotImplemented() return nil } -func (s *tweetManageServant) StickPost(post *core.Post) error { +func (s *tweetManageSrv) StickPost(post *core.Post) error { // TODO debug.NotImplemented() return nil } -func (s *tweetManageServant) VisiblePost(post *core.Post, visibility core.PostVisibleT) error { +func (s *tweetManageSrv) VisiblePost(post *core.Post, visibility core.PostVisibleT) error { // TODO debug.NotImplemented() return nil } -func (s *tweetManageServant) UpdatePost(post *core.Post) error { +func (s *tweetManageSrv) UpdatePost(post *core.Post) error { // TODO debug.NotImplemented() return nil } -func (s *tweetManageServant) CreatePostStar(postID, userID int64) (*core.PostStar, error) { +func (s *tweetManageSrv) CreatePostStar(postID, userID int64) (*core.PostStar, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetManageServant) DeletePostStar(p *core.PostStar) error { +func (s *tweetManageSrv) DeletePostStar(p *core.PostStar) error { // TODO debug.NotImplemented() return nil } -func (s *tweetManageServant) CreateAttachment(obj *cs.Attachment) (int64, error) { +func (s *tweetManageSrv) CreateAttachment(obj *cs.Attachment) (int64, error) { // TODO return 0, debug.ErrNotImplemented } -func (s *tweetManageServant) CreateTweet(userId int64, req *cs.NewTweetReq) (*cs.TweetItem, error) { +func (s *tweetManageSrv) CreateTweet(userId int64, req *cs.NewTweetReq) (*cs.TweetItem, error) { // TODO return nil, debug.ErrNotImplemented } -func (s *tweetManageServant) DeleteTweet(userId int64, tweetId int64) ([]string, error) { +func (s *tweetManageSrv) DeleteTweet(userId int64, tweetId int64) ([]string, error) { // TODO return nil, debug.ErrNotImplemented } -func (s *tweetManageServant) LockTweet(userId int64, tweetId int64) error { +func (s *tweetManageSrv) LockTweet(userId int64, tweetId int64) error { // TODO return debug.ErrNotImplemented } -func (s *tweetManageServant) StickTweet(userId int64, tweetId int64) error { +func (s *tweetManageSrv) StickTweet(userId int64, tweetId int64) error { // TODO return debug.ErrNotImplemented } -func (s *tweetManageServant) VisibleTweet(userId int64, visibility cs.TweetVisibleType) error { +func (s *tweetManageSrv) VisibleTweet(userId int64, visibility cs.TweetVisibleType) error { // TODO return debug.ErrNotImplemented } -func (s *tweetManageServant) CreateReaction(userId int64, tweetId int64) error { +func (s *tweetManageSrv) CreateReaction(userId int64, tweetId int64) error { // TODO return debug.ErrNotImplemented } -func (s *tweetManageServant) DeleteReaction(userId int64, reactionId int64) error { +func (s *tweetManageSrv) DeleteReaction(userId int64, reactionId int64) error { // TODO return debug.ErrNotImplemented } -func (s *tweetManageServant) CreateFavorite(userId int64, tweetId int64) error { +func (s *tweetManageSrv) CreateFavorite(userId int64, tweetId int64) error { // TODO return debug.ErrNotImplemented } -func (s *tweetManageServant) DeleteFavorite(userId int64, favoriteId int64) error { +func (s *tweetManageSrv) DeleteFavorite(userId int64, favoriteId int64) error { // TODO return debug.ErrNotImplemented } -func (s *tweetServant) GetPostByID(id int64) (*core.Post, error) { +func (s *tweetSrv) GetPostByID(id int64) (*core.Post, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetServant) GetPosts(conditions *core.ConditionsT, limit int, offset int) ([]*core.Post, error) { +func (s *tweetSrv) GetPosts(conditions *core.ConditionsT, limit int, offset int) ([]*core.Post, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetServant) GetPostCount(conditions *core.ConditionsT) (int64, error) { +func (s *tweetSrv) GetPostCount(conditions *core.ConditionsT) (int64, error) { // TODO debug.NotImplemented() return 0, nil } -func (s *tweetServant) GetUserPostStar(postID, userID int64) (*core.PostStar, error) { +func (s *tweetSrv) GetUserPostStar(postID, userID int64) (*core.PostStar, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetServant) GetUserPostStars(userID int64, limit int, offset int) ([]*core.PostStar, error) { +func (s *tweetSrv) GetUserPostStars(userID int64, limit int, offset int) ([]*core.PostStar, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetServant) GetUserPostStarCount(userID int64) (int64, error) { +func (s *tweetSrv) GetUserPostStarCount(userID int64) (int64, error) { // TODO debug.NotImplemented() return 0, nil } -func (s *tweetServant) GetUserPostCollection(postID, userID int64) (*core.PostCollection, error) { +func (s *tweetSrv) GetUserPostCollection(postID, userID int64) (*core.PostCollection, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetServant) GetUserPostCollections(userID int64, limit int, offset int) ([]*core.PostCollection, error) { +func (s *tweetSrv) GetUserPostCollections(userID int64, limit int, offset int) ([]*core.PostCollection, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetServant) GetUserPostCollectionCount(userID int64) (int64, error) { +func (s *tweetSrv) GetUserPostCollectionCount(userID int64) (int64, error) { // TODO debug.NotImplemented() return 0, nil } -func (s *tweetServant) GetUserWalletBills(userID int64, limit int, offset int) ([]*core.WalletStatement, error) { +func (s *tweetSrv) GetUserWalletBills(userID int64, limit int, offset int) ([]*core.WalletStatement, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetServant) GetUserWalletBillCount(userID int64) (int64, error) { +func (s *tweetSrv) GetUserWalletBillCount(userID int64) (int64, error) { // TODO debug.NotImplemented() return 0, nil } -func (s *tweetServant) GetPostAttatchmentBill(postID, userID int64) (*core.PostAttachmentBill, error) { +func (s *tweetSrv) GetPostAttatchmentBill(postID, userID int64) (*core.PostAttachmentBill, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetServant) GetPostContentsByIDs(ids []int64) ([]*core.PostContent, error) { +func (s *tweetSrv) GetPostContentsByIDs(ids []int64) ([]*core.PostContent, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetServant) GetPostContentByID(id int64) (*core.PostContent, error) { +func (s *tweetSrv) GetPostContentByID(id int64) (*core.PostContent, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *tweetServant) TweetInfoById(id int64) (*cs.TweetInfo, error) { +func (s *tweetSrv) TweetInfoById(id int64) (*cs.TweetInfo, error) { // TODO return nil, debug.ErrNotImplemented } -func (s *tweetServant) TweetItemById(id int64) (*cs.TweetItem, error) { +func (s *tweetSrv) TweetItemById(id int64) (*cs.TweetItem, error) { // TODO return nil, debug.ErrNotImplemented } -func (s *tweetServant) UserTweets(visitorId, userId int64) (cs.TweetList, error) { +func (s *tweetSrv) UserTweets(visitorId, userId int64) (cs.TweetList, error) { // TODO return nil, debug.ErrNotImplemented } -func (s *tweetServant) ReactionByTweetId(userId int64, tweetId int64) (*cs.ReactionItem, error) { +func (s *tweetSrv) ReactionByTweetId(userId int64, tweetId int64) (*cs.ReactionItem, error) { // TODO return nil, debug.ErrNotImplemented } -func (s *tweetServant) UserReactions(userId int64, limit int, offset int) (cs.ReactionList, error) { +func (s *tweetSrv) UserReactions(userId int64, limit int, offset int) (cs.ReactionList, error) { // TODO return nil, debug.ErrNotImplemented } -func (s *tweetServant) FavoriteByTweetId(userId int64, tweetId int64) (*cs.FavoriteItem, error) { +func (s *tweetSrv) FavoriteByTweetId(userId int64, tweetId int64) (*cs.FavoriteItem, error) { // TODO return nil, debug.ErrNotImplemented } -func (s *tweetServant) UserFavorites(userId int64, limit int, offset int) (cs.FavoriteList, error) { +func (s *tweetSrv) UserFavorites(userId int64, limit int, offset int) (cs.FavoriteList, error) { // TODO return nil, debug.ErrNotImplemented } -func (s *tweetServant) AttachmentByTweetId(userId int64, tweetId int64) (*cs.AttachmentBill, error) { +func (s *tweetSrv) AttachmentByTweetId(userId int64, tweetId int64) (*cs.AttachmentBill, error) { // TODO return nil, debug.ErrNotImplemented } func newTweetService(db *pgx.Conn) core.TweetService { - return &tweetServant{ - pgxServant: newPgxServant(db), + return &tweetSrv{ + pgxSrv: newPgxSrv(db), } } func newTweetManageService(db *pgx.Conn, cacheIndex core.CacheIndexService) core.TweetManageService { - return &tweetManageServant{ - pgxServant: newPgxServant(db), + return &tweetManageSrv{ + pgxSrv: newPgxSrv(db), } } func newTweetHelpService(db *pgx.Conn) core.TweetHelpService { - return &tweetHelpServant{ - pgxServant: newPgxServant(db), + return &tweetHelpSrv{ + pgxSrv: newPgxSrv(db), } } diff --git a/internal/dao/slonik/user.go b/internal/dao/slonik/user.go index 382a971e..0e3d0532 100644 --- a/internal/dao/slonik/user.go +++ b/internal/dao/slonik/user.go @@ -11,57 +11,57 @@ import ( ) var ( - _ core.UserManageService = (*userManageServant)(nil) + _ core.UserManageService = (*userManageSrv)(nil) ) -type userManageServant struct { - *pgxServant +type userManageSrv struct { + *pgxSrv } -func (s *userManageServant) GetUserByID(id int64) (*core.User, error) { +func (s *userManageSrv) GetUserByID(id int64) (*core.User, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *userManageServant) GetUserByUsername(username string) (*core.User, error) { +func (s *userManageSrv) GetUserByUsername(username string) (*core.User, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *userManageServant) GetUserByPhone(phone string) (*core.User, error) { +func (s *userManageSrv) GetUserByPhone(phone string) (*core.User, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *userManageServant) GetUsersByIDs(ids []int64) ([]*core.User, error) { +func (s *userManageSrv) GetUsersByIDs(ids []int64) ([]*core.User, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *userManageServant) GetUsersByKeyword(keyword string) ([]*core.User, error) { +func (s *userManageSrv) GetUsersByKeyword(keyword string) ([]*core.User, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *userManageServant) CreateUser(user *core.User) (*core.User, error) { +func (s *userManageSrv) CreateUser(user *core.User) (*core.User, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *userManageServant) UpdateUser(user *core.User) error { +func (s *userManageSrv) UpdateUser(user *core.User) error { // TODO debug.NotImplemented() return nil } func newUserManageService(db *pgx.Conn) core.UserManageService { - return &userManageServant{ - pgxServant: newPgxServant(db), + return &userManageSrv{ + pgxSrv: newPgxSrv(db), } } diff --git a/internal/dao/slonik/wallet.go b/internal/dao/slonik/wallet.go index 1ef38375..8b4f15ca 100644 --- a/internal/dao/slonik/wallet.go +++ b/internal/dao/slonik/wallet.go @@ -11,50 +11,50 @@ import ( ) var ( - _ core.WalletService = (*walletServant)(nil) + _ core.WalletService = (*walletSrv)(nil) ) -type walletServant struct { - *pgxServant +type walletSrv struct { + *pgxSrv } -func (s *walletServant) GetRechargeByID(id int64) (*core.WalletRecharge, error) { +func (s *walletSrv) GetRechargeByID(id int64) (*core.WalletRecharge, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *walletServant) CreateRecharge(userId, amount int64) (*core.WalletRecharge, error) { +func (s *walletSrv) CreateRecharge(userId, amount int64) (*core.WalletRecharge, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *walletServant) GetUserWalletBills(userID int64, offset, limit int) ([]*core.WalletStatement, error) { +func (s *walletSrv) GetUserWalletBills(userID int64, offset, limit int) ([]*core.WalletStatement, error) { // TODO debug.NotImplemented() return nil, nil } -func (s *walletServant) GetUserWalletBillCount(userID int64) (int64, error) { +func (s *walletSrv) GetUserWalletBillCount(userID int64) (int64, error) { // TODO debug.NotImplemented() return 0, nil } -func (s *walletServant) HandleRechargeSuccess(recharge *core.WalletRecharge, tradeNo string) error { +func (s *walletSrv) HandleRechargeSuccess(recharge *core.WalletRecharge, tradeNo string) error { // TODO debug.NotImplemented() return nil } -func (s *walletServant) HandlePostAttachmentBought(post *core.Post, user *core.User) error { +func (s *walletSrv) HandlePostAttachmentBought(post *core.Post, user *core.User) error { // TODO debug.NotImplemented() return nil } func newWalletService(db *pgx.Conn) core.WalletService { - return &walletServant{ - pgxServant: newPgxServant(db), + return &walletSrv{ + pgxSrv: newPgxSrv(db), } }