Documentation
¶
Index ¶
- func CloseDatabase()
- func ConvertCommaSeparatedString(nullString sql.NullString) []string
- func FromSQLCBook(sqlcBook Book) *model.Book
- func FromSQLCBookmark(sqlcBookmark Bookmark) model.BookMark
- func FromSQLCBookmarks(sqlcBookmarks []Bookmark) model.BookMarks
- func FromSQLCBooks(sqlcBooks []Book, pagesMap map[string][]model.PageInfo, ...) []*model.Book
- func FromSQLCPageInfo(sqlcPageInfo PageInfo) model.PageInfo
- func FromSQLCPageInfos(sqlcPageInfos []PageInfo) []model.PageInfo
- func FromSQLCUser(sqlcUser User) *model.User
- func FromSQLCUsers(sqlcUsers []User) []*model.User
- func OpenDatabase(options DBOptions) error
- type Book
- type Bookmark
- type CreateBookParams
- type CreateBookmarkParams
- type CreatePageInfoParams
- type CreateUserParams
- type DBOptions
- type DBTX
- type DeleteBookmarkByBookIDAndTypeParams
- type GetPageInfoByBookIDAndPageParams
- type PageInfo
- type Queries
- func (q *Queries) CountBooks(ctx context.Context) (int64, error)
- func (q *Queries) CountBooksByType(ctx context.Context, type_ string) (int64, error)
- func (q *Queries) CountPageInfosByBookID(ctx context.Context, bookID string) (int64, error)
- func (q *Queries) CountUsers(ctx context.Context) (int64, error)
- func (q *Queries) CountUsersByRole(ctx context.Context, role sql.NullString) (int64, error)
- func (q *Queries) CreateBook(ctx context.Context, arg CreateBookParams) (Book, error)
- func (q *Queries) CreateBookmark(ctx context.Context, arg CreateBookmarkParams) (Bookmark, error)
- func (q *Queries) CreatePageInfo(ctx context.Context, arg CreatePageInfoParams) (PageInfo, error)
- func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
- func (q *Queries) DeleteBook(ctx context.Context, bookID string) error
- func (q *Queries) DeleteBookmarkByBookIDAndType(ctx context.Context, arg DeleteBookmarkByBookIDAndTypeParams) error
- func (q *Queries) DeleteBookmarksByBookID(ctx context.Context, bookID string) error
- func (q *Queries) DeletePageInfosByBookID(ctx context.Context, bookID string) error
- func (q *Queries) DeleteUser(ctx context.Context, id int64) error
- func (q *Queries) GetBookByBookPath(ctx context.Context, bookPath string) (Book, error)
- func (q *Queries) GetBookByID(ctx context.Context, bookID string) (Book, error)
- func (q *Queries) GetPageInfoByBookIDAndPage(ctx context.Context, arg GetPageInfoByBookIDAndPageParams) (PageInfo, error)
- func (q *Queries) GetPageInfosByBookID(ctx context.Context, bookID string) ([]PageInfo, error)
- func (q *Queries) GetUserByEmail(ctx context.Context, email sql.NullString) (User, error)
- func (q *Queries) GetUserByID(ctx context.Context, id int64) (User, error)
- func (q *Queries) GetUserByUsername(ctx context.Context, username string) (User, error)
- func (q *Queries) ListAllBookStoreURLs(ctx context.Context) ([]string, error)
- func (q *Queries) ListBookmarksByBookID(ctx context.Context, bookID string) ([]Bookmark, error)
- func (q *Queries) ListBooks(ctx context.Context) ([]Book, error)
- func (q *Queries) ListBooksByStorePath(ctx context.Context, storeUrl string) ([]Book, error)
- func (q *Queries) ListBooksByType(ctx context.Context, type_ string) ([]Book, error)
- func (q *Queries) ListUsers(ctx context.Context) ([]User, error)
- func (q *Queries) MarkBookAsDeleted(ctx context.Context, bookID string) error
- func (q *Queries) SearchBooksByTitle(ctx context.Context, dollar_1 sql.NullString) ([]Book, error)
- func (q *Queries) UpdateBook(ctx context.Context, arg UpdateBookParams) error
- func (q *Queries) UpdateBookmark(ctx context.Context, arg UpdateBookmarkParams) error
- func (q *Queries) UpdateLastReadPage(ctx context.Context, arg UpdateLastReadPageParams) error
- func (q *Queries) UpdatePageInfo(ctx context.Context, arg UpdatePageInfoParams) error
- func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) error
- func (q *Queries) UpdateUserKey(ctx context.Context, arg UpdateUserKeyParams) error
- func (q *Queries) UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) error
- func (q *Queries) WithTx(tx *sql.Tx) *Queries
- type StoreDatabase
- func (db *StoreDatabase) CheckDBQueries() error
- func (db *StoreDatabase) DeleteBook(bookID string) error
- func (db *StoreDatabase) DeleteBookMark(bookID string, markType model.MarkType, pageIndex int) error
- func (db *StoreDatabase) GenerateBookGroup() (e error)
- func (db *StoreDatabase) GetBook(bookID string) (*model.Book, error)
- func (db *StoreDatabase) GetBookMarks(bookID string) (*model.BookMarks, error)
- func (db *StoreDatabase) ListBooks() (list []*model.Book, err error)
- func (db *StoreDatabase) SaveBookBookmarks(ctx context.Context, bookID string, bookmarks model.BookMarks) error
- func (db *StoreDatabase) SaveBookPageInfos(ctx context.Context, bookID string, pageInfos []model.PageInfo) error
- func (db *StoreDatabase) StoreBook(book *model.Book) error
- func (db *StoreDatabase) StoreBookMark(mark *model.BookMark) error
- type UpdateBookParams
- type UpdateBookmarkParams
- type UpdateLastReadPageParams
- type UpdatePageInfoParams
- type UpdateUserKeyParams
- type UpdateUserParams
- type UpdateUserPasswordParams
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseDatabase ¶
func CloseDatabase()
func ConvertCommaSeparatedString ¶
func ConvertCommaSeparatedString(nullString sql.NullString) []string
ConvertCommaSeparatedString 将英文逗号分隔的字符串转换为 []string
func FromSQLCBook ¶
FromSQLCBook 将sqlc.Book转换为model.Book
func FromSQLCBookmark ¶
FromSQLCBookmark 将 sqlc.Bookmark 转换为 model.BookMark
func FromSQLCBookmarks ¶
FromSQLCBookmarks 批量转换 sqlc.Bookmark 为 model.BookMarks
func FromSQLCBooks ¶
func FromSQLCBooks(sqlcBooks []Book, pagesMap map[string][]model.PageInfo, bookmarksMap map[string]model.BookMarks) []*model.Book
FromSQLCBooks 批量转换sqlc.Book为model.Book
func FromSQLCPageInfo ¶
FromSQLCPageInfo 将sqlc.PageInfo转换为model.PageInfo
func FromSQLCPageInfos ¶
FromSQLCPageInfos 批量转换sqlc.PageInfo为model.PageInfo
func FromSQLCUser ¶
FromSQLCUser 将sqlc.User转换为model.User
func FromSQLCUsers ¶
FromSQLCUsers 批量转换sqlc.User为model.User
func OpenDatabase ¶
OpenDatabase 根据配置选择 SQLite 或 PostgreSQL 后端。
Types ¶
type Book ¶
type Book struct {
ID int64
Title string
BookID string
Owner sql.NullString
BookPath string
StoreUrl string
Type string
ChildBooksNum sql.NullInt64
ChildBooksID sql.NullString
Depth sql.NullInt64
ParentFolder sql.NullString
PageCount sql.NullInt64
LastReadPage sql.NullInt64
FileSize sql.NullInt64
Author sql.NullString
Isbn sql.NullString
Press sql.NullString
PublishedAt sql.NullString
ExtractPath sql.NullString
ModifiedTime sql.NullTime
ExtractNum sql.NullInt64
BookComplete sql.NullBool
InitComplete sql.NullBool
NonUtf8zip sql.NullBool
ZipTextEncoding sql.NullString
CreatedByVersion sql.NullString
IsRemote sql.NullBool
RemoteUrl sql.NullString
Deleted sql.NullBool
}
type CreateBookParams ¶
type CreateBookParams struct {
Title string
BookID string
Owner sql.NullString
BookPath string
StoreUrl string
Type string
ChildBooksNum sql.NullInt64
ChildBooksID sql.NullString
Depth sql.NullInt64
ParentFolder sql.NullString
PageCount sql.NullInt64
LastReadPage sql.NullInt64
FileSize sql.NullInt64
Author sql.NullString
Isbn sql.NullString
Press sql.NullString
PublishedAt sql.NullString
ExtractPath sql.NullString
ExtractNum sql.NullInt64
BookComplete sql.NullBool
InitComplete sql.NullBool
NonUtf8zip sql.NullBool
ZipTextEncoding sql.NullString
CreatedByVersion sql.NullString
IsRemote sql.NullBool
RemoteUrl sql.NullString
}
func ToSQLCCreateBookParams ¶
func ToSQLCCreateBookParams(book *model.Book) CreateBookParams
ToSQLCCreateBookParams 将model.Book转换为sqlc.CreateBookParams //"Valid"必须是验证条件或true
type CreateBookmarkParams ¶
type CreateBookmarkParams struct {
Type string
BookID string
BookStoreID sql.NullString
PageIndex int64
Description sql.NullString
CreatedAt sql.NullTime
UpdatedAt sql.NullTime
}
func ToSQLCCreateBookmarkParams ¶
func ToSQLCCreateBookmarkParams(bookID string, bookmark model.BookMark) CreateBookmarkParams
ToSQLCCreateBookmarkParams 将 model.BookMark 转换为 sqlc.CreateBookmarkParams
type CreatePageInfoParams ¶
type CreatePageInfoParams struct {
BookID string
Name string
Path sql.NullString
Size sql.NullInt64
ModTime sql.NullTime
Url sql.NullString
PageNum sql.NullInt64
Blurhash sql.NullString
Height sql.NullInt64
Width sql.NullInt64
ImgType sql.NullString
InsertHtml sql.NullString
}
func ToSQLCCreatePageInfoParams ¶
func ToSQLCCreatePageInfoParams(pageInfo model.PageInfo, bookID string) CreatePageInfoParams
ToSQLCCreatePageInfoParams 将model.PageInfo 转换为sqlc.CreatePageInfoParams //"Valid"必须是验证条件或true
type CreateUserParams ¶
type CreateUserParams struct {
Username string
Password string
Role sql.NullString
Email sql.NullString
Key sql.NullString
ExpiresAt sql.NullTime
}
func ToSQLCCreateUserParams ¶
func ToSQLCCreateUserParams(user *model.User) CreateUserParams
ToSQLCCreateUserParams 将model.User转换为sqlc.CreateUserParams
type PageInfo ¶
type PageInfo struct {
ID int64
BookID string
Name string
Path sql.NullString
Size sql.NullInt64
ModTime sql.NullTime
Url sql.NullString
PageNum sql.NullInt64
Blurhash sql.NullString
Height sql.NullInt64
Width sql.NullInt64
ImgType sql.NullString
InsertHtml sql.NullString
}
type Queries ¶
type Queries struct {
// contains filtered or unexported fields
}
func (*Queries) CountBooks ¶
Statistics queries Count total books
func (*Queries) CountBooksByType ¶
Count books by type
func (*Queries) CountPageInfosByBookID ¶
Count media files for a book
func (*Queries) CountUsers ¶
Count total users
func (*Queries) CountUsersByRole ¶
Count users by role
func (*Queries) CreateBook ¶
Create new book
func (*Queries) CreateBookmark ¶
Create a bookmark
func (*Queries) CreatePageInfo ¶
Create media file record
func (*Queries) CreateUser ¶
Create new user
func (*Queries) DeleteBook ¶
Delete book
func (*Queries) DeleteBookmarkByBookIDAndType ¶
func (q *Queries) DeleteBookmarkByBookIDAndType(ctx context.Context, arg DeleteBookmarkByBookIDAndTypeParams) error
Delete a bookmark by (book_id, type)
func (*Queries) DeleteBookmarksByBookID ¶
Delete all bookmarks for a book
func (*Queries) DeletePageInfosByBookID ¶
Delete all media files for a book
func (*Queries) DeleteUser ¶
Delete user
func (*Queries) GetBookByBookPath ¶
Get book by file path
func (*Queries) GetBookByID ¶
Book related queries Get single book by ID
func (*Queries) GetPageInfoByBookIDAndPage ¶
func (q *Queries) GetPageInfoByBookIDAndPage(ctx context.Context, arg GetPageInfoByBookIDAndPageParams) (PageInfo, error)
Get specific page by book ID and page number
func (*Queries) GetPageInfosByBookID ¶
Media files related queries Get all page information by book ID
func (*Queries) GetUserByEmail ¶
Get user by email
func (*Queries) GetUserByID ¶
User related queries Get user by ID
func (*Queries) GetUserByUsername ¶
Get user by username
func (*Queries) ListAllBookStoreURLs ¶
get all store_url for books
func (*Queries) ListBookmarksByBookID ¶
Bookmarks related queries List bookmarks by book ID
func (*Queries) ListBooksByStorePath ¶
List books by store path
func (*Queries) ListBooksByType ¶
List books by type
func (*Queries) MarkBookAsDeleted ¶
Mark book as deleted (soft delete)
func (*Queries) SearchBooksByTitle ¶
Search books by title (fuzzy search)
func (*Queries) UpdateBook ¶
func (q *Queries) UpdateBook(ctx context.Context, arg UpdateBookParams) error
Update book information
func (*Queries) UpdateBookmark ¶
func (q *Queries) UpdateBookmark(ctx context.Context, arg UpdateBookmarkParams) error
Update a bookmark (by book_id, type)
func (*Queries) UpdateLastReadPage ¶
func (q *Queries) UpdateLastReadPage(ctx context.Context, arg UpdateLastReadPageParams) error
Update reading progress
func (*Queries) UpdatePageInfo ¶
func (q *Queries) UpdatePageInfo(ctx context.Context, arg UpdatePageInfoParams) error
Update media file information
func (*Queries) UpdateUser ¶
func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) error
Update user information
func (*Queries) UpdateUserKey ¶
func (q *Queries) UpdateUserKey(ctx context.Context, arg UpdateUserKeyParams) error
Update user key and expiration
func (*Queries) UpdateUserPassword ¶
func (q *Queries) UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) error
Update user password
type StoreDatabase ¶
type StoreDatabase struct {
// contains filtered or unexported fields
}
StoreDatabase 书籍数据访问层
var (
DbStore *StoreDatabase
)
func NewPostgresDBStore ¶ added in v1.2.36
func NewPostgresDBStore(db postgres.DBTX) *StoreDatabase
NewPostgresDBStore 使用 PostgreSQL 生成查询和 adapter 创建统一的数据访问层。
func (*StoreDatabase) CheckDBQueries ¶
func (db *StoreDatabase) CheckDBQueries() error
CheckDBQueries 检查 queries 是否已初始化
func (*StoreDatabase) DeleteBook ¶
func (db *StoreDatabase) DeleteBook(bookID string) error
DeleteBook 删除书籍信息
func (*StoreDatabase) DeleteBookMark ¶ added in v1.2.12
func (db *StoreDatabase) DeleteBookMark(bookID string, markType model.MarkType, pageIndex int) error
DeleteBookMark 删除指定书籍的特定书签 根据 bookID + markType + pageIndex 唯一确定一个书签
func (*StoreDatabase) GenerateBookGroup ¶
func (db *StoreDatabase) GenerateBookGroup() (e error)
GenerateBookGroup 分析所有子书库,并并生成书籍组
func (*StoreDatabase) GetBook ¶
func (db *StoreDatabase) GetBook(bookID string) (*model.Book, error)
GetBook 根据ID获取书籍信息
func (*StoreDatabase) GetBookMarks ¶
func (db *StoreDatabase) GetBookMarks(bookID string) (*model.BookMarks, error)
func (*StoreDatabase) ListBooks ¶
func (db *StoreDatabase) ListBooks() (list []*model.Book, err error)
ListBooks 从数据库查询所有书籍的详细信息,避免重复扫描压缩包。忽略已删除书籍
func (*StoreDatabase) SaveBookBookmarks ¶
func (db *StoreDatabase) SaveBookBookmarks(ctx context.Context, bookID string, bookmarks model.BookMarks) error
SaveBookBookmarks 保存书籍的书签信息
func (*StoreDatabase) SaveBookPageInfos ¶
func (db *StoreDatabase) SaveBookPageInfos(ctx context.Context, bookID string, pageInfos []model.PageInfo) error
SaveBookPageInfos 保存书籍的媒体文件信息
func (*StoreDatabase) StoreBook ¶
func (db *StoreDatabase) StoreBook(book *model.Book) error
StoreBook 向数据库中插入一本书
func (*StoreDatabase) StoreBookMark ¶
func (db *StoreDatabase) StoreBookMark(mark *model.BookMark) error
type UpdateBookParams ¶
type UpdateBookParams struct {
Title string
Owner sql.NullString
BookPath string
StoreUrl string
Type string
ChildBooksNum sql.NullInt64
ChildBooksID sql.NullString
Depth sql.NullInt64
ParentFolder sql.NullString
PageCount sql.NullInt64
LastReadPage sql.NullInt64
FileSize sql.NullInt64
Author sql.NullString
Isbn sql.NullString
Press sql.NullString
PublishedAt sql.NullString
ExtractPath sql.NullString
ExtractNum sql.NullInt64
BookComplete sql.NullBool
InitComplete sql.NullBool
NonUtf8zip sql.NullBool
ZipTextEncoding sql.NullString
CreatedByVersion sql.NullString
IsRemote sql.NullBool
RemoteUrl sql.NullString
BookID string
}
func ToSQLCUpdateBookParams ¶
func ToSQLCUpdateBookParams(book *model.Book) UpdateBookParams
ToSQLCUpdateBookParams 将model.Book转换为sqlc.UpdateBookParams //"Valid"必须是验证条件或true
type UpdateBookmarkParams ¶
type UpdateBookmarkParams struct {
Description sql.NullString
PageIndex int64
BookID string
Type string
}
func ToSQLCUpdateBookmarkParams ¶
func ToSQLCUpdateBookmarkParams(bookID string, bookmark model.BookMark) UpdateBookmarkParams
ToSQLCUpdateBookmarkParams 将 model.BookMark 转换为 sqlc.UpdateBookmarkParams
type UpdatePageInfoParams ¶
type UpdatePageInfoParams struct {
Name string
Path sql.NullString
Size sql.NullInt64
ModTime sql.NullTime
Url sql.NullString
Blurhash sql.NullString
Height sql.NullInt64
Width sql.NullInt64
ImgType sql.NullString
InsertHtml sql.NullString
BookID string
PageNum sql.NullInt64
}
func ToSQLCUpdatePageInfoParams ¶
func ToSQLCUpdatePageInfoParams(pageInfo model.PageInfo, bookID string) UpdatePageInfoParams
ToSQLCUpdatePageInfoParams 将model.PageInfo转换为sqlc.UpdatePageInfoParams //"Valid"必须是验证条件或true
type UpdateUserKeyParams ¶
type UpdateUserKeyParams struct {
Key sql.NullString
ExpiresAt sql.NullTime
ID int64
}
func ToSQLCUpdateUserKeyParams ¶
func ToSQLCUpdateUserKeyParams(userID int, key string, expiresAt time.Time) UpdateUserKeyParams
ToSQLCUpdateUserKeyParams 将用户ID、key和过期时间转换为sqlc.UpdateUserKeyParams
type UpdateUserParams ¶
type UpdateUserParams struct {
Username string
Password string
Role sql.NullString
Email sql.NullString
Key sql.NullString
ExpiresAt sql.NullTime
ID int64
}
func ToSQLCUpdateUserParams ¶
func ToSQLCUpdateUserParams(user *model.User) UpdateUserParams
ToSQLCUpdateUserParams 将model.User转换为sqlc.UpdateUserParams
type UpdateUserPasswordParams ¶
func ToSQLCUpdateUserPasswordParams ¶
func ToSQLCUpdateUserPasswordParams(userID int, newPassword string) UpdateUserPasswordParams
ToSQLCUpdateUserPasswordParams 将用户ID和新密码转换为sqlc.UpdateUserPasswordParams