From c96758c784a502f7e10675857d51bca5493013ce Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Fri, 15 Sep 2023 11:18:21 +0800 Subject: [PATCH] update --- app/admin/hdl/hdl_role.go | 6 +++--- app/db/db_admin_role.go | 8 ++++++++ app/router/admin_router.go | 6 ++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/admin/hdl/hdl_role.go b/app/admin/hdl/hdl_role.go index 14d9c93..908d5c5 100644 --- a/app/admin/hdl/hdl_role.go +++ b/app/admin/hdl/hdl_role.go @@ -105,12 +105,12 @@ func RoleList(c *gin.Context) { for _, v := range *roleList { var temp md.RoleListResp temp.Data = v - adminRole, err1 := adminRoleDb.GetAdminRoleByRole(v.Id) + adminRoles, err1 := adminRoleDb.FindAdminRoleByRoleId(v.Id) if err1 != nil { e.OutErr(c, e.ERR_DB_ORM, err1.Error()) return } - if adminRole != nil { + for _, adminRole := range *adminRoles { admin, err2 := adminDb.GetAdmin(adminRole.AdmId) if err2 != nil { e.OutErr(c, e.ERR_DB_ORM, err2.Error()) @@ -121,8 +121,8 @@ func RoleList(c *gin.Context) { }{ Name: admin.Username, }) + result = append(result, &temp) } - result = append(result, &temp) } e.OutSuc(c, map[string]interface{}{ "list": result, diff --git a/app/db/db_admin_role.go b/app/db/db_admin_role.go index fab6bf7..c2458a8 100644 --- a/app/db/db_admin_role.go +++ b/app/db/db_admin_role.go @@ -23,6 +23,14 @@ func (adminRoleDb *AdminRoleDb) FindAdminRole(id int) (*[]model.AdminRole, error 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) { if reflect.TypeOf(admId).Kind() == reflect.Slice { return session.In("adm_id", admId).Delete(model.AdminRole{}) diff --git a/app/router/admin_router.go b/app/router/admin_router.go index 72276d1..90cc0c7 100644 --- a/app/router/admin_router.go +++ b/app/router/admin_router.go @@ -266,10 +266,12 @@ func AdminRoute(r *gin.RouterGroup) { r.Use(mw.Auth) //检测登录状态 r.GET("/userInfo", hdl2.UserInfo) //用户信息 r.GET("/sysCfg", hdl2.GetSysCfg) //基础配置-获取 - - r.Use(mw.CheckPermission) //检测权限 + rOss(r.Group("/oss")) rComm(r.Group("/comm")) + + r.Use(mw.CheckPermission) //检测权限 + rHomePage(r.Group("/homePage")) //首页 rCompany(r.Group("/company")) //公司管理 rNotice(r.Group("/notice")) //公告管理