Documentation
¶
Index ¶
- Constants
- Variables
- func DB() *gorm.DB
- func MarkTotal(userID uint) (total int64)
- func PaginationScope(vo PaginationVO) func(db *gorm.DB) *gorm.DB
- func Ping() error
- func RegisterGormCallBack() (err error)
- type BaseModel
- type Comment
- func CommentCreate(userID uint, markID uint, content string) (comment *Comment, err error)
- func CommentDestroy(userID uint, markID uint) (comment *Comment, err error)
- func CommentFind(commentID uint) (comment *Comment, err error)
- func CommentFindByMarkID(userID uint, markID uint) (comment *Comment, err error)
- func CommentUpdate(userID uint, markID uint, content string) (comment *Comment, err error)
- func FakeComment(userID uint, markID uint) *Comment
- type CommentVO
- type DeletedAt
- func (DeletedAt) DeleteClauses(f *schema.Field) []clause.Interface
- func (n DeletedAt) MarshalJSON() ([]byte, error)
- func (DeletedAt) QueryClauses(f *schema.Field) []clause.Interface
- func (n *DeletedAt) Scan(value interface{}) error
- func (n *DeletedAt) UnmarshalJSON(b []byte) error
- func (n DeletedAt) Value() (driver.Value, error)
- type Mark
- func FakeMark(userID uint) *Mark
- func MarkCreate(userID uint, vo *MarkCreateVO) (mark *Mark, err error)
- func MarkDestroy(userID uint, hashKey string) (mark *Mark, err error)
- func MarkFind(markID uint) (mark *Mark, err error)
- func MarkFindByHashKey(userID uint, hashKey string) (mark *Mark, err error)
- func MarkList(userID uint, vo PaginationVO) []Mark
- func MarkQuery(userID uint, safeBase64URL string) []*Mark
- func MarkUpdate(userID uint, hashKey string, vo *MarkUpdateVO) (mark *Mark, err error)
- type MarkCreateVO
- type MarkUpdateVO
- type PaginationVO
- type Selection
- type Session
- type SessionVO
- type SoftDeleteDeleteClause
- type SoftDeleteQueryClause
- type User
- type UserStatus
Constants ¶
View Source
const HTMLSplitTag = "\t"
Variables ¶
View Source
var Pagination = PaginationVO{Page: 1, Size: 10}
View Source
var UserStatuses = map[string]UserStatus{ "ActivatedStatus": ActivatedStatus, "InactiveStatus": InactiveStatus, }
Functions ¶
func PaginationScope ¶
func PaginationScope(vo PaginationVO) func(db *gorm.DB) *gorm.DB
func RegisterGormCallBack ¶
func RegisterGormCallBack() (err error)
Types ¶
type Comment ¶ added in v0.2.0
type Comment struct { BaseModel UserID uint `gorm:"not null" json:"-" binding:"required"` User *User `json:"user,omitempty"` MarkID uint `gorm:"index;not null" json:"mark_id" binding:"required"` Content string `gorm:"type:text" json:"content" binding:"required"` }
func CommentCreate ¶ added in v0.2.0
func CommentDestroy ¶ added in v0.2.0
func CommentFind ¶ added in v0.2.0
func CommentFindByMarkID ¶ added in v0.2.0
func CommentUpdate ¶ added in v0.2.0
func FakeComment ¶ added in v0.2.0
type CommentVO ¶ added in v0.2.0
type CommentVO struct {
Content string `json:"content" binding:"required"`
}
type DeletedAt ¶ added in v0.2.0
type DeletedAt int64
func (DeletedAt) DeleteClauses ¶ added in v0.2.0
func (DeletedAt) MarshalJSON ¶ added in v0.2.0
func (DeletedAt) QueryClauses ¶ added in v0.2.0
func (*DeletedAt) UnmarshalJSON ¶ added in v0.2.0
type Mark ¶
type Mark struct { BaseModel UserID uint `gorm:"not null" json:"user_id" binding:"required"` URL string `gorm:"type:varchar(255);index" json:"url" binding:"required"` Tag string `gorm:"type:varchar(255);comment:color or other tag;not null" json:"tag" binding:"required"` HashKey string `gorm:"type:varchar(255);not null" json:"hash_key" binding:"required"` Selection Selection `gorm:"type:text;not null" json:"selection" binding:"required"` Comment *Comment `json:"comment,omitempty"` // has one }
func MarkCreate ¶ added in v0.2.0
func MarkCreate(userID uint, vo *MarkCreateVO) (mark *Mark, err error)
func MarkDestroy ¶ added in v0.2.0
func MarkFindByHashKey ¶ added in v0.2.0
func MarkList ¶ added in v0.2.0
func MarkList(userID uint, vo PaginationVO) []Mark
func MarkUpdate ¶ added in v0.2.0
func MarkUpdate(userID uint, hashKey string, vo *MarkUpdateVO) (mark *Mark, err error)
func (*Mark) SelectionText ¶ added in v0.2.0
type MarkCreateVO ¶
type MarkUpdateVO ¶
type MarkUpdateVO struct {
Tag string `json:"tag"`
}
type PaginationVO ¶
type Selection ¶ added in v0.2.0
type Selection struct { Texts []string `json:"texts" binding:"required"` StartOffset int `json:"startOffset"` EndOffset int `json:"endOffset" binding:"required"` }
func FakeSelection ¶ added in v0.2.0
func FakeSelection() *Selection
type Session ¶
type Session struct { BaseModel Token string `json:"token" gorm:"uniqueindex;not null;type:varchar(255)"` ExpiredAt time.Time `json:"expired_at" gorm:"not null"` UserID uint `json:"user_id" gorm:"not null"` User *User `json:"user,omitempty"` }
func SessionFindByToken ¶ added in v0.2.0
type SoftDeleteDeleteClause ¶ added in v0.2.0
func (SoftDeleteDeleteClause) Build ¶ added in v0.2.0
func (sd SoftDeleteDeleteClause) Build(clause.Builder)
func (SoftDeleteDeleteClause) MergeClause ¶ added in v0.2.0
func (sd SoftDeleteDeleteClause) MergeClause(*clause.Clause)
func (SoftDeleteDeleteClause) ModifyStatement ¶ added in v0.2.0
func (sd SoftDeleteDeleteClause) ModifyStatement(stmt *gorm.Statement)
func (SoftDeleteDeleteClause) Name ¶ added in v0.2.0
func (sd SoftDeleteDeleteClause) Name() string
type SoftDeleteQueryClause ¶ added in v0.2.0
func (SoftDeleteQueryClause) Build ¶ added in v0.2.0
func (sd SoftDeleteQueryClause) Build(clause.Builder)
func (SoftDeleteQueryClause) MergeClause ¶ added in v0.2.0
func (sd SoftDeleteQueryClause) MergeClause(*clause.Clause)
func (SoftDeleteQueryClause) ModifyStatement ¶ added in v0.2.0
func (sd SoftDeleteQueryClause) ModifyStatement(stmt *gorm.Statement)
func (SoftDeleteQueryClause) Name ¶ added in v0.2.0
func (sd SoftDeleteQueryClause) Name() string
type User ¶
type User struct { BaseModel Status string `json:"status"` Email string `json:"email" binding:"required"` Avatar string `json:"avatar"` PasswordHash string `json:"-"` Password string `json:"-" gorm:"-"` }
func UserCreate ¶ added in v0.2.0
func UserFindByEmail ¶ added in v0.2.0
func (*User) CalcPasswordHash ¶
func (*User) GenerateSession ¶
func (*User) ValidPassword ¶
type UserStatus ¶
type UserStatus string
const ( ActivatedStatus UserStatus = "ActivatedStatus" InactiveStatus UserStatus = "InactiveStatus" )
func (UserStatus) String ¶
func (s UserStatus) String() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.