package supplier import ( "context" "srm/global" "srm/model/test" ) type Server struct { UnimplementedSupplierServiceServer } func (s *Server) GetSupplierList(c context.Context, req *SupplierListRequest) (*SupplierListResponse, error) { var supplierList []*test.Supplier resp := new(SupplierListResponse) db := global.GVA_DB.Table("srm_supplier") if req.Status != -1 { db = db.Where("status=?", req.Status) } if err := db.Find(&supplierList).Error; err != nil { return resp, err } for _, v := range supplierList { resp.List = append(resp.List, &SupplierInfo{SupplierId: int32(v.ID), SupplierName: v.Name}) } return resp, nil }