fix
add supplier search with modelNumber, productType, supplierName, and supplier_type
| | |
| | | productList[k].Number = v.Number |
| | | productList[k].Name = v.Name |
| | | productList[k].Unit = v.Unit |
| | | productList[k].PurchasePrice = &v.SalePrice |
| | | productList[k].PurchasePrice = v.SalePrice |
| | | min := int(v.MinInventory) |
| | | productList[k].MinimumStock = &min |
| | | productList[k].MinimumStock = min |
| | | max := int(v.MaxInventory) |
| | | productList[k].MaximumStock = &max |
| | | productList[k].MaximumStock = max |
| | | productList[k].Remark = v.Node |
| | | productList[k].ProductType = v.MaterialMode |
| | | } |
| | |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "supplierName", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "unit", |
| | | "in": "query" |
| | | }, |
| | |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "supplierName", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "unit", |
| | | "in": "query" |
| | | }, |
| | |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "supplierName", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "unit", |
| | | "in": "query" |
| | | }, |
| | |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "supplierName", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "unit", |
| | | "in": "query" |
| | | }, |
| | |
| | | name: supplierId |
| | | type: integer |
| | | - in: query |
| | | name: supplierName |
| | | type: string |
| | | - in: query |
| | | name: unit |
| | | type: string |
| | | - in: query |
| | |
| | | name: supplierId |
| | | type: integer |
| | | - in: query |
| | | name: supplierName |
| | | type: string |
| | | - in: query |
| | | name: unit |
| | | type: string |
| | | - in: query |
| | |
| | | SupplierId uint `json:"supplierId" form:"supplierId" gorm:"column:supplier_id;comment:供应商id;size:255;"` |
| | | Supplier Supplier `json:"supplier" form:"supplier" gorm:"foreignKey:SupplierId;references:ID;comment:供应商"` |
| | | Unit string `json:"unit" form:"unit" gorm:"column:unit;comment:计量单位;size:255;"` |
| | | PurchasePrice *float64 `json:"purchasePrice" form:"purchasePrice" gorm:"column:purchase_price;comment:采购价格;"` |
| | | PurchasePrice float64 `json:"purchasePrice" form:"purchasePrice" gorm:"column:purchase_price;comment:采购价格;"` |
| | | DeliveryTime *int `json:"deliveryTime" form:"deliveryTime" gorm:"column:delivery_time;comment:;size:11;"` |
| | | ShippingDuration *int `json:"shippingDuration" form:"shippingDuration" gorm:"column:shipping_duration;comment:物流时长;size:11;"` |
| | | Specifications string `json:"specifications" form:"specifications" gorm:"column:specifications;comment:规格;size:255;"` |
| | | ModelNumber string `json:"modelNumber" form:"modelNumber" gorm:"column:model_number;comment:型号;size:255;"` |
| | | ProductType string `json:"productType" form:"productType" gorm:"column:product_type;comment:产品类别;size:255;"` |
| | | MinimumStock *int `json:"minimumStock" form:"minimumStock" gorm:"column:minimum_stock;comment:最低库存;"` |
| | | MaximumStock *int `json:"maximumStock" form:"maximumStock" gorm:"column:maximum_stock;comment:最高库存;"` |
| | | MinimumStock int `json:"minimumStock" form:"minimumStock" gorm:"column:minimum_stock;comment:最低库存;"` |
| | | MaximumStock int `json:"maximumStock" form:"maximumStock" gorm:"column:maximum_stock;comment:最高库存;"` |
| | | Remark string `json:"remark" form:"remark" gorm:"column:remark;comment:备注;size:255;"` |
| | | } |
| | | |
| | |
| | | |
| | | type ProductSearch struct { |
| | | test.Product |
| | | SupplierName string `json:"supplierName" form:"supplierName"` |
| | | StartCreatedAt *time.Time `json:"startCreatedAt" form:"startCreatedAt"` |
| | | EndCreatedAt *time.Time `json:"endCreatedAt" form:"endCreatedAt"` |
| | | request.PageInfo |
| | |
| | | db = db.Where("supplier_id = ?", info.SupplierId) |
| | | } |
| | | |
| | | if info.MaximumStock != 0 { |
| | | db = db.Where("maximum_stock = ?", info.MaximumStock) |
| | | } |
| | | |
| | | if info.MinimumStock != 0 { |
| | | db = db.Where("minimum_stock = ?", info.MinimumStock) |
| | | } |
| | | |
| | | if info.PurchasePrice != 0 { |
| | | db = db.Where("purchase_price = ?", info.PurchasePrice) |
| | | } |
| | | |
| | | if info.Specifications != "" { |
| | | db = db.Where("specifications LIKE ?", "%"+info.Specifications+"%") |
| | | } |
| | | |
| | | if info.ModelNumber != "" { |
| | | db = db.Where("model_number LIKE ?", "%"+info.ModelNumber+"%") |
| | | } |
| | | |
| | | if info.ProductType != "" { |
| | | db = db.Where("product_type LIKE ?", "%"+info.ProductType+"%") |
| | | } |
| | | |
| | | if info.SupplierName != "" { |
| | | db = db.Joins("Supplier").Where("Supplier.name LIKE ?", "%"+info.SupplierName+"%") |
| | | } |
| | | |
| | | err = db.Count(&total).Error |
| | | if err != nil { |
| | | return |