This commit is contained in:
aespin 2024-10-02 13:35:38 +02:00
parent cc3cd8cad0
commit 1cb83dbde6
2 changed files with 7 additions and 1 deletions

View File

@ -0,0 +1 @@
# FALCON SYSTEM

View File

@ -11,6 +11,7 @@ import (
type Storager interface { type Storager interface {
StoreBarcode(ctx context.Context, in *types.Barcode) error StoreBarcode(ctx context.Context, in *types.Barcode) error
ConfirmBundle(ctx context.Context, barcode string) error
} }
type storage struct { type storage struct {
@ -25,6 +26,11 @@ type DBConfig struct {
Name string Name string
} }
// ConfirmBundle implements Storager.
func (s *storage) ConfirmBundle(ctx context.Context, barcode string) error {
return s.db.Model(&types.BundleData{}).Where("nromatricula = ?", barcode).Update("confirmed", true).Error
}
// StoreBarcode implements IStorage. // StoreBarcode implements IStorage.
func (s *storage) StoreBarcode(ctx context.Context, in *types.Barcode) error { func (s *storage) StoreBarcode(ctx context.Context, in *types.Barcode) error {
return s.db.Save(in).Error return s.db.Save(in).Error
@ -39,7 +45,6 @@ func ProductionDataBase(conf *DBConfig) (*gorm.DB, error) {
conf.Name, conf.Name,
conf.Port, conf.Port,
) )
// create open database connection // create open database connection
db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{}) db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
if err != nil { if err != nil {