From f5e9638b6ba37c4753e927ffbdec616a073d1670 Mon Sep 17 00:00:00 2001 From: DavidYe68 <30755977@qq.com> Date: Sat, 1 Aug 2026 20:31:32 +0800 Subject: [PATCH] feat: remove tag count limit on hole modification Tag modification via ModifyHole is admin-only (enforced in CheckPermission), so the max=10 validation inherited from TagCreateModelSlice only blocked admins from appending management tags to holes that already have 10 tags. Give ModifyModel its own Tags field without the count cap; hole creation keeps max=10. Closes #230 Co-Authored-By: Claude Fable 5 --- apis/hole/schemas.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/apis/hole/schemas.go b/apis/hole/schemas.go index eb4f4c58..c24371d6 100644 --- a/apis/hole/schemas.go +++ b/apis/hole/schemas.go @@ -94,12 +94,20 @@ type CreateOldResponse struct { } type ModifyModel struct { - TagCreateModelSlice - DivisionID *int `json:"division_id" validate:"omitempty,min=1"` // Admin and owner only - Hidden *bool `json:"hidden"` // Admin only - Unhidden *bool `json:"unhidden"` // admin only - Lock *bool `json:"lock"` // admin only - Frozen *bool `json:"frozen"` // admin only + Tags []tag.CreateModel `json:"tags" validate:"omitempty,min=1,dive"` // Admin only, no count limit + DivisionID *int `json:"division_id" validate:"omitempty,min=1"` // Admin and owner only + Hidden *bool `json:"hidden"` // Admin only + Unhidden *bool `json:"unhidden"` // admin only + Lock *bool `json:"lock"` // admin only + Frozen *bool `json:"frozen"` // admin only +} + +func (body ModifyModel) ToName() []string { + tags := make([]string, 0, len(body.Tags)) + for _, tagCreateModel := range body.Tags { + tags = append(tags, tagCreateModel.Name) + } + return tags } func (body ModifyModel) CheckPermission(user *models.User, hole *models.Hole) error {