1
0
mirror of https://github.com/ManyakRus/crud_generator.git synced 2024-11-24 08:22:42 +02:00

сделал notifier test без ошибок

This commit is contained in:
Nikitin Aleksandr 2024-06-07 16:45:54 +03:00
parent 1fc18a1ad9
commit 5c9d7c72fc

View File

@ -1849,6 +1849,26 @@ func ConvertGolangTypeToProtobufType(Table1 *types.Table, Column1 *types.Column,
return Otvet return Otvet
} }
// ConvertVariableToProtobufType - возвращает имя переменной + имя колонки, преобразованное в тип protobuf
func ConvertVariableToProtobufType(Table1 *types.Table, Column1 *types.Column, VariableName string) string {
Otvet := ""
if Column1 == nil {
return Otvet
}
Otvet = VariableName
switch Column1.TypeGo {
case "time.Time":
Otvet = "timestamppb.New(" + VariableName + ")"
case "uuid.UUID":
Otvet = VariableName + ".String()"
}
return Otvet
}
// ConvertProtobufTypeToGolangType - возвращает имя переменной + имя колонки, преобразованное в тип golang из protobuf // ConvertProtobufTypeToGolangType - возвращает имя переменной + имя колонки, преобразованное в тип golang из protobuf
func ConvertProtobufTypeToGolangType(Table1 *types.Table, Column1 *types.Column, VariableName string) (VariableColumn string, GolangCode string) { func ConvertProtobufTypeToGolangType(Table1 *types.Table, Column1 *types.Column, VariableName string) (VariableColumn string, GolangCode string) {
RequestColumnName := FindRequestColumnName(Table1, Column1) RequestColumnName := FindRequestColumnName(Table1, Column1)
@ -2179,16 +2199,16 @@ func FindTextIDMinimum(Column1 *types.Column) string {
func Replace_Model_ID_Test(Text string, Table1 *types.Table) string { func Replace_Model_ID_Test(Text string, Table1 *types.Table) string {
Otvet := Text Otvet := Text
if Table1.PrimaryKeyColumnsCount == 1 { //if Table1.PrimaryKeyColumnsCount == 1 {
PrimaryKeyColumn := FindPrimaryKeyColumn(Table1) // PrimaryKeyColumn := FindPrimaryKeyColumn(Table1)
if PrimaryKeyColumn == nil { // if PrimaryKeyColumn == nil {
return Otvet // return Otvet
} // }
//
Otvet = Replace_Model_ID_Test1(Otvet, Table1, PrimaryKeyColumn) // Otvet = Replace_Model_ID_Test1(Otvet, Table1, PrimaryKeyColumn)
} else { //} else {
Otvet = Replace_Model_ID_Test_ManyPK(Otvet, Table1) Otvet = Replace_Model_ID_Test_ManyPK(Otvet, Table1)
} //}
return Otvet return Otvet
} }
@ -2215,7 +2235,8 @@ func Replace_Model_ID_Test_ManyPK(Text string, Table1 *types.Table) string {
TextNew = "" TextNew = ""
for _, Column1 := range MassPK { for _, Column1 := range MassPK {
Name := strings.ToUpper(Column1.NameGo) Name := strings.ToUpper(Column1.NameGo)
Text1 := Table1.NameGo + "_" + Name + "_Test" VariableName := Table1.NameGo + "_" + Name + "_Test"
Text1 := ConvertVariableToProtobufType(Table1, Column1, VariableName)
RequestColumnName := FindRequestColumnName(Table1, Column1) RequestColumnName := FindRequestColumnName(Table1, Column1)
TextNew = TextNew + "\tRequest." + RequestColumnName + " = " + Text1 + "\n" TextNew = TextNew + "\tRequest." + RequestColumnName + " = " + Text1 + "\n"
} }
@ -2226,7 +2247,8 @@ func Replace_Model_ID_Test_ManyPK(Text string, Table1 *types.Table) string {
TextNew = "" TextNew = ""
for _, Column1 := range MassPK { for _, Column1 := range MassPK {
Name := strings.ToUpper(Column1.NameGo) Name := strings.ToUpper(Column1.NameGo)
Text1 := Table1.NameGo + "_" + Name + "_Test" VariableName := Table1.NameGo + "_" + Name + "_Test"
Text1 := ConvertVariableToProtobufType(Table1, Column1, VariableName)
RequestColumnName := FindRequestColumnName(Table1, Column1) RequestColumnName := FindRequestColumnName(Table1, Column1)
TextNew = TextNew + "\tRequest2." + RequestColumnName + " = " + Text1 + "\n" TextNew = TextNew + "\tRequest2." + RequestColumnName + " = " + Text1 + "\n"
} }
@ -2521,30 +2543,30 @@ func ReplaceOtvetIDEqual0(Text string, Table1 *types.Table) string {
func ReplaceModelIDEqual1(Text string, Table1 *types.Table) string { func ReplaceModelIDEqual1(Text string, Table1 *types.Table) string {
Otvet := Text Otvet := Text
if Table1.PrimaryKeyColumnsCount == 1 { //if Table1.PrimaryKeyColumnsCount == 1 {
Otvet = ReplaceModelIDEqual1_1(Otvet, Table1) // Otvet = ReplaceModelIDEqual1_1(Otvet, Table1)
} else { //} else {
Otvet = ReplaceModelIDEqual1_ManyPK(Otvet, Table1) Otvet = ReplaceModelIDEqual1_ManyPK(Otvet, Table1)
} //}
return Otvet return Otvet
} }
// ReplaceModelIDEqual1 - заменяет Otvet.ID = -1 //// ReplaceModelIDEqual1 - заменяет Otvet.ID = -1
func ReplaceModelIDEqual1_1(Text string, Table1 *types.Table) string { //func ReplaceModelIDEqual1_1(Text string, Table1 *types.Table) string {
Otvet := Text // Otvet := Text
//
PrimaryKeyColumn := FindPrimaryKeyColumn(Table1) // PrimaryKeyColumn := FindPrimaryKeyColumn(Table1)
if PrimaryKeyColumn == nil { // if PrimaryKeyColumn == nil {
return Otvet // return Otvet
} // }
//
Value := FindNegativeValue(PrimaryKeyColumn.TypeGo) // Value := FindNegativeValue(PrimaryKeyColumn.TypeGo)
//
Otvet = strings.ReplaceAll(Otvet, "m.ID = -1", "m.ID = "+Value) // Otvet = strings.ReplaceAll(Otvet, "m.ID = -1", "m.ID = "+Value)
//
return Otvet // return Otvet
} //}
// ReplaceModelIDEqual1_ManyPK - заменяет m.ID = -1 // ReplaceModelIDEqual1_ManyPK - заменяет m.ID = -1
func ReplaceModelIDEqual1_ManyPK(Text string, Table1 *types.Table) string { func ReplaceModelIDEqual1_ManyPK(Text string, Table1 *types.Table) string {