diff --git a/bin/templates/pkg/db/crud/crud_tables_rapira.go_ b/bin/templates/pkg/db/crud/crud_tables_rapira.go_ index cfd25a4..5dd5304 100644 --- a/bin/templates/pkg/db/crud/crud_tables_rapira.go_ +++ b/bin/templates/pkg/db/crud/crud_tables_rapira.go_ @@ -325,7 +325,7 @@ func Find_ByExtID_ctx(ctx context.Context, db *gorm.DB, m *lawsuit_status_types. } if m.ExtID == 0 { - err = errors.New(m.TableNameDB()+" Find_ByExtID() error: ExtID=0") + err = errors.New(m.TableNameDB()+` Find_ByExtID() error: ExtID == 0`) return err } diff --git a/internal/create_files/create_files.go b/internal/create_files/create_files.go index 4d7f78a..b45c3d2 100644 --- a/internal/create_files/create_files.go +++ b/internal/create_files/create_files.go @@ -1417,7 +1417,7 @@ func DeleteFunc_Find_byExtID(TextModel string, Table1 *types.Table) string { Otvet := TextModel //проверка есть ли колонки ExtID и ConnectionID - if Has_Column_ExtID_ConnectionID_Int64(Table1) == true { + if Has_Column_ExtID_ConnectionID(Table1) == true { return Otvet } diff --git a/internal/create_files/create_files_columns.go b/internal/create_files/create_files_columns.go index ec7685e..2a8d93f 100644 --- a/internal/create_files/create_files_columns.go +++ b/internal/create_files/create_files_columns.go @@ -8,6 +8,26 @@ import ( "strings" ) +// Has_Column_ExtID_ConnectionID - возвращает true если есть поля ExtId и ConnectionID, если они int64 +func Has_Column_ExtID_ConnectionID(Table1 *types.Table) bool { + Otvet := false + + // + _, ok := Table1.MapColumns["ext_id"] + if ok == false { + return Otvet + } + + // + _, ok = Table1.MapColumns["connection_id"] + if ok == false { + return Otvet + } + + Otvet = true + return Otvet +} + // Has_Column_ExtID_ConnectionID_Int64 - возвращает true если есть поля ExtId и ConnectionID, если они int64 func Has_Column_ExtID_ConnectionID_Int64(Table1 *types.Table) bool { Otvet := false @@ -423,3 +443,12 @@ func Is_Need_Сolumn(Column1 *types.Column) bool { return Otvet } + +// GetColumn_ExtID - возвращает колонку ExtID +func GetColumn_ExtID(Table1 *types.Table) *types.Column { + Column1, ok := Table1.MapColumns["ext_id"] + if ok == false { + return nil + } + return Column1 +} diff --git a/internal/create_files/crud_tables/crud_tables_crud.go b/internal/create_files/crud_tables/crud_tables_crud.go index 97297af..2bff820 100644 --- a/internal/create_files/crud_tables/crud_tables_crud.go +++ b/internal/create_files/crud_tables/crud_tables_crud.go @@ -85,6 +85,7 @@ func CreateFiles(Table1 *types.Table) error { TextDB = ReplaceText_created_at(TextDB, Table1) TextDB = ReplaceText_is_deleted_deleted_at(TextDB, Table1) TextDB = create_files.DeleteImportModel(TextDB) + TextDB = ReplaceText_ExtID0(TextDB, Table1) TextDB = ReplaceCacheRemove(TextDB, Table1) @@ -180,6 +181,7 @@ func CreateFiles_Test(Table1 *types.Table) error { TextDB = DeleteFunc_TestDelete(TextDB, Table1) TextDB = DeleteFunc_TestRestore(TextDB, Table1) TextDB = DeleteFunc_TestFind_byExtID(TextDB, Table1) + TextDB = ReplaceText_ExtID0(TextDB, Table1) //Postgres_ID_Test = ID Minimum TextDB = create_files.Replace_Postgres_ID_Test(TextDB, Table1) @@ -488,7 +490,7 @@ func DeleteFunc_TestFind_byExtID(Text string, Table1 *types.Table) string { Otvet := Text //проверка есть ли колонки ExtID и ConnectionID - if create_files.Has_Column_ExtID_ConnectionID_Int64(Table1) == true { + if create_files.Has_Column_ExtID_ConnectionID(Table1) == true { return Otvet } @@ -504,7 +506,7 @@ func DeleteFunc_Find_byExtIDCtx(TextModel string, Table1 *types.Table) string { Otvet := TextModel //проверка есть ли колонки ExtID и ConnectionID - if create_files.Has_Column_ExtID_ConnectionID_Int64(Table1) == true { + if create_files.Has_Column_ExtID_ConnectionID(Table1) == true { return Otvet } @@ -543,3 +545,18 @@ func DeleteFunc_DeleteCtx(TextModel string, Table1 *types.Table) string { return Otvet } + +// ReplaceText_ExtID0 - заменяет текст "ExtID ==0" +func ReplaceText_ExtID0(TextDB string, Table1 *types.Table) string { + Otvet := TextDB + + ColumnExtID := create_files.GetColumn_ExtID(Table1) + if ColumnExtID == nil { + return Otvet + } + + DefaultValue := create_files.FindText_DefaultValue(ColumnExtID.TypeGo) + Otvet = strings.ReplaceAll(Otvet, "ExtID ==0", "ExtID == "+DefaultValue) + + return Otvet +} diff --git a/internal/create_files/entities_tables/entities_tables_crud.go b/internal/create_files/entities_tables/entities_tables_crud.go index 363c790..6515b0a 100644 --- a/internal/create_files/entities_tables/entities_tables_crud.go +++ b/internal/create_files/entities_tables/entities_tables_crud.go @@ -478,7 +478,7 @@ func DeleteFromInterface_Find_ByExtID(TextModel string, Table1 *types.Table) str Otvet := TextModel //проверим есть ли колонки ExtID и ConnectionID - if create_files.Has_Column_ExtID_ConnectionID_Int64(Table1) == true { + if create_files.Has_Column_ExtID_ConnectionID(Table1) == true { return Otvet } diff --git a/internal/create_files/grpc_client_tables/grpc_client_tables_crud.go b/internal/create_files/grpc_client_tables/grpc_client_tables_crud.go index 4e9db05..190f22a 100644 --- a/internal/create_files/grpc_client_tables/grpc_client_tables_crud.go +++ b/internal/create_files/grpc_client_tables/grpc_client_tables_crud.go @@ -283,7 +283,7 @@ func DeleteFuncFind_byExtID(Text, ModelName string, Table1 *types.Table) string Otvet := Text //если есть обе колонки - ничего не делаем - ok := create_files.Has_Column_ExtID_ConnectionID_Int64(Table1) + ok := create_files.Has_Column_ExtID_ConnectionID(Table1) if ok == true { return Otvet } @@ -327,7 +327,7 @@ func DeleteFuncTestFind_byExtID(Text, ModelName string, Table1 *types.Table) str Otvet := Text //если есть обе колонки - ничего не делаем - ok := create_files.Has_Column_ExtID_ConnectionID_Int64(Table1) + ok := create_files.Has_Column_ExtID_ConnectionID(Table1) if ok == true { return Otvet } 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 8a4f77c..7750c91 100644 --- a/internal/create_files/nrpc_client_tables/nrpc_client_tables.go +++ b/internal/create_files/nrpc_client_tables/nrpc_client_tables.go @@ -259,7 +259,7 @@ package nrpc_client_tables // Otvet := Text // // //если есть обе колонки - ничего не делаем -// ok := create_files.Has_Column_ExtID_ConnectionID_Int64(Table1) +// ok := create_files.Has_Column_ExtID_ConnectionID(Table1) // if ok == true { // return Otvet // } @@ -303,7 +303,7 @@ package nrpc_client_tables // Otvet := Text // // //если есть обе колонки - ничего не делаем -// ok := create_files.Has_Column_ExtID_ConnectionID_Int64(Table1) +// ok := create_files.Has_Column_ExtID_ConnectionID(Table1) // if ok == true { // return Otvet // } diff --git a/internal/create_files/protobuf/protobuf_crud.go b/internal/create_files/protobuf/protobuf_crud.go index 53a0f37..e260844 100644 --- a/internal/create_files/protobuf/protobuf_crud.go +++ b/internal/create_files/protobuf/protobuf_crud.go @@ -18,7 +18,7 @@ func FindText_ProtoTable1(TextProto string, Table1 *types.Table) string { Otvet = Otvet + FindText_Create(TextProto, ModelName) Otvet = Otvet + FindText_Update(TextProto, ModelName) Otvet = Otvet + FindText_Save(TextProto, ModelName) - if create_files.Has_Column_ExtID_ConnectionID_Int64(Table1) == true { + if create_files.Has_Column_ExtID_ConnectionID(Table1) == true { Otvet = Otvet + FindText_FindByExtId(TextProto, ModelName) } diff --git a/internal/create_files/server_grpc_tables/server_grpc_tables_crud.go b/internal/create_files/server_grpc_tables/server_grpc_tables_crud.go index 41dd0e7..b83e91d 100644 --- a/internal/create_files/server_grpc_tables/server_grpc_tables_crud.go +++ b/internal/create_files/server_grpc_tables/server_grpc_tables_crud.go @@ -270,7 +270,7 @@ func DeleteFunc_Find_byExtID(Text string, Table1 *types.Table) string { Otvet := Text //если есть обе колонки - ничего не делаем - ok := create_files.Has_Column_ExtID_ConnectionID_Int64(Table1) + ok := create_files.Has_Column_ExtID_ConnectionID(Table1) if ok == true { return Otvet } @@ -317,7 +317,7 @@ func DeleteFunc_Test_Find_byExtID(Text string, Table1 *types.Table) string { Otvet := Text //если есть обе колонки - ничего не делаем - ok := create_files.Has_Column_ExtID_ConnectionID_Int64(Table1) + ok := create_files.Has_Column_ExtID_ConnectionID(Table1) if ok == true { return Otvet }