mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-23 23:05:44 +00:00
feat(BE-34): extend DB schema and update master data APIs [partial]
✅ DB Schema: product_warehouse entity and migration ✅ Master Data: added filter params to getall APIs 🚧 Pending: stock_logs implementation and adjustment APIs
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package entities
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Adjustment struct {
|
||||
Id uint `gorm:"primaryKey"`
|
||||
Name string `gorm:"not null;uniqueIndex:idx_name,where:deleted_at IS NULL"`
|
||||
CreatedBy uint `gorm:"not null"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
CreatedUser User `gorm:"foreignKey:CreatedBy;references:Id"`
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package entities
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ProductWarehouse struct {
|
||||
Id uint `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
ProductId uint `json:"product_id" gorm:"not null"`
|
||||
WarehouseId uint `json:"warehouse_id" gorm:"not null"`
|
||||
Quantity int `json:"quantity" gorm:"default:0"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
|
||||
CreatedBy uint `json:"created_by" gorm:"not null"`
|
||||
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
|
||||
|
||||
// Relations
|
||||
Product Product `json:"product,omitempty" gorm:"foreignKey:ProductId;references:Id"`
|
||||
Warehouse Warehouse `json:"warehouse,omitempty" gorm:"foreignKey:WarehouseId;references:Id"`
|
||||
CreatedUser User `json:"created_user,omitempty" gorm:"foreignKey:CreatedBy;references:Id"`
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package entities
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type StockLog struct {
|
||||
Id uint `json:"id" gorm:"primaryKey;"`
|
||||
TransactionType string `json:"transaction_type" gorm:"type:varchar(20);not null"`
|
||||
Quantity float64 `json:"quantity" gorm:"type:numeric(15,3);not null"`
|
||||
BeforeQuantity float64 `json:"before_quantity" gorm:"type:numeric(15,3);not null"`
|
||||
AfterQuantity float64 `json:"after_quantity" gorm:"type:numeric(15,3);not null"`
|
||||
LogType string `json:"log_type" gorm:"type:varchar(50);not null"`
|
||||
LogId uint `json:"log_id" gorm:"not null"`
|
||||
Note string `json:"note" gorm:"type:text"`
|
||||
ProductWarehouseId uint `json:"product_warehouse_id" gorm:"not null;index"`
|
||||
CreatedBy uint `json:"created_by" gorm:"not null;index"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
|
||||
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
|
||||
|
||||
ProductWarehouse *ProductWarehouse `json:"product_warehouse,omitempty" gorm:"foreignKey:ProductWarehouseId;references:Id"`
|
||||
CreatedUser *User `json:"created_user,omitempty" gorm:"foreignKey:CreatedBy;references:Id"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user