add unloading all requests

This commit is contained in:
DeniskaRediska committed 2019-11-19 19:02:17 +03:00
1 parent 8af97e56d7
commit 37c08f4500
13 files changed
+191 -6

No files matched your search

+1
View File
@@ -16,4 +16,5 @@ var (
}))
SnapshotRep SnapshotRepository = snapshotRepository{rxClient: DbClient}
UnloadRep UnloadRepository = unloadRepository{rxClient: DbClient}
)
+30
View File
@@ -0,0 +1,30 @@
package model
import (
"github.com/go-pg/pg/orm"
"github.com/integration-system/isp-lib/database"
"isp-gate-service/entity"
)
type (
UnloadRepository interface {
Insert([]entity.Unload) error
}
unloadRepository struct {
DB orm.DB
rxClient *database.RxDbClient
}
)
func (r unloadRepository) Insert(model []entity.Unload) error {
_, err := r.getDb().Model(&model).Insert()
return err
}
func (r unloadRepository) getDb() orm.DB {
if r.DB != nil {
return r.DB
}
return r.rxClient.Unsafe()
}