mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2024-12-13 21:42:33 +02:00
сделал NEED_CREATE_CONSTANTS_FILE
This commit is contained in:
parent
767332ee5d
commit
3f2d295f82
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
// }
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user