1
0
mirror of https://github.com/ManyakRus/crud_generator.git synced 2025-01-12 20:20:54 +02:00

сделал settings.txt

This commit is contained in:
Nikitin Aleksandr 2023-11-10 15:04:05 +03:00
parent 4f0a800b67
commit 895e17b632
9 changed files with 122 additions and 16 deletions

108
bin/settings.txt Normal file
View File

@ -0,0 +1,108 @@
#---------------------Database settings---------------------
#DB_HOST - Database server name or ip-address. Only Postgres SQL
DB_HOST=
#DB_NAME - Database table name
DB_NAME=
#DB_SCHEME - Database schema name
DB_SCHEME=
#DB_PORT - Database port number
DB_PORT="5432"
#DB_USER - Database login (user)
DB_USER=
#DB_PASSWORD - Database login password
DB_PASSWORD=
#INCLUDE_TABLES - table name filter. Regular expression
INCLUDE_TABLES=""
#INCLUDE_TABLES - table name ignore filter. Regular expression
EXCLUDE_TABLES=""
#---------------------Template settings---------------------
#SERVICE_REPOSITORY_URL - URL of your new service repository (Github, gitlab, etc.)
SERVICE_REPOSITORY_URL="gitlab.aescorp.ru/dsp_dev/claim/sync_service"
#SERVICE_NAME - service name for your new service
SERVICE_NAME=sync_service
#TEMPLATE_SERVICE_NAME - service name in your template files
TEMPLATE_SERVICE_NAME=Sync_service
#same folder names uses for read template files and create new files
#TEMPLATE_FOLDERNAME - filder name in your computer with templates
TEMPLATE_FOLDERNAME="templates"
#TEMPLATE_FOLDERNAME_MODEL - folder name for create models (golang struct with all table fields)
TEMPLATE_FOLDERNAME_MODEL="pkg/object_model/entities"
#TEMPLATE_FOLDERNAME_DB - folder name for create database crud operations
TEMPLATE_FOLDERNAME_DB="pkg/db"
#TEMPLATE_FOLDERNAME_GRPC - folder name for create .proto file
TEMPLATE_FOLDERNAME_GRPC="pkg/network/grpc"
#TEMPLATE_FOLDERNAME_GRPC_SERVER - filder name for create grpc server files
TEMPLATE_FOLDERNAME_GRPC_SERVER="internal/server_grpc"
#TEMPLATE_FOLDERNAME_GRPC_CLIENT - folder name for create grpc client files
TEMPLATE_FOLDERNAME_GRPC_CLIENT="grpc_client"
#TEMPLATE_FOLDERNAME_NRPC_SERVER - folder name for create nrpc server files
TEMPLATE_FOLDERNAME_NRPC_SERVER="internal/server_nrpc"
#TEMPLATE_FOLDERNAME_NRPC - folder name for create common nrpc files
TEMPLATE_FOLDERNAME_NRPC="pkg/network/nrpc"
#TEMPLATE_FOLDERNAME_NRPC_CLIENT - foldr name for create nrpc client files
TEMPLATE_FOLDERNAME_NRPC_CLIENT="pkg/network/nrpc/nrpc_client"
#TEMPLATE_FOLDERNAME_CRUD_STARTER - folder name for create crud_starter.go file
TEMPLATE_FOLDERNAME_CRUD_STARTER="pkg/crud_starter"
#TEMPLATE_FOLDERNAME_ALIAS - folder name for create alias.go file, with go types with aliases
TEMPLATE_FOLDERNAME_ALIAS="pkg/object_model/types/alias"
#TEXT_TEMPLATE_MODEL - model name text in templates, for replace to new model names
TEXT_TEMPLATE_MODEL="LawsuitStatusType"
#TEXT_TEMPLATE_TABLENAME - table name text in tamplates, for replace to new table names
TEXT_TEMPLATE_TABLENAME="lawsuit_status_types"
#USE_DEFAULT_TEMPLATE - "true" will do default text replaces. "false" - for use own templates
USE_DEFAULT_TEMPLATE=true
#HAS_IS_DELETED - fill "true" if you have "is_deleted" column, and want Delete() Restore() functions.
HAS_IS_DELETED=true
#---------------------Create files settings---------------------
#NEED_CREATE_CRUD - fill "true" if you want create crud operations files
NEED_CREATE_CRUD=true
#NEED_CREATE_GRPC - fill "true" if you want create grpc operations files
NEED_CREATE_GRPC=true
#NEED_CREATE_NRPC - fill "true" if you want create nrpc operations files (need NATS message query server)
NEED_CREATE_NRPC=true
#NEED_CREATE_MODEL_STRUCT - fill "true" if you want create model files with golang struct with all database fields
NEED_CREATE_MODEL_STRUCT=true
#NEED_CREATE_MODEL_CRUD - fill "true" if you want create crud operations in model files
NEED_CREATE_MODEL_CRUD=true
#PREFIX_SERVER_GRPC - filename prefix for grpc server files
PREFIX_SERVER_GRPC="server_grpc_"
#COMMENT_MODEL_STRUCT - fill comments to every model structure
COMMENT_MODEL_STRUCT="модель для таблицы "
#TEXT_MODULE_GENERATED - comment text for every module file
TEXT_MODULE_GENERATED="//File generated automatic with crud_generator app\n//Do not change anything here.\n"

View File

@ -41,6 +41,7 @@ type SettingsINI struct {
USE_DEFAULT_TEMPLATE bool
PREFIX_SERVER_GRPC string
COMMENT_MODEL_STRUCT string
TEXT_MODULE_GENERATED string
}
// FillSettings загружает переменные окружения в структуру из переменных окружения
@ -105,6 +106,8 @@ func FillSettings() {
HAS_IS_DELETED := BoolFromString(sHAS_IS_DELETED)
Settings.HAS_IS_DELETED = HAS_IS_DELETED
Settings.COMMENT_MODEL_STRUCT = os.Getenv("COMMENT_MODEL_STRUCT")
Settings.TEXT_MODULE_GENERATED = os.Getenv("TEXT_MODULE_GENERATED")
}
// CurrentDirectory - возвращает текущую директорию ОС

View File

@ -9,8 +9,3 @@ Need create .env file with settings
//const FolderReady string = "ready"
const FILE_PERMISSIONS = 0666
const TEXT_GENERATED = `//File generated automatic with crud_generator app
//Do not change anything here.
`

View File

@ -51,7 +51,7 @@ func CreateFileCrudStarter(MapAll map[string]*types.Table) error {
////заменим название сервиса
//TextCrudStarter = strings.ReplaceAll(TextCrudStarter, config.Settings.TEMPLATE_SERVICE_NAME, config.Settings.SERVICE_NAME)
TextCrudStarter := constants.TEXT_GENERATED + `package crud_starter`
TextCrudStarter := config.Settings.TEXT_MODULE_GENERATED + `package crud_starter`
//найдём новый текст для каждой таблицы
RepositoryURL := config.Settings.SERVICE_REPOSITORY_URL

View File

@ -77,7 +77,7 @@ func CreateFiles(Table1 *types.Table) error {
ModelName := Table1.NameGo
TextDB = strings.ReplaceAll(TextDB, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
TextDB = strings.ReplaceAll(TextDB, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
TextDB = constants.TEXT_GENERATED + TextDB
TextDB = config.Settings.TEXT_MODULE_GENERATED + TextDB
if config.Settings.HAS_IS_DELETED == true {
TextDB = DeleteFuncDelete(TextDB, Table1)
@ -134,7 +134,7 @@ func CreateTestFiles(Table1 *types.Table) error {
ModelName := Table1.NameGo
TextDB = strings.ReplaceAll(TextDB, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
TextDB = strings.ReplaceAll(TextDB, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
TextDB = constants.TEXT_GENERATED + TextDB
TextDB = config.Settings.TEXT_MODULE_GENERATED + TextDB
if config.Settings.HAS_IS_DELETED == true {
TextDB = DeleteFuncTestDelete(TextDB, Table1)

View File

@ -76,7 +76,7 @@ func CreateFiles(Table1 *types.Table) error {
ModelName := Table1.NameGo
TextDB = strings.ReplaceAll(TextDB, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
TextDB = strings.ReplaceAll(TextDB, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
TextDB = constants.TEXT_GENERATED + TextDB
TextDB = config.Settings.TEXT_MODULE_GENERATED + TextDB
if config.Settings.HAS_IS_DELETED == true {
TextDB = DeleteFuncDelete(TextDB, ModelName, Table1)
@ -127,7 +127,7 @@ func CreateTestFiles(Table1 *types.Table) error {
ModelName := Table1.NameGo
TextDB = strings.ReplaceAll(TextDB, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
TextDB = strings.ReplaceAll(TextDB, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
TextDB = constants.TEXT_GENERATED + TextDB
TextDB = config.Settings.TEXT_MODULE_GENERATED + TextDB
if config.Settings.HAS_IS_DELETED == true {
TextDB = DeleteFuncTestDelete(TextDB, ModelName, Table1)

View File

@ -67,7 +67,7 @@ func CreateFiles(Table1 *types.Table) error {
ModelName := Table1.NameGo
TextDB = strings.ReplaceAll(TextDB, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
TextDB = strings.ReplaceAll(TextDB, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
TextDB = constants.TEXT_GENERATED + TextDB
TextDB = config.Settings.TEXT_MODULE_GENERATED + TextDB
if config.Settings.USE_DEFAULT_TEMPLATE == true {
if config.Settings.HAS_IS_DELETED == true {
@ -112,7 +112,7 @@ func CreateTestFiles(Table1 *types.Table) error {
ModelName := Table1.NameGo
TextDB = strings.ReplaceAll(TextDB, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
TextDB = strings.ReplaceAll(TextDB, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
TextDB = constants.TEXT_GENERATED + TextDB
TextDB = config.Settings.TEXT_MODULE_GENERATED + TextDB
if config.Settings.HAS_IS_DELETED == true {
TextDB = DeleteFuncTestDelete(TextDB, ModelName, Table1)

View File

@ -93,7 +93,7 @@ func CreateFilesModel_struct(Table1 *types.Table, DirTemplatesModel, DirReadyMod
//
TextModel = strings.ReplaceAll(TextModel, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
TextModel = strings.ReplaceAll(TextModel, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
TextModel = constants.TEXT_GENERATED + TextModel
TextModel = config.Settings.TEXT_MODULE_GENERATED + TextModel
if config.Settings.HAS_IS_DELETED == true {
TextModel = DeleteFuncDelete(TextModel, ModelName, Table1)
@ -132,7 +132,7 @@ func CreateFilesModel_crud(Table1 *types.Table, DirTemplatesModel, DirReadyModel
//
TextModel = strings.ReplaceAll(TextModel, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
TextModel = strings.ReplaceAll(TextModel, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
TextModel = constants.TEXT_GENERATED + TextModel
TextModel = config.Settings.TEXT_MODULE_GENERATED + TextModel
if config.Settings.HAS_IS_DELETED == true {
TextModel = DeleteFuncDelete(TextModel, ModelName, Table1)

View File

@ -76,7 +76,7 @@ func CreateFiles(Table1 *types.Table) error {
ModelName := Table1.NameGo
TextDB = strings.ReplaceAll(TextDB, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
TextDB = strings.ReplaceAll(TextDB, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
TextDB = constants.TEXT_GENERATED + TextDB
TextDB = config.Settings.TEXT_MODULE_GENERATED + TextDB
if config.Settings.HAS_IS_DELETED == true {
TextDB = DeleteFuncDelete(TextDB, ModelName, Table1)
@ -127,7 +127,7 @@ func CreateTestFiles(Table1 *types.Table) error {
ModelName := Table1.NameGo
TextDB = strings.ReplaceAll(TextDB, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
TextDB = strings.ReplaceAll(TextDB, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
TextDB = constants.TEXT_GENERATED + TextDB
TextDB = config.Settings.TEXT_MODULE_GENERATED + TextDB
if config.Settings.HAS_IS_DELETED == true {
TextDB = DeleteFuncTestDelete(TextDB, ModelName, Table1)