update project path

This commit is contained in:
zhangwenjian committed 2020-03-18 23:09:37 +08:00
1 parent 26acdbd0d1
commit e027e6a259
76 files changed
+2562 -106

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
package models
import (
orm "go-admin/database"
"go-admin/pkg"
"log"
"strings"
)
type Login struct {
Username string `form:"UserName" json:"username" binding:"required"`
Password string `form:"Password" json:"password" binding:"required"`
Code string `form:"Code" json:"code" binding:"required"`
UUID string `form:"UUID" json:"uuid" binding:"required"`
}
func (u *Login) GetUser() (user SysUser, role SysRole, e error) {
e = orm.Eloquent.Table("sys_user").Where("UserName = ? ", u.Username).Find(&user).Error
if e != nil {
if strings.Contains(e.Error(), "record not found") {
pkg.AssertErr(e, "账号或密码错误(代码204)", 500)
}
log.Print(e)
return
}
_, e = pkg.CompareHashAndPassword(user.Password, u.Password)
if e != nil {
if strings.Contains(e.Error(), "hashedPassword is not the hash of the given password") {
pkg.AssertErr(e, "账号或密码错误(代码201)", 500)
}
log.Print(e)
return
}
e = orm.Eloquent.Table("sys_role").Where("id = ? ", user.RoleId).First(&role).Error
if e != nil {
log.Print(e.Error())
return
}
return
}