Documentation
¶
Index ¶
- func FormatLimitOffset(limit, offset int) string
- type AuthService
- func (s *AuthService) CreateAuth(ctx context.Context, auth *pa.Auth) error
- func (s *AuthService) DeleteAuth(ctx context.Context, id int) error
- func (s *AuthService) FindAuthByID(ctx context.Context, id int) (*pa.Auth, error)
- func (s *AuthService) FindAuths(ctx context.Context, filter pa.AuthFilter) ([]*pa.Auth, int, error)
- type BlogService
- func (s *BlogService) CreateBlog(ctx context.Context, blog *pa.Blog) error
- func (s *BlogService) DeleteBlog(ctx context.Context, id int) error
- func (s *BlogService) FindBlogByID(ctx context.Context, id int) (*pa.Blog, error)
- func (s *BlogService) FindBlogs(ctx context.Context, filter pa.BlogFilter) ([]*pa.Blog, int, error)
- func (s *BlogService) UpdateBlog(ctx context.Context, id int, update pa.BlogUpdate) (*pa.Blog, error)
- type CommentService
- func (s *CommentService) CreateComment(ctx context.Context, comment *pa.Comment) error
- func (s *CommentService) DeleteComment(ctx context.Context, id int) error
- func (s *CommentService) FindCommentByID(ctx context.Context, id int) (*pa.Comment, error)
- func (s *CommentService) FindComments(ctx context.Context, filter pa.CommentFilter) ([]*pa.Comment, int, error)
- func (s *CommentService) UpdateComment(ctx context.Context, id int, update pa.CommentUpdate) (*pa.Comment, error)
- type DB
- type NullTime
- type ProjectService
- func (s *ProjectService) CreateOrUpdateProject(ctx context.Context, project *pa.Project) error
- func (s *ProjectService) DeleteProject(ctx context.Context, name string) error
- func (s *ProjectService) FindProjectByID(ctx context.Context, id int) (*pa.Project, error)
- func (s *ProjectService) FindProjectByName(ctx context.Context, name string) (*pa.Project, error)
- func (s *ProjectService) FindProjects(ctx context.Context, filter pa.ProjectFilter) ([]*pa.Project, int, error)
- type SubBlogService
- func (s *SubBlogService) CreateSubBlog(ctx context.Context, subBlog *pa.SubBlog) error
- func (s *SubBlogService) DeleteSubBlog(ctx context.Context, id int) error
- func (s *SubBlogService) FindSubBlogByID(ctx context.Context, id int) (*pa.SubBlog, error)
- func (s *SubBlogService) FindSubBlogs(ctx context.Context, filter pa.SubBlogFilter) ([]*pa.SubBlog, int, error)
- func (s *SubBlogService) UpdateSubBlog(ctx context.Context, id int, update pa.SubBlogUpdate) (*pa.SubBlog, error)
- type SubscriptionService
- func (s *SubscriptionService) CreateSubscription(ctx context.Context, subscription *pa.Subscription) error
- func (s *SubscriptionService) DeleteSubscription(ctx context.Context, id int, topic string) error
- func (s *SubscriptionService) FindSubscriptionByID(ctx context.Context, id int, topic string) (*pa.Subscription, error)
- func (s *SubscriptionService) FindSubscriptions(ctx context.Context, filter pa.SubscriptionFilter) ([]*pa.Subscription, int, error)
- type Tx
- type UserService
- func (s *UserService) CreateUser(ctx context.Context, user *pa.User) error
- func (s *UserService) DeleteUser(ctx context.Context, id int) error
- func (s *UserService) FindUserByID(ctx context.Context, id int) (*pa.User, error)
- func (s *UserService) FindUsers(ctx context.Context, filter pa.UserFilter) ([]*pa.User, int, error)
- func (s *UserService) UpdateUser(ctx context.Context, id int, update pa.UserUpdate) (*pa.User, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatLimitOffset ¶
Types ¶
type AuthService ¶
type AuthService struct {
// contains filtered or unexported fields
}
AuthService represents a service used to manage OAuth.
func NewAuthService ¶
func NewAuthService(db *DB) *AuthService
NewAuthService returns a new instance of AuthService attached to db.
func (*AuthService) CreateAuth ¶
CreateAuth creates a new auth obj if a user is attached, the auth obj is linked back to only an existing user, if not existing the user is created and the auth is attached. A sucessful call will return an auth with the auth.UserID != 0
func (*AuthService) DeleteAuth ¶
func (s *AuthService) DeleteAuth(ctx context.Context, id int) error
DeleteAuth permanently deletes the auth specified by the id. attached user wont be removed.
func (*AuthService) FindAuthByID ¶
FindAuthByID returns a auth based on the id. returns ENOTFOUND if the auth doesent exist.
type BlogService ¶
type BlogService struct {
// contains filtered or unexported fields
}
BlogService represents a service used to manage blogs.
func NewBlogService ¶
func NewBlogService(db *DB) *BlogService
NewBlogService returns a new instance of BlogService attached to db.
func (*BlogService) CreateBlog ¶
CreateBlog creates a new blog. returns EUNAUTHORIZED if the user trying to create the blog isnt the admin user.
func (*BlogService) DeleteBlog ¶
func (s *BlogService) DeleteBlog(ctx context.Context, id int) error
DeleteBlog permanently deletes the blog specified by id. returns EUNAUTHORIZED if the user trying to delete the blog isnt the admin user. returns ENOTFOUND if the blog doesent exist.
func (*BlogService) FindBlogByID ¶
FindBlogByID returns a blog based on id. returns ENOTFOUND if the blog doesent exist.
func (*BlogService) FindBlogs ¶
func (s *BlogService) FindBlogs(ctx context.Context, filter pa.BlogFilter) ([]*pa.Blog, int, error)
FindBlogs returns a range of blog based on filter.
func (*BlogService) UpdateBlog ¶
func (s *BlogService) UpdateBlog(ctx context.Context, id int, update pa.BlogUpdate) (*pa.Blog, error)
UpdateBlog updates blog with id: id. returns EUNAUTHORIZED if the user trying to update the blog isnt the admin user. returns ENOTFOUND if the blog doesent exist.
type CommentService ¶
type CommentService struct {
// contains filtered or unexported fields
}
CommentService represents a service used to manage comments.
func NewCommentService ¶
func NewCommentService(db *DB) *CommentService
NewCommentService returns a new instance of CommentService attached to db.
func (*CommentService) CreateComment ¶
CreateComment creates a new comment.
func (*CommentService) DeleteComment ¶
func (s *CommentService) DeleteComment(ctx context.Context, id int) error
DeleteComment permanently deletes the comment specified by id. returns EUNAUTHORIZED if the user isnt trying to delete his own comment. returns ENOTFOUND if the comment doesent exist.
func (*CommentService) FindCommentByID ¶
FindCommentByID returns a comment based on id. returns ENOTFOUND if the comment doesent exist.
func (*CommentService) FindComments ¶
func (s *CommentService) FindComments(ctx context.Context, filter pa.CommentFilter) ([]*pa.Comment, int, error)
FindComments returns a range of comment based on filter.
func (*CommentService) UpdateComment ¶
func (s *CommentService) UpdateComment(ctx context.Context, id int, update pa.CommentUpdate) (*pa.Comment, error)
UpdateComment updates comment with id: id. returns EUNAUTHORIZED if the user isnt trying to update isnt the admin user. returns ENOTFOUND if the comment doesent exist.
type DB ¶
func (*DB) MustBeginTX ¶
testing only
type ProjectService ¶
type ProjectService struct {
// contains filtered or unexported fields
}
ProjectService represents a service used to manage projects.
func NewProjectService ¶
func NewProjectService(db *DB) *ProjectService
NewProjectService returns a new instance of ProjectService attached to db.
func (*ProjectService) CreateOrUpdateProject ¶
func (*ProjectService) DeleteProject ¶
func (s *ProjectService) DeleteProject(ctx context.Context, name string) error
func (*ProjectService) FindProjectByID ¶
func (*ProjectService) FindProjectByName ¶
func (*ProjectService) FindProjects ¶
func (s *ProjectService) FindProjects(ctx context.Context, filter pa.ProjectFilter) ([]*pa.Project, int, error)
type SubBlogService ¶
type SubBlogService struct {
// contains filtered or unexported fields
}
SubBlogService represents a service used to manage sub blogs.
func NewSubBlogService ¶
func NewSubBlogService(db *DB) *SubBlogService
NewSubBlogService returns a new instance of SubBlogService attached to db.
func (*SubBlogService) CreateSubBlog ¶
CreateSubBlog creates a new sub blog. returns EUNAUTHORIZED if the user trying to create the sub blog isnt the admin user.
func (*SubBlogService) DeleteSubBlog ¶
func (s *SubBlogService) DeleteSubBlog(ctx context.Context, id int) error
DeleteSubBlog permanently deletes the sub blog specified by id. returns EUNAUTHORIZED if the user trying to delete the sub blog isnt the admin user. returns ENOTFOUND if the sub blog doesent exist.
func (*SubBlogService) FindSubBlogByID ¶
FindSubBlogByID returns a sub blog based on id. returns ENOTFOUND if the sub blog doesent exist.
func (*SubBlogService) FindSubBlogs ¶
func (s *SubBlogService) FindSubBlogs(ctx context.Context, filter pa.SubBlogFilter) ([]*pa.SubBlog, int, error)
FindSubBlogs returns a range of sub blog based on filter.
func (*SubBlogService) UpdateSubBlog ¶
func (s *SubBlogService) UpdateSubBlog(ctx context.Context, id int, update pa.SubBlogUpdate) (*pa.SubBlog, error)
UpdateSubBlog updates sub blog with id: id. returns EUNAUTHORIZED if the user trying to update the sub blog isnt the admin user. returns ENOTFOUND if the sub blog doesent exist.
type SubscriptionService ¶
type SubscriptionService struct {
// contains filtered or unexported fields
}
SubscriptionService represents a serivce used to manage subscriptions.
func NewSubscriptionService ¶
func NewSubscriptionService(db *DB) *SubscriptionService
NewSubscriptionService returns a new instance of SubscriptionService attached to db.
func (*SubscriptionService) CreateSubscription ¶
func (s *SubscriptionService) CreateSubscription(ctx context.Context, subscription *pa.Subscription) error
CreateSubscription creates a new subscription and links it to the user.
func (*SubscriptionService) DeleteSubscription ¶
DeleteSubscription permanently deletes the subscription only if the owner of the subscription is the user himself.
func (*SubscriptionService) FindSubscriptionByID ¶
func (s *SubscriptionService) FindSubscriptionByID(ctx context.Context, id int, topic string) (*pa.Subscription, error)
FindSubscriptionByID returns a subscription based on the id and topic. returns ENOTFOUND if the subscription doesent exist.
func (*SubscriptionService) FindSubscriptions ¶
func (s *SubscriptionService) FindSubscriptions(ctx context.Context, filter pa.SubscriptionFilter) ([]*pa.Subscription, int, error)
FindSubscriptions returns a range of subscriptions based on filter. Only returns subscriptions which the user owns.
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService represents a service used to manage users.
func NewUserService ¶
func NewUserService(db *DB) *UserService
NewUserService returns a new instance of UserService attached to db.
func (*UserService) CreateUser ¶
CreateUser creates a new user. To only be used in testing as users are created through the create auth process AuthService.CreateAuth() -> ./auth.go
func (*UserService) DeleteUser ¶
func (s *UserService) DeleteUser(ctx context.Context, id int) error
DeleteUser permanently deletes the user specified by id. returns EUNAUTHORIZED if the user isnt trying to delete himself. returns ENOTFOUND if the user doesent exist.
func (*UserService) FindUserByID ¶
FindUserByID returns a user based on id. returns ENOTFOUND if the user doesent exist.
func (*UserService) FindUsers ¶
func (s *UserService) FindUsers(ctx context.Context, filter pa.UserFilter) ([]*pa.User, int, error)
FindUsers returns a range of user based on filter.
func (*UserService) UpdateUser ¶
func (s *UserService) UpdateUser(ctx context.Context, id int, update pa.UserUpdate) (*pa.User, error)
UpdateUser updates user with id: id. returns EUNAUTHORIZED if the user isnt trying to update himself. returns ENOTFOUND if the user doesent exist.