|
|
@ -16,7 +16,7 @@ import ( |
|
|
|
|
|
|
|
func FindTreePermission() []*modeluis.TreePermssion { |
|
|
|
rets := make([]*modeluis.TreePermssion, 0) |
|
|
|
err := comm.DbMain.Where("parent is null or parent=''").OrderBy("sort ASC,id ASC").Find(&rets) |
|
|
|
err := comm.DbSys.Where("parent is null or parent=''").OrderBy("sort ASC,id ASC").Find(&rets) |
|
|
|
if err != nil { |
|
|
|
println("findPermChilds err:" + err.Error()) |
|
|
|
return nil |
|
|
@ -33,7 +33,7 @@ func findPermChilds(parent *modeluis.TreePermssion, upms map[string]bool) { |
|
|
|
return |
|
|
|
} |
|
|
|
childs := make([]*modeluis.TreePermssion, 0) |
|
|
|
err := comm.DbMain.Where("parent=?", parent.Uuid).OrderBy("sort ASC,id ASC").Find(&childs) |
|
|
|
err := comm.DbSys.Where("parent=?", parent.Uuid).OrderBy("sort ASC,id ASC").Find(&childs) |
|
|
|
if err != nil { |
|
|
|
println("findPermChilds err:" + err.Error()) |
|
|
|
return |
|
|
@ -57,9 +57,9 @@ func FindUPermissions(uid string) []*modeluis.SysPermssion { |
|
|
|
} |
|
|
|
perms := make(map[string]*modeluis.SysPermssion) |
|
|
|
userRole := FindUserRole(uid) |
|
|
|
//comm.DbMain.SqlTemplateClient("role.stpl")
|
|
|
|
//comm.DbSys.SqlTemplateClient("role.stpl")
|
|
|
|
//rids:=strings.Split(userRole.RoleCodes,",")
|
|
|
|
ses := comm.DbMain.Where("uuid='common'") |
|
|
|
ses := comm.DbSys.Where("uuid='common'") |
|
|
|
if len(userRole.RoleCodes) > 0 { |
|
|
|
rcds := strings.Split(userRole.RoleCodes, ",") |
|
|
|
ses.Or(builder.In("uuid", rcds)) |
|
|
@ -75,7 +75,7 @@ func FindUPermissions(uid string) []*modeluis.SysPermssion { |
|
|
|
continue |
|
|
|
} |
|
|
|
permssions := make([]*modeluis.SysPermssion, 0) |
|
|
|
ses := comm.DbMain.Where(builder.In("uuid", strings.Split(role.Perms, ","))) |
|
|
|
ses := comm.DbSys.Where(builder.In("uuid", strings.Split(role.Perms, ","))) |
|
|
|
err := ses.Find(&permssions) |
|
|
|
if err != nil { |
|
|
|
println("FindUserPermission err:" + err.Error()) |
|
|
@ -109,12 +109,12 @@ func FindUPermissions(uid string) []*modeluis.SysPermssion { |
|
|
|
} |
|
|
|
func FindUserRole(uid string) *models.SysUserRole { |
|
|
|
userRole := new(models.SysUserRole) |
|
|
|
ok, err := comm.DbMain.Where("user_code=?", uid).Get(userRole) |
|
|
|
ok, err := comm.DbSys.Where("user_code=?", uid).Get(userRole) |
|
|
|
if err != nil { |
|
|
|
println("FindUserPermission err:" + err.Error()) |
|
|
|
} else if !ok { |
|
|
|
userRole.UserCode = uid |
|
|
|
comm.DbMain.Insert(userRole) |
|
|
|
comm.DbSys.Insert(userRole) |
|
|
|
} |
|
|
|
return userRole |
|
|
|
} |
|
|
@ -128,7 +128,7 @@ func FindUserRoles(uid string) []*modeluis.SysURole { |
|
|
|
} |
|
|
|
} |
|
|
|
roles := make([]*modeluis.SysURole, 0) |
|
|
|
err := comm.DbMain.Where("uuid!='common'").Find(&roles) |
|
|
|
err := comm.DbSys.Where("uuid!='common'").Find(&roles) |
|
|
|
if err != nil { |
|
|
|
println("FindUserRoles:" + err.Error()) |
|
|
|
} |
|
|
@ -141,9 +141,9 @@ func FindUserRoles(uid string) []*modeluis.SysURole { |
|
|
|
func FindUserPermission(uid string) map[string]bool { |
|
|
|
perms := make(map[string]bool) |
|
|
|
userRole := FindUserRole(uid) |
|
|
|
//comm.DbMain.SqlTemplateClient("role.stpl")
|
|
|
|
//comm.DbSys.SqlTemplateClient("role.stpl")
|
|
|
|
//rids:=strings.Split(userRole.RoleCodes,",")
|
|
|
|
ses := comm.DbMain.Where("uuid='common'") |
|
|
|
ses := comm.DbSys.Where("uuid='common'") |
|
|
|
if len(userRole.RoleCodes) > 0 { |
|
|
|
rcds := strings.Split(userRole.RoleCodes, ",") |
|
|
|
ses.Or(builder.In("uuid", rcds)) |
|
|
@ -159,7 +159,7 @@ func FindUserPermission(uid string) map[string]bool { |
|
|
|
continue |
|
|
|
} |
|
|
|
permssions := make([]*models.SysPermssion, 0) |
|
|
|
ses := comm.DbMain.Where(builder.In("uuid", strings.Split(role.Perms, ","))) |
|
|
|
ses := comm.DbSys.Where(builder.In("uuid", strings.Split(role.Perms, ","))) |
|
|
|
if len(userRole.Limits) > 0 { |
|
|
|
rcds := strings.Split(userRole.Limits, ",") |
|
|
|
ses.And(builder.NotIn("uuid", rcds)) |
|
|
|