mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 15:55:54 +01:00
[+] Improved some samples
This commit is contained in:
parent
79f4dd1384
commit
bc96a6866a
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Delphi MVC Framework
|
||||
//
|
||||
// Copyright (c) 2010-2020 Daniele Teti and the DMVCFramework Team
|
||||
// Copyright (c) 2010-2021 Daniele Teti and the DMVCFramework Team
|
||||
//
|
||||
// https://github.com/danieleteti/delphimvcframework
|
||||
//
|
||||
@ -84,10 +84,6 @@ begin
|
||||
TCustomAuth.Create,
|
||||
'/system/users/logged'
|
||||
));
|
||||
// FMVC.AddMiddleware(TMVCStaticFilesMiddleware.Create(
|
||||
// '/app', { StaticFilesPath }
|
||||
// ExtractFilePath(GetModuleName(HInstance)) + 'www' { DocumentRoot }
|
||||
// ));
|
||||
end;
|
||||
|
||||
procedure TMyWebModule.WebModuleDestroy(Sender: TObject);
|
||||
|
@ -1111,6 +1111,9 @@ var
|
||||
lCustomer: TCustomerWithSpaces;
|
||||
lID: Integer;
|
||||
I: Integer;
|
||||
cRQL1: string;
|
||||
lList: TMVCActiveRecordList;
|
||||
lItem: TMVCActiveRecord;
|
||||
begin
|
||||
Log('** Simple CRUD (table and fields with spaces) test');
|
||||
Log('There are ' + TMVCActiveRecord.Count<TCustomerWithSpaces>().ToString + ' row/s for entity ' +
|
||||
@ -1121,7 +1124,8 @@ begin
|
||||
begin
|
||||
lCustomer := TCustomerWithSpaces.Create;
|
||||
try
|
||||
lCustomer.ID := I;
|
||||
lID := I;
|
||||
lCustomer.ID := lID;
|
||||
// just for test!!
|
||||
case I mod 3 of
|
||||
0:
|
||||
@ -1134,7 +1138,6 @@ begin
|
||||
lCustomer.City := 'Montain View, CA';
|
||||
lCustomer.Note := 'Hello there!';
|
||||
lCustomer.Insert;
|
||||
lID := lCustomer.ID;
|
||||
Log('Just inserted Customer ' + lID.ToString);
|
||||
finally
|
||||
lCustomer.Free;
|
||||
@ -1143,8 +1146,12 @@ begin
|
||||
|
||||
Log('Now there are ' + TMVCActiveRecord.Count<TCustomerWithSpaces>().ToString +
|
||||
' row/s for entity ' + TCustomerWithSpaces.ClassName);
|
||||
TMVCActiveRecord.DeleteRQL(TCustomerWithSpaces, 'lt(id,90)');
|
||||
Log('Deleting using RQL...');
|
||||
TMVCActiveRecord.DeleteRQL(TCustomerWithSpaces, 'lt(id,80)');
|
||||
Log('Now there are ' + TMVCActiveRecord.Count<TCustomerWithSpaces>().ToString +
|
||||
' row/s for entity ' + TCustomerWithSpaces.ClassName);
|
||||
|
||||
//gets the last inserted customer
|
||||
lCustomer := TMVCActiveRecord.GetByPK<TCustomerWithSpaces>(lID);
|
||||
try
|
||||
Assert(not lCustomer.Code.HasValue);
|
||||
@ -1172,6 +1179,21 @@ begin
|
||||
finally
|
||||
lCustomer.Free;
|
||||
end;
|
||||
|
||||
cRQL1 := 'eq(CompanyName,"Google Inc.")';
|
||||
Log('>> RQL Query (customers with spaces) - ' + cRQL1);
|
||||
lList := TMVCActiveRecord.SelectRQL(TCustomerWithSpaces, cRQL1, 20);
|
||||
try
|
||||
Log(lList.Count.ToString + ' record/s found');
|
||||
for lItem in lList do
|
||||
begin
|
||||
lCustomer := TCustomerWithSpaces(lItem);
|
||||
Log(Format('%5s - %s (%s)', [lCustomer.Code.ValueOrDefault,
|
||||
lCustomer.CompanyName.ValueOrDefault, lCustomer.City]));
|
||||
end;
|
||||
finally
|
||||
lList.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormDestroy(Sender: TObject);
|
||||
@ -1227,8 +1249,8 @@ begin
|
||||
{$ENDIF}
|
||||
btnWithSpaces.Enabled :=
|
||||
(ActiveRecordConnectionsRegistry.GetCurrentBackend = 'postgresql') or
|
||||
// (ActiveRecordConnectionsRegistry.GetCurrentBackend = 'firebird') or
|
||||
// (ActiveRecordConnectionsRegistry.GetCurrentBackend = 'interbase') or
|
||||
(ActiveRecordConnectionsRegistry.GetCurrentBackend = 'firebird') or
|
||||
(ActiveRecordConnectionsRegistry.GetCurrentBackend = 'interbase') or
|
||||
(ActiveRecordConnectionsRegistry.GetCurrentBackend = 'sqlite');
|
||||
|
||||
btnJSON_XML_Types.Enabled := ActiveRecordConnectionsRegistry.GetCurrentBackend = 'postgresql';
|
||||
|
@ -36,7 +36,9 @@ begin
|
||||
lClient := TMVCRESTClient.New.BaseURL('localhost', 8080);
|
||||
lClient.SetBasicAuthorization('user1', 'user1');
|
||||
lRest := lClient.Get('/admin/role1?par1=daniele');
|
||||
ShowMessage(lRest.Content);
|
||||
ShowMessage(
|
||||
Format('%d %s', [lRest.StatusCode, lRest.StatusText]) + sLineBreak +
|
||||
lRest.Content);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user