修复若干问题 (#229)
* 优化图标和LOGO * 修改登录页面动画的速度为3 * 增加对websocket的异常处理 * 修复了用户组和用户名唯一判断错误的问题 * 提示版本号
This commit is contained in:
@ -78,14 +78,17 @@ func (r userRepository) FindByUsername(c context.Context, username string) (o mo
|
||||
return
|
||||
}
|
||||
|
||||
func (r userRepository) ExistByUsername(c context.Context, username string) (exist bool) {
|
||||
count := int64(0)
|
||||
err := r.GetDB(c).Table("users").Where("username = ?", username).Count(&count).Error
|
||||
func (r userRepository) ExistByUsername(c context.Context, username string) (exist bool, err error) {
|
||||
user := model.User{}
|
||||
var count uint64
|
||||
err = r.GetDB(c).Table(user.TableName()).Select("count(*)").
|
||||
Where("username = ?", username).
|
||||
Find(&count).
|
||||
Error
|
||||
if err != nil {
|
||||
return false
|
||||
return false, err
|
||||
}
|
||||
|
||||
return count > 0
|
||||
return count > 0, nil
|
||||
}
|
||||
|
||||
func (r userRepository) FindOnlineUsers(c context.Context) (o []model.User, err error) {
|
||||
|
@ -57,6 +57,19 @@ func (r userGroupRepository) FindByName(c context.Context, name string) (o model
|
||||
return
|
||||
}
|
||||
|
||||
func (r userGroupRepository) ExistByName(ctx context.Context, name string) (exists bool, err error) {
|
||||
userGroup := model.UserGroup{}
|
||||
var count uint64
|
||||
err = r.GetDB(ctx).Table(userGroup.TableName()).Select("count(*)").
|
||||
Where("name = ?", name).
|
||||
Find(&count).
|
||||
Error
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return count > 0, nil
|
||||
}
|
||||
|
||||
func (r userGroupRepository) Create(c context.Context, o *model.UserGroup) (err error) {
|
||||
return r.GetDB(c).Create(o).Error
|
||||
}
|
||||
|
Reference in New Issue
Block a user