fix: issues

This commit is contained in:
Rogee
2024-12-06 16:13:28 +08:00
parent 233847f233
commit 7d9ec4ef81
5 changed files with 54 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"path/filepath"
"time"
"backend/common/media_store"
"backend/database/models/qvyun/public/table"
@@ -182,14 +183,15 @@ func (svc *Service) Upsert(ctx context.Context, tenantId int64, item media_store
tbl := table.Medias
stmt := tbl.
INSERT(tbl.TenantID, tbl.Hash, tbl.Title, tbl.Price, tbl.Resources, tbl.Publish).
VALUES(Int(tenantId), String(item.Hash), String(item.Name), Int(item.Price()), Json(resources), Bool(true)).
VALUES(Int(tenantId), String(item.Hash), String(item.Name), Int(item.Price()), Json(resources.MustValue()), Bool(true)).
ON_CONFLICT(tbl.Hash).
DO_UPDATE(
SET(
tbl.Title.SET(String(item.Name)),
tbl.Price.SET(Int(item.Price())),
tbl.Resources.SET(Json(resources)),
tbl.Resources.SET(Json(resources.MustValue())),
tbl.Publish.SET(Bool(true)),
tbl.UpdatedAt.SET(TimestampT(time.Now())),
),
)
log.Debug(stmt.DebugSql())