pgstore

package
v0.7.56 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPage = 1
View Source
const DefaultPageSize = 50

Variables

This section is empty.

Functions

func CheckDB

func CheckDB(beforeConnect bool) error

Types

type Activity

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

func (*Activity) Create

func (a *Activity) Create(userId int, actType, action, targetModel string, targetId any, ipAddr, deviceInfo, details string) (int, error)

func (*Activity) List

func (a *Activity) List(userId int, userName, actType, action string, page, pageSize int) ([]*model.Activity, int, error)

type Article

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

func (*Article) AddHistory

func (a *Article) AddHistory(
	articleId, operatorId int,
	curr, prev time.Time,
	titleDelta, urlDelta, contentDelta, categoryFrontDelta string,
	isHidden bool,
) (int, error)

func (*Article) CheckLocked

func (a *Article) CheckLocked(id int) (bool, error)

func (*Article) CheckSubscribe

func (a *Article) CheckSubscribe(id, userId int) (int, error)

Check if user already subscribe in ancestor node

func (*Article) Count

func (a *Article) Count(frontId string, includePinned bool) (int, error)

func (*Article) CountTotalReply

func (a *Article) CountTotalReply(id int) (int, error)

func (*Article) Create

func (a *Article) Create(title, url, content string, authorId, replyToId int, categoryFrontId string, pinnedExpireAt time.Time, locked bool) (int, error)

func (*Article) Delete

func (a *Article) Delete(id int) (rootArticleId int, err error)

func (*Article) GetReactList

func (a *Article) GetReactList() ([]*model.ArticleReact, error)

func (*Article) Item

func (a *Article) Item(id, userId int) (*model.Article, error)

func (*Article) ItemTreeUserState

func (a *Article) ItemTreeUserState(ids []int, userId int) ([]*model.Article, error)

func (*Article) List

func (a *Article) List(
	page, pageSize int,
	sortType model.ArticleSortType,
	categoryFrontId string,
	pinned, deleted, includeReplies bool,
	keywords string,
) ([]*model.Article, int, error)

func (*Article) ListHistory

func (a *Article) ListHistory(articleId int) ([]*model.ArticleLog, error)

func (*Article) ListLatestCount

func (a *Article) ListLatestCount(start, end time.Time) (int, error)

func (*Article) ListUserState

func (a *Article) ListUserState(ids []int, userId int) ([]*model.Article, error)

func (*Article) Notify

func (a *Article) Notify(senderUserId, sourceArticleId, contentArticleId int) error

func (*Article) Pin

func (a *Article) Pin(id int, expireAt time.Time) error

func (*Article) ReactCheck

func (a *Article) ReactCheck(id, userId int) (int, string, error)

func (*Article) ReactItem

func (a *Article) ReactItem(reactId int) (*model.ArticleReact, error)

func (*Article) Recover

func (a *Article) Recover(id int) error

func (*Article) ReplyList

func (a *Article) ReplyList(page, pageSize, id int, sortType model.ArticleSortType, pinned bool) ([]*model.Article, error)

func (*Article) ReplyTree

func (a *Article) ReplyTree(page, pageSize, id int, sortType model.ArticleSortType, pinned bool) ([]*model.Article, error)

func (*Article) SetAfterUpdateWeights

func (a *Article) SetAfterUpdateWeights(fn func() error)

func (*Article) SetBlockRegions

func (a *Article) SetBlockRegions(articleId int, regions []string) error

func (*Article) Tag

func (a *Article) Tag(id int, tagFrontId string) error

func (*Article) ToggleFadeOut

func (a *Article) ToggleFadeOut(id int) (int, error)

func (*Article) ToggleHideHistory

func (a *Article) ToggleHideHistory(historyId int, isHidden bool) error

func (*Article) ToggleLock

func (a *Article) ToggleLock(id int) error

func (*Article) ToggleReact

func (a *Article) ToggleReact(id, userId, reactId int) (int, string, error)

Return int value, 0 for error, -1 for canceled, 1 for added String value for previous react id

func (*Article) ToggleSave

func (a *Article) ToggleSave(id, userId int) error

func (*Article) ToggleSubscribe

func (a *Article) ToggleSubscribe(id, userId int) error

func (*Article) ToggleVote

func (a *Article) ToggleVote(id, userId int, voteType string) (int, error)

Return int value, 0 for error, -1 for canceled, 1 for added

func (*Article) Unpin

func (a *Article) Unpin(id int) error

func (*Article) UpdateReply

func (a *Article) UpdateReply(id int, content string, pinnedExpireAt time.Time, locked bool) (int, error)

func (*Article) UpdateRootArticle

func (a *Article) UpdateRootArticle(id int, title, content, link, categoryFrontId string, pinnedExpireAt time.Time, locked bool) (int, error)

func (*Article) VoteCheck

func (a *Article) VoteCheck(id, userId int) (error, string)

type Category

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

func (*Category) Approval

func (p *Category) Approval(frontId string, pass bool, comment string) error

func (*Category) Create

func (p *Category) Create(frontId, name, describe string, authorId int) (int, error)

func (*Category) Delete

func (p *Category) Delete(frontId string) error

func (*Category) Item

func (p *Category) Item(frontId string, userId int) (*model.Category, error)

func (*Category) List

func (p *Category) List(state model.CategoryState) ([]*model.Category, error)

func (*Category) Notify

func (c *Category) Notify(sourceCateogryFrontId string, senderUserId, contentArticleId int) error

func (*Category) Subscribe

func (c *Category) Subscribe(frontId string, loginedUserId int) error

func (*Category) Update

func (p *Category) Update(frontId, name, describe string) (int, error)

type DB

type DB struct {
	DSN string
	// Conn *pgx.Conn
	Pool *pgxpool.Pool
}

func (*DB) Close

func (db *DB) Close()

func (*DB) Connect

func (db *DB) Connect() error

type DBConfig

type DBConfig struct {
	DSN string
}

type Message

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

func (*Message) List

func (m *Message) List(userId int, status string, page, pageSize int) ([]*model.Message, int, error)

func (*Message) Read

func (m *Message) Read(messageId int) error

func (*Message) ReadAll

func (m *Message) ReadAll(userId int) error

func (*Message) ReadMany

func (m *Message) ReadMany(messageIds []any) error

func (*Message) UnreadCount

func (m *Message) UnreadCount(userId int) (int, error)

type PGStore

type PGStore struct {
	Activity   *Activity
	Article    *Article
	Message    *Message
	Permission *Permission
	Role       *Role
	User       *User
	Category   *Category
}

func New

func New(config *DBConfig) *PGStore

func (*PGStore) CloseDB

func (pg *PGStore) CloseDB()

func (*PGStore) ConnectDB

func (pg *PGStore) ConnectDB() error

func (*PGStore) InitModules

func (pg *PGStore) InitModules() error

func (*PGStore) Ping

func (pg *PGStore) Ping(ctx context.Context) error

type Permission

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

func (*Permission) Clear

func (p *Permission) Clear() error

func (*Permission) Create

func (p *Permission) Create(module, frontId, name string) (int, error)

func (*Permission) CreateMany

func (p *Permission) CreateMany(list []*model.Permission) error

func (*Permission) Item

func (p *Permission) Item(id int) (*model.Permission, error)

func (*Permission) List

func (p *Permission) List(page, pageSize int, module string) ([]*model.Permission, error)

func (*Permission) Update

func (p *Permission) Update(name string) (int, error)

type Role

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

func (*Role) Create

func (r *Role) Create(frontId, name string, permissions []int) (int, error)

func (*Role) CreateManyWithFrontId

func (r *Role) CreateManyWithFrontId(list []*model.Role) error

func (*Role) CreateWithFrontId

func (r *Role) CreateWithFrontId(frontId, name string, permissionFrontIds []string) (int, error)

func (*Role) Delete

func (r *Role) Delete(id int) error

func (*Role) Item

func (r *Role) Item(id int) (*model.Role, error)

func (*Role) List

func (r *Role) List(page, pageSize int) ([]*model.Role, error)

func (*Role) Update

func (r *Role) Update(id int, name string, permissions []int) (int, error)

func (*Role) UpdateWithFrontId

func (r *Role) UpdateWithFrontId(id int, name string, permissionFrontIds []string) (int, error)

type User

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

func (*User) AddReputation

func (u *User) AddReputation(username string, changeType model.ReputationChangeType, isRevert bool) error

func (*User) AddReputationVal

func (u *User) AddReputationVal(username string, value int, comment string, isRevert bool) error

func (*User) Ban

func (u *User) Ban(username string, bannedDays int) (int, error)

func (*User) Count

func (u *User) Count() (int, error)

func (*User) Create

func (u *User) Create(email, password, name string, roleFrontId string) (int, error)

func (*User) CreateWithOAuth

func (u *User) CreateWithOAuth(email, username, roleFrontId, authType string) (int, error)

func (*User) Delete

func (u *User) Delete(id int) error

func (*User) DeleteHard

func (u *User) DeleteHard(id int) error

func (*User) Exists

func (u *User) Exists(email, username string) (int, error)

func (*User) GetPassword

func (u *User) GetPassword(username string) (string, error)

func (*User) GetPosts

func (u *User) GetPosts(username string, listType string) ([]*model.Article, error)

func (*User) GetSavedPosts

func (u *User) GetSavedPosts(username string) ([]*model.Article, error)

func (*User) GetSubscribedPosts

func (u *User) GetSubscribedPosts(username string) ([]*model.Article, error)

func (*User) GetVotedPosts

func (u *User) GetVotedPosts(username string, voteType model.VoteType) ([]*model.Article, error)

func (*User) Item

func (u *User) Item(id int) (*model.User, error)

func (*User) ItemWithEmail

func (u *User) ItemWithEmail(email string) (*model.User, error)

func (*User) ItemWithUsername

func (u *User) ItemWithUsername(username string) (*model.User, error)

func (*User) ItemWithUsernameEmail

func (u *User) ItemWithUsernameEmail(usernameEmail string) (*model.User, error)

func (*User) List

func (u *User) List(page, pageSize int, oldest bool, username, roleFrontId string, authType model.AuthType) ([]*model.User, int, error)

func (*User) SetRole

func (u *User) SetRole(userId int, roleFrontId string) (int, error)

func (*User) SetRoleManyWithFrontId

func (u *User) SetRoleManyWithFrontId(list []*model.User) error

func (*User) Unban

func (u *User) Unban(username string) (int, error)

func (*User) UpdateIntroduction

func (u *User) UpdateIntroduction(username, introduction string) error

func (*User) UpdatePassword

func (u *User) UpdatePassword(email, password string) (int, error)

Jump to

Keyboard shortcuts

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