You are not logged in.
Pages: 1
Hi,
I have a basic object structure declared like this
TProduct = class(TSynAutoCreateFields)
private
FID: RawUTF8;
FNumber: Integer;
published
property ID : RawUTF8 read FID write FID;
property Number : Integer read FNumber write FNumber;
end;
If I call service to GET specified product I receive a JSON like this
{
"TypeID": "7328059c-51ec-4104-ac9e-1e8af3e32228",
"Description_0": "Produit AKMN202482",
"Description_1": "Product AKMN202482",
"Number": "AKMN202482",
"ID": "993a1d67-bbe2-4ad0-826c-0be01c51a83f"
}
So this is a basic product class (TSynAutoCreateFields)
If I call service to GET all product list I receive a JSON like this
[
{
"TypeID": "7328059c-51ec-4104-ac9e-1e8af3e32228",
"Description_0": "Produit AKMN202482",
"Description_1": "Product AKMN202482",
"Number": "AKMN202482",
"ID": "993a1d67-bbe2-4ad0-826c-0be01c51a83f"
},
{
"TypeID": "7328059c-51ec-4104-ac9e-1e8af3e32228",
"Description_0" : "Produit FACR426534",
"Description_1" : "Product FACR426534",
"Number": "FACR426534",
"ID": "ec324edb-4a03-4c31-96f0-0bd7b679320b"
}
]
This is a Basic product class into CollectionItem (TCollectionItemAutoCreateFields)
I tried this and it work but I wouldn't use interface for each class I need (Product, Customer, Group, etc)
IProduct = interface(IInterface)
function GetID : RawUTF8;
function GetNumber : RawUTF8;
procedure SetID(Value : RawUTF8);
procedure SetNumber(value : RawUTF8);
property ID : RawUTF8 read GetID write SetID;
property Number : RawUTF8 read GetNumber write SetNumber;
end;
TProduct = class(TSynAutoCreateFields, IProduct)
private
FID : RawUTF8;
FNumber : RawUTF8;
function GetID : RawUTF8;
function GetNumber : RawUTF8;
procedure SetID(Value : RawUTF8);
procedure SetNumber(value : RawUTF8);
protected
FRefCount: Integer;
function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
function _AddRef: Integer; stdcall;
function _Release: Integer; stdcall;
published
property ID : RawUTF8 read GetID write SetID;
property Number : RawUTF8 read GetNumber write SetNumber;
end;
TProducts = class(TCollectionItemAutoCreateFields, IProduct)
private
FID : RawUTF8;
FNumber : RawUTF8;
function GetID : RawUTF8;
function GetNumber : RawUTF8;
procedure SetID(Value : RawUTF8);
procedure SetNumber(value : RawUTF8);
protected
FRefCount: Integer;
function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
function _AddRef: Integer; stdcall;
function _Release: Integer; stdcall;
published
property ID : RawUTF8 read GetID write SetID;
property Number : RawUTF8 read GetNumber write SetNumber;
end;
How I can implement code to specified what kind of interface I need it without declase Interface and without declare two different classes with same property ?
Thank you
Offline
Pages: 1