mirror of https://github.com/rocboss/paopao-ce
Merge pull request #146 from alimy/pr-optimize-service-define
optimize core service definepull/147/head
commit
2531ed940f
@ -1,5 +0,0 @@
|
||||
package core
|
||||
|
||||
type AttachmentCheckService interface {
|
||||
Check(uri string) error
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/model"
|
||||
)
|
||||
|
||||
// CommentService 评论检索服务
|
||||
type CommentService interface {
|
||||
GetComments(conditions *model.ConditionsT, offset, limit int) ([]*model.Comment, error)
|
||||
GetCommentByID(id int64) (*model.Comment, error)
|
||||
GetCommentCount(conditions *model.ConditionsT) (int64, error)
|
||||
GetCommentReplyByID(id int64) (*model.CommentReply, error)
|
||||
GetCommentContentsByIDs(ids []int64) ([]*model.CommentContent, error)
|
||||
GetCommentRepliesByID(ids []int64) ([]*model.CommentReplyFormated, error)
|
||||
}
|
||||
|
||||
// CommentManageService 评论管理服务
|
||||
type CommentManageService interface {
|
||||
DeleteComment(comment *model.Comment) error
|
||||
CreateComment(comment *model.Comment) (*model.Comment, error)
|
||||
CreateCommentReply(reply *model.CommentReply) (*model.CommentReply, error)
|
||||
DeleteCommentReply(reply *model.CommentReply) error
|
||||
CreateCommentContent(content *model.CommentContent) (*model.CommentContent, error)
|
||||
}
|
@ -1,77 +1,34 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/model"
|
||||
)
|
||||
|
||||
// DataService data service interface that process data related logic on database
|
||||
// DataService 数据服务集成
|
||||
type DataService interface {
|
||||
// 钱包服务
|
||||
WalletService
|
||||
IndexPostsService
|
||||
|
||||
GetComments(conditions *model.ConditionsT, offset, limit int) ([]*model.Comment, error)
|
||||
GetCommentByID(id int64) (*model.Comment, error)
|
||||
DeleteComment(comment *model.Comment) error
|
||||
GetCommentCount(conditions *model.ConditionsT) (int64, error)
|
||||
CreateComment(comment *model.Comment) (*model.Comment, error)
|
||||
CreateCommentReply(reply *model.CommentReply) (*model.CommentReply, error)
|
||||
GetCommentReplyByID(id int64) (*model.CommentReply, error)
|
||||
DeleteCommentReply(reply *model.CommentReply) error
|
||||
GetCommentContentsByIDs(ids []int64) ([]*model.CommentContent, error)
|
||||
GetCommentRepliesByID(ids []int64) ([]*model.CommentReplyFormated, error)
|
||||
CreateCommentContent(content *model.CommentContent) (*model.CommentContent, error)
|
||||
// 消息服务
|
||||
MessageService
|
||||
|
||||
// 话题服务
|
||||
TopicService
|
||||
|
||||
// 广场泡泡服务
|
||||
IndexPostsService
|
||||
|
||||
CreateMessage(msg *model.Message) (*model.Message, error)
|
||||
GetUnreadCount(userID int64) (int64, error)
|
||||
GetMessageByID(id int64) (*model.Message, error)
|
||||
ReadMessage(message *model.Message) error
|
||||
GetMessages(conditions *model.ConditionsT, offset, limit int) ([]*model.MessageFormated, error)
|
||||
GetMessageCount(conditions *model.ConditionsT) (int64, error)
|
||||
// 推文服务
|
||||
TweetService
|
||||
TweetManageService
|
||||
TweetHelpService
|
||||
|
||||
CreateAttachment(attachment *model.Attachment) (*model.Attachment, error)
|
||||
CreatePost(post *model.Post) (*model.Post, error)
|
||||
DeletePost(post *model.Post) error
|
||||
LockPost(post *model.Post) error
|
||||
StickPost(post *model.Post) error
|
||||
VisiblePost(post *model.Post, visibility model.PostVisibleT) error
|
||||
GetPostByID(id int64) (*model.Post, error)
|
||||
GetPosts(conditions *model.ConditionsT, offset, limit int) ([]*model.Post, error)
|
||||
MergePosts(posts []*model.Post) ([]*model.PostFormated, error)
|
||||
RevampPosts(posts []*model.PostFormated) ([]*model.PostFormated, error)
|
||||
GetPostCount(conditions *model.ConditionsT) (int64, error)
|
||||
UpdatePost(post *model.Post) error
|
||||
GetUserPostStar(postID, userID int64) (*model.PostStar, error)
|
||||
GetUserPostStars(userID int64, offset, limit int) ([]*model.PostStar, error)
|
||||
GetUserPostStarCount(userID int64) (int64, error)
|
||||
CreatePostStar(postID, userID int64) (*model.PostStar, error)
|
||||
DeletePostStar(p *model.PostStar) error
|
||||
GetUserPostCollection(postID, userID int64) (*model.PostCollection, error)
|
||||
GetUserPostCollections(userID int64, offset, limit int) ([]*model.PostCollection, error)
|
||||
GetUserPostCollectionCount(userID int64) (int64, error)
|
||||
GetUserWalletBills(userID int64, offset, limit int) ([]*model.WalletStatement, error)
|
||||
GetUserWalletBillCount(userID int64) (int64, error)
|
||||
CreatePostCollection(postID, userID int64) (*model.PostCollection, error)
|
||||
DeletePostCollection(p *model.PostCollection) error
|
||||
GetPostAttatchmentBill(postID, userID int64) (*model.PostAttachmentBill, error)
|
||||
CreatePostContent(content *model.PostContent) (*model.PostContent, error)
|
||||
GetPostContentsByIDs(ids []int64) ([]*model.PostContent, error)
|
||||
GetPostContentByID(id int64) (*model.PostContent, error)
|
||||
// 附件检测服务
|
||||
AttachmentCheckService
|
||||
|
||||
CreateTag(tag *model.Tag) (*model.Tag, error)
|
||||
DeleteTag(tag *model.Tag) error
|
||||
GetTags(conditions *model.ConditionsT, offset, limit int) ([]*model.Tag, error)
|
||||
// 评论服务
|
||||
CommentService
|
||||
CommentManageService
|
||||
|
||||
GetUserByID(id int64) (*model.User, error)
|
||||
GetUserByUsername(username string) (*model.User, error)
|
||||
GetUserByPhone(phone string) (*model.User, error)
|
||||
GetUsersByIDs(ids []int64) ([]*model.User, error)
|
||||
GetUsersByKeyword(keyword string) ([]*model.User, error)
|
||||
GetTagsByKeyword(keyword string) ([]*model.Tag, error)
|
||||
CreateUser(user *model.User) (*model.User, error)
|
||||
UpdateUser(user *model.User) error
|
||||
GetLatestPhoneCaptcha(phone string) (*model.Captcha, error)
|
||||
UsePhoneCaptcha(captcha *model.Captcha) error
|
||||
SendPhoneCaptcha(phone string) error
|
||||
// 用户服务
|
||||
UserManageService
|
||||
|
||||
IsFriend(userID int64, friendID int64) bool
|
||||
// 安全服务
|
||||
SecurityService
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/model"
|
||||
)
|
||||
|
||||
type IndexPostsService interface {
|
||||
IndexPosts(user *model.User, offset int, limit int) ([]*model.PostFormated, error)
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/model"
|
||||
)
|
||||
|
||||
// MessageService 消息服务
|
||||
type MessageService interface {
|
||||
CreateMessage(msg *model.Message) (*model.Message, error)
|
||||
GetUnreadCount(userID int64) (int64, error)
|
||||
GetMessageByID(id int64) (*model.Message, error)
|
||||
ReadMessage(message *model.Message) error
|
||||
GetMessages(conditions *model.ConditionsT, offset, limit int) ([]*model.MessageFormated, error)
|
||||
GetMessageCount(conditions *model.ConditionsT) (int64, error)
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/model"
|
||||
)
|
||||
|
||||
// SecurityService 安全相关服务
|
||||
type SecurityService interface {
|
||||
GetLatestPhoneCaptcha(phone string) (*model.Captcha, error)
|
||||
UsePhoneCaptcha(captcha *model.Captcha) error
|
||||
SendPhoneCaptcha(phone string) error
|
||||
}
|
||||
|
||||
// 附件检测服务
|
||||
type AttachmentCheckService interface {
|
||||
CheckAttachment(uri string) error
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/model"
|
||||
)
|
||||
|
||||
// TopicService 话题服务
|
||||
type TopicService interface {
|
||||
CreateTag(tag *model.Tag) (*model.Tag, error)
|
||||
DeleteTag(tag *model.Tag) error
|
||||
GetTags(conditions *model.ConditionsT, offset, limit int) ([]*model.Tag, error)
|
||||
GetTagsByKeyword(keyword string) ([]*model.Tag, error)
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/model"
|
||||
)
|
||||
|
||||
// TweetService 推文检索服务
|
||||
type TweetService interface {
|
||||
GetPostByID(id int64) (*model.Post, error)
|
||||
GetPosts(conditions *model.ConditionsT, offset, limit int) ([]*model.Post, error)
|
||||
GetPostCount(conditions *model.ConditionsT) (int64, error)
|
||||
GetUserPostStar(postID, userID int64) (*model.PostStar, error)
|
||||
GetUserPostStars(userID int64, offset, limit int) ([]*model.PostStar, error)
|
||||
GetUserPostStarCount(userID int64) (int64, error)
|
||||
GetUserPostCollection(postID, userID int64) (*model.PostCollection, error)
|
||||
GetUserPostCollections(userID int64, offset, limit int) ([]*model.PostCollection, error)
|
||||
GetUserPostCollectionCount(userID int64) (int64, error)
|
||||
GetPostAttatchmentBill(postID, userID int64) (*model.PostAttachmentBill, error)
|
||||
GetPostContentsByIDs(ids []int64) ([]*model.PostContent, error)
|
||||
GetPostContentByID(id int64) (*model.PostContent, error)
|
||||
}
|
||||
|
||||
// TweetManageService 推文管理服务,包括创建/删除/更新推文
|
||||
type TweetManageService interface {
|
||||
CreateAttachment(attachment *model.Attachment) (*model.Attachment, error)
|
||||
CreatePost(post *model.Post) (*model.Post, error)
|
||||
DeletePost(post *model.Post) error
|
||||
LockPost(post *model.Post) error
|
||||
StickPost(post *model.Post) error
|
||||
VisiblePost(post *model.Post, visibility model.PostVisibleT) error
|
||||
UpdatePost(post *model.Post) error
|
||||
CreatePostStar(postID, userID int64) (*model.PostStar, error)
|
||||
DeletePostStar(p *model.PostStar) error
|
||||
CreatePostCollection(postID, userID int64) (*model.PostCollection, error)
|
||||
DeletePostCollection(p *model.PostCollection) error
|
||||
CreatePostContent(content *model.PostContent) (*model.PostContent, error)
|
||||
}
|
||||
|
||||
// TweetHelpService 推文辅助服务
|
||||
type TweetHelpService interface {
|
||||
RevampPosts(posts []*model.PostFormated) ([]*model.PostFormated, error)
|
||||
MergePosts(posts []*model.Post) ([]*model.PostFormated, error)
|
||||
}
|
||||
|
||||
// IndexPostsService 广场首页推文列表服务
|
||||
type IndexPostsService interface {
|
||||
IndexPosts(user *model.User, offset int, limit int) ([]*model.PostFormated, error)
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/model"
|
||||
)
|
||||
|
||||
// UserManageService 用户管理服务
|
||||
type UserManageService interface {
|
||||
GetUserByID(id int64) (*model.User, error)
|
||||
GetUserByUsername(username string) (*model.User, error)
|
||||
GetUserByPhone(phone string) (*model.User, error)
|
||||
GetUsersByIDs(ids []int64) ([]*model.User, error)
|
||||
GetUsersByKeyword(keyword string) ([]*model.User, error)
|
||||
CreateUser(user *model.User) (*model.User, error)
|
||||
UpdateUser(user *model.User) error
|
||||
IsFriend(userID int64, friendID int64) bool
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"github.com/Masterminds/semver/v3"
|
||||
)
|
||||
|
||||
type VersionInfo interface {
|
||||
Name() string
|
||||
Version() *semver.Version
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"github.com/Masterminds/semver/v3"
|
||||
)
|
||||
|
||||
// versionInfo 版本信息
|
||||
type versionInfo interface {
|
||||
name() string
|
||||
version() *semver.Version
|
||||
}
|
Loading…
Reference in new issue