增加备份和导出功能
This commit is contained in:
@ -79,9 +79,7 @@ func (r StorageRepository) FindById(id string) (m model.Storage, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (r StorageRepository) FindAll() (o []model.Storage) {
|
||||
if r.DB.Find(&o).Error != nil {
|
||||
return nil
|
||||
}
|
||||
func (r StorageRepository) FindAll() (o []model.Storage, err error) {
|
||||
err = r.DB.Find(&o).Error
|
||||
return
|
||||
}
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user