mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-06-21 21:39:58 +02:00
Add files via upload
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user