feat: 迁移 Admin Repository 到 MySQL 8 (#79)
This commit is contained in:
+15
-15
@@ -24,11 +24,11 @@ func UpsertShopeeProduct(q Execer, goodsID, title, shopeeStatus, mainSKUCode str
|
||||
_, err := q.Exec(`
|
||||
INSERT INTO shopee_products (goods_id, title, shopee_status, main_sku_code, created_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT(goods_id) DO UPDATE SET
|
||||
title = excluded.title,
|
||||
shopee_status = excluded.shopee_status,
|
||||
main_sku_code = excluded.main_sku_code,
|
||||
updated_at = excluded.updated_at`,
|
||||
ON DUPLICATE KEY UPDATE
|
||||
title = VALUES(title),
|
||||
shopee_status = VALUES(shopee_status),
|
||||
main_sku_code = VALUES(main_sku_code),
|
||||
updated_at = VALUES(updated_at)`,
|
||||
// 注意:pdd_goods_url / pdd_goods_id 两列不在 INSERT 的列清单里,
|
||||
// 也不在 DO UPDATE SET 里——新建时它们是 NULL(未填链接),
|
||||
// 已存在时它们完全不受这条语句影响。
|
||||
@@ -61,15 +61,15 @@ func UpsertShopeeSKU(q Execer, skuID, goodsID, specRaw, color, size, advice stri
|
||||
(sku_id, goods_id, spec_raw, color, size, advice, parse_ok, sku_code,
|
||||
is_manual, created_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?)
|
||||
ON CONFLICT(sku_id) DO UPDATE SET
|
||||
goods_id = excluded.goods_id,
|
||||
spec_raw = excluded.spec_raw,
|
||||
color = excluded.color,
|
||||
size = excluded.size,
|
||||
advice = excluded.advice,
|
||||
parse_ok = excluded.parse_ok,
|
||||
sku_code = excluded.sku_code,
|
||||
updated_at = excluded.updated_at`,
|
||||
ON DUPLICATE KEY UPDATE
|
||||
goods_id = VALUES(goods_id),
|
||||
spec_raw = VALUES(spec_raw),
|
||||
color = VALUES(color),
|
||||
size = VALUES(size),
|
||||
advice = VALUES(advice),
|
||||
parse_ok = VALUES(parse_ok),
|
||||
sku_code = VALUES(sku_code),
|
||||
updated_at = VALUES(updated_at)`,
|
||||
// is_manual 不在上面的 SET 列表里,SQLite 对没提到的列保持原值不变。
|
||||
skuID, goodsID, specRaw, color, size, advice, parseOKInt, skuCode, now, now)
|
||||
if err != nil {
|
||||
@@ -132,7 +132,7 @@ func shopeeFilterClause(filter ShopeeFilter) (string, []any) {
|
||||
|
||||
if kw := strings.TrimSpace(filter.Keyword); kw != "" {
|
||||
like := "%" + escapeLike(kw) + "%"
|
||||
clauses = append(clauses, `(sp.goods_id LIKE ? ESCAPE '\' OR sp.title LIKE ? ESCAPE '\')`)
|
||||
clauses = append(clauses, `(sp.goods_id LIKE ? ESCAPE '!' OR sp.title LIKE ? ESCAPE '!')`)
|
||||
args = append(args, like, like)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user