29 lines
797 B
Go
29 lines
797 B
Go
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()
|
|
}
|
|
}
|