wip
This commit is contained in:
parent
193b82725f
commit
eb99161ada
@ -16,7 +16,7 @@ COPY . .
|
|||||||
|
|
||||||
RUN go get -d -v ./...
|
RUN go get -d -v ./...
|
||||||
|
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -mod=mod -ldflags "-s -w" -o cml04-falcon-system main.go
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -mod=mod -ldflags "-s -w" -o cml04-falcon-ui main.go
|
||||||
|
|
||||||
# Etapa de producción
|
# Etapa de producción
|
||||||
|
|
||||||
@ -33,6 +33,6 @@ ADD templates /root/templates
|
|||||||
RUN update-ca-certificates
|
RUN update-ca-certificates
|
||||||
WORKDIR /root/
|
WORKDIR /root/
|
||||||
|
|
||||||
COPY --from=builder /app/cml04-falcon-system .
|
COPY --from=builder /app/cml04-falcon-ui .
|
||||||
|
|
||||||
CMD ["./cml04-falcon-ui"]
|
CMD ["./cml04-falcon-ui"]
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.espin.casa/albert/cml04-falcon-ui/types"
|
"git.espin.casa/albert/cml04-falcon-ui/types"
|
||||||
"gorm.io/driver/postgres"
|
"gorm.io/driver/postgres"
|
||||||
@ -22,7 +23,7 @@ type Storager interface {
|
|||||||
Barcode(ctx context.Context, reading string) (barcode *types.Barcode, err error)
|
Barcode(ctx context.Context, reading string) (barcode *types.Barcode, err error)
|
||||||
ListBarcode(ctx context.Context, lb types.LoadingBed, inicio, final string) (barcodes []types.Barcode, err error)
|
ListBarcode(ctx context.Context, lb types.LoadingBed, inicio, final string) (barcodes []types.Barcode, err error)
|
||||||
Bundle(ctx context.Context, ua string) (bundle *types.BundleData, err error)
|
Bundle(ctx context.Context, ua string) (bundle *types.BundleData, err error)
|
||||||
ListBundle(ctx context.Context)
|
ListBundle(ctx context.Context, lb types.LoadingBed, inicio string, final string) (bundles []types.BundleData, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type storage struct {
|
type storage struct {
|
||||||
@ -31,25 +32,63 @@ type storage struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListBundle implements Storager.
|
// ListBundle implements Storager.
|
||||||
func (s *storage) ListBundle(ctx context.Context) {
|
func (s *storage) ListBundle(ctx context.Context, lb types.LoadingBed, inicio string, final string) (bundles []types.BundleData, err error) {
|
||||||
panic("unimplemented")
|
ti, err := time.Parse("02/01/2006 15:04", inicio)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
tf, err := time.Parse("02/01/2006 15:04", final)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if lb == types.ALL {
|
||||||
|
if err := s.db.Where("created_at >= ? and created_at < ?", ti, tf).Find(bundles).WithContext(ctx).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := s.db.Where("loading_bed = ? and created_at >= ? and created_at < ?", lb, ti, tf).Find(bundles).WithContext(ctx).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bundle implements Storager.
|
// Bundle implements Storager.
|
||||||
func (s *storage) Bundle(ctx context.Context, ua string) (bundle *types.BundleData, err error) {
|
func (s *storage) Bundle(ctx context.Context, ua string) (bundle *types.BundleData, err error) {
|
||||||
panic("unimplemented")
|
if err := s.db.First(bundle, ua).WithContext(ctx).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListBarcode implements Storager.
|
// ListBarcode implements Storager.
|
||||||
func (s *storage) ListBarcode(ctx context.Context, lb types.LoadingBed, inicio string, final string) (barcodes []types.Barcode, err error) {
|
func (s *storage) ListBarcode(ctx context.Context, lb types.LoadingBed, inicio string, final string) (barcodes []types.Barcode, err error) {
|
||||||
fmt.Println(lb, inicio, final)
|
ti, err := time.Parse("02/01/2006 15:04", inicio)
|
||||||
return []types.Barcode{}, nil
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
tf, err := time.Parse("02/01/2006 15:04", final)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if lb == types.ALL {
|
||||||
|
if err := s.db.Where("created_at >= ? and created_at < ?", ti, tf).Find(barcodes).WithContext(ctx).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := s.db.Where("loading_bed = ? and created_at >= ? and created_at < ?", lb, ti, tf).Find(barcodes).WithContext(ctx).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Barcode implements Storager.
|
// Barcode implements Storager.
|
||||||
func (s *storage) Barcode(ctx context.Context, reading string) (barcode *types.Barcode, err error) {
|
func (s *storage) Barcode(ctx context.Context, reading string) (barcode *types.Barcode, err error) {
|
||||||
fmt.Println(reading)
|
if err := s.db.First(barcode, reading).WithContext(ctx).Error; err != nil {
|
||||||
return &types.Barcode{}, nil
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProductionDataBase(conf *DBConfig) (*gorm.DB, error) {
|
func ProductionDataBase(conf *DBConfig) (*gorm.DB, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user