Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -38,6 +38,32 @@ func tokenizeImageFileName(fileName string) []string {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isAllDigits(s string) bool {
|
||||||
|
if s == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, r := range s {
|
||||||
|
if r < '0' || r > '9' {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func imageFileHasDim3Pattern(fileName string) bool {
|
||||||
|
tokens := tokenizeImageFileName(fileName)
|
||||||
|
for _, t := range tokens {
|
||||||
|
parts := strings.SplitN(t, "_", 2)
|
||||||
|
if len(parts) != 2 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if len(parts[0]) == 3 && isAllDigits(parts[0]) && isAllDigits(parts[1]) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func imageFileMatches(fileName, dim1, dim3 string) bool {
|
func imageFileMatches(fileName, dim1, dim3 string) bool {
|
||||||
dim1 = strings.ToUpper(strings.TrimSpace(dim1))
|
dim1 = strings.ToUpper(strings.TrimSpace(dim1))
|
||||||
dim3 = strings.ToUpper(strings.TrimSpace(dim3))
|
dim3 = strings.ToUpper(strings.TrimSpace(dim3))
|
||||||
@@ -122,9 +148,11 @@ JOIN mmitem i
|
|||||||
WHERE b.typ = 'img'
|
WHERE b.typ = 'img'
|
||||||
AND b.src_table = 'mmitem'
|
AND b.src_table = 'mmitem'
|
||||||
AND (
|
AND (
|
||||||
UPPER(i.code) = UPPER($1)
|
-- exact code match (spaces ignored)
|
||||||
OR UPPER(i.code) = UPPER('S001-' || $1)
|
UPPER(REPLACE(COALESCE(i.code,''), ' ', '')) = UPPER(REPLACE(COALESCE($1,''), ' ', ''))
|
||||||
OR UPPER(i.code) LIKE '%-' || UPPER($1)
|
-- or exact core-code match after last '-' (e.g. S901-DMY18252 -> DMY18252)
|
||||||
|
OR UPPER(REPLACE(REGEXP_REPLACE(COALESCE(i.code,''), '^.*-', ''), ' ', '')) =
|
||||||
|
UPPER(REPLACE(REGEXP_REPLACE(COALESCE($1,''), '^.*-', ''), ' ', ''))
|
||||||
)
|
)
|
||||||
ORDER BY
|
ORDER BY
|
||||||
COALESCE(b.sort_order,999999),
|
COALESCE(b.sort_order,999999),
|
||||||
@@ -204,6 +232,21 @@ ORDER BY
|
|||||||
} else if dim3 == "" && len(matchedByNameDim1Only) > 0 {
|
} else if dim3 == "" && len(matchedByNameDim1Only) > 0 {
|
||||||
// Sadece 1. renk filtreleniyorsa dim1-only fallback kabul.
|
// Sadece 1. renk filtreleniyorsa dim1-only fallback kabul.
|
||||||
items = matchedByNameDim1Only
|
items = matchedByNameDim1Only
|
||||||
|
} else if dim3 != "" && len(matchedByNameDim1Only) > 0 {
|
||||||
|
// dim3 verilmis ama kayitlar eski tek-renk adlandirma kullaniyor olabilir.
|
||||||
|
// Eger dosya adlarinda "001_1" gibi ikinci renk pattern'i yoksa dim1-only fallback kabul.
|
||||||
|
hasDim3Pattern := false
|
||||||
|
for _, it := range matchedByNameDim1Only {
|
||||||
|
if imageFileHasDim3Pattern(it.FileName) {
|
||||||
|
hasDim3Pattern = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !hasDim3Pattern {
|
||||||
|
items = matchedByNameDim1Only
|
||||||
|
} else {
|
||||||
|
items = []ProductImageItem{}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// dim3 (2. renk) verildiyse yanlis varyanta dusmemek icin bos don.
|
// dim3 (2. renk) verildiyse yanlis varyanta dusmemek icin bos don.
|
||||||
items = []ProductImageItem{}
|
items = []ProductImageItem{}
|
||||||
|
|||||||
Reference in New Issue
Block a user