zhangqian
2024-07-04 c950586b718ae6fc198bedf424609a4ac94cb5d1
models/operation.go
@@ -61,7 +61,7 @@
      CheckedBy    string `json:"checkedBy" gorm:"type:varchar(255);comment:验证者UserId"`
      Remark       string `json:"remark"`
      WarehouseId         int       `json:"warehouseId" gorm:"type:int;not null;comment:仓库id"`
      WarehouseId         int       `json:"warehouseId" gorm:"type:int;not null;default:0;comment:仓库id"`
      Warehouse           Warehouse `json:"warehouse" gorm:"foreignKey:WarehouseId"`
      IsInternalOutput    bool      `json:"isInternalOutput"` //是否调拨产生的出库
      InventoryDealerType int       `json:"inventoryDealerType" gorm:"type:varchar(255);comment:调拨出入库分类(对应dict字典表的ID)"`
@@ -93,6 +93,12 @@
func NewOperationSearch() *OperationSearch {
   return &OperationSearch{Orm: mysqlx.GetDB()}
}
func (slf *OperationSearch) BeforeCreate(tx *gorm.DB) {
   for k := range slf.Details {
      slf.Details[k].BaseOperationType = slf.BaseOperationType
   }
}
func (slf *OperationSearch) SetOrm(tx *gorm.DB) *OperationSearch {
@@ -196,6 +202,11 @@
   return slf
}
func (slf *OperationSearch) SetWarehouseId(warehouseId int) *OperationSearch {
   slf.WarehouseId = warehouseId
   return slf
}
func (slf *OperationSearch) build() *gorm.DB {
   var db = slf.Orm.Model(&Operation{})
@@ -277,6 +288,10 @@
      db = db.Where("inventory_dealer_type in (?)", slf.InventoryDealerTypeIds)
   }
   if slf.WarehouseId != 0 {
      db = db.Where("warehouse_id = ?", slf.WarehouseId)
   }
   return db
}