You've already forked crud_generator
							
							
				mirror of
				https://github.com/ManyakRus/crud_generator.git
				synced 2025-10-31 00:17:48 +02:00 
			
		
		
		
	сделал constants_
This commit is contained in:
		| @@ -4,6 +4,7 @@ import ( | ||||
| 	configmain "github.com/ManyakRus/starter/config_main" | ||||
| 	"github.com/ManyakRus/starter/stopapp" | ||||
| 	"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/crud_starter" | ||||
| 	"gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/constants" | ||||
| 	"github.com/ManyakRus/starter/postgres_gorm" | ||||
| ) | ||||
|  | ||||
| @@ -18,7 +19,7 @@ func StartApp() { | ||||
|  | ||||
| 	stopapp.StartWaitStop() | ||||
| 	crud_starter.InitCrudTransport_DB() | ||||
| 	postgres_gorm.StartDB() | ||||
| 	postgres_gorm.Start(constants.SERVICE_NAME) | ||||
| 	server_grpc.Start() | ||||
| 	server_nrpc.Start() | ||||
|  | ||||
|   | ||||
| @@ -23,6 +23,9 @@ INCLUDE_TABLES="" | ||||
| #INCLUDE_TABLES - table name ignore filter. Regular expression | ||||
| EXCLUDE_TABLES="ext_" | ||||
|  | ||||
| #SINGULAR_TABLE_NAMES: true = table names will be not renamed to plural name | ||||
| SINGULAR_TABLE_NAMES=true | ||||
|  | ||||
| #---------------------Template settings--------------------- | ||||
|  | ||||
| #SERVICE_REPOSITORY_URL - URL of your new service repository (Github, gitlab, etc.) | ||||
|   | ||||
| @@ -93,6 +93,7 @@ type SettingsINI struct { | ||||
| 	READY_ALIAS_FILENAME                             string | ||||
| 	NEED_CREATE_UPDATE_EVERY_COLUMN                  bool | ||||
| 	CACHE_ELEMENTS_COUNT_MAX                         int64 | ||||
| 	SINGULAR_TABLE_NAMES                             bool | ||||
| } | ||||
|  | ||||
| func Getenv(Name string, IsRequired bool) string { | ||||
| @@ -514,6 +515,11 @@ func FillSettings() { | ||||
| 	s = Getenv(Name, true) | ||||
| 	Settings.TEMPLATES_CONSTANTS_FILENAME = s | ||||
|  | ||||
| 	// | ||||
| 	Name = "SINGULAR_TABLE_NAMES" | ||||
| 	s = Getenv(Name, true) | ||||
| 	Settings.SINGULAR_TABLE_NAMES = BoolFromString(s) | ||||
|  | ||||
| } | ||||
|  | ||||
| // CurrentDirectory - возвращает текущую директорию ОС | ||||
|   | ||||
| @@ -1964,3 +1964,17 @@ func FindRequestColumnName(Table1 *types.Table, Column1 *types.Column) string { | ||||
|  | ||||
| 	return Otvet | ||||
| } | ||||
|  | ||||
| // ReplaceConnect_WithApplicationName - заменяет Connect_WithApplicationName() на Connect_WithApplicationName_SingularTableName() | ||||
| func ReplaceConnect_WithApplicationName(Text string) string { | ||||
| 	Otvet := Text | ||||
|  | ||||
| 	if config.Settings.SINGULAR_TABLE_NAMES == false { | ||||
| 		return Otvet | ||||
| 	} | ||||
|  | ||||
| 	Otvet = strings.ReplaceAll(Otvet, "postgres_gorm.Connect_WithApplicationName(", "postgres_gorm.Connect_WithApplicationName_SingularTableName(") | ||||
| 	Otvet = strings.ReplaceAll(Otvet, "postgres_gorm.Start(", "postgres_gorm.Start_SingularTableName(") | ||||
|  | ||||
| 	return Otvet | ||||
| } | ||||
|   | ||||
| @@ -240,6 +240,9 @@ func CreateFilesTest(Table1 *types.Table) error { | ||||
| 		//добавим импорт uuid | ||||
| 		TextDB = create_files.CheckAndAddImportUUID_FromText(TextDB) | ||||
|  | ||||
| 		//замена "postgres_gorm.Connect_WithApplicationName(" | ||||
| 		TextDB = create_files.ReplaceConnect_WithApplicationName(TextDB) | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	//создание текста | ||||
| @@ -726,6 +729,9 @@ func CreateFilesUpdateEveryColumnTest(Table1 *types.Table) error { | ||||
| 		ConstantsURL := create_files.FindConstantsURL() | ||||
| 		TextCrud = create_files.AddImport(TextCrud, ConstantsURL) | ||||
|  | ||||
| 		//замена "postgres_gorm.Connect_WithApplicationName(" | ||||
| 		TextCrud = create_files.ReplaceConnect_WithApplicationName(TextCrud) | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	//создание текста | ||||
| @@ -933,6 +939,9 @@ func CreateFilesCacheTest(Table1 *types.Table) error { | ||||
| 		ConstantsURL := create_files.FindConstantsURL() | ||||
| 		TextCache = create_files.AddImport(TextCache, ConstantsURL) | ||||
|  | ||||
| 		//замена "postgres_gorm.Connect_WithApplicationName(" | ||||
| 		TextCache = create_files.ReplaceConnect_WithApplicationName(TextCache) | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	//замена слов | ||||
|   | ||||
| @@ -68,6 +68,13 @@ func CreateFileMain() error { | ||||
|  | ||||
| 		URLCrudStarter := create_files.FindCrudStarterURL() | ||||
| 		TextMain = create_files.AddImport(TextMain, URLCrudStarter) | ||||
|  | ||||
| 		ConstantsURL := create_files.FindConstantsURL() | ||||
| 		TextMain = create_files.AddImport(TextMain, ConstantsURL) | ||||
|  | ||||
| 		//замена "postgres_gorm.Start(" | ||||
| 		TextMain = create_files.ReplaceConnect_WithApplicationName(TextMain) | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	//замена импортов на новые URL | ||||
|   | ||||
| @@ -216,6 +216,9 @@ func CreateFilesTest(Table1 *types.Table) error { | ||||
|  | ||||
| 		TextGRPCServer = create_files.CheckAndAddImport(TextGRPCServer, "encoding/json") | ||||
|  | ||||
| 		//замена "postgres_gorm.Connect_WithApplicationName(" | ||||
| 		TextGRPCServer = create_files.ReplaceConnect_WithApplicationName(TextGRPCServer) | ||||
|  | ||||
| 		//Postgres_ID_Test = ID Minimum | ||||
| 		TextGRPCServer = create_files.Replace_Model_ID_Test(TextGRPCServer, Table1) | ||||
|  | ||||
| @@ -590,6 +593,9 @@ func CreateFilesUpdateEveryColumnTest(Table1 *types.Table) error { | ||||
| 		ConstantsURL := create_files.FindConstantsURL() | ||||
| 		TextGRPCServer = create_files.AddImport(TextGRPCServer, ConstantsURL) | ||||
|  | ||||
| 		//замена "postgres_gorm.Connect_WithApplicationName(" | ||||
| 		TextGRPCServer = create_files.ReplaceConnect_WithApplicationName(TextGRPCServer) | ||||
|  | ||||
| 		//TextGRPCServer = create_files.ConvertRequestIdToAlias(TextGRPCServer, Table1) | ||||
| 	} | ||||
|  | ||||
| @@ -806,6 +812,9 @@ func CreateFilesCacheTest(Table1 *types.Table) error { | ||||
| 		ConstantsURL := create_files.FindConstantsURL() | ||||
| 		TextGRPCServer = create_files.AddImport(TextGRPCServer, ConstantsURL) | ||||
|  | ||||
| 		//замена "postgres_gorm.Connect_WithApplicationName(" | ||||
| 		TextGRPCServer = create_files.ReplaceConnect_WithApplicationName(TextGRPCServer) | ||||
|  | ||||
| 		//замена RequestId{} | ||||
| 		TextGRPCServer = create_files.ReplaceTextRequestID_PrimaryKey(TextGRPCServer, Table1) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user