zhangqian
2024-07-01 73b6baf6af3d88cdcb0e2df7932a9bd96b0b85c5
models/material.go
@@ -51,7 +51,6 @@
      CategoryId          int                        `gorm:"type:int(11);comment:产品类别id" json:"categoryId"`                //产品类别id
      CategoryName        string                     `gorm:"type:varchar(255);comment:产品类别名称" json:"categoryName"`         //产品类别名称
      InternalReference   string                     `gorm:"type:varchar(255);comment:内部参考" json:"internalReference"`      //内部参考
      Barcode             string                     `gorm:"type:varchar(255);comment:条码" json:"barcode"`                  //条码
      ProductTagId        int                        `gorm:"type:int(11);comment:产品标签id" json:"productTagId"`              //产品标签id
      ProductTagName      string                     `gorm:"type:varchar(255);comment:产品标签名称" json:"productTagName"`       //产品标签名称
      CompanyId           int                        `gorm:"type:int(11);comment:公司id" json:"companyId"`                   //公司id
@@ -96,7 +95,8 @@
      MinInventoryRule decimal.Decimal `json:"minInventoryRule" gorm:"-"` //最小库存
      MaxInventoryRule decimal.Decimal `json:"maxInventoryRule" gorm:"-"` //最大库存
      CreateBy string `gorm:"type:varchar(255);comment:导入人、创建人" json:"createBy"` //创建人
      CreateBy string `gorm:"type:varchar(255);comment:导入人、创建人" json:"createBy"`       //创建人
      BarCode  string `gorm:"type:varchar(255);comment:(商品/产品/物料的)条形码" json:"barCode"` //条码
   }
   MaterialSearch struct {
@@ -164,7 +164,14 @@
      }
   }
   if len(slf.MoreUnitList) != 0 {
      str, err := json.Marshal(slf.MoreUnitList)
      items := make([]UnitItems, 0)
      for k, item := range slf.MoreUnitList {
         if item.Unit != "" && !item.Amount.IsZero() {
            items = append(items, slf.MoreUnitList[k])
         }
      }
      str, err := json.Marshal(items)
      if err != nil {
         return err
      }
@@ -198,6 +205,11 @@
func (slf *MaterialSearch) SetID(id string) *MaterialSearch {
   slf.ID = id
   return slf
}
func (slf *MaterialSearch) SetBarCode(barCode string) *MaterialSearch {
   slf.BarCode = barCode
   return slf
}
@@ -272,6 +284,9 @@
   if slf.ID != "" {
      db = db.Where("id = ?", slf.ID)
   }
   if slf.BarCode != "" {
      db = db.Where("bar_code = ?", slf.BarCode)
   }
   if slf.Name != "" {
      db = db.Where("name = ?", slf.Name)