liujiandao
2023-12-28 f8199011df53b4d88ce1268e8e1ff4196a9ef127
proto/purchase_wms/server.go
@@ -160,3 +160,31 @@
   resp.Infos = infos
   return resp, nil
}
func (s *Server) ExistSupplier(ctx context.Context, req *ExistSupplierRequest) (*ExistSupplierResponse, error) {
   resp := new(ExistSupplierResponse)
   if len(req.ProductId) == 0 {
      resp.Exist = false
      return resp, nil
   }
   var products []test.SupplierMaterial
   err := global.GVA_DB.Model(&test.SupplierMaterial{}).Where("number in (?)", req.ProductId).Find(&products).Error
   if err != nil {
      return nil, err
   }
   for _, number := range req.ProductId {
      exit := false
      for _, product := range products {
         if number == product.Number && product.SupplierId > 0 {
            exit = true
            break
         }
      }
      if !exit {
         resp.Exist = exit
         return resp, nil
      }
   }
   resp.Exist = true
   return resp, nil
}