Feat[BE]: enhance transfer laying functionality with comprehensive filtering options and improved DTO structures

This commit is contained in:
aguhh18
2026-01-26 23:50:04 +07:00
parent 7a704c4ec4
commit 3e0291c2ba
6 changed files with 286 additions and 171 deletions
+52
View File
@@ -2,6 +2,7 @@ package utils
import (
"sort"
"strconv"
"strings"
)
@@ -47,3 +48,54 @@ func ParseFlags(raw string) []string {
sort.Strings(res)
return res
}
// ParseQueryArray parses comma-separated string values and returns a slice of trimmed strings
// Example: "a, b, c" → ["a", "b", "c"]
func ParseQueryArray(raw string) []string {
if raw == "" {
return nil
}
parts := strings.Split(raw, ",")
result := make([]string, 0, len(parts))
for _, p := range parts {
trimmed := strings.TrimSpace(p)
if trimmed != "" {
result = append(result, trimmed)
}
}
if len(result) == 0 {
return nil
}
return result
}
// ParseQueryUintArray parses comma-separated string values and returns a slice of uint
// Invalid values are skipped
// Example: "1, 2, 3" → [1, 2, 3]
func ParseQueryUintArray(raw string) []uint {
if raw == "" {
return nil
}
parts := strings.Split(raw, ",")
result := make([]uint, 0, len(parts))
for _, p := range parts {
trimmed := strings.TrimSpace(p)
if trimmed == "" {
continue
}
if num, err := strconv.ParseUint(trimmed, 10, 32); err == nil {
result = append(result, uint(num))
}
}
if len(result) == 0 {
return nil
}
return result
}