2024-04-16 00:22:41 +02:00
|
|
|
// ***************************************************************************
|
|
|
|
//
|
|
|
|
// Delphi MVC Framework
|
|
|
|
//
|
|
|
|
// Copyright (c) 2010-2024 Daniele Teti and the DMVCFramework Team
|
|
|
|
//
|
|
|
|
// https://github.com/danieleteti/delphimvcframework
|
|
|
|
//
|
|
|
|
// ***************************************************************************
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
// ***************************************************************************
|
|
|
|
|
2024-04-12 12:28:34 +02:00
|
|
|
unit DMVC.Expert.Commons;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2024-04-16 11:09:02 +02:00
|
|
|
MVCFramework.Commons, System.SysUtils, JsonDataObjects, ToolsAPI;
|
2024-04-12 12:28:34 +02:00
|
|
|
|
|
|
|
type
|
|
|
|
IGenCommand = interface
|
|
|
|
['{B5F6B048-FB5A-48EA-80F9-D8395B4DE40D}']
|
|
|
|
procedure ExecuteInterface(Section: TStringBuilder; Model: TJSONObject);
|
|
|
|
procedure ExecuteImplementation(Section: TStringBuilder; Model: TJSONObject);
|
|
|
|
end;
|
|
|
|
|
|
|
|
TCustomCommand = class abstract(TInterfacedObject, IGenCommand)
|
|
|
|
protected
|
|
|
|
procedure CheckFor(const Key: String; Model: TJSONObject);
|
|
|
|
public
|
|
|
|
procedure ExecuteInterface(Section: TStringBuilder; Model: TJSONObject); virtual; abstract;
|
|
|
|
procedure ExecuteImplementation(Section: TStringBuilder; Model: TJSONObject); virtual; abstract;
|
|
|
|
end;
|
|
|
|
|
2024-04-16 00:22:41 +02:00
|
|
|
TDefaultValues = class sealed
|
|
|
|
public
|
|
|
|
const sDefaultControllerName = 'TMyController';
|
|
|
|
const sDefaultWebModuleName = 'TMyWebModule';
|
|
|
|
const sDefaultServerPort = '8080';
|
|
|
|
end;
|
|
|
|
|
2024-04-12 12:28:34 +02:00
|
|
|
TConfigKey = class sealed
|
|
|
|
public const
|
|
|
|
program_name = 'program.name';
|
|
|
|
program_default_server_port= 'program.default_server_port';
|
|
|
|
program_msheap='program.msheap';
|
2024-05-10 16:16:47 +02:00
|
|
|
program_sqids='program.sqids';
|
2024-04-19 15:58:19 +02:00
|
|
|
program_dotenv='program.dotenv';
|
2024-08-24 16:32:38 +02:00
|
|
|
program_ssv_templatepro='program.ssv.templatepro';
|
2024-10-14 09:21:56 +02:00
|
|
|
program_ssv_webstencils='program.ssv.webstencils';
|
2024-04-29 13:35:07 +02:00
|
|
|
program_ssv_mustache='program.ssv.mustache';
|
2024-04-29 17:49:54 +02:00
|
|
|
program_service_container_generate = 'program.service.container.generate';
|
|
|
|
program_service_container_unit_name = 'program.service.container.unit_name';
|
2024-04-29 13:35:07 +02:00
|
|
|
mustache_helpers_unit_name = 'mustache.helpers_unit_name';
|
2024-08-24 16:32:38 +02:00
|
|
|
templatepro_helpers_unit_name = 'templatepro.helpers_unit_name';
|
2024-10-14 09:21:56 +02:00
|
|
|
webstencils_helpers_unit_name = 'webstencils.helpers_unit_name';
|
2024-04-12 12:28:34 +02:00
|
|
|
controller_unit_name='controller.unit_name';
|
|
|
|
controller_classname= 'controller.classname';
|
|
|
|
controller_index_methods_generate= 'controller.index_methods.generate';
|
|
|
|
controller_action_filters_generate= 'controller.action_filters.generate';
|
|
|
|
controller_crud_methods_generate= 'controller.crud_methods.generate';
|
2024-04-19 18:19:08 +02:00
|
|
|
controller_actions_profiling_generate= 'controller.actions.profiling.generate';
|
2024-04-12 12:28:34 +02:00
|
|
|
entity_generate= 'entity.generate';
|
|
|
|
entity_classname= 'entity.classname';
|
2024-04-29 17:49:54 +02:00
|
|
|
entity_unit_name='entity.unit_name';
|
2024-04-12 12:28:34 +02:00
|
|
|
jsonrpc_generate= 'jsonrpc.generate';
|
|
|
|
jsonrpc_classname= 'jsonrpc.classname';
|
|
|
|
jsonrpc_unit_name='jsonrpc.unit_name';
|
2024-06-09 23:53:25 +02:00
|
|
|
serializer_name_case= 'serializer.name_case';
|
2024-04-12 12:28:34 +02:00
|
|
|
webmodule_classname= 'webmodule.classname';
|
|
|
|
webmodule_unit_name= 'webmodule.unit_name';
|
|
|
|
webmodule_middleware_analytics= 'webmodule.middleware.analytics';
|
|
|
|
webmodule_middleware_staticfiles= 'webmodule.middleware.staticfiles';
|
|
|
|
webmodule_middleware_trace= 'webmodule.middleware.trace';
|
|
|
|
webmodule_middleware_compression= 'webmodule.middleware.compression';
|
|
|
|
webmodule_middleware_etag= 'webmodule.middleware.etag';
|
|
|
|
webmodule_middleware_cors= 'webmodule.middleware.cors';
|
|
|
|
webmodule_middleware_activerecord= 'webmodule.middleware.activerecord';
|
|
|
|
webmodule_middleware_activerecord_con_def_name= 'webmodule.middleware.activerecord.con_def_name';
|
|
|
|
webmodule_middleware_activerecord_con_def_filename= 'webmodule.middleware.activerecord.con_def_filename';
|
|
|
|
end;
|
|
|
|
|
2024-04-16 11:09:02 +02:00
|
|
|
procedure ChangeIOTAModuleFileNamePrefix(const IOTA: IOTAModule; const FileNamePrefix: String);
|
|
|
|
|
2024-04-12 12:28:34 +02:00
|
|
|
implementation
|
|
|
|
|
2024-04-16 11:09:02 +02:00
|
|
|
uses
|
|
|
|
System.IOUtils;
|
|
|
|
|
2024-04-12 12:28:34 +02:00
|
|
|
{ TCustomCommand }
|
|
|
|
|
|
|
|
procedure TCustomCommand.CheckFor(const Key: String;
|
|
|
|
Model: TJSONObject);
|
|
|
|
begin
|
|
|
|
if (not Model.Contains(Key)) or Model.S[Key].IsEmpty then
|
|
|
|
begin
|
|
|
|
raise Exception.CreateFmt('Required key "%s" not found or empty while processing %s', [Key, ClassName]);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2024-04-16 11:09:02 +02:00
|
|
|
procedure ChangeIOTAModuleFileNamePrefix(const IOTA: IOTAModule; const FileNamePrefix: String);
|
|
|
|
var
|
|
|
|
lDirName: string;
|
|
|
|
lFileName: string;
|
|
|
|
lFileExt: string;
|
|
|
|
begin
|
|
|
|
lDirName := TPath.GetDirectoryName(IOTA.FileName);
|
|
|
|
lFileName := TPath.GetFileNameWithoutExtension(IOTA.FileName);
|
|
|
|
lFileExt := TPath.GetExtension(IOTA.FileName);
|
|
|
|
lFileName := FileNamePrefix;
|
2024-04-19 13:21:45 +02:00
|
|
|
// IOTA.FileName := TPath.Combine(lDirName, lFileName + lFileExt);
|
|
|
|
// IOTA.Refresh(False);
|
2024-04-16 11:09:02 +02:00
|
|
|
end;
|
|
|
|
|
2024-04-12 12:28:34 +02:00
|
|
|
end.
|