增加备份和导出功能

This commit is contained in:
dushixiang
2021-11-15 14:21:46 +08:00
parent 52309870d8
commit 1d232f7269
14 changed files with 472 additions and 134 deletions

View File

@ -90,6 +90,16 @@ func (r UserRepository) FindByUsername(username string) (o model.User, err error
return
}
func (r UserRepository) ExistByUsername(username string) (exist bool) {
count := int64(0)
err := r.DB.Table("users").Where("username = ?", username).Count(&count).Error
if err != nil {
return false
}
return count > 0
}
func (r UserRepository) FindOnlineUsers() (o []model.User, err error) {
err = r.DB.Where("online = ?", true).Find(&o).Error
return