mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
Feat[BE]: enhance transfer laying functionality with comprehensive filtering options and improved DTO structures
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user