feat: add knowledge management functionality with CRUD operations and database schema

- Implemented KnowledgeHandler for managing knowledge groups and items, including listing, creating, updating, and deleting operations.
- Added database migration scripts to create necessary tables for knowledge management, including knowledge_groups, knowledge_items, knowledge_parse_tasks, and knowledge_chunks_meta.
- Introduced prompt_rule_knowledge_groups table to associate prompt rules with knowledge groups.
This commit is contained in:
2026-04-05 17:14:13 +08:00
parent 134dd063c3
commit 446f865cdf
62 changed files with 9503 additions and 2664 deletions
+26 -2
View File
@@ -5,19 +5,43 @@ import (
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"github.com/geo-platform/tenant-api/internal/shared/response"
)
func Logger(logger *zap.Logger) gin.HandlerFunc {
return func(c *gin.Context) {
start := time.Now()
c.Next()
logger.Info("request",
fields := []zap.Field{
zap.String("method", c.Request.Method),
zap.String("path", c.Request.URL.Path),
zap.Int("status", c.Writer.Status()),
zap.Duration("latency", time.Since(start)),
zap.String("request_id", RequestIDFromGin(c)),
zap.String("client_ip", c.ClientIP()),
)
}
if appErr, ok := response.AppErrorFromGin(c); ok {
fields = append(fields,
zap.Int("app_code", appErr.Code),
zap.String("app_message", appErr.Message),
)
if appErr.Detail != "" {
fields = append(fields, zap.String("app_detail", appErr.Detail))
}
} else if len(c.Errors) > 0 {
fields = append(fields, zap.String("error", c.Errors.String()))
}
switch status := c.Writer.Status(); {
case status >= 500:
logger.Error("request", fields...)
case status >= 400:
logger.Warn("request", fields...)
default:
logger.Info("request", fields...)
}
}
}