Skip to content

Commit db26f5b

Browse files
author
pixel
committed
冗余代码修复
1 parent 5d411c0 commit db26f5b

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

server/service/sys_user.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@ func Register(u model.SysUser) (err error, userInter model.SysUser) {
4242
func Login(u *model.SysUser) (err error, userInter *model.SysUser) {
4343
var user model.SysUser
4444
u.Password = utils.MD5V([]byte(u.Password))
45-
err = global.GVA_DB.Where("username = ? AND password = ?", u.Username, u.Password).First(&user).Error
46-
if err != nil {
47-
return err, &user
48-
}
49-
err = global.GVA_DB.Where("authority_id = ?", user.AuthorityId).First(&user.Authority).Error
45+
err = global.GVA_DB.Where("username = ? AND password = ?", u.Username, u.Password).Preload("Authority").First(&user).Error
5046
return err, &user
5147
}
5248

0 commit comments

Comments
 (0)