Prvni verze
This commit is contained in:
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.
|
||||
Reference in New Issue
Block a user