@@ -105,12 +105,12 @@ func RoleList(c *gin.Context) { | |||||
for _, v := range *roleList { | for _, v := range *roleList { | ||||
var temp md.RoleListResp | var temp md.RoleListResp | ||||
temp.Data = v | temp.Data = v | ||||
adminRole, err1 := adminRoleDb.GetAdminRoleByRole(v.Id) | |||||
adminRoles, err1 := adminRoleDb.FindAdminRoleByRoleId(v.Id) | |||||
if err1 != nil { | if err1 != nil { | ||||
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | ||||
return | return | ||||
} | } | ||||
if adminRole != nil { | |||||
for _, adminRole := range *adminRoles { | |||||
admin, err2 := adminDb.GetAdmin(adminRole.AdmId) | admin, err2 := adminDb.GetAdmin(adminRole.AdmId) | ||||
if err2 != nil { | if err2 != nil { | ||||
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | ||||
@@ -121,8 +121,8 @@ func RoleList(c *gin.Context) { | |||||
}{ | }{ | ||||
Name: admin.Username, | Name: admin.Username, | ||||
}) | }) | ||||
result = append(result, &temp) | |||||
} | } | ||||
result = append(result, &temp) | |||||
} | } | ||||
e.OutSuc(c, map[string]interface{}{ | e.OutSuc(c, map[string]interface{}{ | ||||
"list": result, | "list": result, | ||||
@@ -23,6 +23,14 @@ func (adminRoleDb *AdminRoleDb) FindAdminRole(id int) (*[]model.AdminRole, error | |||||
return &m, nil | return &m, nil | ||||
} | } | ||||
func (adminRoleDb *AdminRoleDb) FindAdminRoleByRoleId(id int) (*[]model.AdminRole, error) { | |||||
var m []model.AdminRole | |||||
if err := adminRoleDb.Db.Where("role_id =?", id).Find(&m); err != nil { | |||||
return nil, logx.Error(err) | |||||
} | |||||
return &m, nil | |||||
} | |||||
func (adminRoleDb *AdminRoleDb) AdminDeleteBySessionForAdmId(session *xorm.Session, admId interface{}) (int64, error) { | func (adminRoleDb *AdminRoleDb) AdminDeleteBySessionForAdmId(session *xorm.Session, admId interface{}) (int64, error) { | ||||
if reflect.TypeOf(admId).Kind() == reflect.Slice { | if reflect.TypeOf(admId).Kind() == reflect.Slice { | ||||
return session.In("adm_id", admId).Delete(model.AdminRole{}) | return session.In("adm_id", admId).Delete(model.AdminRole{}) | ||||
@@ -266,10 +266,12 @@ func AdminRoute(r *gin.RouterGroup) { | |||||
r.Use(mw.Auth) //检测登录状态 | r.Use(mw.Auth) //检测登录状态 | ||||
r.GET("/userInfo", hdl2.UserInfo) //用户信息 | r.GET("/userInfo", hdl2.UserInfo) //用户信息 | ||||
r.GET("/sysCfg", hdl2.GetSysCfg) //基础配置-获取 | r.GET("/sysCfg", hdl2.GetSysCfg) //基础配置-获取 | ||||
r.Use(mw.CheckPermission) //检测权限 | |||||
rOss(r.Group("/oss")) | rOss(r.Group("/oss")) | ||||
rComm(r.Group("/comm")) | rComm(r.Group("/comm")) | ||||
r.Use(mw.CheckPermission) //检测权限 | |||||
rHomePage(r.Group("/homePage")) //首页 | rHomePage(r.Group("/homePage")) //首页 | ||||
rCompany(r.Group("/company")) //公司管理 | rCompany(r.Group("/company")) //公司管理 | ||||
rNotice(r.Group("/notice")) //公告管理 | rNotice(r.Group("/notice")) //公告管理 | ||||