jiangshuai
2023-10-23 0551df1d2a65876b2427df112e37625f128b67e4
models/location_product_amount.go
@@ -20,28 +20,30 @@
   LocationProductAmountSearch struct {
      LocationProductAmount
      Order    string
      PageNum  int
      PageSize int
      Keyword  string
      Orm      *gorm.DB
      Preload  bool
      Order              string
      PageNum            int
      PageSize           int
      Keyword            string
      Orm                *gorm.DB
      Preload            bool
      LocationProductIds []int
   }
   LocationProductAmountWithOperation struct {
      //LocationProductAmount LocationProductAmount `json:"locationProductAmount"`
      LocationProductAmountId int                      `json:"locationProductAmount" gorm:"location_product_amount_id"`
      LocationId              int                      `json:"locationId" gorm:"column:location_id"`
      LocationName            string                   `json:"locationName" gorm:"column:location_name"`
      ProductId               string                   `json:"productId" gorm:"column:product_id"`
      ProductName             string                   `json:"productName" gorm:"column:product_name"`
      Amount                  decimal.Decimal          `json:"amount" gorm:"column:amount"`
      Unit                    string                   `json:"unit" gorm:"column:unit"`
      CreateDate              string                   `json:"createDate" gorm:"column:create_date"`
      AdjustAmount            decimal.Decimal          `json:"adjustAmount" gorm:"column:adjust_amount"`
      DifferenceAmount        decimal.Decimal          `json:"differenceAmount" gorm:"-"`
      OperationId             int                      `json:"operationId" gorm:"column:operation_id"`
      Status                  constvar.OperationStatus `json:"status" gorm:"status"`
      LocationProductAmountId int                        `json:"locationProductAmountId" gorm:"location_product_amount_id"`
      LocationId              int                        `json:"locationId" gorm:"column:location_id"`
      LocationName            string                     `json:"locationName" gorm:"column:location_name"`
      ProductId               string                     `json:"productId" gorm:"column:product_id"`
      ProductName             string                     `json:"productName" gorm:"column:product_name"`
      Amount                  decimal.Decimal            `json:"amount" gorm:"column:amount"`
      Unit                    string                     `json:"unit" gorm:"column:unit"`
      CreateDate              string                     `json:"createDate" gorm:"column:create_date"`
      AdjustAmount            decimal.Decimal            `json:"adjustAmount" gorm:"column:adjust_amount"`
      DifferenceAmount        decimal.Decimal            `json:"differenceAmount" gorm:"-"`
      OperationId             int                        `json:"operationId" gorm:"column:operation_id"`
      Status                  constvar.OperationStatus   `json:"status" gorm:"status"`
      BaseOperationType       constvar.BaseOperationType `json:"baseOperationType" gorm:"base_operation_type"`
   }
)
@@ -88,6 +90,11 @@
   return slf
}
func (slf *LocationProductAmountSearch) SetLocationProductIds(ids []int) *LocationProductAmountSearch {
   slf.LocationProductIds = ids
   return slf
}
func (slf *LocationProductAmountSearch) build() *gorm.DB {
   var db = slf.Orm.Model(&LocationProductAmount{})
@@ -108,6 +115,9 @@
   if slf.LocationProductId != 0 {
      db = db.Where("location_product_id=?", slf.LocationProductId)
   }
   if len(slf.LocationProductIds) > 0 {
      db = db.Where("location_product_id in (?)", slf.LocationProductIds)
   }
   return db
}