mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-23 23:05:44 +00:00
(BE-58,,59): extend db schema & build stock transfer api
- Extend DB schema for stock transfers - Build stock transfer API (create,)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.com/mbugroup/lti-api.git/internal/common/repository"
|
||||
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type StockTransferRepository interface {
|
||||
repository.BaseRepository[entity.StockTransfer]
|
||||
// get sequence for movement number
|
||||
GetNextMovementNumber(ctx context.Context) (int64, error)
|
||||
}
|
||||
|
||||
type StockTransferRepositoryImpl struct {
|
||||
*repository.BaseRepositoryImpl[entity.StockTransfer]
|
||||
}
|
||||
|
||||
func NewStockTransferRepository(db *gorm.DB) StockTransferRepository {
|
||||
return &StockTransferRepositoryImpl{
|
||||
BaseRepositoryImpl: repository.NewBaseRepository[entity.StockTransfer](db),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *StockTransferRepositoryImpl) GetNextMovementNumber(ctx context.Context) (int64, error) {
|
||||
var seq int64
|
||||
err := r.DB().WithContext(ctx).Raw("SELECT nextval('stock_transfer_seq')").Scan(&seq).Error
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return seq, nil
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"gitlab.com/mbugroup/lti-api.git/internal/common/repository"
|
||||
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type StockTransferDeliveryRepository interface {
|
||||
repository.BaseRepository[entity.StockTransferDelivery]
|
||||
// Tambahkan custom method jika perlu
|
||||
}
|
||||
|
||||
type StockTransferDeliveryRepositoryImpl struct {
|
||||
*repository.BaseRepositoryImpl[entity.StockTransferDelivery]
|
||||
}
|
||||
|
||||
func NewStockTransferDeliveryRepository(db *gorm.DB) StockTransferDeliveryRepository {
|
||||
return &StockTransferDeliveryRepositoryImpl{
|
||||
BaseRepositoryImpl: repository.NewBaseRepository[entity.StockTransferDelivery](db),
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"gitlab.com/mbugroup/lti-api.git/internal/common/repository"
|
||||
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type StockTransferDeliveryItemRepository interface {
|
||||
repository.BaseRepository[entity.StockTransferDeliveryItem]
|
||||
// Tambahkan custom method jika perlu
|
||||
}
|
||||
|
||||
type StockTransferDeliveryItemRepositoryImpl struct {
|
||||
*repository.BaseRepositoryImpl[entity.StockTransferDeliveryItem]
|
||||
}
|
||||
|
||||
func NewStockTransferDeliveryItemRepository(db *gorm.DB) StockTransferDeliveryItemRepository {
|
||||
return &StockTransferDeliveryItemRepositoryImpl{
|
||||
BaseRepositoryImpl: repository.NewBaseRepository[entity.StockTransferDeliveryItem](db),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"gitlab.com/mbugroup/lti-api.git/internal/common/repository"
|
||||
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type StockTransferDetailRepository interface {
|
||||
repository.BaseRepository[entity.StockTransferDetail]
|
||||
// Tambahkan custom method jika perlu
|
||||
}
|
||||
|
||||
type StockTransferDetailRepositoryImpl struct {
|
||||
*repository.BaseRepositoryImpl[entity.StockTransferDetail]
|
||||
}
|
||||
|
||||
func NewStockTransferDetailRepository(db *gorm.DB) StockTransferDetailRepository {
|
||||
return &StockTransferDetailRepositoryImpl{
|
||||
BaseRepositoryImpl: repository.NewBaseRepository[entity.StockTransferDetail](db),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user