Breaking Change! TMVCActiveRecordController uses (and requires) TMVCActiveRecordMiddleware - it doesn't require a TFDConnection on constructor

This commit is contained in:
Daniele Teti 2024-01-20 10:37:34 +01:00
parent 7a11512347
commit 30a247281f
3 changed files with 168 additions and 38 deletions

View File

@ -50,6 +50,7 @@ implementation
uses
System.IOUtils,
MVCFramework.Commons,
MVCFramework.Middleware.ActiveRecord,
MVCFramework.ActiveRecordController,
MVCFramework.ActiveRecord,
MVCFramework.Middleware.StaticFiles,
@ -76,13 +77,10 @@ begin
// Enable Server Signature in response
Config[TMVCConfigKey.ExposeServerSignature] := 'true';
end);
FMVC.AddController(TOtherController, '/api/foo');
FMVC.AddController(TMVCActiveRecordController,
function: TMVCController
begin
Result := TMVCActiveRecordController.Create(CON_DEF_NAME);
end, '/api/entities');
FMVC.AddController(TMVCActiveRecordController, '/api/entities');
{Since 3.4.2-magnesium, TMVCActiveRecordMiddleware is required by TMVCActiveRecordController!}
FMVC.AddMiddleware(TMVCActiveRecordMiddleware.Create(CON_DEF_NAME));
end;
procedure TMyWebModule.WebModuleDestroy(Sender: TObject);

View File

@ -46,6 +46,8 @@ type
function GetSingleObject: TPerson;
[MVCPath('/objects/multiple')]
function GetMultipleObjects: TObjectList<TPerson>;
{ actions returning json }
[MVCPath('/objects/jsonobject')]
function GetJSONObject: TJSONObject;
[MVCPath('/objects/jsonarray')]
@ -88,16 +90,6 @@ uses
{ TMyController }
function TMyController.GetJSONArray: TJsonArray;
begin
Result := StrToJSONArray('[1,2,3, {"name":"Daniele","surname":"Teti"}]');
end;
function TMyController.GetJSONObject: TJSONObject;
begin
Result := StrToJSONObject('{"name":"Daniele","surname":"Teti"}');
end;
function TMyController.GetSingleDataSet: TDataSet;
begin
var lDM := TdmMain.Create(nil);
@ -136,28 +128,7 @@ begin
end;
end;
function TMyController.GetMultipleObjects: TObjectList<TPerson>;
begin
Result := TObjectList<TPerson>.Create;
Result.Add(TPerson.Create('Daniele', 'Teti', YearsBetween(Date, EncodeDateDay(1979, 1))));
Result.Add(TPerson.Create('Daniele', 'Teti', Result[0].Age + 10));
Result.Add(TPerson.Create('Daniele', 'Teti', Result[0].Age + 20));
end;
function TMyController.GetMultipleRecords: TArray<TPersonRec>;
begin
SetLength(Result, 3);
Result[0] := TPersonRec.Create;
Result[1] := TPersonRec.Create;
Result[2] := TPersonRec.Create;
Inc(Result[1].Age, 10);
Inc(Result[2].Age, 20);
end;
function TMyController.GetMVCResponseSimple: IMVCResponse;
begin
@ -241,11 +212,42 @@ begin
Result := TPerson.Create('Daniele', 'Teti', YearsBetween(Date, EncodeDateDay(1979, 1)));
end;
function TMyController.GetMultipleObjects: TObjectList<TPerson>;
begin
Result := TObjectList<TPerson>.Create;
Result.Add(TPerson.Create('Daniele', 'Teti', YearsBetween(Date, EncodeDateDay(1979, 1))));
Result.Add(TPerson.Create('Daniele', 'Teti', Result[0].Age + 10));
Result.Add(TPerson.Create('Daniele', 'Teti', Result[0].Age + 20));
end;
function TMyController.GetJSONArray: TJsonArray;
begin
Result := StrToJSONArray('[1,2,3, {"name":"Daniele","surname":"Teti"}]');
end;
function TMyController.GetJSONObject: TJSONObject;
begin
Result := StrToJSONObject('{"name":"Daniele","surname":"Teti"}');
end;
function TMyController.GetSingleRecord: TPersonRec;
begin
Result := TPersonRec.Create;
end;
function TMyController.GetMultipleRecords: TArray<TPersonRec>;
begin
SetLength(Result, 3);
Result[0] := TPersonRec.Create;
Result[1] := TPersonRec.Create;
Result[2] := TPersonRec.Create;
Inc(Result[1].Age, 10);
Inc(Result[2].Age, 20);
end;
function TMyController.GetSum(const A, B: Integer): Integer;
begin
Result := A + B;

View File

@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{84012097-1BD4-41B3-A479-B831D1147725}</ProjectGuid>
<ProjectVersion>19.5</ProjectVersion>
<ProjectVersion>20.1</ProjectVersion>
<FrameworkType>None</FrameworkType>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
@ -254,6 +254,16 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidSplashImageDefV21">
<Platform Name="Android">
<RemoteDir>res\drawable-anydpi-v21</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-anydpi-v21</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidSplashStyles">
<Platform Name="Android">
<RemoteDir>res\values</RemoteDir>
@ -274,6 +284,66 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidSplashStylesV31">
<Platform Name="Android">
<RemoteDir>res\values-v31</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\values-v31</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_AdaptiveIcon">
<Platform Name="Android">
<RemoteDir>res\drawable-anydpi-v26</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-anydpi-v26</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_AdaptiveIconBackground">
<Platform Name="Android">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_AdaptiveIconForeground">
<Platform Name="Android">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_AdaptiveIconMonochrome">
<Platform Name="Android">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_AdaptiveIconV33">
<Platform Name="Android">
<RemoteDir>res\drawable-anydpi-v33</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-anydpi-v33</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_Colors">
<Platform Name="Android">
<RemoteDir>res\values</RemoteDir>
@ -284,6 +354,16 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_ColorsDark">
<Platform Name="Android">
<RemoteDir>res\values-night-v21</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\values-night-v21</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_DefaultAppIcon">
<Platform Name="Android">
<RemoteDir>res\drawable</RemoteDir>
@ -454,6 +534,56 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_VectorizedNotificationIcon">
<Platform Name="Android">
<RemoteDir>res\drawable-anydpi-v24</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-anydpi-v24</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_VectorizedSplash">
<Platform Name="Android">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_VectorizedSplashDark">
<Platform Name="Android">
<RemoteDir>res\drawable-night-anydpi-v21</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-night-anydpi-v21</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_VectorizedSplashV31">
<Platform Name="Android">
<RemoteDir>res\drawable-anydpi-v31</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-anydpi-v31</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_VectorizedSplashV31Dark">
<Platform Name="Android">
<RemoteDir>res\drawable-night-anydpi-v31</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-night-anydpi-v31</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="DebugSymbols">
<Platform Name="iOSSimulator">
<Operation>1</Operation>