1
0
mirror of https://github.com/ManyakRus/crud_generator.git synced 2024-11-27 08:40:53 +02:00

сделал Has_Column_ID_Int64()

This commit is contained in:
Nikitin Aleksandr 2024-07-16 13:57:06 +03:00
parent 011e1a625e
commit 743bf2a146
8 changed files with 69 additions and 35 deletions

View File

@ -1351,7 +1351,7 @@ func DeleteFuncDelete(TextModel string, Table1 *types.Table) string {
Otvet := TextModel
//проверим есть ли колонка IsDeleted
if Has_Column_IsDeleted(Table1) == true {
if Has_Column_IsDeleted_Bool(Table1) == true {
return Otvet
}
@ -1366,7 +1366,7 @@ func DeleteFuncRestore(TextModel string, Table1 *types.Table) string {
Otvet := TextModel
//проверим есть ли колонка IsDeleted
if Has_Column_IsDeleted(Table1) == true && config.Settings.HAS_IS_DELETED == true {
if Has_Column_IsDeleted_Bool(Table1) == true && config.Settings.HAS_IS_DELETED == true {
return Otvet
}
@ -1381,7 +1381,7 @@ func DeleteFuncFind_byExtID(TextModel string, Table1 *types.Table) string {
Otvet := TextModel
//проверка есть ли колонки ExtID и ConnectionID
if Has_Column_ExtID_ConnectionID(Table1) == true {
if Has_Column_ExtID_ConnectionID_Int64(Table1) == true {
return Otvet
}
@ -1396,7 +1396,7 @@ func DeleteFuncDeleteCtx(TextModel string, Table1 *types.Table) string {
Otvet := TextModel
//проверим есть ли колонка IsDeleted
if Has_Column_IsDeleted(Table1) == true {
if Has_Column_IsDeleted_Bool(Table1) == true {
return Otvet
}
@ -1411,7 +1411,7 @@ func DeleteFuncRestoreCtx(TextModel string, Table1 *types.Table) string {
Otvet := TextModel
//проверим есть ли колонка IsDeleted
if Has_Column_IsDeleted(Table1) == true && config.Settings.HAS_IS_DELETED == true {
if Has_Column_IsDeleted_Bool(Table1) == true && config.Settings.HAS_IS_DELETED == true {
return Otvet
}
@ -1426,7 +1426,7 @@ func DeleteFuncFind_byExtIDCtx(TextModel string, Table1 *types.Table) string {
Otvet := TextModel
//проверка есть ли колонки ExtID и ConnectionID
if Has_Column_ExtID_ConnectionID(Table1) == true {
if Has_Column_ExtID_ConnectionID_Int64(Table1) == true {
return Otvet
}
@ -1441,7 +1441,7 @@ func DeleteFuncTestDelete(Text string, Table1 *types.Table) string {
Otvet := Text
//проверим есть ли колонка IsDeleted
if Has_Column_IsDeleted(Table1) == true {
if Has_Column_IsDeleted_Bool(Table1) == true {
return Otvet
}
@ -1456,7 +1456,7 @@ func DeleteFuncReadFromCache(TextModel string, Table1 *types.Table) string {
Otvet := TextModel
//проверим есть ли колонка IsDeleted
if Has_Column_IsDeleted(Table1) == true {
if Has_Column_IsDeleted_Bool(Table1) == true {
return Otvet
}
@ -1471,7 +1471,7 @@ func DeleteFuncTestRestore(Text string, Table1 *types.Table) string {
Otvet := Text
//проверим есть ли колонка IsDeleted
if Has_Column_IsDeleted(Table1) == true && config.Settings.HAS_IS_DELETED == true {
if Has_Column_IsDeleted_Bool(Table1) == true && config.Settings.HAS_IS_DELETED == true {
return Otvet
}
@ -1486,7 +1486,7 @@ func DeleteFuncTestFind_byExtID(Text string, Table1 *types.Table) string {
Otvet := Text
//проверка есть ли колонки ExtID и ConnectionID
if Has_Column_ExtID_ConnectionID(Table1) == true {
if Has_Column_ExtID_ConnectionID_Int64(Table1) == true {
return Otvet
}

View File

@ -8,36 +8,51 @@ import (
"strings"
)
// Has_Column_ExtID_ConnectionID - возвращает true если есть поля ExtId и ConnectionID
func Has_Column_ExtID_ConnectionID(Table1 *types.Table) bool {
// Has_Column_ExtID_ConnectionID_Int64 - возвращает true если есть поля ExtId и ConnectionID, если они int64
func Has_Column_ExtID_ConnectionID_Int64(Table1 *types.Table) bool {
Otvet := false
//
_, ok := Table1.MapColumns["ext_id"]
Column1, ok := Table1.MapColumns["ext_id"]
if ok == false {
return Otvet
}
//
_, ok = Table1.MapColumns["connection_id"]
if Column1.TypeGo != "int64" {
return Otvet
}
//
Column1, ok = Table1.MapColumns["connection_id"]
if ok == false {
return Otvet
}
//
if Column1.TypeGo != "int64" {
return Otvet
}
Otvet = true
return Otvet
}
// Has_Column_IsDeleted - возвращает true если есть поле is_deleted
func Has_Column_IsDeleted(Table1 *types.Table) bool {
// Has_Column_IsDeleted_Bool - возвращает true если есть поле is_deleted
func Has_Column_IsDeleted_Bool(Table1 *types.Table) bool {
Otvet := false
//
_, ok := Table1.MapColumns["is_deleted"]
Column1, ok := Table1.MapColumns["is_deleted"]
if ok == false {
return Otvet
}
//
if Column1.TypeGo != "bool" {
return Otvet
}
Otvet = true
return Otvet
}
@ -286,7 +301,7 @@ func Has_Column_Description_String(Table1 *types.Table) bool {
func Has_Columns_CommonStruct(Table1 *types.Table) bool {
Otvet := false
Otvet = Has_Column_ExtID_Int64(Table1) && Has_Column_CreatedAt_Time(Table1) && Has_Column_ModifiedAt_Time(Table1) && Has_Column_DeletedAt_Time(Table1) && Has_Column_IsDeleted(Table1) && Has_Column_ID_Int64(Table1)
Otvet = Has_Column_ExtID_Int64(Table1) && Has_Column_CreatedAt_Time(Table1) && Has_Column_ModifiedAt_Time(Table1) && Has_Column_DeletedAt_Time(Table1) && Has_Column_IsDeleted_Bool(Table1) && Has_Column_ID_Int64(Table1)
return Otvet
}

View File

@ -150,6 +150,9 @@ func CreateFiles(Table1 *types.Table) error {
//исправление Save()
TextDB = strings.ReplaceAll(TextDB, `//`+constants.TEXT_CACHE_REMOVE, constants.TEXT_CACHE_REMOVE)
}
//
TextDB = Replace_ExtID_equal0_string(TextDB, Table1)
}
//TextDB = create_files.DeleteFuncFind_byExtID(TextDB, Table1)
@ -348,7 +351,7 @@ func CreateFilesTest(Table1 *types.Table) error {
// Otvet := Text
//
// //если есть обе колонки - ничего не делаем
// ok := create_files.Has_Column_ExtID_ConnectionID(Table1)
// ok := create_files.Has_Column_ExtID_ConnectionID_Int64(Table1)
// if ok == true {
// return Otvet
// }
@ -364,7 +367,7 @@ func CreateFilesTest(Table1 *types.Table) error {
// Otvet := Text
//
// //если есть обе колонки - ничего не делаем
// ok := create_files.Has_Column_ExtID_ConnectionID(Table1)
// ok := create_files.Has_Column_ExtID_ConnectionID_Int64(Table1)
// if ok == true {
// return Otvet
// }
@ -1039,3 +1042,19 @@ func CreateFilesCacheTest(Table1 *types.Table) error {
return err
}
// Replace_ExtID_equal0_string - заменяет "ExtID == 0 " на "ExtID == "" "
func Replace_ExtID_equal0_string(TextDB string, Table1 *types.Table) string {
Otvet := TextDB
Column1, ok := Table1.MapColumns["ext_id"]
if ok == false {
return Otvet
}
TypeGo := Column1.TypeGo
if TypeGo == "string" {
Otvet = strings.ReplaceAll(Otvet, "ExtID == 0 ", `ExtID == "" `)
}
return Otvet
}

View File

@ -463,7 +463,7 @@ func DeleteFromInterfaceDelete(TextModel string, Table1 *types.Table) string {
Otvet := TextModel
//проверим есть ли колонка IsDeleted
if create_files.Has_Column_IsDeleted(Table1) == true {
if create_files.Has_Column_IsDeleted_Bool(Table1) == true {
return Otvet
}
@ -479,7 +479,7 @@ func DeleteFromInterfaceRestore(TextModel string, Table1 *types.Table) string {
Otvet := TextModel
//проверим есть ли колонка IsDeleted
if create_files.Has_Column_IsDeleted(Table1) == true && config.Settings.HAS_IS_DELETED == true {
if create_files.Has_Column_IsDeleted_Bool(Table1) == true && config.Settings.HAS_IS_DELETED == true {
return Otvet
}
@ -495,7 +495,7 @@ func DeleteFromInterfaceFind_ByExtID(TextModel string, Table1 *types.Table) stri
Otvet := TextModel
//проверим есть ли колонки ExtID и ConnectionID
if create_files.Has_Column_ExtID_ConnectionID(Table1) == true {
if create_files.Has_Column_ExtID_ConnectionID_Int64(Table1) == true {
return Otvet
}

View File

@ -328,7 +328,7 @@ func DeleteFuncFind_byExtID(Text, ModelName string, Table1 *types.Table) string
Otvet := Text
//если есть обе колонки - ничего не делаем
ok := create_files.Has_Column_ExtID_ConnectionID(Table1)
ok := create_files.Has_Column_ExtID_ConnectionID_Int64(Table1)
if ok == true {
return Otvet
}
@ -372,7 +372,7 @@ func DeleteFuncTestFind_byExtID(Text, ModelName string, Table1 *types.Table) str
Otvet := Text
//если есть обе колонки - ничего не делаем
ok := create_files.Has_Column_ExtID_ConnectionID(Table1)
ok := create_files.Has_Column_ExtID_ConnectionID_Int64(Table1)
if ok == true {
return Otvet
}

View File

@ -258,7 +258,7 @@ func DeleteFuncFind_byExtID(Text, ModelName string, Table1 *types.Table) string
Otvet := Text
//если есть обе колонки - ничего не делаем
ok := create_files.Has_Column_ExtID_ConnectionID(Table1)
ok := create_files.Has_Column_ExtID_ConnectionID_Int64(Table1)
if ok == true {
return Otvet
}
@ -302,7 +302,7 @@ func DeleteFuncTestFind_byExtID(Text, ModelName string, Table1 *types.Table) str
Otvet := Text
//если есть обе колонки - ничего не делаем
ok := create_files.Has_Column_ExtID_ConnectionID(Table1)
ok := create_files.Has_Column_ExtID_ConnectionID_Int64(Table1)
if ok == true {
return Otvet
}

View File

@ -144,11 +144,11 @@ func FindTextProtoTable1(TextProto string, Table1 *types.Table) string {
Otvet = Otvet + FindTextCreate(TextProto, ModelName)
Otvet = Otvet + FindTextUpdate(TextProto, ModelName)
Otvet = Otvet + FindTextSave(TextProto, ModelName)
if create_files.Has_Column_ExtID_ConnectionID(Table1) == true {
if create_files.Has_Column_ExtID_ConnectionID_Int64(Table1) == true {
Otvet = Otvet + FindTextFindByExtId(TextProto, ModelName)
}
if create_files.Has_Column_IsDeleted(Table1) == true {
if create_files.Has_Column_IsDeleted_Bool(Table1) == true {
Otvet = Otvet + FindTextDelete(TextProto, Table1)
if config.Settings.HAS_IS_DELETED == true {

View File

@ -281,7 +281,7 @@ func DeleteFuncDelete(Text string, Table1 *types.Table) string {
Otvet := Text
//проверим есть ли колонка IsDeleted
if create_files.Has_Column_IsDeleted(Table1) == true {
if create_files.Has_Column_IsDeleted_Bool(Table1) == true {
return Otvet
}
@ -296,7 +296,7 @@ func DeleteFuncRestore(Text string, Table1 *types.Table) string {
Otvet := Text
//проверим есть ли колонка IsDeleted
if create_files.Has_Column_IsDeleted(Table1) == true && config.Settings.HAS_IS_DELETED == true {
if create_files.Has_Column_IsDeleted_Bool(Table1) == true && config.Settings.HAS_IS_DELETED == true {
return Otvet
}
@ -339,7 +339,7 @@ func DeleteFuncFind_byExtID(Text string, Table1 *types.Table) string {
Otvet := Text
//если есть обе колонки - ничего не делаем
ok := create_files.Has_Column_ExtID_ConnectionID(Table1)
ok := create_files.Has_Column_ExtID_ConnectionID_Int64(Table1)
if ok == true {
return Otvet
}
@ -356,7 +356,7 @@ func DeleteFuncTestDelete(Text string, Table1 *types.Table) string {
Otvet := Text
//проверим есть ли колонка IsDeleted
if create_files.Has_Column_IsDeleted(Table1) == true {
if create_files.Has_Column_IsDeleted_Bool(Table1) == true {
return Otvet
}
@ -371,7 +371,7 @@ func DeleteFuncTestRestore(Text string, Table1 *types.Table) string {
Otvet := Text
//проверим есть ли колонка IsDeleted
if create_files.Has_Column_IsDeleted(Table1) == true && config.Settings.HAS_IS_DELETED == true {
if create_files.Has_Column_IsDeleted_Bool(Table1) == true && config.Settings.HAS_IS_DELETED == true {
return Otvet
}
@ -386,7 +386,7 @@ func DeleteFuncTestFind_byExtID(Text string, Table1 *types.Table) string {
Otvet := Text
//если есть обе колонки - ничего не делаем
ok := create_files.Has_Column_ExtID_ConnectionID(Table1)
ok := create_files.Has_Column_ExtID_ConnectionID_Int64(Table1)
if ok == true {
return Otvet
}