307 lines
6.6 KiB
ObjectPascal
307 lines
6.6 KiB
ObjectPascal
unit uCtrlCustom;
|
|
|
|
interface
|
|
{$I 'GlobalDefs.inc'}
|
|
|
|
uses
|
|
MVCframework,
|
|
MVCframework.Commons,
|
|
MVCframework.Serializer.Commons,
|
|
// MVCframework.Serializer.Intf,
|
|
System.Generics.Collections, // kvuli TDictionary
|
|
System.RegularExpressions,
|
|
// JsonDataObjects,
|
|
uCommons, // kvuli EServiceException
|
|
uCtrlBase,
|
|
// uSvc_Base,
|
|
helTabsBIDs,
|
|
uHeoObj_Base,
|
|
uHeOObj_Custom,
|
|
uSvcCustom,
|
|
uSvc_Obecne,
|
|
MVCFramework.Swagger.Commons; // kvuli dokumentaci
|
|
|
|
const
|
|
{$I .\..\..\globalConsts.inc}
|
|
|
|
|
|
type
|
|
|
|
[MVCPath('/emp/nadoba')]
|
|
TEMPNadobaController = class(TBaseController)
|
|
public
|
|
|
|
[MVCPath('')]
|
|
[MVCSwagSummary('EMP - vyrábìné nádoby', 'Vrátí seznam nádob', 'EMPNadobaGetByCislo')]
|
|
[MVCHTTPMethod([httpGET])]
|
|
[MVCSwagParam(plQuery, 'cislo', 'Èíslo nádoby', ptString, false, '1')]
|
|
procedure GetByCislo ([MVCFromQueryString('cislo', '')] cislo: string
|
|
);
|
|
|
|
[MVCPath('/meta')]
|
|
[MVCHTTPMethod([httpGET])]
|
|
[MVCSwagSummary('EMP - vyrábìné nádoby', 'Meta informace seznamu nádob', 'EMPNadobaGetMeta')]
|
|
procedure GetMeta;
|
|
|
|
[MVCPath('/($id)')]
|
|
[MVCHTTPMethod([httpGET])]
|
|
[MVCSwagSummary('EMP - vyrábìné nádoby', 'Vrátí údaje nádoby dle jejího ID', 'EMPNadobaGetByID')]
|
|
[MVCSwagParam(plPath, 'id', 'ID nádoby', ptString, true)]
|
|
[MVCProduces('application/json')]
|
|
procedure GetByID (id: string);
|
|
end;
|
|
|
|
|
|
|
|
|
|
[MVCPath('/emp/atest')]
|
|
TEMPDokumentAtestController = class(TBaseController)
|
|
private
|
|
FDokumService: TDokumentService;
|
|
public
|
|
constructor Create; override;
|
|
destructor Destroy; override;
|
|
|
|
[MVCPath('/meta')]
|
|
[MVCHTTPMethod([httpGET])]
|
|
[MVCSwagSummary('EMP - dokumenty atestù', 'Meta informace dokumentu atestu', 'EMPDokumAtestGetMeta')]
|
|
procedure GetMeta;
|
|
|
|
[MVCPath('/($id)')]
|
|
[MVCHTTPMethod([httpGET])]
|
|
[MVCSwagSummary('EMP - dokumenty atestù', 'Vrátí údaje dokumentu atestu dle jeho ID', 'EMPDokumAtestGetByID')]
|
|
[MVCSwagParam(plPath, 'id', 'ID dokumentu atestu', ptString, true)]
|
|
[MVCProduces('application/json')]
|
|
procedure GetByID (id: string);
|
|
|
|
end;
|
|
|
|
[MVCPath('/emp/vytezeni')]
|
|
TEMPVytezeniDoklController = class(TBaseController)
|
|
private
|
|
FSelfSvc: TEMPVytezeniDoklService;
|
|
public
|
|
constructor Create; override;
|
|
destructor Destroy; override;
|
|
|
|
[MVCPath('/fprij/post/($id)')]
|
|
[MVCHTTPMethod([httpGET])]
|
|
[MVCSwagSummary('EMP - vytìžení dokumentù dokladu FaktPrij', 'Pošle dokument dokladu Faktury pøijaté na AiDOCU API', 'EMPVytezDokFPrijPostByID')]
|
|
[MVCSwagParam(plPath, 'id', 'ID dokladu Faktury pøijaté', ptString, true)]
|
|
[MVCProduces('application/json')]
|
|
procedure FPrij_PostByID (id: string);
|
|
end;
|
|
|
|
|
|
implementation
|
|
uses
|
|
System.SysUtils,
|
|
FireDAC.Stan.Option,
|
|
FireDAC.Comp.Client,
|
|
FireDAC.Stan.Param,
|
|
MVCFramework.FireDAC.Utils,
|
|
MVCFramework.DataSet.Utils,
|
|
uDataMod;
|
|
|
|
|
|
{ TEMPNadobaController }
|
|
|
|
procedure TEMPNadobaController.GetByCislo (cislo: string);
|
|
begin
|
|
cislo:= sanitizeSQLString (cislo);
|
|
|
|
try
|
|
if (cislo<>'') then
|
|
Render(ObjectDict().Add('data', GetEMPNadobaService.GetByCislo (cislo)))
|
|
else
|
|
Render(ObjectDict().Add('data', GetEMPNadobaService.GetAll));
|
|
except
|
|
// RenderStatusMessage (200);
|
|
{
|
|
on E: EServiceException do
|
|
begin
|
|
raise EMVCException.Create(E.Message, '', 0, 200);
|
|
end
|
|
}
|
|
on E:Exception do
|
|
begin
|
|
Writeln(E.Message);
|
|
raise EMVCException.Create(E.Message, '', 0, 200);
|
|
end;
|
|
// RenderStatusMessage (200); // raise;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TEMPNadobaController.GetByID (id: string);
|
|
var iId: integer;
|
|
begin
|
|
id:= sanitizeSQLString (id);
|
|
if not(TryStrToInt(id, iId)) then
|
|
iId:= 0;
|
|
|
|
try
|
|
Render(ObjectDict().Add('data', GetEMPNadobaService.GetByID (iId))); // viz uSvc_Custom1.pas
|
|
except
|
|
// RenderStatusMessage (200);
|
|
{
|
|
on E: EServiceException do
|
|
begin
|
|
raise EMVCException.Create(E.Message, '', 0, 200);
|
|
end
|
|
}
|
|
on E:Exception do
|
|
begin
|
|
Writeln(E.Message);
|
|
raise EMVCException.Create(E.Message, '', 0, 200);
|
|
end;
|
|
// RenderStatusMessage (200); // raise;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
procedure TEMPNadobaController.GetMeta;
|
|
begin
|
|
try
|
|
Render(ObjectDict().Add('data', GetEMPNadobaService.GetMeta));
|
|
except
|
|
// RenderStatusMessage (200);
|
|
{
|
|
on E: EServiceException do
|
|
begin
|
|
raise EMVCException.Create(E.Message, '', 0, 200);
|
|
end
|
|
}
|
|
on E:Exception do
|
|
begin
|
|
Writeln(E.Message);
|
|
raise EMVCException.Create(E.Message, '', 0, 200);
|
|
end;
|
|
// RenderStatusMessage (200); // raise;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ TEMPDokumentAtestController }
|
|
|
|
constructor TEMPDokumentAtestController.Create;
|
|
begin
|
|
inherited;
|
|
FDokumService:= GetDokumentService;
|
|
end;
|
|
|
|
|
|
|
|
|
|
destructor TEMPDokumentAtestController.Destroy;
|
|
begin
|
|
if (FDokumService<>nil) then
|
|
FreeAndNil (FDokumService);
|
|
inherited;
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TEMPDokumentAtestController.GetMeta;
|
|
begin
|
|
try
|
|
Render(ObjectDict().Add('data', GetDokumentService.GetMeta));
|
|
except
|
|
{$IFDEF NORENDER400}
|
|
RenderStatusMessage (200);
|
|
{$ELSE}
|
|
on E: EServiceException do
|
|
begin
|
|
raise EMVCException.Create(E.Message, '', 0, 404);
|
|
end
|
|
else
|
|
raise;
|
|
{$ENDIF}
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
procedure TEMPDokumentAtestController.GetByID (id: string);
|
|
var iId: integer;
|
|
p: TDictionary<string, string>;
|
|
begin
|
|
id:= sanitizeSQLString (id);
|
|
if not(TryStrToInt(id, iId)) then
|
|
iId:= 0;
|
|
|
|
p:= TDictionary<string, string>.Create;
|
|
|
|
try
|
|
Render(ObjectDict().Add('data', GetDokumentService.GetByID (iId, true))) // viz uSvc_Custom1.pas
|
|
except
|
|
{$IFDEF NORENDER400}
|
|
RenderStatusMessage (200);
|
|
{$ELSE}
|
|
on E: EServiceException do
|
|
begin
|
|
raise EMVCException.Create(E.Message, '', 0, 404);
|
|
end
|
|
else
|
|
raise;
|
|
{$ENDIF}
|
|
end;
|
|
|
|
p.Free;
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ TEMPVytezeniDoklService }
|
|
|
|
constructor TEMPVytezeniDoklController.Create;
|
|
begin
|
|
inherited;
|
|
end;
|
|
|
|
|
|
|
|
destructor TEMPVytezeniDoklController.Destroy;
|
|
begin
|
|
inherited;
|
|
end;
|
|
|
|
|
|
procedure TEMPVytezeniDoklController.FPrij_PostByID (id: string);
|
|
var iId: integer;
|
|
begin
|
|
id:= sanitizeSQLString (id);
|
|
if not(TryStrToInt(id, iId)) then
|
|
iId:= 0;
|
|
|
|
try
|
|
Render(ObjectDict().Add('data', GetEMPVytezeniDoklService.FPrij_PostByID (iId))); // viz uSvcCustom.pas
|
|
except
|
|
{$IFDEF NORENDER400}
|
|
RenderStatusMessage (200);
|
|
{$ELSE}
|
|
on E: EServiceException do
|
|
begin
|
|
raise EMVCException.Create(E.Message, '', 0, 404);
|
|
end
|
|
else
|
|
raise;
|
|
{$ENDIF}
|
|
end;
|
|
end;
|
|
|
|
|
|
end.
|
|
|