Documentation ¶
Index ¶
- Variables
- func CreateAdministrator()
- func CreateComment(data *Comment) error
- func CreatePost(data *Post) error
- func CreateSite(data *Site) error
- func CreateUser(data *User) error
- func DeleteCommentByID(id uint) error
- func DeleteSiteById(id uint) error
- func InitDatabase()
- func UpdateCommentByID(id uint, data *Comment) error
- func UpdateSiteById(id uint, site *Site) error
- func UpdateUser(id uint, data map[string]interface{}) error
- type Comment
- type Post
- type Site
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var (
DB *gorm.DB
)
Functions ¶
func UpdateCommentByID ¶
UpdateCommentByID 根据ID更新评论
Types ¶
type Comment ¶
type Comment struct { Content string UA string IP string Region string Type string `gorm:"default:published"` Up int Down int PostID uint `gorm:"index"` // 外键,指向 Post Post Post `gorm:"foreignKey:PostID"` UserID uint `gorm:"index"` // 外键,指向 User User User `gorm:"foreignKey:UserID"` Parent uint `gorm:"index;default:0"` gorm.Model }
type Post ¶
type Post struct { Slug string `gorm:"index;size:255"` Up int Down int Read int SiteID uint `gorm:"index"` // 外键,指向 Site Site Site `gorm:"foreignKey:SiteID"` Comments []Comment `gorm:"foreignKey:PostID"` // 定义一对多关系 gorm.Model }
func FindOrCreatePost ¶
func FindOrCreatePost(data dto.CommentDTO) (*Post, error)
FindOrCreatePost 查找或创建
type Site ¶
type User ¶
type User struct { gorm.Model Name string `gorm:"index;size:255"` Email string `gorm:"index;size:255"` Url string Password string LastIP string LastUA string Role string Notice bool `gorm:"default:false"` Comments []Comment `gorm:"foreignKey:UserID"` // 用户评论 }
User 用户表
func FindOrCreateUser ¶
func FindOrCreateUser(data dto.CommentDTO) (*User, error)
FindOrCreateUser 查找或创建
func GetUserByEmail ¶
GetUserByEmail 通过用户email找到用户信息
func GetUserByNameOrEmail ¶
GetUserByNameOrEmail 通过name或email查找用户
func (*User) CheckPassword ¶
func (*User) SetPasswordEncrypt ¶
SetPasswordEncrypt 设置密码加密
Click to show internal directories.
Click to hide internal directories.