From 33e4f023b5842ed636f82db3478e5baf0b9b0d95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AC=E6=98=8E?= <83812544+Ed1s0nZ@users.noreply.github.com> Date: Sun, 14 Jun 2026 19:48:07 +0800 Subject: [PATCH] Add files via upload --- internal/handler/project.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/handler/project.go b/internal/handler/project.go index eeeb82e8..b585c57e 100644 --- a/internal/handler/project.go +++ b/internal/handler/project.go @@ -12,6 +12,16 @@ import ( "go.uber.org/zap" ) +const maxProjectDescriptionRunes = 4000 + +func clampProjectDescription(s string) string { + r := []rune(s) + if len(r) <= maxProjectDescriptionRunes { + return s + } + return string(r[:maxProjectDescriptionRunes]) +} + // ProjectHandler 项目管理处理器。 type ProjectHandler struct { db *database.DB @@ -48,7 +58,7 @@ func (h *ProjectHandler) CreateProject(c *gin.Context) { } p := &database.Project{ Name: strings.TrimSpace(req.Name), - Description: req.Description, + Description: clampProjectDescription(req.Description), ScopeJSON: req.ScopeJSON, Status: strings.TrimSpace(req.Status), } @@ -184,7 +194,7 @@ func (h *ProjectHandler) UpdateProject(c *gin.Context) { } } if req.Description != nil { - p.Description = *req.Description + p.Description = clampProjectDescription(*req.Description) } if req.ScopeJSON != nil { p.ScopeJSON = *req.ScopeJSON