|
@ -1,7 +1,7 @@ |
|
|
package userService |
|
|
package userService |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"GoClouds/core/comm" |
|
|
|
|
|
|
|
|
"GoClouds/core/comms" |
|
|
"GoClouds/models" |
|
|
"GoClouds/models" |
|
|
"GoClouds/modeluis" |
|
|
"GoClouds/modeluis" |
|
|
"GoClouds/service/sysService" |
|
|
"GoClouds/service/sysService" |
|
@ -13,7 +13,7 @@ import ( |
|
|
|
|
|
|
|
|
func FindTreePermission() []*modeluis.TreePermssion { |
|
|
func FindTreePermission() []*modeluis.TreePermssion { |
|
|
rets := make([]*modeluis.TreePermssion, 0) |
|
|
rets := make([]*modeluis.TreePermssion, 0) |
|
|
err := comm.DbSysHelper.GetDB().Where("parent is null or parent=''").OrderBy("sort ASC,id ASC").Find(&rets) |
|
|
|
|
|
|
|
|
err := comms.DbSysHelper.GetDB().Where("parent is null or parent=''").OrderBy("sort ASC,id ASC").Find(&rets) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
println("findPermChilds err:" + err.Error()) |
|
|
println("findPermChilds err:" + err.Error()) |
|
|
return nil |
|
|
return nil |
|
@ -30,7 +30,7 @@ func findPermChilds(parent *modeluis.TreePermssion, upms map[string]bool) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
childs := make([]*modeluis.TreePermssion, 0) |
|
|
childs := make([]*modeluis.TreePermssion, 0) |
|
|
err := comm.DbSysHelper.GetDB().Where("parent=?", parent.Xid).OrderBy("sort ASC,id ASC").Find(&childs) |
|
|
|
|
|
|
|
|
err := comms.DbSysHelper.GetDB().Where("parent=?", parent.Xid).OrderBy("sort ASC,id ASC").Find(&childs) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
println("findPermChilds err:" + err.Error()) |
|
|
println("findPermChilds err:" + err.Error()) |
|
|
return |
|
|
return |
|
@ -56,7 +56,7 @@ func FindUPermissions(uid string) []*modeluis.SysPermssion { |
|
|
userRole := FindUserRole(uid) |
|
|
userRole := FindUserRole(uid) |
|
|
//comm.DbSysHelper.GetDB().SqlTemplateClient("role.stpl")
|
|
|
//comm.DbSysHelper.GetDB().SqlTemplateClient("role.stpl")
|
|
|
//rids:=strings.Split(userRole.RoleCodes,",")
|
|
|
//rids:=strings.Split(userRole.RoleCodes,",")
|
|
|
ses := comm.DbSysHelper.GetDB().Where("xid='common'") |
|
|
|
|
|
|
|
|
ses := comms.DbSysHelper.GetDB().Where("xid='common'") |
|
|
if len(userRole.RoleCodes) > 0 { |
|
|
if len(userRole.RoleCodes) > 0 { |
|
|
rcds := strings.Split(userRole.RoleCodes, ",") |
|
|
rcds := strings.Split(userRole.RoleCodes, ",") |
|
|
ses.Or(builder.In("xid", rcds)) |
|
|
ses.Or(builder.In("xid", rcds)) |
|
@ -72,7 +72,7 @@ func FindUPermissions(uid string) []*modeluis.SysPermssion { |
|
|
continue |
|
|
continue |
|
|
} |
|
|
} |
|
|
permssions := make([]*modeluis.SysPermssion, 0) |
|
|
permssions := make([]*modeluis.SysPermssion, 0) |
|
|
ses := comm.DbSysHelper.GetDB().Where(builder.In("xid", strings.Split(role.Perms, ","))) |
|
|
|
|
|
|
|
|
ses := comms.DbSysHelper.GetDB().Where(builder.In("xid", strings.Split(role.Perms, ","))) |
|
|
err := ses.Find(&permssions) |
|
|
err := ses.Find(&permssions) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
println("FindUserPermission err:" + err.Error()) |
|
|
println("FindUserPermission err:" + err.Error()) |
|
@ -106,12 +106,12 @@ func FindUPermissions(uid string) []*modeluis.SysPermssion { |
|
|
} |
|
|
} |
|
|
func FindUserRole(uid string) *models.SysUserRole { |
|
|
func FindUserRole(uid string) *models.SysUserRole { |
|
|
userRole := new(models.SysUserRole) |
|
|
userRole := new(models.SysUserRole) |
|
|
ok, err := comm.DbSysHelper.GetDB().Where("user_code=?", uid).Get(userRole) |
|
|
|
|
|
|
|
|
ok, err := comms.DbSysHelper.GetDB().Where("user_code=?", uid).Get(userRole) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
println("FindUserPermission err:" + err.Error()) |
|
|
println("FindUserPermission err:" + err.Error()) |
|
|
} else if !ok { |
|
|
} else if !ok { |
|
|
userRole.UserCode = uid |
|
|
userRole.UserCode = uid |
|
|
comm.DbSysHelper.GetDB().Insert(userRole) |
|
|
|
|
|
|
|
|
comms.DbSysHelper.GetDB().Insert(userRole) |
|
|
} |
|
|
} |
|
|
return userRole |
|
|
return userRole |
|
|
} |
|
|
} |
|
@ -125,7 +125,7 @@ func FindUserRoles(uid string) []*modeluis.SysURole { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
roles := make([]*modeluis.SysURole, 0) |
|
|
roles := make([]*modeluis.SysURole, 0) |
|
|
err := comm.DbSysHelper.GetDB().Where("xid!='common'").Find(&roles) |
|
|
|
|
|
|
|
|
err := comms.DbSysHelper.GetDB().Where("xid!='common'").Find(&roles) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
println("FindUserRoles:" + err.Error()) |
|
|
println("FindUserRoles:" + err.Error()) |
|
|
} |
|
|
} |
|
@ -140,7 +140,7 @@ func FindUserPermission(uid string) map[string]bool { |
|
|
userRole := FindUserRole(uid) |
|
|
userRole := FindUserRole(uid) |
|
|
//comm.DbSysHelper.GetDB().SqlTemplateClient("role.stpl")
|
|
|
//comm.DbSysHelper.GetDB().SqlTemplateClient("role.stpl")
|
|
|
//rids:=strings.Split(userRole.RoleCodes,",")
|
|
|
//rids:=strings.Split(userRole.RoleCodes,",")
|
|
|
ses := comm.DbSysHelper.GetDB().Where("xid='common'") |
|
|
|
|
|
|
|
|
ses := comms.DbSysHelper.GetDB().Where("xid='common'") |
|
|
if len(userRole.RoleCodes) > 0 { |
|
|
if len(userRole.RoleCodes) > 0 { |
|
|
rcds := strings.Split(userRole.RoleCodes, ",") |
|
|
rcds := strings.Split(userRole.RoleCodes, ",") |
|
|
ses.Or(builder.In("xid", rcds)) |
|
|
ses.Or(builder.In("xid", rcds)) |
|
@ -156,7 +156,7 @@ func FindUserPermission(uid string) map[string]bool { |
|
|
continue |
|
|
continue |
|
|
} |
|
|
} |
|
|
permssions := make([]*models.SysPermssion, 0) |
|
|
permssions := make([]*models.SysPermssion, 0) |
|
|
ses := comm.DbSysHelper.GetDB().Where(builder.In("xid", strings.Split(role.Perms, ","))) |
|
|
|
|
|
|
|
|
ses := comms.DbSysHelper.GetDB().Where(builder.In("xid", strings.Split(role.Perms, ","))) |
|
|
if len(userRole.Limits) > 0 { |
|
|
if len(userRole.Limits) > 0 { |
|
|
rcds := strings.Split(userRole.Limits, ",") |
|
|
rcds := strings.Split(userRole.Limits, ",") |
|
|
ses.And(builder.NotIn("xid", rcds)) |
|
|
ses.And(builder.NotIn("xid", rcds)) |
|
|