db

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ForeignKeyViolation = "23503"
	UniqueViolation     = "23505"
)

Variables

View Source
var ErrRecordNotFound = pgx.ErrNoRows
View Source
var ErrUniqueViolation = &pgconn.PgError{Code: UniqueViolation}

Functions

func ErrorCode

func ErrorCode(err error) string

Types

type Admin

type Admin struct {
	// 主键ID
	ID int64 `json:"id"`
	// 管理员名称
	Username string `json:"username"`
	// 密码
	HashedPassword string `json:"hashed_password"`
	// 是否激活,默认:否
	IsActive bool `json:"is_active"`
	// 角色ID,默认:2
	RoleID int64 `json:"role_id"`
	// 创建时间
	CreatedAt time.Time `json:"created_at"`
	// 更新时间
	UpdatedAt time.Time `json:"updated_at"`
}

管理员账号表

type Article

type Article struct {
	ID uuid.UUID `json:"id"`
	// 标题
	Title string `json:"title"`
	// 摘要
	Summary string `json:"summary"`
	// 内容
	Content string `json:"content"`
	// 浏览量
	Views int32 `json:"views"`
	// 点赞数
	Likes int32 `json:"likes"`
	// 是否发布
	IsPublish bool `json:"is_publish"`
	// 拥有者
	Owner      uuid.UUID `json:"owner"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
	DeletedAt  time.Time `json:"deleted_at"`
	CategoryID int64     `json:"category_id"`
	// 短标识
	Slug pgtype.Text `json:"slug"`
	// 封面
	Cover string `json:"cover"`
	// 最后更新时间
	LastUpdated time.Time `json:"last_updated"`
	// 检查过时
	CheckOutdated bool `json:"check_outdated"`
	// 阅读时间
	ReadTime string `json:"read_time"`
}

type Category

type Category struct {
	ID int64 `json:"id"`
	// 分类名称
	Name string `json:"name"`
	// 是否为系统分类
	IsSystem  bool      `json:"is_system"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

文章分类表

type Comment

type Comment struct {
	ID int64 `json:"id"`
	// 评论内容
	Content string `json:"content"`
	// 文章ID
	ArticleID uuid.UUID `json:"article_id"`
	// 父评论ID
	ParentID int64 `json:"parent_id"`
	Likes    int32 `json:"likes"`
	// 评论人ID
	FromUserID uuid.UUID `json:"from_user_id"`
	// 被评论人ID
	ToUserID  uuid.UUID `json:"to_user_id"`
	CreatedAt time.Time `json:"created_at"`
	DeletedAt time.Time `json:"deleted_at"`
}

type CountArticlesParams

type CountArticlesParams struct {
	IsPublish  pgtype.Bool `json:"is_publish"`
	CategoryID pgtype.Int8 `json:"category_id"`
}

type CountSearchArticlesParams added in v1.2.1

type CountSearchArticlesParams struct {
	Keyword   string      `json:"keyword"`
	IsPublish pgtype.Bool `json:"is_publish"`
}

type CreateAdminParams

type CreateAdminParams struct {
	Username       string `json:"username"`
	HashedPassword string `json:"hashed_password"`
	IsActive       bool   `json:"is_active"`
	RoleID         int64  `json:"role_id"`
}

type CreateArticleParams

type CreateArticleParams struct {
	ID         uuid.UUID `json:"id"`
	Title      string    `json:"title"`
	Summary    string    `json:"summary"`
	Content    string    `json:"content"`
	IsPublish  bool      `json:"is_publish"`
	Owner      uuid.UUID `json:"owner"`
	CategoryID int64     `json:"category_id"`
	Cover      string    `json:"cover"`
}

type CreateCategoryTxParams added in v1.3.0

type CreateCategoryTxParams struct {
	Name        string
	AfterCreate func() error
}

CreateCategoryTxParams contains the input parameters of the create category transaction

type CreateCategoryTxResult added in v1.3.0

type CreateCategoryTxResult struct {
	Category Category
}

CreateCategoryTxResult is the result of the create category transaction

type CreateCommentParams

type CreateCommentParams struct {
	Content    string    `json:"content"`
	ArticleID  uuid.UUID `json:"article_id"`
	ParentID   int64     `json:"parent_id"`
	FromUserID uuid.UUID `json:"from_user_id"`
	ToUserID   uuid.UUID `json:"to_user_id"`
}

type CreateSessionParams

type CreateSessionParams struct {
	ID           uuid.UUID `json:"id"`
	UserID       uuid.UUID `json:"user_id"`
	RefreshToken string    `json:"refresh_token"`
	UserAgent    string    `json:"user_agent"`
	ClientIp     string    `json:"client_ip"`
	IsBlocked    bool      `json:"is_blocked"`
	ExpiresAt    time.Time `json:"expires_at"`
}

type CreateUserParams

type CreateUserParams struct {
	ID             uuid.UUID `json:"id"`
	Username       string    `json:"username"`
	HashedPassword string    `json:"hashed_password"`
	FullName       string    `json:"full_name"`
	Email          string    `json:"email"`
}

type CreateUserTxParams

type CreateUserTxParams struct {
	CreateUserParams
	AfterCreate func(user User) error
}

CreateUserTxParams contains the input parameters of the transfer transaction

type CreateUserTxResult

type CreateUserTxResult struct {
	User User
}

CreateUserTxResult is the result of the transfer transaction

type CreateVerifyEmailParams

type CreateVerifyEmailParams struct {
	UserID     uuid.UUID `json:"user_id"`
	Email      string    `json:"email"`
	SecretCode string    `json:"secret_code"`
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type DeleteArticleTxParams

type DeleteArticleTxParams struct {
	ID          uuid.UUID
	AfterUpdate func(articleID uuid.UUID) error
}

DeleteArticleTxParams contains the input parameters of the transfer transaction

type DeleteCategoryTxParams added in v1.3.0

type DeleteCategoryTxParams struct {
	ID          int64
	AfterDelete func() error
}

type GetArticleBySlugRow added in v1.3.0

type GetArticleBySlugRow struct {
	ID            uuid.UUID   `json:"id"`
	Title         string      `json:"title"`
	Summary       string      `json:"summary"`
	Content       string      `json:"content"`
	IsPublish     bool        `json:"is_publish"`
	Views         int32       `json:"views"`
	Likes         int32       `json:"likes"`
	Cover         string      `json:"cover"`
	Slug          pgtype.Text `json:"slug"`
	CheckOutdated bool        `json:"check_outdated"`
	LastUpdated   time.Time   `json:"last_updated"`
	ReadTime      string      `json:"read_time"`
	Owner         uuid.UUID   `json:"owner"`
	CreatedAt     time.Time   `json:"created_at"`
	UpdatedAt     time.Time   `json:"updated_at"`
	DeletedAt     time.Time   `json:"deleted_at"`
	CategoryID    int64       `json:"category_id"`
	CategoryName  pgtype.Text `json:"category_name"`
}

type GetArticleForUpdateRow added in v1.3.0

type GetArticleForUpdateRow struct {
	ID         uuid.UUID `json:"id"`
	Title      string    `json:"title"`
	Summary    string    `json:"summary"`
	Content    string    `json:"content"`
	Views      int32     `json:"views"`
	Likes      int32     `json:"likes"`
	IsPublish  bool      `json:"is_publish"`
	Owner      uuid.UUID `json:"owner"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
	DeletedAt  time.Time `json:"deleted_at"`
	CategoryID int64     `json:"category_id"`
}

type GetArticleRow

type GetArticleRow struct {
	ID            uuid.UUID   `json:"id"`
	Title         string      `json:"title"`
	Summary       string      `json:"summary"`
	Content       string      `json:"content"`
	IsPublish     bool        `json:"is_publish"`
	Views         int32       `json:"views"`
	Likes         int32       `json:"likes"`
	Cover         string      `json:"cover"`
	Slug          pgtype.Text `json:"slug"`
	CheckOutdated bool        `json:"check_outdated"`
	LastUpdated   time.Time   `json:"last_updated"`
	ReadTime      string      `json:"read_time"`
	Owner         uuid.UUID   `json:"owner"`
	CreatedAt     time.Time   `json:"created_at"`
	UpdatedAt     time.Time   `json:"updated_at"`
	DeletedAt     time.Time   `json:"deleted_at"`
	CategoryID    int64       `json:"category_id"`
	CategoryName  pgtype.Text `json:"category_name"`
}

type ListAllArticlesParams

type ListAllArticlesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListAllArticlesRow

type ListAllArticlesRow struct {
	ID            uuid.UUID   `json:"id"`
	Title         string      `json:"title"`
	Summary       string      `json:"summary"`
	Views         int32       `json:"views"`
	Likes         int32       `json:"likes"`
	IsPublish     bool        `json:"is_publish"`
	Cover         string      `json:"cover"`
	Slug          pgtype.Text `json:"slug"`
	CheckOutdated bool        `json:"check_outdated"`
	LastUpdated   time.Time   `json:"last_updated"`
	ReadTime      string      `json:"read_time"`
	Owner         uuid.UUID   `json:"owner"`
	CreatedAt     time.Time   `json:"created_at"`
	UpdatedAt     time.Time   `json:"updated_at"`
	DeletedAt     time.Time   `json:"deleted_at"`
	CategoryName  pgtype.Text `json:"category_name"`
}

type ListArticlesByCategoryIDParams

type ListArticlesByCategoryIDParams struct {
	CategoryID int64 `json:"category_id"`
	Limit      int32 `json:"limit"`
	Offset     int32 `json:"offset"`
}

type ListArticlesByCategoryIDRow

type ListArticlesByCategoryIDRow struct {
	ID         uuid.UUID   `json:"id"`
	Title      string      `json:"title"`
	Summary    string      `json:"summary"`
	Views      int32       `json:"views"`
	Likes      int32       `json:"likes"`
	IsPublish  bool        `json:"is_publish"`
	Owner      uuid.UUID   `json:"owner"`
	CategoryID int64       `json:"category_id"`
	CreatedAt  time.Time   `json:"created_at"`
	UpdatedAt  time.Time   `json:"updated_at"`
	DeletedAt  time.Time   `json:"deleted_at"`
	Name       pgtype.Text `json:"name"`
	Username   pgtype.Text `json:"username"`
}

type ListArticlesParams

type ListArticlesParams struct {
	Limit      int32       `json:"limit"`
	Offset     int32       `json:"offset"`
	IsPublish  pgtype.Bool `json:"is_publish"`
	CategoryID pgtype.Int8 `json:"category_id"`
}

type ListArticlesRow

type ListArticlesRow struct {
	ID            uuid.UUID   `json:"id"`
	Title         string      `json:"title"`
	Summary       string      `json:"summary"`
	Views         int32       `json:"views"`
	Likes         int32       `json:"likes"`
	IsPublish     bool        `json:"is_publish"`
	Cover         string      `json:"cover"`
	Slug          pgtype.Text `json:"slug"`
	CheckOutdated bool        `json:"check_outdated"`
	LastUpdated   time.Time   `json:"last_updated"`
	ReadTime      string      `json:"read_time"`
	Owner         uuid.UUID   `json:"owner"`
	CreatedAt     time.Time   `json:"created_at"`
	UpdatedAt     time.Time   `json:"updated_at"`
	DeletedAt     time.Time   `json:"deleted_at"`
	CategoryName  pgtype.Text `json:"category_name"`
	Username      pgtype.Text `json:"username"`
}

type ListCategoriesCountArticlesRow

type ListCategoriesCountArticlesRow struct {
	ID           int64     `json:"id"`
	Name         string    `json:"name"`
	IsSystem     bool      `json:"is_system"`
	ArticleCount int64     `json:"article_count"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

type ListCommentsByArticleIDRow

type ListCommentsByArticleIDRow struct {
	ID           int64       `json:"id"`
	Content      string      `json:"content"`
	ArticleID    uuid.UUID   `json:"article_id"`
	ParentID     int64       `json:"parent_id"`
	Likes        int32       `json:"likes"`
	FromUserID   uuid.UUID   `json:"from_user_id"`
	ToUserID     uuid.UUID   `json:"to_user_id"`
	CreatedAt    time.Time   `json:"created_at"`
	DeletedAt    time.Time   `json:"deleted_at"`
	FromUserName pgtype.Text `json:"from_user_name"`
	ToUserName   pgtype.Text `json:"to_user_name"`
}

type ListInitSysMenusRow

type ListInitSysMenusRow struct {
	ID       int64       `json:"id"`
	Name     string      `json:"name"`
	Path     string      `json:"path"`
	Icon     string      `json:"icon"`
	Type     int32       `json:"type"`
	ParentID pgtype.Int8 `json:"parent_id"`
}

type Querier

type Querier interface {
	AddCommentLikes(ctx context.Context, id int64) (Comment, error)
	CountAllArticles(ctx context.Context) (int64, error)
	CountArticles(ctx context.Context, arg CountArticlesParams) (int64, error)
	CountArticlesByCategoryID(ctx context.Context, categoryID int64) (int64, error)
	CountCategories(ctx context.Context) (int64, error)
	CountSearchArticles(ctx context.Context, arg CountSearchArticlesParams) (int64, error)
	CreateAdmin(ctx context.Context, arg CreateAdminParams) (Admin, error)
	CreateArticle(ctx context.Context, arg CreateArticleParams) (Article, error)
	CreateCategory(ctx context.Context, name string) (Category, error)
	CreateComment(ctx context.Context, arg CreateCommentParams) (Comment, error)
	CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)
	CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
	CreateVerifyEmail(ctx context.Context, arg CreateVerifyEmailParams) (VerifyEmail, error)
	DeleteArticle(ctx context.Context, id uuid.UUID) error
	DeleteCategory(ctx context.Context, id int64) error
	DeleteChildComments(ctx context.Context, parentID int64) error
	DeleteComment(ctx context.Context, id int64) error
	DeleteCommentsByArticleID(ctx context.Context, articleID uuid.UUID) error
	GetAdmin(ctx context.Context, username string) (Admin, error)
	GetAdminById(ctx context.Context, id int64) (Admin, error)
	GetArticle(ctx context.Context, id uuid.UUID) (GetArticleRow, error)
	GetArticleBySlug(ctx context.Context, slug pgtype.Text) (GetArticleBySlugRow, error)
	GetArticleForUpdate(ctx context.Context, id uuid.UUID) (GetArticleForUpdateRow, error)
	GetCategory(ctx context.Context, id int64) (Category, error)
	GetCategoryByName(ctx context.Context, name string) (Category, error)
	GetComment(ctx context.Context, id int64) (Comment, error)
	GetSession(ctx context.Context, id uuid.UUID) (Session, error)
	GetUser(ctx context.Context, id uuid.UUID) (User, error)
	GetUserByUsername(ctx context.Context, username string) (User, error)
	IncrementArticleLikes(ctx context.Context, id uuid.UUID) error
	IncrementArticleViews(ctx context.Context, id uuid.UUID) error
	ListAllArticles(ctx context.Context, arg ListAllArticlesParams) ([]ListAllArticlesRow, error)
	ListAllCategories(ctx context.Context) ([]Category, error)
	ListArticles(ctx context.Context, arg ListArticlesParams) ([]ListArticlesRow, error)
	ListArticlesByCategoryID(ctx context.Context, arg ListArticlesByCategoryIDParams) ([]ListArticlesByCategoryIDRow, error)
	ListCategoriesCountArticles(ctx context.Context) ([]ListCategoriesCountArticlesRow, error)
	ListCommentsByArticleID(ctx context.Context, articleID uuid.UUID) ([]ListCommentsByArticleIDRow, error)
	ListInitSysMenus(ctx context.Context, roleID int64) ([]ListInitSysMenusRow, error)
	SearchArticles(ctx context.Context, arg SearchArticlesParams) ([]SearchArticlesRow, error)
	SetArticleDefaultCategoryIdByCategoryId(ctx context.Context, categoryID int64) error
	UpdateAdmin(ctx context.Context, arg UpdateAdminParams) (Admin, error)
	UpdateArticle(ctx context.Context, arg UpdateArticleParams) (Article, error)
	UpdateCategory(ctx context.Context, arg UpdateCategoryParams) (Category, error)
	UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error)
	UpdateVerifyEmail(ctx context.Context, arg UpdateVerifyEmailParams) (VerifyEmail, error)
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) AddCommentLikes

func (q *Queries) AddCommentLikes(ctx context.Context, id int64) (Comment, error)

func (*Queries) CountAllArticles

func (q *Queries) CountAllArticles(ctx context.Context) (int64, error)

func (*Queries) CountArticles

func (q *Queries) CountArticles(ctx context.Context, arg CountArticlesParams) (int64, error)

func (*Queries) CountArticlesByCategoryID

func (q *Queries) CountArticlesByCategoryID(ctx context.Context, categoryID int64) (int64, error)

func (*Queries) CountCategories

func (q *Queries) CountCategories(ctx context.Context) (int64, error)

func (*Queries) CountSearchArticles added in v1.2.1

func (q *Queries) CountSearchArticles(ctx context.Context, arg CountSearchArticlesParams) (int64, error)

func (*Queries) CreateAdmin

func (q *Queries) CreateAdmin(ctx context.Context, arg CreateAdminParams) (Admin, error)

func (*Queries) CreateArticle

func (q *Queries) CreateArticle(ctx context.Context, arg CreateArticleParams) (Article, error)

func (*Queries) CreateCategory

func (q *Queries) CreateCategory(ctx context.Context, name string) (Category, error)

func (*Queries) CreateComment

func (q *Queries) CreateComment(ctx context.Context, arg CreateCommentParams) (Comment, error)

func (*Queries) CreateSession

func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error)

func (*Queries) CreateVerifyEmail

func (q *Queries) CreateVerifyEmail(ctx context.Context, arg CreateVerifyEmailParams) (VerifyEmail, error)

func (*Queries) DeleteArticle

func (q *Queries) DeleteArticle(ctx context.Context, id uuid.UUID) error

func (*Queries) DeleteCategory

func (q *Queries) DeleteCategory(ctx context.Context, id int64) error

func (*Queries) DeleteChildComments

func (q *Queries) DeleteChildComments(ctx context.Context, parentID int64) error

func (*Queries) DeleteComment

func (q *Queries) DeleteComment(ctx context.Context, id int64) error

func (*Queries) DeleteCommentsByArticleID

func (q *Queries) DeleteCommentsByArticleID(ctx context.Context, articleID uuid.UUID) error

func (*Queries) GetAdmin

func (q *Queries) GetAdmin(ctx context.Context, username string) (Admin, error)

func (*Queries) GetAdminById

func (q *Queries) GetAdminById(ctx context.Context, id int64) (Admin, error)

func (*Queries) GetArticle

func (q *Queries) GetArticle(ctx context.Context, id uuid.UUID) (GetArticleRow, error)

func (*Queries) GetArticleBySlug added in v1.3.0

func (q *Queries) GetArticleBySlug(ctx context.Context, slug pgtype.Text) (GetArticleBySlugRow, error)

func (*Queries) GetArticleForUpdate

func (q *Queries) GetArticleForUpdate(ctx context.Context, id uuid.UUID) (GetArticleForUpdateRow, error)

func (*Queries) GetCategory

func (q *Queries) GetCategory(ctx context.Context, id int64) (Category, error)

func (*Queries) GetCategoryByName

func (q *Queries) GetCategoryByName(ctx context.Context, name string) (Category, error)

func (*Queries) GetComment

func (q *Queries) GetComment(ctx context.Context, id int64) (Comment, error)

func (*Queries) GetSession

func (q *Queries) GetSession(ctx context.Context, id uuid.UUID) (Session, error)

func (*Queries) GetUser

func (q *Queries) GetUser(ctx context.Context, id uuid.UUID) (User, error)

func (*Queries) GetUserByUsername

func (q *Queries) GetUserByUsername(ctx context.Context, username string) (User, error)

func (*Queries) IncrementArticleLikes

func (q *Queries) IncrementArticleLikes(ctx context.Context, id uuid.UUID) error

func (*Queries) IncrementArticleViews

func (q *Queries) IncrementArticleViews(ctx context.Context, id uuid.UUID) error

func (*Queries) ListAllArticles

func (q *Queries) ListAllArticles(ctx context.Context, arg ListAllArticlesParams) ([]ListAllArticlesRow, error)

func (*Queries) ListAllCategories

func (q *Queries) ListAllCategories(ctx context.Context) ([]Category, error)

func (*Queries) ListArticles

func (q *Queries) ListArticles(ctx context.Context, arg ListArticlesParams) ([]ListArticlesRow, error)

func (*Queries) ListArticlesByCategoryID

func (q *Queries) ListArticlesByCategoryID(ctx context.Context, arg ListArticlesByCategoryIDParams) ([]ListArticlesByCategoryIDRow, error)

func (*Queries) ListCategoriesCountArticles

func (q *Queries) ListCategoriesCountArticles(ctx context.Context) ([]ListCategoriesCountArticlesRow, error)

func (*Queries) ListCommentsByArticleID

func (q *Queries) ListCommentsByArticleID(ctx context.Context, articleID uuid.UUID) ([]ListCommentsByArticleIDRow, error)

func (*Queries) ListInitSysMenus

func (q *Queries) ListInitSysMenus(ctx context.Context, roleID int64) ([]ListInitSysMenusRow, error)

func (*Queries) SearchArticles added in v1.2.1

func (q *Queries) SearchArticles(ctx context.Context, arg SearchArticlesParams) ([]SearchArticlesRow, error)

func (*Queries) SetArticleDefaultCategoryIdByCategoryId

func (q *Queries) SetArticleDefaultCategoryIdByCategoryId(ctx context.Context, categoryID int64) error

func (*Queries) UpdateAdmin

func (q *Queries) UpdateAdmin(ctx context.Context, arg UpdateAdminParams) (Admin, error)

func (*Queries) UpdateArticle

func (q *Queries) UpdateArticle(ctx context.Context, arg UpdateArticleParams) (Article, error)

func (*Queries) UpdateCategory

func (q *Queries) UpdateCategory(ctx context.Context, arg UpdateCategoryParams) (Category, error)

func (*Queries) UpdateUser

func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error)

func (*Queries) UpdateVerifyEmail

func (q *Queries) UpdateVerifyEmail(ctx context.Context, arg UpdateVerifyEmailParams) (VerifyEmail, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type Role

type Role struct {
	// 主键ID
	ID int64 `json:"id"`
	// 角色名称
	RoleName string `json:"role_name"`
	// 角色描述
	Description string `json:"description"`
	// 是否为系统角色
	IsSystem bool `json:"is_system"`
	// 创建时间
	CreatedAt time.Time `json:"created_at"`
}

角色表

type RolePermission

type RolePermission struct {
	// 主键ID
	ID int64 `json:"id"`
	// 角色ID
	RoleID int64 `json:"role_id"`
	// 菜单ID
	MenuID int64 `json:"menu_id"`
	// 创建人ID
	CreatedBy int64 `json:"created_by"`
	// 创建时间
	CreatedAt time.Time `json:"created_at"`
}

角色权限表

type SQLStore

type SQLStore struct {
	*Queries
	// contains filtered or unexported fields
}

SQLStore provides all functions to execute SQL queries and transactions

func (*SQLStore) CreateCategoryTx added in v1.3.0

func (store *SQLStore) CreateCategoryTx(ctx context.Context, arg CreateCategoryTxParams) (CreateCategoryTxResult, error)

func (*SQLStore) CreateUserTx

func (store *SQLStore) CreateUserTx(ctx context.Context, arg CreateUserTxParams) (CreateUserTxResult, error)

CreateUserTx performs a money transfer from on account to the other It creates a transfer record, add account entries, and update account's balance within a single database transaction

func (*SQLStore) DeleteArticleTx

func (store *SQLStore) DeleteArticleTx(ctx context.Context, arg DeleteArticleTxParams) error

func (*SQLStore) DeleteCategoryTx

func (store *SQLStore) DeleteCategoryTx(ctx context.Context, arg DeleteCategoryTxParams) error

func (*SQLStore) UpdateArticleTx

func (store *SQLStore) UpdateArticleTx(ctx context.Context, arg UpdateArticleTxParams) (UpdateArticleTxResult, error)

func (*SQLStore) UpdateCategoryTx added in v1.3.0

func (store *SQLStore) UpdateCategoryTx(ctx context.Context, arg UpdateCategoryTxParams) (UpdateCategoryTxResult, error)

func (*SQLStore) VerifyEmailTx

func (store *SQLStore) VerifyEmailTx(ctx context.Context, arg VerifyEmailTxParams) (VerifyEmailTxResult, error)

VerifyEmailTx performs a money transfer from on account to the other It creates a transfer record, add account entries, and update account's balance within a single database transaction

type SearchArticlesParams added in v1.2.1

type SearchArticlesParams struct {
	Limit     int32       `json:"limit"`
	Offset    int32       `json:"offset"`
	Keyword   string      `json:"keyword"`
	IsPublish pgtype.Bool `json:"is_publish"`
}

type SearchArticlesRow added in v1.2.1

type SearchArticlesRow struct {
	ID            uuid.UUID   `json:"id"`
	Title         string      `json:"title"`
	Summary       string      `json:"summary"`
	Views         int32       `json:"views"`
	Likes         int32       `json:"likes"`
	IsPublish     bool        `json:"is_publish"`
	Cover         string      `json:"cover"`
	Slug          pgtype.Text `json:"slug"`
	CheckOutdated bool        `json:"check_outdated"`
	LastUpdated   time.Time   `json:"last_updated"`
	ReadTime      string      `json:"read_time"`
	Owner         uuid.UUID   `json:"owner"`
	CreatedAt     time.Time   `json:"created_at"`
	UpdatedAt     time.Time   `json:"updated_at"`
	DeletedAt     time.Time   `json:"deleted_at"`
	CategoryName  pgtype.Text `json:"category_name"`
	Username      pgtype.Text `json:"username"`
	Score         interface{} `json:"score"`
}

type Session

type Session struct {
	ID           uuid.UUID `json:"id"`
	UserID       uuid.UUID `json:"user_id"`
	RefreshToken string    `json:"refresh_token"`
	UserAgent    string    `json:"user_agent"`
	ClientIp     string    `json:"client_ip"`
	IsBlocked    bool      `json:"is_blocked"`
	ExpiresAt    time.Time `json:"expires_at"`
	CreatedAt    time.Time `json:"created_at"`
}

type Store

Store provides all functions to execute db queries and transactions

func NewStore

func NewStore(connPool *pgxpool.Pool) Store

type SysMenu

type SysMenu struct {
	// 主键ID
	ID int64 `json:"id"`
	// 菜单名称
	Name string `json:"name"`
	// 菜单路径
	Path string `json:"path"`
	// 菜单图标
	Icon string `json:"icon"`
	// 是否激活,默认:否
	IsActive bool `json:"is_active"`
	// 1:目录;2:菜单;3:按钮(事件)
	Type int32 `json:"type"`
	// 排序编号
	Sort int32 `json:"sort"`
	// 父菜单ID
	ParentID pgtype.Int8 `json:"parent_id"`
	// 创建时间
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

后台系统菜单表

type Tag

type Tag struct {
	ID int64 `json:"id"`
	// 名称
	Name string `json:"name"`
	// 文章ID
	ArticleID uuid.UUID `json:"article_id"`
	CreatedAt time.Time `json:"created_at"`
}

type UpdateAdminParams

type UpdateAdminParams struct {
	Username       pgtype.Text        `json:"username"`
	HashedPassword pgtype.Text        `json:"hashed_password"`
	IsActive       pgtype.Bool        `json:"is_active"`
	RoleID         pgtype.Int8        `json:"role_id"`
	UpdatedAt      pgtype.Timestamptz `json:"updated_at"`
	ID             int64              `json:"id"`
}

type UpdateArticleParams

type UpdateArticleParams struct {
	Title         pgtype.Text        `json:"title"`
	Summary       pgtype.Text        `json:"summary"`
	Content       pgtype.Text        `json:"content"`
	IsPublish     pgtype.Bool        `json:"is_publish"`
	CategoryID    pgtype.Int8        `json:"category_id"`
	Cover         pgtype.Text        `json:"cover"`
	Slug          pgtype.Text        `json:"slug"`
	CheckOutdated pgtype.Bool        `json:"check_outdated"`
	LastUpdated   pgtype.Timestamptz `json:"last_updated"`
	ReadTime      pgtype.Text        `json:"read_time"`
	UpdatedAt     pgtype.Timestamptz `json:"updated_at"`
	ID            uuid.UUID          `json:"id"`
}

type UpdateArticleTxParams

type UpdateArticleTxParams struct {
	UpdateArticleParams
	AfterUpdate func(article Article) error
}

UpdateArticleTxParams contains the input parameters of the transfer transaction

type UpdateArticleTxResult

type UpdateArticleTxResult struct {
	Article Article
}

UpdateArticleTxResult is the result of the transfer transaction

type UpdateCategoryParams

type UpdateCategoryParams struct {
	Name string `json:"name"`
	ID   int64  `json:"id"`
}

type UpdateCategoryTxParams added in v1.3.0

type UpdateCategoryTxParams struct {
	UpdateCategoryParams
	AfterUpdate func() error
}

type UpdateCategoryTxResult added in v1.3.0

type UpdateCategoryTxResult struct {
	Category Category
}

type UpdateUserParams

type UpdateUserParams struct {
	HashedPassword  pgtype.Text `json:"hashed_password"`
	FullName        pgtype.Text `json:"full_name"`
	Email           pgtype.Text `json:"email"`
	IsEmailVerified pgtype.Bool `json:"is_email_verified"`
	ID              uuid.UUID   `json:"id"`
}

type UpdateVerifyEmailParams

type UpdateVerifyEmailParams struct {
	ID         int64  `json:"id"`
	SecretCode string `json:"secret_code"`
}

type User

type User struct {
	ID              uuid.UUID `json:"id"`
	Username        string    `json:"username"`
	HashedPassword  string    `json:"hashed_password"`
	FullName        string    `json:"full_name"`
	Email           string    `json:"email"`
	IsEmailVerified bool      `json:"is_email_verified"`
	// 介绍
	About     string    `json:"about"`
	Role      string    `json:"role"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	DeletedAt time.Time `json:"deleted_at"`
}

type VerifyEmail

type VerifyEmail struct {
	ID         int64     `json:"id"`
	UserID     uuid.UUID `json:"user_id"`
	Email      string    `json:"email"`
	SecretCode string    `json:"secret_code"`
	IsUsed     bool      `json:"is_used"`
	CreatedAt  time.Time `json:"created_at"`
	ExpiredAt  time.Time `json:"expired_at"`
}

type VerifyEmailTxParams

type VerifyEmailTxParams struct {
	EmailId    int64
	SecretCode string
}

VerifyEmailTxParams contains the input parameters of the transfer transaction

type VerifyEmailTxResult

type VerifyEmailTxResult struct {
	User        User
	VerifyEmail VerifyEmail
}

VerifyEmailTxResult is the result of the transfer transaction

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL