Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into feat/BE/sso-adjustment

This commit is contained in:
ragilap
2026-01-27 10:46:49 +07:00
30 changed files with 1027 additions and 1134 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
}