feat(admin): 拆分经营站点与历史分销后台
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"hfb_sys/backend/internal/sitecode"
|
||||
"hfb_sys/backend/internal/tenancy"
|
||||
"hfb_sys/backend/pkg/response"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// BlockTenantLegacyDistributionAdmin 阻止经营租户后台调用历史分销管理接口。
|
||||
// 独立分销后台使用 /api/distribution/*,不经过该守卫。
|
||||
func BlockTenantLegacyDistributionAdmin() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
tenantScoped := sitecode.HasTenantScope(c.Request.Context())
|
||||
if _, ok := tenancy.FromContext(c.Request.Context()); ok {
|
||||
tenantScoped = true
|
||||
}
|
||||
if tenantScoped && strings.HasPrefix(c.Request.URL.Path, "/api/admin/distribution/") {
|
||||
response.Forbidden(c, "经营站点后台不能管理历史分销渠道")
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user