unit uCtrlCustom;

interface

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,
  MVCFramework.Swagger.Commons; // kvuli dokumentaci

type

  [MVCPath('/westra')]
  TWestraController = class(TBaseController)
{
   strict private
    FSelfSvc: TWestraService;
   strict protected
    function GetWestraService: TWestraService;
}
   public
    destructor Destroy; override;

//    [MVCDoc('Pomocí POST zapíše obecná json data do Heliosu')]
    [MVCPath('/zapisjson')] // zapis obecnych json data do Heliosu
    [MVCHTTPMethod([httpPOST])]
    [MVCSwagSummary('MBM Westra', 'Zápis JSON dat do db Heliosu', 'GORZapisJSONDoHeliosu')]
    [MVCConsumes(TMVCMediaType.APPLICATION_JSON)]
    procedure ZapisJSONDoHeliosu (CTX: TWebContext);

    [MVCPath('/nactiurl')] // zapis obecnych json data do Heliosu
    [MVCHTTPMethod([httpGET])]
    [MVCSwagSummary('MBM Westra', 'Načte data ze zadané URL adresy', 'GORNacteniDatURL')]
    [MVCSwagParam(plQuery, 'url', 'URL adresa', ptString, true)]
    procedure NactiDataZURL ([MVCFromQueryString('url', '')] sURL: string=''
                            );

  end;



implementation
uses
 FireDAC.Stan.Option,
 FireDAC.Comp.Client,
 FireDAC.Stan.Param,
 MVCFramework.FireDAC.Utils,
 MVCFramework.DataSet.Utils,
 System.StrUtils,
 System.SysUtils,
 System.JSON,
 JsonDataObjects,
 Winapi.ActiveX,
 uDataMod,
 Quick.Logger;

const
 selSloupce = '';




{ TWestraController }
 destructor TWestraController.Destroy;
  begin
//   FSelfSvc.Free;
   inherited;
  end;



 procedure TWestraController.ZapisJSONDoHeliosu (CTX: TWebContext);
  var respData, jsonData: string;
//      o: System.JSON.TJSONObject;
  begin
   respData:= '';
   try
     jsonData:= CTX.Request.Body.Trim;
     if (jsonData<>'') then
      GetWestraService.ZapisJsonDoHeliosu (jsonData, respData);
     ResponseStatus(HTTP_STATUS.OK, 'OK');
     Render(respData);
    except
     RenderStatusMessage (200);
   end;
  end;


 procedure TWestraController.NactiDataZURL (sURL: string = '');
  begin

  end;


end.
