mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2024-11-21 05:05:52 +02:00
сделал make mod
This commit is contained in:
parent
c0ecbc7947
commit
14bc84a674
1
.gitignore
vendored
1
.gitignore
vendored
@ -27,3 +27,4 @@
|
||||
/bin/templates/configs_/.env*
|
||||
/bin/notifier_service/
|
||||
|
||||
/bin/tinkoff_invest/
|
||||
|
Binary file not shown.
@ -1 +1 @@
|
||||
2024-09-12 14:54:53.250
|
||||
2024-11-19 11:05:46.755
|
@ -1 +1 @@
|
||||
00136
|
||||
00137
|
@ -354,7 +354,7 @@ func FillSettings() {
|
||||
//
|
||||
Name = "SERVICE_REPOSITORY_URL"
|
||||
s = Getenv(Name, true)
|
||||
s = strings.ToLower(s)
|
||||
//s = strings.ToLower(s)
|
||||
Settings.SERVICE_REPOSITORY_URL = s
|
||||
|
||||
//
|
||||
|
@ -3095,3 +3095,31 @@ func SnakeCase_lower(Text string) string {
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// Replace_ServiceName_CamelCase - заменяет ServiceNameTemplate на ServiceName + CamelCase
|
||||
func Replace_ServiceName_CamelCase(Text string) string {
|
||||
Otvet := Text
|
||||
|
||||
ServiceNameTemplate := config.Settings.TEMPLATE_SERVICE_NAME
|
||||
ServiceName := config.Settings.SERVICE_NAME
|
||||
|
||||
ServiceNameTemplate = FormatName(ServiceNameTemplate)
|
||||
ServiceName = FormatName(ServiceName)
|
||||
Otvet = strings.ReplaceAll(Otvet, ServiceNameTemplate, ServiceName)
|
||||
Otvet = strings.ReplaceAll(Otvet, micro.StringFromUpperCase(ServiceNameTemplate), micro.StringFromUpperCase(ServiceName))
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// Replace_ServiceName - заменяет ServiceNameTemplate на ServiceName
|
||||
func Replace_ServiceName(Text string) string {
|
||||
Otvet := Text
|
||||
|
||||
ServiceNameTemplate := config.Settings.TEMPLATE_SERVICE_NAME
|
||||
ServiceName := config.Settings.SERVICE_NAME
|
||||
|
||||
Otvet = strings.ReplaceAll(Otvet, ServiceNameTemplate, ServiceName)
|
||||
Otvet = strings.ReplaceAll(Otvet, micro.StringFromUpperCase(ServiceNameTemplate), micro.StringFromUpperCase(ServiceName))
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
@ -62,11 +62,6 @@ func CreateFileGRPCClientFunc() error {
|
||||
}
|
||||
TextGRPCClientFunc := string(bytes)
|
||||
|
||||
//заменим название сервиса
|
||||
ServiceNameTemplate := config.Settings.TEMPLATE_SERVICE_NAME
|
||||
ServiceNameNew := config.Settings.SERVICE_NAME
|
||||
TextGRPCClientFunc = strings.ReplaceAll(TextGRPCClientFunc, ServiceNameTemplate, ServiceNameNew)
|
||||
|
||||
//добавим импорты
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextGRPCClientFunc = create_files.Delete_TemplateRepositoryImports(TextGRPCClientFunc)
|
||||
@ -84,6 +79,22 @@ func CreateFileGRPCClientFunc() error {
|
||||
TextGRPCClientFunc = create_files.AddImport(TextGRPCClientFunc, GRPCConstantsURL)
|
||||
|
||||
}
|
||||
|
||||
//заменим имя сервиса на новое
|
||||
TextGRPCClientFunc = create_files.Replace_ServiceName(TextGRPCClientFunc)
|
||||
//ServiceNameTemplate := config.Settings.TEMPLATE_SERVICE_NAME
|
||||
//ServiceName := config.Settings.SERVICE_NAME
|
||||
//TextAfterImport = strings.ReplaceAll(TextAfterImport, ServiceNameTemplate, ServiceName)
|
||||
//TextAfterImport = strings.ReplaceAll(TextAfterImport, micro.StringFromUpperCase(ServiceNameTemplate), micro.StringFromUpperCase(ServiceName))
|
||||
|
||||
//заменим имя сервиса на новое с CamelCase
|
||||
TextGRPCClientFunc = create_files.Replace_ServiceName_CamelCase(TextGRPCClientFunc)
|
||||
|
||||
////заменим название сервиса
|
||||
//ServiceNameTemplate := config.Settings.TEMPLATE_SERVICE_NAME
|
||||
//ServiceNameNew := config.Settings.SERVICE_NAME
|
||||
//TextGRPCClientFunc = strings.ReplaceAll(TextGRPCClientFunc, ServiceNameTemplate, ServiceNameNew)
|
||||
|
||||
//запись файла
|
||||
err = os.WriteFile(FilenameReadyGRPCClientFunc, []byte(TextGRPCClientFunc), config.Settings.FILE_PERMISSIONS)
|
||||
|
||||
@ -122,11 +133,6 @@ func CreateFileGRPCClientFuncTest() error {
|
||||
}
|
||||
TextGRPCClientFunc := string(bytes)
|
||||
|
||||
//заменим название сервиса
|
||||
ServiceNameTemplate := config.Settings.TEMPLATE_SERVICE_NAME
|
||||
ServiceNameNew := config.Settings.SERVICE_NAME
|
||||
TextGRPCClientFunc = strings.ReplaceAll(TextGRPCClientFunc, ServiceNameTemplate, ServiceNameNew)
|
||||
|
||||
//добавим импорты
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextGRPCClientFunc = create_files.Delete_TemplateRepositoryImports(TextGRPCClientFunc)
|
||||
@ -136,6 +142,12 @@ func CreateFileGRPCClientFuncTest() error {
|
||||
TextGRPCClientFunc = create_files.AddImport(TextGRPCClientFunc, DBConstantsURL)
|
||||
|
||||
}
|
||||
|
||||
//заменим название сервиса
|
||||
ServiceNameTemplate := config.Settings.TEMPLATE_SERVICE_NAME
|
||||
ServiceNameNew := config.Settings.SERVICE_NAME
|
||||
TextGRPCClientFunc = strings.ReplaceAll(TextGRPCClientFunc, ServiceNameTemplate, ServiceNameNew)
|
||||
|
||||
//запись файла
|
||||
err = os.WriteFile(FilenameReadyGRPCClientFunc, []byte(TextGRPCClientFunc), config.Settings.FILE_PERMISSIONS)
|
||||
|
||||
|
@ -68,16 +68,18 @@ func CreateFiles_ServerGRPCStarter() error {
|
||||
}
|
||||
|
||||
//заменим имя сервиса на новое
|
||||
ServiceNameTemplate := config.Settings.TEMPLATE_SERVICE_NAME
|
||||
ServiceName := config.Settings.SERVICE_NAME
|
||||
TextAfterImport = strings.ReplaceAll(TextAfterImport, ServiceNameTemplate, ServiceName)
|
||||
TextAfterImport = strings.ReplaceAll(TextAfterImport, micro.StringFromUpperCase(ServiceNameTemplate), micro.StringFromUpperCase(ServiceName))
|
||||
TextAfterImport = create_files.Replace_ServiceName(TextAfterImport)
|
||||
//ServiceNameTemplate := config.Settings.TEMPLATE_SERVICE_NAME
|
||||
//ServiceName := config.Settings.SERVICE_NAME
|
||||
//TextAfterImport = strings.ReplaceAll(TextAfterImport, ServiceNameTemplate, ServiceName)
|
||||
//TextAfterImport = strings.ReplaceAll(TextAfterImport, micro.StringFromUpperCase(ServiceNameTemplate), micro.StringFromUpperCase(ServiceName))
|
||||
|
||||
//заменим имя сервиса на новое с CamelCase
|
||||
ServiceNameTemplate = create_files.FormatName(ServiceNameTemplate)
|
||||
ServiceName = create_files.FormatName(ServiceName)
|
||||
TextAfterImport = strings.ReplaceAll(TextAfterImport, ServiceNameTemplate, ServiceName)
|
||||
TextAfterImport = strings.ReplaceAll(TextAfterImport, micro.StringFromUpperCase(ServiceNameTemplate), micro.StringFromUpperCase(ServiceName))
|
||||
TextAfterImport = create_files.Replace_ServiceName_CamelCase(TextAfterImport)
|
||||
//ServiceNameTemplate = create_files.FormatName(ServiceNameTemplate)
|
||||
//ServiceName = create_files.FormatName(ServiceName)
|
||||
//TextAfterImport = strings.ReplaceAll(TextAfterImport, ServiceNameTemplate, ServiceName)
|
||||
//TextAfterImport = strings.ReplaceAll(TextAfterImport, micro.StringFromUpperCase(ServiceNameTemplate), micro.StringFromUpperCase(ServiceName))
|
||||
TextGRPCStarter = TextGRPCStarter[:pos1+2] + TextAfterImport
|
||||
|
||||
//удаление пустого импорта
|
||||
|
@ -24,7 +24,7 @@ func FillMapTable(SettingsFill types.SettingsFillFromDatabase) (map[string]*type
|
||||
|
||||
//заполним NameGo + TypeGo + NameGo_translit
|
||||
MapDBTypes := dbmeta.GetMappings()
|
||||
err = FillNameGoAll(MapTable, MapDBTypes)
|
||||
err = FillNameGoAll(SettingsFill, MapTable, MapDBTypes)
|
||||
|
||||
//зазполним PrimaryKeys ручные
|
||||
err = FillPrimaryKeysAll_from_MapPrimaryKeys(MapTable, types.MapPrimaryKeys)
|
||||
@ -33,14 +33,17 @@ func FillMapTable(SettingsFill types.SettingsFillFromDatabase) (map[string]*type
|
||||
}
|
||||
|
||||
// FillNameGoAll - заполняет NameGo во всех таблицах, а также NameGo_translit
|
||||
func FillNameGoAll(MapTable map[string]*types.Table, MapDBTypes map[string]*dbmeta.SQLMapping) error {
|
||||
func FillNameGoAll(SettingsFill types.SettingsFillFromDatabase, MapTable map[string]*types.Table, MapDBTypes map[string]*dbmeta.SQLMapping) error {
|
||||
var err error
|
||||
|
||||
trans := transliterator.NewTransliterator(nil)
|
||||
|
||||
for TableName, Table1 := range MapTable {
|
||||
//заполним имя колонки
|
||||
ModelName := create_files.Find_SingularName(TableName)
|
||||
ModelName := TableName
|
||||
if SettingsFill.SINGULAR_TABLE_NAMES == false {
|
||||
ModelName = create_files.Find_SingularName(TableName)
|
||||
}
|
||||
ModelName = create_files.FormatName(ModelName)
|
||||
NameGo_translit := trans.Transliterate(ModelName, "en")
|
||||
Table1.NameGo = ModelName
|
||||
|
@ -46,6 +46,7 @@ func StartFillAll() error {
|
||||
SettingsFillFromDatabase.INCLUDE_TABLES = config.Settings.INCLUDE_TABLES
|
||||
SettingsFillFromDatabase.EXCLUDE_TABLES = config.Settings.EXCLUDE_TABLES
|
||||
SettingsFillFromDatabase.NEED_USE_DB_VIEWS = config.Settings.NEED_USE_DB_VIEWS
|
||||
SettingsFillFromDatabase.SINGULAR_TABLE_NAMES = config.Settings.SINGULAR_TABLE_NAMES
|
||||
SettingsFillFromDatabase.MapDBTypes = dbmeta.GetMappings()
|
||||
MapAll, err := database.FillMapTable(SettingsFillFromDatabase)
|
||||
if err != nil {
|
||||
|
@ -97,10 +97,11 @@ var MapReadAll = make(map[*Table]bool, 0)
|
||||
|
||||
// SettingsFillFromDatabase - настройки для заполнения данных из базы данных
|
||||
type SettingsFillFromDatabase struct {
|
||||
INCLUDE_TABLES string
|
||||
EXCLUDE_TABLES string
|
||||
NEED_USE_DB_VIEWS bool
|
||||
MapDBTypes map[string]*dbmeta.SQLMapping //карта соответсвий типов в базе данных и типов в golang
|
||||
INCLUDE_TABLES string
|
||||
EXCLUDE_TABLES string
|
||||
NEED_USE_DB_VIEWS bool
|
||||
SINGULAR_TABLE_NAMES bool
|
||||
MapDBTypes map[string]*dbmeta.SQLMapping //карта соответсвий типов в базе данных и типов в golang
|
||||
//MapPrimaryKeys map[string][]string
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user