Prvni verze
This commit is contained in:
3
_custom/Kdynium/customDefs.inc
Normal file
3
_custom/Kdynium/customDefs.inc
Normal file
@ -0,0 +1,3 @@
|
||||
,uHeOObj_Custom in 'uHeOObj_Custom.pas'
|
||||
,uCtrlCustom in 'uCtrlCustom.pas'
|
||||
,uSvcCustom in 'uSvcCustom.pas'
|
||||
121
_custom/Kdynium/uCtrlCustom.pas
Normal file
121
_custom/Kdynium/uCtrlCustom.pas
Normal file
@ -0,0 +1,121 @@
|
||||
unit uCtrlCustom;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
mvcframework,
|
||||
mvcframework.Commons,
|
||||
mvcframework.Serializer.Commons,
|
||||
mvcframework.Serializer.Intf,
|
||||
System.Generics.Collections,
|
||||
System.RegularExpressions,
|
||||
System.StrUtils,
|
||||
System.SysUtils,
|
||||
JsonDataObjects,
|
||||
uCommons,
|
||||
uCtrlBase,
|
||||
uSvc_Base,
|
||||
uHeoObj_Base,
|
||||
uHeOObj_Custom,
|
||||
uSvcCustom;
|
||||
|
||||
type
|
||||
|
||||
[MVCDoc('Zdroj Nadoba')]
|
||||
[MVCPath('/planlisu')]
|
||||
TKDYPlanLisuController = class(TBaseController)
|
||||
private
|
||||
FSelfSvc: TKDYPlanLisuService;
|
||||
public
|
||||
procedure InitController;
|
||||
|
||||
[MVCDoc('Vrati metadata')]
|
||||
[MVCPath('/meta')]
|
||||
[MVCHTTPMethod([httpGET])]
|
||||
procedure GetMeta;
|
||||
|
||||
[MVCPath('/($id)')]
|
||||
[MVCHTTPMethod([httpGET])]
|
||||
[MVCSwagSummary('KDYPlanNasazeniLisu', 'Vrací data plánu nasazení lisů', 'GetByID')]
|
||||
[MVCSwagParam(plPath, 'id', 'ID plánu', ptString, true)]
|
||||
[MVCSwagParam(plPath, 'barcode', 'Barcode plánu', ptString, true)]
|
||||
[MVCSwagResponses(200, 'Success', TStavSkladu, true)]
|
||||
procedure GetByID(id: string='';
|
||||
[MVCFromQueryString('barcode', '')] barcode: string=''
|
||||
);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
implementation
|
||||
uses FireDAC.Stan.Option,
|
||||
FireDAC.Comp.Client,
|
||||
FireDAC.Stan.Param,
|
||||
MVCFramework.FireDAC.Utils,
|
||||
MVCFramework.DataSet.Utils,
|
||||
uDataMod;
|
||||
|
||||
const
|
||||
selSloupce = '';
|
||||
|
||||
{ TKDYPlanLisuController }
|
||||
|
||||
procedure TKDYPlanLisuController.InitController;
|
||||
begin
|
||||
inherited;
|
||||
if (FSelfSvc=nil) then
|
||||
FSelfSvc:= TKDYPlanLisuService.Create(datMod);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TKDYPlanLisuController.GetByID(id: string=''; barcode: string='');
|
||||
var iId: integer;
|
||||
params: TDictionary<string, string>;
|
||||
begin
|
||||
params:= TDictionary<string, string>.Create;
|
||||
|
||||
iId:= 0;
|
||||
id:= sanitizeSQLString(id);
|
||||
if not(TryStrToInt(id, iId)) then
|
||||
iId:= 0;
|
||||
if (iId>0) then
|
||||
params.Add('id', iId.ToString);
|
||||
|
||||
try
|
||||
InitController;
|
||||
|
||||
Render(ObjectDict().Add('data', FSelfSvc.GetByParams(params))); // viz uSvcCustom.pas
|
||||
except
|
||||
on E: EServiceException do
|
||||
begin
|
||||
raise EMVCException.Create(E.Message, '', 0, 404);
|
||||
end
|
||||
else
|
||||
raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TKDYPlanLisuController.GetMeta;
|
||||
begin
|
||||
try
|
||||
InitController;
|
||||
|
||||
Render(ObjectDict().Add('data', FSelfSvc.GetMeta));
|
||||
except
|
||||
on E: EServiceException do
|
||||
begin
|
||||
raise EMVCException.Create(E.Message, '', 0, 404);
|
||||
end
|
||||
else
|
||||
raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
40
_custom/Kdynium/uHeOObj_Custom.pas
Normal file
40
_custom/Kdynium/uHeOObj_Custom.pas
Normal file
@ -0,0 +1,40 @@
|
||||
unit uHeOObj_Custom;
|
||||
{$RTTI EXPLICIT METHODS([vcPublic, vcPublished]) FIELDS([vcPrivate, vcProtected, vcPublic, vcPublished]) PROPERTIES([vcPublic, vcPublished])}
|
||||
|
||||
|
||||
interface
|
||||
{$I 'GlobalDefs.inc'}
|
||||
|
||||
uses
|
||||
System.Generics.Collections,
|
||||
MVCFramework.Serializer.Commons,
|
||||
MVCFramework.ActiveRecord,
|
||||
MVCFramework.Nullables,
|
||||
{$IFDEF SWAGGER}
|
||||
MVCFramework.Swagger.Commons,
|
||||
{$ENDIF}
|
||||
helTabsBIDs,
|
||||
uHeoObj_Base;
|
||||
|
||||
const
|
||||
tblPlanNasazLisu = '[dbo].[_hdc_TabPlanNasazeniLisu]';
|
||||
tblPlanNasazLisuR = '[dbo].[_hdc_TabPlanNasazeniLisuR]';
|
||||
tblPlanNasazLisuVstr = '[dbo].[_hdc_TabPlanNasazeniLisuVstr]';
|
||||
tblPlanNasazLisuZm = '[dbo].[_hdc_TabPlanNasazeniLisuZmetky]';
|
||||
|
||||
|
||||
type
|
||||
[MVCNameCase(ncLowerCase)]
|
||||
TKDYPlanLisu = class(THeliosObjekty)
|
||||
private
|
||||
FIndexZmeny: NullableInt32;
|
||||
public
|
||||
[MVCColumn('Cislo', true)] // is PrimaryKey
|
||||
property IndexZmeny: NullableInt32 read FIndexZmeny write FIndexZmeny;
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
end.
|
||||
87
_custom/Kdynium/uSvcCustom.pas
Normal file
87
_custom/Kdynium/uSvcCustom.pas
Normal file
@ -0,0 +1,87 @@
|
||||
unit uSvcCustom;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
System.Generics.Collections,
|
||||
System.SysUtils,
|
||||
JsonDataObjects,
|
||||
uSvc_Base,
|
||||
uCommons,
|
||||
uHeoObj_Base,
|
||||
uHeOObj_Custom;
|
||||
|
||||
type
|
||||
|
||||
TKDYPlanLisuService = class(TServiceBase)
|
||||
public
|
||||
function GetAll: TObjectList<TKDYPlanLisu>;
|
||||
function GetByParams(params: TDictionary<string, string>): TObjectList<TKDYPlanLisu>;
|
||||
function GetByID (const AID: integer): TKDYPlanLisu;
|
||||
function GetMeta: TJSONObject;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
System.StrUtils,
|
||||
FireDAC.Stan.Option,
|
||||
FireDAC.Comp.Client,
|
||||
FireDAC.Stan.Param,
|
||||
MVCFramework.FireDAC.Utils,
|
||||
MVCFramework.DataSet.Utils,
|
||||
MVCFramework.Serializer.Commons,
|
||||
helTabsBIDs;
|
||||
|
||||
|
||||
{ TKDYPlanLisuService }
|
||||
|
||||
function TKDYPlanLisuService.GetAll:TObjectList<TKDYPlanLisu>;
|
||||
var lSQL: string;
|
||||
begin
|
||||
lSQL:= 'SELECT ' + GetTabCols('dbo', tblPlanNasazLisu) + ' FROM ' + tblPlanNasazLisu + ' ORDER BY ID';
|
||||
FDM.sqlQry1.Open(lSQL, []);
|
||||
result:= FDM.sqlQry1.AsObjectList<TKDYPlanLisu>;
|
||||
FDM.sqlQry1.Close;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function TKDYPlanLisuService.GetByParams(params: TDictionary<string, string>): TObjectList<TKDYPlanLisu>;
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function TKDYPlanLisuService.GetByID (const AID: integer): TKDYPlanLisu;
|
||||
var lSQL: string;
|
||||
begin
|
||||
lSQL:= 'SELECT ' + GetTabCols('dbo', tblPlanNasazLisu) + ' FROM ' + tblPlanNasazLisu + ' WHERE ID=:ID';
|
||||
FDM.sqlQry1.Open(lSQL, [AID]);
|
||||
try
|
||||
if not(FDM.sqlQry1.EOF) then
|
||||
result:= FDM.sqlQry1.AsObject<TKDYPlanLisu>
|
||||
else
|
||||
raise EServiceException.Create('Plán s ID ' + AID.ToString + ' nebyl nalezen.');
|
||||
finally
|
||||
FDM.sqlQry1.Close;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function TKDYPlanLisuService.GetMeta: TJSONObject;
|
||||
var lSQL: string;
|
||||
begin
|
||||
try
|
||||
lSQL:= 'SELECT ' + GetTabCols('dbo', tblPlanNasazLisu) + ' FROM ' + tblPlanNasazLisu + ' WHERE 1=0';
|
||||
FDM.sqlQry1.Open(lSQL);
|
||||
Result := FDM.sqlQry1.MetadataAsJSONObject();
|
||||
finally
|
||||
FDM.sqlQry1.Close;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
1
_custom/Kdynium/uWebModCustom.inc
Normal file
1
_custom/Kdynium/uWebModCustom.inc
Normal file
@ -0,0 +1 @@
|
||||
FEngine.AddController(TKDYPlanLisuController);
|
||||
Reference in New Issue
Block a user