diff --git a/bin/notifier_service/pkg/crud_starter/crud_starter_manual.go b/bin/notifier_service/pkg/crud_starter/crud_starter_manual.go index 5cb1cec..efc2b2b 100644 --- a/bin/notifier_service/pkg/crud_starter/crud_starter_manual.go +++ b/bin/notifier_service/pkg/crud_starter/crud_starter_manual.go @@ -7,6 +7,7 @@ import ( "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/crud_starter/crud_starter_attachament" "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/crud_starter/crud_starter_channel" "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/crud_starter/crud_starter_channel_prod" + "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/crud_starter/crud_starter_constructor_users" "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/crud_starter/crud_starter_debt_list" "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/crud_starter/crud_starter_debt_list2" "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/crud_starter/crud_starter_delivery_error" @@ -34,6 +35,7 @@ import ( "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/db/crud/crud_attachament" "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/db/crud/crud_channel" "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/db/crud/crud_channel_prod" + "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/db/crud/crud_constructor_users" "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/db/crud/crud_debt_list" "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/db/crud/crud_debt_list2" "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/db/crud/crud_delivery_error" @@ -61,6 +63,7 @@ import ( "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/network/grpc/grpc_client/grpc_attachament" "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/network/grpc/grpc_client/grpc_channel" "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/network/grpc/grpc_client/grpc_channel_prod" + "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/network/grpc/grpc_client/grpc_constructor_users" "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/network/grpc/grpc_client/grpc_debt_list" "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/network/grpc/grpc_client/grpc_debt_list2" "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/network/grpc/grpc_client/grpc_delivery_error" @@ -91,6 +94,7 @@ func initCrudTransport_manual_DB() { crud_starter_attachament.SetCrudManualInterface(crud_attachament.Crud_DB{}) crud_starter_channel.SetCrudManualInterface(crud_channel.Crud_DB{}) crud_starter_channel_prod.SetCrudManualInterface(crud_channel_prod.Crud_DB{}) + crud_starter_constructor_users.SetCrudManualInterface(crud_constructor_users.Crud_DB{}) crud_starter_debt_list.SetCrudManualInterface(crud_debt_list.Crud_DB{}) crud_starter_debt_list2.SetCrudManualInterface(crud_debt_list2.Crud_DB{}) crud_starter_delivery_error.SetCrudManualInterface(crud_delivery_error.Crud_DB{}) @@ -121,6 +125,7 @@ func initCrudTransport_manual_GRPC() { crud_starter_attachament.SetCrudManualInterface(grpc_attachament.Crud_GRPC{}) crud_starter_channel.SetCrudManualInterface(grpc_channel.Crud_GRPC{}) crud_starter_channel_prod.SetCrudManualInterface(grpc_channel_prod.Crud_GRPC{}) + crud_starter_constructor_users.SetCrudManualInterface(grpc_constructor_users.Crud_GRPC{}) crud_starter_debt_list.SetCrudManualInterface(grpc_debt_list.Crud_GRPC{}) crud_starter_debt_list2.SetCrudManualInterface(grpc_debt_list2.Crud_GRPC{}) crud_starter_delivery_error.SetCrudManualInterface(grpc_delivery_error.Crud_GRPC{}) @@ -151,6 +156,7 @@ func initCrudTransport_manual_NRPC() { crud_starter_attachament.SetCrudManualInterface(grpc_attachament.Crud_GRPC{}) crud_starter_channel.SetCrudManualInterface(grpc_channel.Crud_GRPC{}) crud_starter_channel_prod.SetCrudManualInterface(grpc_channel_prod.Crud_GRPC{}) + crud_starter_constructor_users.SetCrudManualInterface(grpc_constructor_users.Crud_GRPC{}) crud_starter_debt_list.SetCrudManualInterface(grpc_debt_list.Crud_GRPC{}) crud_starter_debt_list2.SetCrudManualInterface(grpc_debt_list2.Crud_GRPC{}) crud_starter_delivery_error.SetCrudManualInterface(grpc_delivery_error.Crud_GRPC{}) diff --git a/bin/notifier_service/pkg/object_model/entities/attachament/attachament.go b/bin/notifier_service/pkg/object_model/entities/attachament/attachament.go index 5b86c5d..5d1e55a 100644 --- a/bin/notifier_service/pkg/object_model/entities/attachament/attachament.go +++ b/bin/notifier_service/pkg/object_model/entities/attachament/attachament.go @@ -4,8 +4,7 @@ import ( "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/db/tables/table_attachament" ) -// Attachament - модель для таблицы attachament: Вложения прикладываемые к сообщению -Целевая БД сервиса уведомлений +// Attachament - модель для таблицы attachament: Вложения прикладываемые к сообщениюЦелевая БД сервиса уведомлений type Attachament struct { table_attachament.Table_Attachament } diff --git a/bin/notifier_service/pkg/object_model/entities/incoming_event/incoming_event.go b/bin/notifier_service/pkg/object_model/entities/incoming_event/incoming_event.go index def31f1..9284fcb 100644 --- a/bin/notifier_service/pkg/object_model/entities/incoming_event/incoming_event.go +++ b/bin/notifier_service/pkg/object_model/entities/incoming_event/incoming_event.go @@ -4,8 +4,7 @@ import ( "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/db/tables/table_incoming_event" ) -// IncomingEvent - модель для таблицы incoming_event: Входяшие события из шины или API, как есть. -Целевая БД сервиса уведомлений +// IncomingEvent - модель для таблицы incoming_event: Входяшие события из шины или API, как есть.Целевая БД сервиса уведомлений type IncomingEvent struct { table_incoming_event.Table_IncomingEvent } diff --git a/bin/notifier_service/pkg/object_model/entities/mailing/mailing.go b/bin/notifier_service/pkg/object_model/entities/mailing/mailing.go index 81fa3f1..ff7a1bf 100644 --- a/bin/notifier_service/pkg/object_model/entities/mailing/mailing.go +++ b/bin/notifier_service/pkg/object_model/entities/mailing/mailing.go @@ -4,8 +4,7 @@ import ( "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/db/tables/table_mailing" ) -// Mailing - модель для таблицы mailing: Рассылки -Целевая БД сервиса уведомлений +// Mailing - модель для таблицы mailing: РассылкиЦелевая БД сервиса уведомлений type Mailing struct { table_mailing.Table_Mailing } diff --git a/bin/notifier_service/pkg/object_model/entities/message/message.go b/bin/notifier_service/pkg/object_model/entities/message/message.go index 692740a..a6099a5 100644 --- a/bin/notifier_service/pkg/object_model/entities/message/message.go +++ b/bin/notifier_service/pkg/object_model/entities/message/message.go @@ -4,8 +4,7 @@ import ( "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/db/tables/table_message" ) -// Message - модель для таблицы message: сообщения -Целевая БД сервиса уведомлений +// Message - модель для таблицы message: сообщенияЦелевая БД сервиса уведомлений type Message struct { table_message.Table_Message } diff --git a/bin/notifier_service/pkg/object_model/entities/template/template.go b/bin/notifier_service/pkg/object_model/entities/template/template.go index 07136b0..cbd76ea 100644 --- a/bin/notifier_service/pkg/object_model/entities/template/template.go +++ b/bin/notifier_service/pkg/object_model/entities/template/template.go @@ -4,8 +4,7 @@ import ( "gitlab.aescorp.ru/dsp_dev/claim/notifier_service/pkg/db/tables/table_template" ) -// Template - модель для таблицы template: Шаблоны уведомлений -Целевая БД сервиса уведомлений +// Template - модель для таблицы template: Шаблоны уведомленийЦелевая БД сервиса уведомлений type Template struct { table_template.Table_Template } diff --git a/internal/create_files/create_files.go b/internal/create_files/create_files.go index 10f4197..855c2cc 100644 --- a/internal/create_files/create_files.go +++ b/internal/create_files/create_files.go @@ -174,16 +174,71 @@ func FindPrimaryKeyNameType(Table1 *types.Table) (string, string) { // return Otvet, Type //} -// ReplacePrimaryKeyID - заменяет "ID" на название колонки PrimaryKey -func ReplacePrimaryKeyID(Text string, Table1 *types.Table) string { +// ReplacePrimaryKeyOtvetID - заменяет "Otvet.ID" на название колонки PrimaryKey +func ReplacePrimaryKeyOtvetID(Text string, Table1 *types.Table) string { Otvet := Text ColumnName, ColumnTypeGo := FindPrimaryKeyNameTypeGo(Table1) + + //заменим ID-Alias на ID + TableName := Table1.Name + IDName, _ := FindPrimaryKeyNameType(Table1) + _, ok := types.MapConvertID[TableName+"."+IDName] + OtvetColumnName := "Otvet." + ColumnName + if ok == true { + OtvetColumnName = ColumnTypeGo + "(" + OtvetColumnName + ")" + } + + //заменим int64(m.ID) на m.ID if mini_func.IsNumberType(ColumnTypeGo) == true { - Otvet = strings.ReplaceAll(Otvet, "Otvet.ID", "Otvet."+ColumnName) + Otvet = strings.ReplaceAll(Otvet, "Otvet.ID", OtvetColumnName) } else if ColumnTypeGo == "string" { - Otvet = strings.ReplaceAll(Otvet, "Otvet.ID == 0", "Otvet."+ColumnName+" == \"\"") - Otvet = strings.ReplaceAll(Otvet, "Otvet.ID", "Otvet."+ColumnName) + Otvet = strings.ReplaceAll(Otvet, "Otvet.ID == 0", OtvetColumnName+" == \"\"") + Otvet = strings.ReplaceAll(Otvet, "Otvet.ID != 0", OtvetColumnName+" != \"\"") + Otvet = strings.ReplaceAll(Otvet, "Otvet.ID", OtvetColumnName) + } else if ColumnTypeGo == "uuid.UUID" || ColumnTypeGo == "uuid.NullUUID" { + Otvet = strings.ReplaceAll(Otvet, "Otvet.ID == 0", OtvetColumnName+" == uuid.Nil") + Otvet = strings.ReplaceAll(Otvet, "Otvet.ID != 0", OtvetColumnName+" != uuid.Nil") + Otvet = strings.ReplaceAll(Otvet, "Otvet.ID", OtvetColumnName) + } else if ColumnTypeGo == "time.Time" { + Otvet = strings.ReplaceAll(Otvet, "int64(Otvet.ID) == 0", OtvetColumnName+".IsZero() == true") + Otvet = strings.ReplaceAll(Otvet, "int64(Otvet.ID) != 0", OtvetColumnName+".IsZero() == false") + Otvet = strings.ReplaceAll(Otvet, "int64(Otvet.ID)", OtvetColumnName) + } + + return Otvet +} + +// ReplacePrimaryKeyM_ID - заменяет "m.ID" на название колонки PrimaryKey +func ReplacePrimaryKeyM_ID(Text string, Table1 *types.Table) string { + Otvet := Text + + ColumnName, ColumnTypeGo := FindPrimaryKeyNameTypeGo(Table1) + + //заменим ID-Alias на ID + TableName := Table1.Name + IDName, _ := FindPrimaryKeyNameType(Table1) + _, ok := types.MapConvertID[TableName+"."+IDName] + OtvetColumnName := "m." + ColumnName + if ok == true { + OtvetColumnName = ColumnTypeGo + "(" + OtvetColumnName + ")" + } + + //заменим int64(m.ID) на m.ID + if mini_func.IsNumberType(ColumnTypeGo) == true { + Otvet = strings.ReplaceAll(Otvet, "int64(m.ID)", OtvetColumnName) + } else if ColumnTypeGo == "string" { + Otvet = strings.ReplaceAll(Otvet, "int64(m.ID) == 0", OtvetColumnName+" == \"\"") + Otvet = strings.ReplaceAll(Otvet, "int64(m.ID) != 0", OtvetColumnName+" != \"\"") + Otvet = strings.ReplaceAll(Otvet, "int64(m.ID)", OtvetColumnName) + } else if ColumnTypeGo == "uuid.UUID" || ColumnTypeGo == "uuid.NullUUID" { + Otvet = strings.ReplaceAll(Otvet, "int64(m.ID) == 0", OtvetColumnName+" == uuid.Nil") + Otvet = strings.ReplaceAll(Otvet, "int64(m.ID) != 0", OtvetColumnName+" != uuid.Nil") + Otvet = strings.ReplaceAll(Otvet, "int64(m.ID)", OtvetColumnName) + } else if ColumnTypeGo == "time.Time" { + Otvet = strings.ReplaceAll(Otvet, "int64(m.ID) == 0", OtvetColumnName+".IsZero() == true") + Otvet = strings.ReplaceAll(Otvet, "int64(m.ID) != 0", OtvetColumnName+".IsZero() == false") + Otvet = strings.ReplaceAll(Otvet, "int64(m.ID)", OtvetColumnName) } return Otvet @@ -709,7 +764,7 @@ func CheckAndAddImportTime_FromText(Text string) string { func CheckAndAddImportUUID_FromText(Text string) string { Otvet := Text - pos1 := strings.Index(Text, " uuid.") + pos1 := strings.Index(Text, "uuid.") if pos1 < 0 { return Otvet } @@ -1484,3 +1539,22 @@ func Is_UUID_Type(TypeGo string) bool { Otvet := TypeGo == "uuid.UUID" || TypeGo == "uuid.NullUUID" return Otvet } + +//// ConvertID_toTypeID - заменяет int64(m.ID) на m.ID +//func ConvertID_toTypeID(Text string, Table1 *types.Table) string { +// Otvet := Text +// +// //заменим ID-Alias на ID +// TableName := Table1.Name +// IDName, _ := FindPrimaryKeyNameType(Table1) +// TextConvert, ok := types.MapConvertID[TableName+"."+IDName] +// if ok == true { +// Otvet = strings.ReplaceAll(Otvet, "int64(m.ID)", ""+TextConvert+"(m.ID)") +// return Otvet +// } +// +// //заменим int64(m.ID) на m.ID +// Otvet = strings.ReplaceAll(Otvet, "int64(m.ID)", "m.ID") +// +// return Otvet +//} diff --git a/internal/create_files/crud_tables/crud_tables.go b/internal/create_files/crud_tables/crud_tables.go index 5e1a69d..cbb9f45 100644 --- a/internal/create_files/crud_tables/crud_tables.go +++ b/internal/create_files/crud_tables/crud_tables.go @@ -155,6 +155,7 @@ func CreateFiles(Table1 *types.Table) error { //создание текста TextDB = strings.ReplaceAll(TextDB, config.Settings.TEXT_TEMPLATE_MODEL, ModelName) TextDB = strings.ReplaceAll(TextDB, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name) + TextDB = create_files.ReplacePrimaryKeyM_ID(TextDB, Table1) TextDB = config.Settings.TEXT_MODULE_GENERATED + TextDB //TextDB = create_files.DeleteFuncFind_byExtID(TextDB, Table1) @@ -247,7 +248,7 @@ func CreateTestFiles(Table1 *types.Table) error { TextDB = create_files.AddSkipNow(TextDB, Table1) //замена ID на PrimaryKey - TextDB = create_files.ReplacePrimaryKeyID(TextDB, Table1) + TextDB = create_files.ReplacePrimaryKeyOtvetID(TextDB, Table1) //замена импортов на новые URL TextDB = create_files.ReplaceServiceURLImports(TextDB) @@ -832,6 +833,13 @@ func CreateFilesCache(Table1 *types.Table) error { sCACHE_ELEMENTS_COUNT := micro.StringFromInt64(CACHE_ELEMENTS_COUNT) TextCache = create_files.FillVariable(TextCache, constants.TEXT_CACHE_SIZE_1000, sCACHE_ELEMENTS_COUNT) + //тип ID кэша + _, ColumnTypeGo := create_files.FindPrimaryKeyNameTypeGo(Table1) + TextCache = strings.ReplaceAll(TextCache, ".LRU[int64", ".LRU["+ColumnTypeGo) + + //uuid + TextCache = create_files.CheckAndAddImportUUID_FromText(TextCache) + //удаление пустого импорта TextCache = create_files.DeleteEmptyImport(TextCache) diff --git a/internal/create_files/grpc_client_tables/grpc_client_tables.go b/internal/create_files/grpc_client_tables/grpc_client_tables.go index cd0a2bb..2762cac 100644 --- a/internal/create_files/grpc_client_tables/grpc_client_tables.go +++ b/internal/create_files/grpc_client_tables/grpc_client_tables.go @@ -226,7 +226,7 @@ func CreateTestFiles(Table1 *types.Table) error { } // замена ID на PrimaryKey - TextGRPCClient = create_files.ReplacePrimaryKeyID(TextGRPCClient, Table1) + TextGRPCClient = create_files.ReplacePrimaryKeyOtvetID(TextGRPCClient, Table1) //SkipNow() TextGRPCClient = create_files.AddSkipNow(TextGRPCClient, Table1) @@ -798,7 +798,7 @@ func CreateFiles_GRPC_Client_Cache_Test(Table1 *types.Table) error { TextGRPCClient = config.Settings.TEXT_MODULE_GENERATED + TextGRPCClient // замена ID на PrimaryKey - TextGRPCClient = create_files.ReplacePrimaryKeyID(TextGRPCClient, Table1) + TextGRPCClient = create_files.ReplacePrimaryKeyOtvetID(TextGRPCClient, Table1) //SkipNow() TextGRPCClient = create_files.AddSkipNow(TextGRPCClient, Table1) diff --git a/internal/create_files/nrpc_client_tables/nrpc_client_tables.go b/internal/create_files/nrpc_client_tables/nrpc_client_tables.go index 5c68a07..5c08bf3 100644 --- a/internal/create_files/nrpc_client_tables/nrpc_client_tables.go +++ b/internal/create_files/nrpc_client_tables/nrpc_client_tables.go @@ -180,7 +180,7 @@ func CreateTestFiles(Table1 *types.Table) error { } // замена ID на PrimaryKey - TextNRPCClient = create_files.ReplacePrimaryKeyID(TextNRPCClient, Table1) + TextNRPCClient = create_files.ReplacePrimaryKeyOtvetID(TextNRPCClient, Table1) //SkipNow() TextNRPCClient = create_files.AddSkipNow(TextNRPCClient, Table1) diff --git a/internal/create_files/server_grpc_tables/server_grpc_tables.go b/internal/create_files/server_grpc_tables/server_grpc_tables.go index e112c13..d86b4ba 100644 --- a/internal/create_files/server_grpc_tables/server_grpc_tables.go +++ b/internal/create_files/server_grpc_tables/server_grpc_tables.go @@ -215,7 +215,7 @@ func CreateTestFiles(Table1 *types.Table) error { } // замена ID на PrimaryKey - TextGRPCServer = create_files.ReplacePrimaryKeyID(TextGRPCServer, Table1) + TextGRPCServer = create_files.ReplacePrimaryKeyOtvetID(TextGRPCServer, Table1) //SkipNow() TextGRPCServer = create_files.AddSkipNow(TextGRPCServer, Table1) diff --git a/internal/postgres/postgres.go b/internal/postgres/postgres.go index cf7992c..15fe024 100644 --- a/internal/postgres/postgres.go +++ b/internal/postgres/postgres.go @@ -256,10 +256,13 @@ order by ModelName = create_files.FormatName(ModelName) // + TableComment := v.TableComment + TableComment = strings.ReplaceAll(TableComment, "\n", "") + TableComment = strings.ReplaceAll(TableComment, "\r", "") Table1 = CreateTable() Table1.Name = TableName Table1.OrderNumber = OrderNumberTable - Table1.Comment = v.TableComment + Table1.Comment = TableComment Table1.NameGo = ModelName }