zhangqian
2024-03-29 c2be95e83d1597eed8623fdd70a77d617465f91e
models/warehouse.go
@@ -25,8 +25,9 @@
      Address                string       `json:"address" gorm:"type:varchar(512);comment:地址"`         //地址
      InboundTransportation  int          `json:"inboundTransportation" gorm:"type:int;comment:入向运输"`  //入向运输
      OutboundTransportation int          `json:"outboundTransportation" gorm:"type:int;comment:出库运输"` //出库运输
      LocationId             int          `json:"locationId" gorm:"type:int;comment:位置id"`             //位置id
      LocationId             int          `json:"locationId" gorm:"type:int;comment:位置id"`             //默认位置id
      WarehouseLocation      string       `json:"warehouseLocation" gorm:"-"`                          //库存位置
      Contacts               string       `json:"contacts" gorm:"type:varchar(255);comment:联系人"`       //联系人
   }
   WarehouseSearch struct {
@@ -37,6 +38,7 @@
      Keyword  string
      Orm      *gorm.DB
      Preload  bool
      Codes    []string
   }
)
@@ -78,6 +80,11 @@
   return slf
}
func (slf *WarehouseSearch) SetCodes(codes []string) *WarehouseSearch {
   slf.Codes = codes
   return slf
}
func (slf *WarehouseSearch) SetName(name string) *WarehouseSearch {
   slf.Name = name
   return slf
@@ -115,10 +122,15 @@
   if slf.Preload {
      db = db.Preload("Company")
   }
   if slf.Code != "" {
      db = db.Where("code = ?", slf.Code)
   }
   if len(slf.Codes) > 0 {
      db = db.Where("code in ?", slf.Codes)
   }
   return db
}