model

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2019 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Book

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

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

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

type ClippingID = int64

type ClippingService

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

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

type CommentService interface {
	Create(comment *Comment) error
}

func NewCommentService

func NewCommentService() CommentService

type ExternalAccount

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

func (externalAcc *ExternalAccount) Create() error

func (*ExternalAccount) CreateWechat

func (externalAcc *ExternalAccount) CreateWechat() error

type GithubService

type GithubService interface {
	Load(accessToken string) (ExternalAccount, error)
	BindWhithinExternalAndUsers(userid int64, accessToken string) error
}

func NewGithubService

func NewGithubService() GithubService

type ImageService

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

func NewImageService() ImageService

type MailService

type MailService interface {
	Send(address, code string) error
}

func NewMailService

func NewMailService() MailService

type SearchService

type SearchService interface {
	SimpleMineSearch(uid int64, keyword string, take, offset int) (books []Book, clippings []Clipping, err error)
}

func NewSearchService

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 UserID

type UserID = int64

type UserService

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

func NewUserService(db *sqlx.DB) UserService

type Version

type Version struct {
	ID        int       `json:"id" db:"id"`
	Platform  string    `json:"platform" db:"platform"`
	Version   string    `json:"version" db:"version"`
	Info      string    `json:"info" db:"info"`
	URL       string    `json:"url" db:"url"`
	CreatedAt time.Time `json:"createdAt" db:"created_at"`
}

type VersionService

type VersionService interface {
	GetVersionList(platform string, limit int) ([]Version, error)
}

func NewVersionService

func NewVersionService(db *sqlx.DB) VersionService

type WechatLoginResponse

type WechatLoginResponse struct {
	OpenID     string `json:"openid"`
	SessionKey string `json:"session_key"`
	UnionID    string `json:"unionid"`
	ErrCode    int    `json:"errcode"`
	ErrMsg     string `json:"errmsg"`
}

type WechatService

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

func NewWechatService(cache *redis.Client) WechatService

Jump to

Keyboard shortcuts

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