2021-12-31 18:00:54 +01:00
|
|
|
unit BaseControllerU;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
MVCFramework,
|
|
|
|
MVCFramework.Commons,
|
|
|
|
MVCFramework.Swagger.Commons,
|
|
|
|
MVCFramework.Serializer.Commons;
|
|
|
|
|
|
|
|
type
|
|
|
|
TBaseController<T: class; R: record> = class(TMVCController)
|
|
|
|
public
|
|
|
|
[MVCPath]
|
|
|
|
[MVCHTTPMethod([httpGET])]
|
2022-01-04 15:44:47 +01:00
|
|
|
[MVCSwagSummary(TSwaggerConst.USE_DEFAULT_SUMMARY_TAGS,
|
|
|
|
'List all ' + TSwaggerConst.PLURAL_MODEL_NAME,
|
|
|
|
'getAll' + TSwaggerConst.PLURAL_MODEL_NAME)]
|
2021-12-31 18:00:54 +01:00
|
|
|
[MVCSwagResponses(200, 'Success', SWAGUseDefaultControllerModel, True)]
|
2022-01-11 15:30:40 +01:00
|
|
|
[MVCSwagResponses(500, 'Internal Server Error', TMVCErrorResponse)]
|
2021-12-31 18:00:54 +01:00
|
|
|
procedure GetAll; virtual;
|
|
|
|
|
|
|
|
[MVCPath]
|
|
|
|
[MVCHTTPMethod([httpPOST])]
|
2022-01-04 15:44:47 +01:00
|
|
|
[MVCSwagSummary(TSwaggerConst.USE_DEFAULT_SUMMARY_TAGS,
|
|
|
|
'Create a ' + TSwaggerConst.SINGULAR_MODEL_NAME,
|
|
|
|
'create' + TSwaggerConst.SINGULAR_MODEL_NAME)]
|
2021-12-31 18:00:54 +01:00
|
|
|
[MVCSwagResponses(201, 'Created')]
|
2022-01-11 15:30:40 +01:00
|
|
|
[MVCSwagResponses(500, 'Internal Server Error', TMVCErrorResponse)]
|
|
|
|
[MVCSwagParam(plBody,
|
|
|
|
TSwaggerConst.SINGULAR_MODEL_NAME + ' entity',
|
|
|
|
'The ' + TSwaggerConst.SINGULAR_MODEL_NAME + ' to create',
|
|
|
|
SWAGUseDefaultControllerModel)]
|
2021-12-31 18:00:54 +01:00
|
|
|
procedure CreateEntity; virtual;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
{ TBaseController<T, R> }
|
|
|
|
|
|
|
|
procedure TBaseController<T, R>.CreateEntity;
|
|
|
|
begin
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TBaseController<T, R>.GetAll;
|
|
|
|
begin
|
|
|
|
Render(ObjectDict().Add('data',
|
|
|
|
StrDict(['prop1','prop2'],['value1','value2']))
|
|
|
|
);
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|