add unloading all requests
This commit is contained in:
1 parent
8af97e56d7
commit
37c08f4500
13 files changed
+191
-6
No files matched your search
@@ -16,4 +16,5 @@ var (
|
||||
}))
|
||||
|
||||
SnapshotRep SnapshotRepository = snapshotRepository{rxClient: DbClient}
|
||||
UnloadRep UnloadRepository = unloadRepository{rxClient: DbClient}
|
||||
)
|
||||
@@ -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()
|
||||
}
|
||||
Reference in new issue
Block a user