Documentation ¶
Index ¶
- Variables
- func BuildCommentTree(comments []*models.Comment) []*models.Comment
- func NewID() string
- type Comment
- type CommentService
- func (s *CommentService) Create(ctx context.Context, comment *models.Comment) error
- func (s *CommentService) Delete(ctx context.Context, id int) error
- func (s *CommentService) DeleteBySlug(ctx context.Context, slug string) error
- func (s *CommentService) DeleteByUserID(ctx context.Context, userId int) error
- func (s *CommentService) FindByID(ctx context.Context, id int) (*models.Comment, error)
- func (s *CommentService) FindBySlug(ctx context.Context, slug string) ([]*models.Comment, int, error)
- func (s *CommentService) FindComments(ctx context.Context, filter models.CommentFilter) ([]*models.Comment, int, error)
- func (s *CommentService) Hide(ctx context.Context, id int) error
- type CreateUserParams
- type DB
- type DBTX
- type ListUserParams
- type ListUserRow
- type Migration
- type Post
- type PostService
- func (s *PostService) Create(ctx context.Context, post *models.Post) error
- func (s *PostService) Delete(ctx context.Context, id int) (string, error)
- func (s *PostService) FindByID(ctx context.Context, id int) (*models.Post, error)
- func (s *PostService) FindBySlug(ctx context.Context, slug string) (*models.Post, error)
- func (s *PostService) FindPosts(ctx context.Context, filter models.PostFilter) ([]*models.Post, int, error)
- func (s *PostService) Update(ctx context.Context, post *models.Post) error
- type Queries
- func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (int32, error)
- func (q *Queries) GetUser(ctx context.Context, id int32) (User, error)
- func (q *Queries) ListUser(ctx context.Context, arg ListUserParams) ([]ListUserRow, error)
- func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error)
- func (q *Queries) WithTx(tx pgx.Tx) *Queries
- type Scanner
- type UpdateUserParams
- type User
- type UserService
- func (s *UserService) AddRole(ctx context.Context, user *models.User, role string) error
- func (s *UserService) Auth(ctx context.Context, user *models.User) (*models.User, error)
- func (s *UserService) Block(ctx context.Context, id int) error
- func (s *UserService) CompareHashAndPassword(hashed string, password string) error
- func (s *UserService) Create(ctx context.Context, user *models.User) (*models.User, error)
- func (s *UserService) Delete(ctx context.Context, id int) error
- func (s *UserService) FindByEmailToken(ctx context.Context, token string) (*models.User, error)
- func (s *UserService) FindByID(ctx context.Context, id int) (*models.User, error)
- func (s *UserService) FindByRPT(ctx context.Context, token string) (*models.User, error)
- func (s *UserService) FindUsers(ctx context.Context, filter models.UserFilter) ([]*models.User, int, error)
- func (s *UserService) HasRole(ctx context.Context, id int, role string) (bool, error)
- func (s *UserService) HashPassword(str string) (string, error)
- func (s *UserService) LogSendResetPassword(ctx context.Context, email string) (*models.User, error)
- func (s *UserService) LogSendVerifyEmail(ctx context.Context, user *models.User) error
- func (s *UserService) UpdatePassword(ctx context.Context, user *models.User) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUserNotFound = errors.New("user not found") ErrUserNotVerifiedEmail = errors.New("user not verified email") ErrorCannotBlockAdmin = errors.New("cannot block admin") ErrorCannotDeleteAdmin = errors.New("cannot delete admin") )
View Source
var (
ErrCommentNotFound = errors.New("comment not found")
)
View Source
var (
ErrPostNotFound = errors.New("post not found")
)
Functions ¶
Types ¶
type Comment ¶
type Comment struct { ID int32 AuthorID int32 ParentID int32 Slug string Body string CreatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz IsHidden bool }
type CommentService ¶
type CommentService struct {
// contains filtered or unexported fields
}
func NewCommentService ¶
func NewCommentService(db *DB) *CommentService
func (*CommentService) DeleteBySlug ¶
func (s *CommentService) DeleteBySlug(ctx context.Context, slug string) error
func (*CommentService) DeleteByUserID ¶
func (s *CommentService) DeleteByUserID(ctx context.Context, userId int) error
func (*CommentService) FindBySlug ¶
func (*CommentService) FindComments ¶
func (s *CommentService) FindComments(ctx context.Context, filter models.CommentFilter) ([]*models.Comment, int, error)
type CreateUserParams ¶
type DB ¶
type DB struct { Conn *pgx.Conn Datasource string // contains filtered or unexported fields }
type ListUserParams ¶
type ListUserRow ¶
type ListUserRow struct { ID int32 Username string Email string Password string Roles []string EmailToken string CreatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz SendVerifiedEmailAt pgtype.Timestamptz ResetPwdToken string RptExpiredAt pgtype.Timestamptz IsBlocked bool Total int64 }
type PostService ¶
type PostService struct {
// contains filtered or unexported fields
}
func NewPostService ¶
func NewPostService(db *DB) *PostService
func (*PostService) FindBySlug ¶
type Queries ¶
type Queries struct {
// contains filtered or unexported fields
}
func (*Queries) CreateUser ¶
func (*Queries) ListUser ¶
func (q *Queries) ListUser(ctx context.Context, arg ListUserParams) ([]ListUserRow, error)
func (*Queries) UpdateUser ¶
type UpdateUserParams ¶
type User ¶
type User struct { ID int32 Username string Email string Password string Roles []string EmailToken string CreatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz SendVerifiedEmailAt pgtype.Timestamptz ResetPwdToken string RptExpiredAt pgtype.Timestamptz IsBlocked bool }
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
func NewUserService ¶
func NewUserService(db *DB) *UserService
func (*UserService) CompareHashAndPassword ¶
func (s *UserService) CompareHashAndPassword(hashed string, password string) error
func (*UserService) FindByEmailToken ¶
func (*UserService) FindUsers ¶
func (s *UserService) FindUsers(ctx context.Context, filter models.UserFilter) ([]*models.User, int, error)
func (*UserService) HashPassword ¶
func (s *UserService) HashPassword(str string) (string, error)
func (*UserService) LogSendResetPassword ¶
func (*UserService) LogSendVerifyEmail ¶
func (*UserService) UpdatePassword ¶
Click to show internal directories.
Click to hide internal directories.