fix: issues
This commit is contained in:
@@ -2,6 +2,7 @@ package medias
|
||||
|
||||
import (
|
||||
"backend/providers/http"
|
||||
"backend/providers/storage"
|
||||
"database/sql"
|
||||
|
||||
"git.ipao.vip/rogeecn/atom"
|
||||
@@ -37,9 +38,11 @@ func Provide(opts ...opt.Option) error {
|
||||
|
||||
if err := container.Container.Provide(func(
|
||||
db *sql.DB,
|
||||
storageConfig *storage.Config,
|
||||
) (*Service, error) {
|
||||
obj := &Service{
|
||||
db: db,
|
||||
db: db,
|
||||
storageConfig: storageConfig,
|
||||
}
|
||||
if err := obj.Prepare(); err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -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())
|
||||
|
||||
26
backend/modules/tasks/store/provider.gen.go
Executable file
26
backend/modules/tasks/store/provider.gen.go
Executable file
@@ -0,0 +1,26 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"backend/modules/medias"
|
||||
|
||||
"git.ipao.vip/rogeecn/atom/container"
|
||||
"git.ipao.vip/rogeecn/atom/utils/opt"
|
||||
)
|
||||
|
||||
func Provide(opts ...opt.Option) error {
|
||||
if err := container.Container.Provide(func(
|
||||
mediasSvc *medias.Service,
|
||||
) (*StoreMedias, error) {
|
||||
obj := &StoreMedias{
|
||||
mediasSvc: mediasSvc,
|
||||
}
|
||||
if err := obj.Prepare(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user