Fix problems modifying personal information,Upgrade route configuration format
This commit is contained in:
1 parent
e07cb22255
commit
c0b8199c36
18 files changed
+355
-244
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"errors"
|
||||
orm "go-admin/database"
|
||||
"go-admin/tools"
|
||||
_ "time"
|
||||
@@ -188,11 +189,17 @@ func (e *Dept) Update(id int) (update Dept, err error) {
|
||||
}
|
||||
e.DeptPath = deptPath
|
||||
|
||||
if e.DeptPath != "" && e.DeptPath != update.DeptPath {
|
||||
return update, errors.New("上级部门不允许修改!")
|
||||
}
|
||||
|
||||
//参数1:是要修改的数据
|
||||
//参数2:是修改的数据
|
||||
|
||||
if err = orm.Eloquent.Table(e.TableName()).Model(&update).Updates(&e).Error; err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@ package models
|
||||
import (
|
||||
orm "go-admin/database"
|
||||
"go-admin/tools"
|
||||
"log"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Login struct {
|
||||
@@ -18,23 +16,14 @@ 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") {
|
||||
tools.HasError(e, "账号或密码错误(代码204)", 500)
|
||||
}
|
||||
log.Print(e)
|
||||
return
|
||||
}
|
||||
_, e = tools.CompareHashAndPassword(user.Password, u.Password)
|
||||
if e != nil {
|
||||
if strings.Contains(e.Error(), "hashedPassword is not the hash of the given password") {
|
||||
tools.HasError(e, "账号或密码错误(代码201)", 500)
|
||||
}
|
||||
log.Print(e)
|
||||
return
|
||||
}
|
||||
e = orm.Eloquent.Table("sys_role").Where("role_id = ? ", user.RoleId).First(&role).Error
|
||||
if e != nil {
|
||||
log.Print(e.Error())
|
||||
return
|
||||
}
|
||||
return
|
||||
|
||||
+6
-5
@@ -120,6 +120,7 @@ func (e *SysUser) Get() (SysUserView SysUserView, err error) {
|
||||
if err = table.First(&SysUserView).Error; err != nil {
|
||||
return
|
||||
}
|
||||
SysUserView.Password = ""
|
||||
return
|
||||
}
|
||||
|
||||
@@ -146,7 +147,7 @@ func (e *SysUser) GetPage(pageSize int, pageIndex int) ([]SysUserPage, int, erro
|
||||
// 数据权限控制
|
||||
dataPermission := new(DataPermission)
|
||||
dataPermission.UserId, _ = tools.StringToInt(e.DataScope)
|
||||
table,err := dataPermission.GetDataScope("sys_user", table)
|
||||
table, err := dataPermission.GetDataScope("sys_user", table)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
@@ -198,10 +199,10 @@ func (e SysUser) Insert() (id int, err error) {
|
||||
|
||||
//修改
|
||||
func (e *SysUser) Update(id int) (update SysUser, err error) {
|
||||
if err = e.Encrypt(); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
//if err = e.Encrypt(); err != nil {
|
||||
// return
|
||||
//}
|
||||
e.Password = ""
|
||||
if err = orm.Eloquent.Table(e.TableName()).First(&update, id).Error; err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user