Prvni verze

This commit is contained in:
2025-05-21 21:14:32 +02:00
commit 03ff9ebc84
147 changed files with 40100 additions and 0 deletions

180
uCtrlZamestnanci.pas Normal file
View File

@ -0,0 +1,180 @@
unit uCtrlZamestnanci;
interface
{$I 'GlobalDefs.inc'}
uses
System.Generics.Collections,
mvcframework,
mvcframework.Commons,
mvcframework.Serializer.Commons,
uCtrlBase,
uHeoObj_Base
{$IFDEF SWAGGER}
, MVCFramework.Swagger.Commons
{$ENDIF}
;
const
{$I globalConsts.inc}
type
[MVCPath('/zamestnanec')]
[MVCSwagSummary('Zam<61>stnanec', 'Zam<61>stnanci', '')]
TZamestnanciController = class(TBaseController)
public
[MVCPath('/meta')]
[MVCHTTPMethod([httpGET])]
[MVCSwagSummary('Zam<61>stnanec', 'Vrat<61> metadata', 'ZamestnanciGetMeta')]
procedure GetMeta;
// [MVCDoc('Vrati udaje zamestnance dle jeho ID')]
[MVCPath('/($id)')]
[MVCHTTPMethod([httpGET])]
[MVCSwagSummary('Zam<61>stnanec', 'Vrat<61> detail zam<61>stnance (jen jm<6A>no/p<><70>jmen<65>/tituly/st<73>edisko/zak<61>zka)', 'ZamestnanciGetByID')]
[MVCSwagParam(plPath, 'id', 'ID zam<61>stnance', ptString, true)]
[MVCSwagParam(plQuery, 'cislo', '<27><>slo zam<61>stnance', ptString, false)]
[MVCSwagParam(plQuery, 'prijm', 'P<><50>jmen<65> zam<61>stnance', ptString, false)]
[MVCSwagParam(plQuery, 'vestavu', '1=zam<61>stnanci ve stavu', ptString, false)]
[MVCSwagParam(plQuery, 'kodcipu', 'K<>d <20>ipu zam<61>stnance (max 36 znak<61>)', ptString, false)]
[MVCSwagResponses(200, 'Success', TZamestnanec)]
procedure GetByID (id: string='';
[MVCFromQueryString('cislo', '')] cislo: string='';
[MVCFromQueryString('prijm', '')] prijm: string='';
[MVCFromQueryString('vestavu', '')] veStavu: string='';
[MVCFromQueryString('kodcipu', '')] kodCipu: string=''
);
[MVCPath('')]
[MVCHTTPMethod([httpGET])]
[MVCSwagSummary('Zam<61>stnanec', 'Vrat<61> seznam zam<61>stnanc<6E>', 'ZamestnanciGetAll')]
[MVCSwagParam(plQuery, 'vestavu', '1=jen zam<61>stnance ve stavu', ptString, false)]
[MVCSwagResponses(200, 'Success', TZamestnanec, true)]
procedure GetAll ([MVCFromQueryString('vestavu', '')] veStavu: string=''
);
end;
implementation
uses
uSvc_Base,
uCommons,
mvcframework.Serializer.Intf,
System.RegularExpressions,
System.StrUtils,
System.SysUtils;
procedure TZamestnanciController.GetAll (veStavu: string= '');
var idZam, cisZam: integer;
params: TDictionary<string, string>;
begin
params:= TDictionary<string, string>.Create;
veStavu:= sanitizeSQLString(veStavu);
if (veStavu='1') then
params.Add('veStavu', veStavu);
try
Render(ObjectDict().Add('data', GetZamestnanciService.GetByParams (params)))
except
RenderStatusMessage (200);
{
on E: EServiceException do
begin
raise EMVCException.Create(E.Message, '', 0, 200);
end
else
raise;
}
end;
params.Free;
end;
procedure TZamestnanciController.GetByID (id: string=''; cislo: string=''; prijm: string=''; veStavu: string=''; kodCipu: string='');
var idZam, cisZam: integer;
params: TDictionary<string, string>;
begin
params:= TDictionary<string, string>.Create;
idZam:= 0;
id:= sanitizeSQLString(id);
if (id<>'') then
if not(TryStrToInt(id, idZam)) then
idZam:= 0;
if (idZam>0) then
params.Add('id', idZam.ToString);
cisZam:= 0;
cislo:= sanitizeSQLString(cislo);
if (cislo<>'') then
if not(TryStrToInt(cislo, cisZam)) then
cisZam:= 0;
if (cisZam>0) then
params.Add('cislo', cisZam.ToString);
prijm:= sanitizeSQLString(prijm);
if (prijm<>'') then
params.Add('prijm', prijm);
kodCipu:= sanitizeSQLString(kodCipu);
if (kodCipu<>'') then
params.Add('kodCipu', kodCipu);
veStavu:= sanitizeSQLString(veStavu);
if (veStavu<>'') then
params.Add('veStavu', veStavu);
try
Render(ObjectDict().Add('data', GetZamestnanciService.GetByParams (params)))
except
RenderStatusMessage (200);
{
on E: EServiceException do
begin
raise EMVCException.Create(E.Message, '', 0, 200);
end
else
raise;
}
end;
params.Free;
end;
procedure TZamestnanciController.GetMeta;
begin
try
Render(ObjectDict().Add('data', GetZamestnanciService.GetMeta));
except
RenderStatusMessage (200);
{
on E: EServiceException do
begin
raise EMVCException.Create(E.Message, '', 0, 200);
end
else
raise;
}
end;
end;
end.