org 模块: - tenants 表 (UUID PK, name, slug, status, settings) - 完整 CRUD API: /api/v1/org/tenants - 多租户隔离 audit 模块: - audit_logs 表 (actor, action, resource, IP, 时间) - 查询 API: /api/v1/audit/logs (支持分页+筛选) - 按 tenant_id/user_id/action/resource 过滤
34 lines
738 B
Go
34 lines
738 B
Go
package interfaces
|
|
|
|
import (
|
|
"mengstack/internal/app/middleware"
|
|
"mengstack/internal/modules/audit/application"
|
|
auditinfra "mengstack/internal/modules/audit/infrastructure"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"go.uber.org/fx"
|
|
"go.uber.org/zap"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
func SetupRoutes(r *gin.Engine, h *Handler, authMW gin.HandlerFunc) {
|
|
audit := r.Group("/api/v1/audit")
|
|
audit.Use(authMW, middleware.MultiTenant())
|
|
{
|
|
audit.GET("/logs", h.ListLogs)
|
|
}
|
|
}
|
|
|
|
var Module = fx.Module("audit",
|
|
fx.Provide(
|
|
auditinfra.NewAuditRepository,
|
|
application.NewService,
|
|
NewHandler,
|
|
),
|
|
fx.Invoke(func(db *gorm.DB, log *zap.Logger) {
|
|
if err := auditinfra.Migrate(db); err != nil {
|
|
log.Fatal("audit migration failed", zap.Error(err))
|
|
}
|
|
}),
|
|
)
|