Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-03-10 17:51:31 +03:00
parent d590732f38
commit aba71341b9
24 changed files with 299 additions and 160 deletions

View File

@@ -4,7 +4,6 @@ import (
"bssapp-backend/auth"
"context"
"fmt"
"strings"
)
func BuildMSSQLPiyasaFilter(
@@ -27,37 +26,5 @@ func BuildMSSQLPiyasaFilter(
func BuildMSSQLPiyasaFilterWithCodes(column string, codes []string) string {
normalizedCol := fmt.Sprintf("UPPER(LTRIM(RTRIM(%s)))", column)
exact := BuildINClause(normalizedCol, codes)
prefixCodes := first3Codes(codes)
if len(prefixCodes) == 0 {
return exact
}
prefix := BuildINClause(
fmt.Sprintf("LEFT(%s, 3)", normalizedCol),
prefixCodes,
)
return fmt.Sprintf("(%s OR %s)", exact, prefix)
}
func first3Codes(codes []string) []string {
seen := make(map[string]struct{}, len(codes))
out := make([]string, 0, len(codes))
for _, c := range codes {
n := strings.ToUpper(strings.TrimSpace(c))
if len(n) < 3 {
continue
}
n = n[:3]
if _, ok := seen[n]; ok {
continue
}
seen[n] = struct{}{}
out = append(out, n)
}
return out
return BuildINClause(normalizedCol, codes)
}