feat(migrations): Harden task audit tracking and optimize article templates

- Added migration to harden task audit tracking by modifying audit_logs and related tables.
- Introduced operator_id to several tables for better tracking of actions.
- Updated article_templates with new prompt templates for various article types, enhancing content generation.
- Created prompt_rules and schedule_tasks tables to manage content generation rules and scheduling.
- Added foreign key constraints to articles for better data integrity.
This commit is contained in:
2026-04-02 00:31:28 +08:00
parent de30497f59
commit b31d8d0096
101 changed files with 16671 additions and 721 deletions
@@ -1,6 +1,8 @@
package middleware
import (
"context"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
)
@@ -8,6 +10,8 @@ import (
const RequestIDHeader = "X-Request-ID"
const requestIDKey = "request_id"
type requestIDContextKey struct{}
func RequestID() gin.HandlerFunc {
return func(c *gin.Context) {
rid := c.GetHeader(RequestIDHeader)
@@ -15,6 +19,7 @@ func RequestID() gin.HandlerFunc {
rid = uuid.New().String()
}
c.Set(requestIDKey, rid)
c.Request = c.Request.WithContext(context.WithValue(c.Request.Context(), requestIDContextKey{}, rid))
c.Header(RequestIDHeader, rid)
c.Next()
}
@@ -26,3 +31,10 @@ func RequestIDFromGin(c *gin.Context) string {
}
return ""
}
func RequestIDFromContext(ctx context.Context) string {
if rid, ok := ctx.Value(requestIDContextKey{}).(string); ok {
return rid
}
return ""
}