优化企业网站功能
This commit is contained in:
@@ -34,6 +34,12 @@ func (c *BackendMenuFrontController) checkAuth() (uint64, bool) {
|
||||
_ = c.ServeJSON()
|
||||
return 0, false
|
||||
}
|
||||
// tenant_id=0 为全局默认菜单保留值,不允许任何接口以租户身份操作
|
||||
if claims.TenantId <= 0 {
|
||||
c.Data["json"] = map[string]interface{}{"code": 401, "msg": "租户ID缺失"}
|
||||
_ = c.ServeJSON()
|
||||
return 0, false
|
||||
}
|
||||
return uint64(claims.TenantId), true
|
||||
}
|
||||
|
||||
@@ -43,11 +49,15 @@ func (c *BackendMenuFrontController) List() {
|
||||
return
|
||||
}
|
||||
|
||||
// 保证全局默认导航(tenant_id=0)齐全,缺失自动补齐
|
||||
models.EnsureGlobalDefaultFrontMenus()
|
||||
|
||||
// 全局默认菜单(tenant_id=0,不可删改)+ 租户自定义菜单
|
||||
var menus []models.BackendMenuFront
|
||||
_, err := models.Orm.QueryTable("yz_backend_menu_front").
|
||||
Filter("tenant_id", tid).
|
||||
Filter("tenant_id__in", []uint64{0, tid}).
|
||||
Filter("delete_time__isnull", true).
|
||||
OrderBy("sort").
|
||||
OrderBy("sort", "id").
|
||||
All(&menus)
|
||||
|
||||
if err != nil {
|
||||
@@ -151,4 +161,4 @@ func (c *BackendMenuFrontController) Delete() {
|
||||
c.Data["json"] = map[string]interface{}{"code": 200, "msg": "删除成功"}
|
||||
}
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user