Documentation
¶
Index ¶
- type Book
- type BookService
- type Clipping
- type ClippingID
- type ClippingService
- type Collection
- type Comment
- type CommentService
- type ExternalAccount
- type GithubService
- type ImageService
- type MailService
- type SearchService
- type User
- type UserID
- type UserService
- type Version
- type VersionService
- type WechatLoginResponse
- type WechatService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Book ¶ added in v1.0.2
type Book struct {
ID int `json:"id"`
Rating float32 `json:"rating" db:"rating"`
Author string `json:"author" db:"author"`
Pubdate time.Time `json:"pubdate" db:"pubdate"`
OriginTitle string `json:"originTitle" db:"origin_title"`
Image string `json:"image" db:"image"`
DoubanID string `json:"doubanId" db:"douban_id"`
Title string `json:"title" db:"title"`
URL string `json:"url" db:"url"`
AuthorIntro string `json:"authorIntro" db:"author_intro"`
Summary string `json:"summary" db:"summary"`
Raw string `json:"-" db:"raw"`
}
type BookService ¶ added in v1.0.2
type BookService interface {
Search(doubanID string) (Book, error)
Fetch(title string) (*doubanBook, string, error)
Save(dbBook *doubanBook, raw string) (*Book, error)
Load(doubanID string) (*doubanBook, string, error)
}
func NewBookService ¶ added in v1.0.2
func NewBookService() BookService
type Clipping ¶
type Clipping struct {
ID int64 `json:"id" db:"id"`
Title string `json:"title" db:"title"`
Content string `json:"content" db:"content"`
BookID string `json:"bookId" db:"book_id"`
PageAt string `json:"pageAt" db:"page_at"`
DataID string `json:"dataId" db:"data_id"`
// user id
CreatedBy int64 `json:"createdBy" db:"created_by"`
CreatedAt time.Time `json:"createdAt" db:"created_at"`
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
Sequence int `json:"seq" db:"seq"`
}
Clipping is a book clipping item
type ClippingID ¶ added in v1.0.2
type ClippingID = int64
type ClippingService ¶ added in v1.0.1
type ClippingService interface {
Create(clipping *Clipping) error
Comments(uid int64, take, from int) ([]*Comment, error)
HasCount(uid int64) (int, error)
Load(c *Clipping) error
// 根据书名,获取对应的 clippings
ClippingsByBook(doubanID string, uid int64, take, from int) ([]*Clipping, error)
AssocClippingsWithBook(doubanID string, clippingTitle string, uid int64) error
}
func NewClippingService ¶ added in v1.0.1
func NewClippingService() ClippingService
type Collection ¶
type Collection struct {
ID int64 `json:"id"`
ClipID int64 `json:"clipId"`
UserID int64 `json:"userId"`
}
Collection is a N-N mapping that map clipping to users collection
type Comment ¶
type Comment struct {
ID int64 `json:"id"`
BelongsTo int64 `json:"belongsTo" db:"belongs_to"`
CreatedBy int64 `json:"createdBy" db:"created_by"`
Content string `json:"content" db:"content"`
Author User `json:"author"`
Clipping Clipping `json:"clipping"`
}
Comment is a sub content that belongs to a clip
type CommentService ¶ added in v1.0.1
func NewCommentService ¶ added in v1.0.1
func NewCommentService() CommentService
type ExternalAccount ¶ added in v1.0.2
type ExternalAccount struct {
ID int64 `json:"id" db:"id"`
UserID int64 `json:"user_id" db:"user_id"`
WechatOpenID string `json:"wechat_openid" db:"wechat_openid"`
WechatUnionID string `json:"wechat_unionid" db:"wechat_unionid"`
GithubAccessToken string `json:"github_access_token" db:"github_access_token"`
GithubUser types.JSONText `json:"-" db:"github_user"`
WechatUser types.JSONText `json:"-" db:"wechat_user"`
}
func (*ExternalAccount) Create ¶ added in v1.0.2
func (externalAcc *ExternalAccount) Create() error
func (*ExternalAccount) CreateWechat ¶ added in v1.0.2
func (externalAcc *ExternalAccount) CreateWechat() error
type GithubService ¶ added in v1.0.2
type GithubService interface {
Load(accessToken string) (ExternalAccount, error)
BindWhithinExternalAndUsers(userid int64, accessToken string) error
}
func NewGithubService ¶ added in v1.0.2
func NewGithubService() GithubService
type ImageService ¶ added in v1.0.2
type ImageService interface {
Upload(url string, filename string) (string, error)
UploadImage(file io.Reader, filename string, size int64) (string, error)
// contains filtered or unexported methods
}
func NewImageService ¶ added in v1.0.2
func NewImageService() ImageService
type MailService ¶ added in v1.0.1
func NewMailService ¶ added in v1.0.1
func NewMailService() MailService
type SearchService ¶ added in v1.0.2
type SearchService interface {
SimpleMineSearch(uid int64, keyword string, take, offset int) (books []Book, clippings []Clipping, err error)
}
func NewSearchService ¶ added in v1.0.2
func NewSearchService() SearchService
type User ¶
type User struct {
ID int64 `json:"id"`
Name string `json:"name" db:"name"`
Email string `json:"email" db:"email"`
Pwd string `json:"-" db:"pwd"`
Avatar string `json:"avatar" db:"avatar"`
Checked bool `json:"checked" db:"checked"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
User is a database related model
type UserService ¶ added in v1.0.1
type UserService interface {
Get(user *User) error
Auth(user *User) error
Create(user *User) error
Books(uid int64, take, from int) ([]string, error)
LoadByEmail(email string) (user User, err error)
CreateUser(user *User) error
Clippings(uid int64, take, from int) ([]*Clipping, error)
Comments(uid int64, take, from int) ([]*Comment, error)
// ClippingsHasUpdate 客户端用户存在的长度,以这个长度和服务端做对比来判断客户端是否需要更新
ClippingsHasUpdate(uid int64, index int) (bool, error)
SessionValidated(uid int64) error
}
func NewUserService ¶ added in v1.0.1
func NewUserService(db *sqlx.DB) UserService
type VersionService ¶ added in v1.0.2
func NewVersionService ¶ added in v1.0.2
func NewVersionService(db *sqlx.DB) VersionService
type WechatLoginResponse ¶ added in v1.0.2
type WechatService ¶ added in v1.0.2
type WechatService interface {
Login(code string) (WechatLoginResponse, error)
Load(openID string) (ExternalAccount, error)
HasBind(openID string) bool
Bind(externalAccount ExternalAccount) error
// contains filtered or unexported methods
}
func NewWechatService ¶ added in v1.0.2
func NewWechatService(cache *redis.Client) WechatService
Click to show internal directories.
Click to hide internal directories.