优化企业网站功能

This commit is contained in:
2026-08-20 16:21:07 +08:00
parent 112d60b993
commit 3f0fcb88e7
45 changed files with 8758 additions and 5058 deletions
+13 -3
View File
@@ -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()
}
}