Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -186,9 +186,12 @@ ORDER BY
|
|||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
|
||||||
items := make([]ProductImageItem, 0, 16)
|
items := make([]ProductImageItem, 0, 16)
|
||||||
|
rowDim1ByID := make(map[int64]string, 16)
|
||||||
matchedByDim := make([]ProductImageItem, 0, 16)
|
matchedByDim := make([]ProductImageItem, 0, 16)
|
||||||
matchedByName := make([]ProductImageItem, 0, 16)
|
matchedByName := make([]ProductImageItem, 0, 16)
|
||||||
matchedByNameDim1Only := make([]ProductImageItem, 0, 16)
|
matchedByNameDim1Only := make([]ProductImageItem, 0, 16)
|
||||||
|
dim1Upper := strings.ToUpper(strings.TrimSpace(dim1))
|
||||||
|
dim3Upper := strings.ToUpper(strings.TrimSpace(dim3))
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
|
|
||||||
@@ -209,39 +212,44 @@ ORDER BY
|
|||||||
|
|
||||||
it.ContentURL = fmt.Sprintf("/api/product-images/%d/content", it.ID)
|
it.ContentURL = fmt.Sprintf("/api/product-images/%d/content", it.ID)
|
||||||
items = append(items, it)
|
items = append(items, it)
|
||||||
|
rowDim1ByID[it.ID] = strings.TrimSpace(rowDim1)
|
||||||
|
|
||||||
dimMatched := true
|
dimMatched := true
|
||||||
if dim1 != "" {
|
if dim1Upper != "" {
|
||||||
// Bazı eski kayıtlarda dimval1 gerçek renk kodu yerine numeric id tutulmuş olabilir.
|
// Bazı eski kayıtlarda dimval1 gerçek renk kodu yerine numeric id tutulmuş olabilir.
|
||||||
// Bu yüzden dimval karşılaştırması yardımcı; asıl fallback file_name token eşleşmesidir.
|
// Bu yüzden dimval karşılaştırması yardımcı; asıl fallback file_name token eşleşmesidir.
|
||||||
dimMatched = dimMatched && (rowDim1 == strings.ToUpper(dim1))
|
dimMatched = dimMatched && (rowDim1 == dim1Upper)
|
||||||
}
|
}
|
||||||
if dim3 != "" {
|
if dim3Upper != "" {
|
||||||
dimMatched = dimMatched && (rowDim3 == strings.ToUpper(dim3) || rowDim2 == strings.ToUpper(dim3))
|
dimMatched = dimMatched && (rowDim3 == dim3Upper || rowDim2 == dim3Upper)
|
||||||
}
|
}
|
||||||
if dimMatched {
|
if dimMatched {
|
||||||
matchedByDim = append(matchedByDim, it)
|
matchedByDim = append(matchedByDim, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
if imageFileMatches(it.FileName, dim1, dim3) {
|
if imageFileMatches(it.FileName, dim1Upper, dim3Upper) {
|
||||||
matchedByName = append(matchedByName, it)
|
matchedByName = append(matchedByName, it)
|
||||||
}
|
}
|
||||||
if dim1 != "" && imageFileMatches(it.FileName, dim1, "") {
|
if dim1Upper != "" && imageFileMatches(it.FileName, dim1Upper, "") {
|
||||||
matchedByNameDim1Only = append(matchedByNameDim1Only, it)
|
matchedByNameDim1Only = append(matchedByNameDim1Only, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if dim1 != "" || dim3 != "" {
|
if dim1Upper != "" || dim3Upper != "" {
|
||||||
if len(matchedByDim) > 0 {
|
targetDimval1 := make(map[string]struct{}, 4)
|
||||||
items = matchedByDim
|
for _, it := range matchedByName {
|
||||||
} else if len(matchedByName) > 0 {
|
if dv := rowDim1ByID[it.ID]; dv != "" {
|
||||||
items = matchedByName
|
targetDimval1[dv] = struct{}{}
|
||||||
} else if dim3 == "" && len(matchedByNameDim1Only) > 0 {
|
}
|
||||||
// Sadece 1. renk filtreleniyorsa dim1-only fallback kabul.
|
}
|
||||||
items = matchedByNameDim1Only
|
if len(targetDimval1) == 0 && dim3Upper == "" {
|
||||||
} else if dim3 != "" && len(matchedByNameDim1Only) > 0 {
|
for _, it := range matchedByNameDim1Only {
|
||||||
// dim3 verilmis ama kayitlar eski tek-renk adlandirma kullaniyor olabilir.
|
if dv := rowDim1ByID[it.ID]; dv != "" {
|
||||||
// Eger dosya adlarinda "001_1" gibi ikinci renk pattern'i yoksa dim1-only fallback kabul.
|
targetDimval1[dv] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(targetDimval1) == 0 && dim3Upper != "" && len(matchedByNameDim1Only) > 0 {
|
||||||
hasDim3Pattern := false
|
hasDim3Pattern := false
|
||||||
for _, it := range matchedByNameDim1Only {
|
for _, it := range matchedByNameDim1Only {
|
||||||
if imageFileHasDim3Pattern(it.FileName) {
|
if imageFileHasDim3Pattern(it.FileName) {
|
||||||
@@ -250,14 +258,31 @@ ORDER BY
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !hasDim3Pattern {
|
if !hasDim3Pattern {
|
||||||
|
for _, it := range matchedByNameDim1Only {
|
||||||
|
if dv := rowDim1ByID[it.ID]; dv != "" {
|
||||||
|
targetDimval1[dv] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(targetDimval1) > 0 {
|
||||||
|
clustered := make([]ProductImageItem, 0, len(items))
|
||||||
|
for _, it := range items {
|
||||||
|
if _, ok := targetDimval1[rowDim1ByID[it.ID]]; ok {
|
||||||
|
clustered = append(clustered, it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
items = clustered
|
||||||
|
} else if len(matchedByDim) > 0 {
|
||||||
|
items = matchedByDim
|
||||||
|
} else if len(matchedByName) > 0 {
|
||||||
|
items = matchedByName
|
||||||
|
} else if dim3Upper == "" && len(matchedByNameDim1Only) > 0 {
|
||||||
items = matchedByNameDim1Only
|
items = matchedByNameDim1Only
|
||||||
} else {
|
} else {
|
||||||
items = []ProductImageItem{}
|
items = []ProductImageItem{}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// dim3 (2. renk) verildiyse yanlis varyanta dusmemek icin bos don.
|
|
||||||
items = []ProductImageItem{}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
slog.Info("product_images.list.ok",
|
slog.Info("product_images.list.ok",
|
||||||
|
|||||||
Reference in New Issue
Block a user