| | |
| | | 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 |
| | | } |