book

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2019 License: Apache-2.0, Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIDELETEBook added in v0.0.11

func APIDELETEBook(c *gin.Context)

@since 0.0.10

func APIDELETEBookCard

func APIDELETEBookCard(c *gin.Context)

APIDELETEBookCard 移除book下的card下的引用 @since 0.0.3

func APIDELETECard

func APIDELETECard(c *gin.Context)

func APIGETBook

func APIGETBook(c *gin.Context)

APIGETBook 获取图书基本信息

func APIGETBookCards

func APIGETBookCards(c *gin.Context)

func APIGETBooks

func APIGETBooks(c *gin.Context)

APIGETBook 获取图书列表信息 @since 0.0.12 增加翻页功能

func APIGETCard

func APIGETCard(c *gin.Context)

APIGETCard 用于获取 book 下 card 原始内容以供编辑 @since 0.0.3

func APIGETPointCards

func APIGETPointCards(c *gin.Context)

func APIGetBook

func APIGetBook(c *gin.Context)

func APIOPTIONCard added in v0.0.10

func APIOPTIONCard(c *gin.Context)

APIOPTIONCard 跨域

func APIPOSTBook

func APIPOSTBook(c *gin.Context)

func APIPOSTBookTaxonomy

func APIPOSTBookTaxonomy(c *gin.Context)

APIPOSTBookTaxonomy 将已有的 card 添加引用到 book

func APIPOSTCard

func APIPOSTCard(c *gin.Context)

APIPOSTCard 向card表插入一行数据 不关联 book @since 0.0.3

func APIPUTCard

func APIPUTCard(c *gin.Context)

APIPUTCard 更新 card 内容

func APIPostCard

func APIPostCard(c *gin.Context)

APIPostCard 添加卡片 bookID == 0 只添加 card !=0 关联到 book

func APIPostUpdateCardsTreeNew added in v0.0.10

func APIPostUpdateCardsTreeNew(c *gin.Context)

APIPostUpdateCardTreeNew 更新手册排序 @since 0.0.9 ant 重写

func AdminGETBook

func AdminGETBook(c *gin.Context)

func DELETEBookCard

func DELETEBookCard(bookID uint64, cardID uint64) error

DELETEBookCard 删除book下的card引用 @since 0.0.3

func GETPoint

func GETPoint(c *gin.Context)

GETPoint 零散未成书的知识点

func GetBookEdit

func GetBookEdit(c *gin.Context)

GetBookEdit 图书编辑页

func GetBookList

func GetBookList(uid uint64, p *pagination.Pagination) ([]model.DBBook, uint64, error)

GetBookList 获取图书列表 @since 0.0.3

func InsterCard

func InsterCard(userID uint64, bookID uint64, cardName string, cardDesc string, state model.CardState) error

InsterCard 向book插入新Card sp insert_card 先增加card再添加book的引用关系 @since 0.0.3

func POSTBook

func POSTBook(userID uint64, name string, desc string) error

POSTBook 添加新的图书 @since 0.0.3

func PUTCard

func PUTCard(cardID uint64, name string, desc string, state string) (sql.Result, error)

TODO 增加管理员可以修改

func PUTCardInBook added in v0.0.10

func PUTCardInBook(tx *sql.Tx, uid uint64, cardID uint64, inBook bool) error

PUTCardInBook 修改 card 的 in_book 字段状态 @since v0.0.9

func PutBookCardsTree added in v0.0.10

func PutBookCardsTree(bookID uint64, t []TreeData, parent uint64, cardOrder *int) error

func Register

func Register()

Register 注册文章组件路由 @since 0.0.1 @since 0.0.10 增加删除 book 功能

Types

type APIDELETEBookCardForm

type APIDELETEBookCardForm struct {
	BookID uint64 `form:"book_id" json:"book_id"`
	CardID uint64 `form:"card_id" json:"card_id"`
}

type APIDELETEBookForm added in v0.0.11

type APIDELETEBookForm struct {
	BookID uint64 `form:"book_id" binding:"required"`
}

@since 0.0.10

type APIDELETECardForm

type APIDELETECardForm struct {
	CardID uint64 `form:"card_id" json:"card_id"`
}

type APIGETBookCardsForm

type APIGETBookCardsForm struct {
	BookID       uint64 `form:"book_id" binding:"required"`
	ParentCardID uint64 `form:"parent_card_id"`
}

type APIGETBooksForm added in v0.0.12

type APIGETBooksForm struct {
	pagination.Form
}

APIGETBooksForm 分页表单

type APIGETCardForm

type APIGETCardForm struct {
	// BookID uint64 `json:"book_id" form:"book_id"`
	CardID uint64 `json:"card_id" form:"card_id"`
}

type APIGETCardsForm added in v0.0.10

type APIGETCardsForm struct {
	ParentCardID uint64 `form:"parent_card_id" binding:"required"`
}

type APIPOSTBookForm

type APIPOSTBookForm struct {
	Name string `form:"name"`
	Desc string `form:"desc"`
}

type APIPOSTBookTaxonomyFrom

type APIPOSTBookTaxonomyFrom struct {
	CardID uint64 `json:"card_id" form:"card_id"`
	BookID uint64 `json:"book_id" form:"book_id"`
}

type APIPOSTCardForm

type APIPOSTCardForm struct {
	BookID uint64 `json:"book_id"`
	Name   string `json:"name"`
	Desc   string `json:"desc"`
}

APIPOSTCardForm APIPOSTCard

type APIPUTCardForm

type APIPUTCardForm struct {
	CardID uint64 `json:"card_id"` // 主键ID
	//UserID uint64 `json:"user_id"` // 用户ID
	Name  string `json:"name"`  // 卡片名称
	Desc  string `json:"desc"`  // 卡片内容
	State string `json:"state"` // enum 状态 ('close','open')

}

@since v0.0.9 取消了 user_id

type Book

type Book struct {
	BookID           uint64          // 主键ID
	UserID           uint64          // 用户ID
	Name             string          // 卡片名称
	Desc             string          // 卡片内容
	State            model.CardState // enum 状态 ('close','open')
	DateLastActivity time.Time       // 最后操作时间
	ShortLink        string          // 短链接
	Date             time.Time       // 创建时间
}

func GetBookByID

func GetBookByID(bookID uint64) (*Book, error)

GetBook 获取手册头 @since 0.0.3

type BookCards

type BookCards struct {
	ID     uint64 // book_id
	Name   string
	Desc   string
	UserID uint64 // Book 的 user ID
	Cards  []Card
}

func GetBookCardsByBookID

func GetBookCardsByBookID(id uint64) (*BookCards, error)

GetBookCardsByBookID 获取 book card 内容 @since 0.0.3

type Card

type Card struct {
	CardID           uint64
	UserID           uint64
	Name             string
	Desc             string
	State            model.CardState
	DateLastActivity time.Time
	ShortLink        string
	Date             time.Time
	// @since v0.0.9
	InBook bool

	Level     int
	CardOrder uint64

	Cards []Card
}

func GetBookCard

func GetBookCard(cardID uint64) (*Card, error)

GetBookCard card 表没有存 bookID 且 如果同一个卡片挂载到多个 book 的时候 是复制操作 所以这里不做 book 验证

type FormAPIPostCard

type FormAPIPostCard struct {
	Name   string `form:"name" binding:"required"`
	Desc   string `form:"desc" binding:"required"`
	BookID uint64 `form:"book_id" binding:"required"`
}

type FormAPIPostUpdateCardTree

type FormAPIPostUpdateCardTree struct {
	BookID   uint64     `form:"book_id" json:"book_id" binding:"required"`
	TreeData []TreeData `form:"tree_data" json:"tree_data" binding:"required"`
}

type GetBookForm

type GetBookForm struct {
	ID uint64 `form:"book_id" `
}

GetBookForm 表单

type SPErr

type SPErr struct {
	Errcode int64
	Errmsg  string
}

func CheckSpErr

func CheckSpErr(row *sql.Row) (err error, hasSPErr bool, spErr SPErr)

CheckSpErr 通用的 sp 操作结果的检查 err Scan 错误 有错直接返回 HasSPErr 有错为真, 假则跳过直接处理后续业务,为真时处理 spErr SPErr @since 0.0.3

type TreeData added in v0.0.10

type TreeData struct {
	Title            string     `json:"title"`
	Key              uint64     `json:"key"`
	Desc             string     `json:"desc"`
	IsLeaf           bool       `json:"isLeaf"`
	DateLastActivity time.Time  `json:"dateLastActivity"`
	Children         []TreeData `json:"children"`
}

Jump to

Keyboard shortcuts

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