Documentation ¶
Index ¶
- Constants
- Variables
- func GetArticleCountByCateId(cateId uint64) uint64
- func GetArticleCountByUserCateId(userId uint64, cateId uint64) uint64
- func GetArticleCountByUserId(userID uint64) uint64
- func GetArticleJson(article *Article, cate *Category) string
- func GetArticleJsonData(perPageInt int, offset int) []interface{}
- func GetArtileCount() uint64
- func GetCateCountByUserId(userID uint64) uint64
- func GetPageCountByUserId(userID uint64) uint64
- func InitDB() (*gorm.DB, error)
- type Article
- type ArticleArch
- type ArticleCate
- type ArticleCateInfo
- type ArticleData
- type BaseModel
- type Category
- type Link
- type Page
- type User
- func (user User) CheckPassword(password string) bool
- func (user User) EncryptPassword(password, salt string) (hash string)
- func (user *User) Insert() error
- func (user *User) Lock() error
- func (user User) Salt() string
- func (user *User) UpdateImage() error
- func (user *User) UpdateUserInfo() error
- func (user *User) UpdateUserPwd() error
Constants ¶
View Source
const ( // DevelopmentMode 开发模式 DevelopmentMode = "development" // TestMode 测试模式 TestMode = "test" // ProductionMode 产品模式 ProductionMode = "production" )
Variables ¶
View Source
var DB *gorm.DB
Functions ¶
func GetArticleCountByCateId ¶
func GetArticleCountByUserId ¶
func GetArticleJson ¶
func GetArticleJsonData ¶
func GetArtileCount ¶
func GetArtileCount() uint64
func GetCateCountByUserId ¶
func GetPageCountByUserId ¶
Types ¶
type Article ¶
type Article struct { BaseModel Title string `json:"title"` Desc string `json:"desc"` Content string `json:"content"` UserID uint64 `json:"userId"` ViewCount uint64 `json:"viewCount"` CommentCount uint64 `json:"commentCount"` CategoryID uint64 `json:"categoryId"` User User `gorm:"ForeignKey:ID" json:"user"` Category Category `gorm:"ForeignKey:ID" json:"category"` IsPublished bool }
Table Article
func GetArticleById ¶
func GetRecentArticleQuerys ¶
func (*Article) UpdateView ¶
type ArticleArch ¶
type ArticleArch struct { Year int `json:"year"` Month string `json:"month"` YearMonth string `json:"yearMonth"` Articles []*Article `json:"articles"` }
Article Archive
func GetArticleArchiveQuerys ¶
func GetArticleArchiveQuerys() ([]*ArticleArch, error)
type ArticleCate ¶
type ArticleCate struct { CateID uint64 `json:"cateId"` CateCount uint64 `json:"cateCount"` CateName string `json:"cateName"` }
Article Category
func GetArticleCategoryQuerys ¶
func GetArticleCategoryQuerys() ([]*ArticleCate, error)
type ArticleCateInfo ¶
type ArticleCateInfo struct { ID uint64 `gorm:"primary_key"` Title string `json:"title"` Name string `json:"name"` IsPublished bool Count uint64 `json:"count"` CreatedAt time.Time UpdatedAt time.Time }
Article Category Info
func AdminGetArticleByCategory ¶
func AdminGetArticleByCategory(userId uint64, cateId uint64) ([]*ArticleCateInfo, error)
type ArticleData ¶
type ArticleData struct { Title string `json:"title"` ReadCount uint64 `json:"readCount"` ArticleID uint64 `json:"articleID"` CommentCount uint64 `json:"commentCount"` Desc string `json:"desc"` Category string `json:"category"` CategoryID uint64 `json:"categoryID"` CreateTime string `json:"createTime"` }
ArticleData
func GetArticleArchiveQuerysByTime ¶
func GetArticleArchiveQuerysByTime(archTime string) ([]*ArticleData, error)
func GetArticleQuerysByCateId ¶
func GetArticleQuerysByCateId(cateId uint64) ([]*ArticleData, error)
func GetArticlesByKeyword ¶
func GetArticlesByKeyword(keyword string) ([]*ArticleData, error)
type Category ¶
Table Category
func GetCategoryByName ¶
Get Category by name
func GetCategoryQuerys ¶
type Link ¶
type Link struct { BaseModel Name string `json:"name"` //名称 Url string `json:"url"` //地址 Sort int `json:"default:'0'"` //排序 View int `json:"view"` //访问次数 UserID uint64 `json:"userId"` User User `gorm:"ForeignKey:ID" json:"user"` }
Table link
func GetLinkQuerysByUserID ¶
Get Link Querys By UserID
type Page ¶
type Page struct { BaseModel Title string `json:"title"` Content string `json:"content"` View int `json:"view"` UserID uint64 `json:"userId"` User User `gorm:"ForeignKey:ID" json:"user"` IsPublished bool }
Table Page
func GetPageById ¶
func GetPageQuerysByUserId ¶
type User ¶
type User struct { BaseModel RealName string `json:"realName"` //真实姓名 UserName string `json:"userName"` //昵称 Email string `gorm:"unique_index;default:null"` //邮箱 Telephone string `gorm:"unique_index;default:null"` //手机号码 Password string `gorm:"default:null"` //密码 VerifyState string `gorm:"default:'0'"` //邮箱验证状态 AvatarUrl string `json:"avatarUrl"` //头像链接 IsAdmin bool //是否是管理员 LockState bool `gorm:"default:'0'"` //锁定状态 }
User Table
func (User) CheckPassword ¶
CheclPassword 验证密码是否正确
func (User) EncryptPassword ¶
EncryptPassword 给密码加密
func (*User) UpdateImage ¶
func (*User) UpdateUserInfo ¶
func (*User) UpdateUserPwd ¶
Click to show internal directories.
Click to hide internal directories.