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

сделал refactoring

This commit is contained in:
Nikitin Aleksandr 2024-09-11 17:49:55 +03:00
parent 0d0d5a8470
commit 5259bc50cd
11 changed files with 567 additions and 227 deletions

View File

@ -2163,63 +2163,45 @@ func Replace_Model_ID_Test1(Text string, Table1 *types.Table, Column1 *types.Col
return Otvet
}
// ReplaceText_RequestID_and_Column - заменяет RequestId{} на RequestString{}
func ReplaceText_RequestID_and_Column(Text string, Table1 *types.Table, Column1 *types.Column) string {
Otvet := Text
//TypeGo := Column1.TypeGo
TextRequestID, _, _, _ := FindText_ProtobufRequest_ID_Type(Table1, Column1, "Request")
Otvet = strings.ReplaceAll(Otvet, "RequestId{}", TextRequestID+"{}")
//Otvet = strings.ReplaceAll(Otvet, "Request.ID", "Request."+TextID)
return Otvet
}
// ReplaceText_RequestID_PrimaryKey - заменяет RequestId{} на RequestString{}
func ReplaceText_RequestID_PrimaryKey(Text string, Table1 *types.Table) string {
Otvet := Text
TextRequest := "Request"
Otvet = ReplaceText_RequestID_PrimaryKey_ManyPK(Otvet, Table1, TextRequest)
TextRequest = "Request2"
Otvet = ReplaceText_RequestID_PrimaryKey_ManyPK(Otvet, Table1, TextRequest)
//}
Otvet = ReplaceText_RequestID_PrimaryKey_ManyPK(Otvet, Table1)
return Otvet
}
// ReplaceText_RequestID_PrimaryKey1 - заменяет RequestId{} на RequestString{}
func ReplaceText_RequestID_PrimaryKey1(Text string, Table1 *types.Table, VariableName string) string {
Otvet := Text
ColumnPK := Find_PrimaryKeyColumn(Table1)
if ColumnPK == nil {
return Otvet
}
//TypeGo := ColumnPK.TypeGo
TextRequestID, TextID := FindText_ProtobufRequest(Table1)
_, GolangCode := Convert_ProtobufVariableToGolangVariable(Table1, ColumnPK, "Request.")
if GolangCode != "" {
Otvet = strings.ReplaceAll(Otvet, "ID := "+VariableName+".ID", GolangCode)
Otvet = strings.ReplaceAll(Otvet, VariableName+".ID = ", VariableName+"."+TextID+" = ")
}
Otvet = strings.ReplaceAll(Otvet, "RequestId{}", TextRequestID+"{}")
Otvet = strings.ReplaceAll(Otvet, "*grpc_proto.RequestId", "*grpc_proto."+TextRequestID)
//Otvet = strings.ReplaceAll(Otvet, "Request.ID", "Request."+TextID)
Otvet = strings.ReplaceAll(Otvet, "ID := "+VariableName+".ID", ColumnPK.NameGo+" := "+VariableName+"."+TextID)
Otvet = strings.ReplaceAll(Otvet, VariableName+".ID", VariableName+"."+TextID)
return Otvet
}
//// ReplaceText_RequestID_PrimaryKey1 - заменяет RequestId{} на RequestString{}
//func ReplaceText_RequestID_PrimaryKey1(Text string, Table1 *types.Table, VariableName string) string {
// Otvet := Text
//
// ColumnPK := Find_PrimaryKeyColumn(Table1)
// if ColumnPK == nil {
// return Otvet
// }
//
// //TypeGo := ColumnPK.TypeGo
//
// TextRequestID, TextID := FindText_ProtobufRequest(Table1)
//
// _, GolangCode := Convert_ProtobufVariableToGolangVariable(Table1, ColumnPK, "Request.")
// if GolangCode != "" {
// Otvet = strings.ReplaceAll(Otvet, "ID := "+VariableName+".ID", GolangCode)
// Otvet = strings.ReplaceAll(Otvet, VariableName+".ID = ", VariableName+"."+TextID+" = ")
// }
//
// Otvet = strings.ReplaceAll(Otvet, "RequestId{}", TextRequestID+"{}")
// Otvet = strings.ReplaceAll(Otvet, "*grpc_proto.RequestId", "*grpc_proto."+TextRequestID)
// //Otvet = strings.ReplaceAll(Otvet, "Request.ID", "Request."+TextID)
// Otvet = strings.ReplaceAll(Otvet, "ID := "+VariableName+".ID", ColumnPK.NameGo+" := "+VariableName+"."+TextID)
// Otvet = strings.ReplaceAll(Otvet, VariableName+".ID", VariableName+"."+TextID)
//
// return Otvet
//}
// ReplaceText_RequestID_PrimaryKey_ManyPK - заменяет RequestId{} на RequestString{}
func ReplaceText_RequestID_PrimaryKey_ManyPK(Text string, Table1 *types.Table, TextRequest string) string {
func ReplaceText_RequestID_PrimaryKey_ManyPK(Text string, Table1 *types.Table) string {
Otvet := Text
TextRequestID := FindText_ProtobufRequest_ManyPK(Table1)
@ -2230,36 +2212,6 @@ func ReplaceText_RequestID_PrimaryKey_ManyPK(Text string, Table1 *types.Table, T
return Otvet
}
func Replace_IDtoID(Text string, Table1 *types.Table) string {
Otvet := Text
PrimaryKeyCount := Table1.PrimaryKeyColumnsCount
if PrimaryKeyCount == 1 {
Otvet = Replace_IDtoID1(Otvet, Table1)
} else {
Otvet = Replace_IDtoID_Many(Otvet, Table1)
}
return Otvet
}
// Replace_IDtoID1 - заменяет int64(ID) на ID
func Replace_IDtoID1(Text string, Table1 *types.Table) string {
Otvet := Text
PrimaryKeyColumn := Find_PrimaryKeyColumn(Table1)
OtvetColumnName := Convert_GolangVariableToProtobufVariable(Table1, PrimaryKeyColumn, "")
if OtvetColumnName == "" {
return Otvet
}
Otvet = strings.ReplaceAll(Otvet, "int64(ID)", OtvetColumnName)
Otvet = strings.ReplaceAll(Otvet, "(ID int64", "("+PrimaryKeyColumn.NameGo+" "+PrimaryKeyColumn.TypeGo)
Otvet = strings.ReplaceAll(Otvet, "(ID)", "("+PrimaryKeyColumn.NameGo+")")
return Otvet
}
// FindText_IDMany - находит все PrimaryKey строкой
func FindText_IDMany(Table1 *types.Table) (TextNames, TextNamesTypes, TextProtoNames string) {
//TextProtoNames := ""
@ -2314,101 +2266,51 @@ func FindText_ID_VariableName_Many(Table1 *types.Table, VariableName string) (Te
return
}
// Replace_IDtoID_Many - заменяет int64(ID) на ID, и остальные PrimaryKey
func Replace_IDtoID_Many(Text string, Table1 *types.Table) string {
Otvet := Text
//// Replace_OtvetIDEqual1 - заменяет Otvet.ID = -1
//func Replace_OtvetIDEqual1(Text string, Table1 *types.Table) string {
// Otvet := Text
//
// Otvet = Replace_OtvetIDEqual1_ManyPK(Text, Table1)
//
// return Otvet
//}
TextNames, TextNamesTypes, TextProtoNames := FindText_IDMany(Table1)
//// Replace_OtvetIDEqual1_1 - заменяет Otvet.ID = -1
//func Replace_OtvetIDEqual1_1(Text string, Table1 *types.Table) string {
// Otvet := Text
//
// PrimaryKeyColumn := Find_PrimaryKeyColumn(Table1)
// if PrimaryKeyColumn == nil {
// return Otvet
// }
//
// Value := Find_NegativeValue(PrimaryKeyColumn.TypeGo)
//
// Otvet = strings.ReplaceAll(Otvet, "Otvet.ID = -1", "Otvet.ID = "+Value)
//
// return Otvet
//}
Otvet = strings.ReplaceAll(Otvet, "ReplaceManyID(ID)", TextNames)
Otvet = strings.ReplaceAll(Otvet, "int64(ID)", TextProtoNames)
Otvet = strings.ReplaceAll(Otvet, "(ID int64", "("+TextNamesTypes)
Otvet = strings.ReplaceAll(Otvet, "(ID)", "("+TextNames+")")
Otvet = strings.ReplaceAll(Otvet, ", ID)", ", "+TextNames+")")
Otvet = strings.ReplaceAll(Otvet, ", ID int64)", ", "+TextNamesTypes+")")
return Otvet
}
// Replace_OtvetIDEqual1 - заменяет Otvet.ID = -1
func Replace_OtvetIDEqual1(Text string, Table1 *types.Table) string {
Otvet := Text
//if Table1.PrimaryKeyColumnsCount == 1 {
// Otvet = Replace_OtvetIDEqual1_1(Text, Table1)
//} else {
Otvet = Replace_OtvetIDEqual1_ManyPK(Text, Table1)
//}
return Otvet
}
// Replace_OtvetIDEqual1_1 - заменяет Otvet.ID = -1
func Replace_OtvetIDEqual1_1(Text string, Table1 *types.Table) string {
Otvet := Text
PrimaryKeyColumn := Find_PrimaryKeyColumn(Table1)
if PrimaryKeyColumn == nil {
return Otvet
}
Value := Find_NegativeValue(PrimaryKeyColumn.TypeGo)
Otvet = strings.ReplaceAll(Otvet, "Otvet.ID = -1", "Otvet.ID = "+Value)
return Otvet
}
// Replace_OtvetIDEqual1_ManyPK - заменяет Otvet.ID = -1
func Replace_OtvetIDEqual1_ManyPK(Text string, Table1 *types.Table) string {
Otvet := Text
PrimaryKeyColumns := Find_PrimaryKeyColumns(Table1)
if len(PrimaryKeyColumns) == 0 {
return Otvet
}
TextFind := "\tOtvet.ID = -1\n"
TextNew := ""
for _, ColumnPK1 := range PrimaryKeyColumns {
Value := Find_NegativeValue(ColumnPK1.TypeGo)
TextNew = TextNew + "\tOtvet." + ColumnPK1.NameGo + " = " + Value + "\n"
}
Otvet = strings.ReplaceAll(Otvet, TextFind, TextNew)
return Otvet
}
// Replace_OtvetIDEqual0 - заменяет Otvet.ID = -1
func Replace_OtvetIDEqual0(Text string, Table1 *types.Table) string {
Otvet := Text
ColumnsPK := Find_PrimaryKeyColumns(Table1)
if len(ColumnsPK) == 0 {
return Otvet
}
//
TextFind := "\tOtvet.ID = 0\n"
TextNew := ""
for _, ColumnPK1 := range ColumnsPK {
Value := FindText_DefaultValue(ColumnPK1.TypeGo)
TextNew = TextNew + "\tOtvet." + ColumnPK1.NameGo + " = " + Value + "\n"
}
Otvet = strings.ReplaceAll(Otvet, TextFind, TextNew)
//
TextFind = " Otvet.ID == 0"
for _, ColumnPK1 := range ColumnsPK {
Value := FindText_DefaultValue(ColumnPK1.TypeGo)
TextNew = " Otvet." + ColumnPK1.NameGo + " == " + Value + ""
Otvet = strings.ReplaceAll(Otvet, TextFind, TextNew)
break
}
return Otvet
}
//// Replace_OtvetIDEqual1_ManyPK - заменяет Otvet.ID = -1
//func Replace_OtvetIDEqual1_ManyPK(Text string, Table1 *types.Table) string {
// Otvet := Text
//
// PrimaryKeyColumns := Find_PrimaryKeyColumns(Table1)
// if len(PrimaryKeyColumns) == 0 {
// return Otvet
// }
//
// TextFind := "\tOtvet.ID = -1\n"
// TextNew := ""
// for _, ColumnPK1 := range PrimaryKeyColumns {
// Value := Find_NegativeValue(ColumnPK1.TypeGo)
// TextNew = TextNew + "\tOtvet." + ColumnPK1.NameGo + " = " + Value + "\n"
// }
//
// Otvet = strings.ReplaceAll(Otvet, TextFind, TextNew)
//
// return Otvet
//}
//// Replace_ModelIDEqual1 - заменяет Otvet.ID = -1
//func ReplaceModelIDEqual1_1(Text string, Table1 *types.Table) string {
@ -2761,24 +2663,3 @@ func Find_ColumnNamesWithComma(MassColumns []*types.Column) string {
return Otvet
}
// Convert_RequestIdToAlias - заменяет ID на Alias
func Convert_RequestIdToAlias(Text string, Table1 *types.Table) string {
Otvet := Text
TableName := Table1.Name
IDName, _ := Find_PrimaryKeyNameType(Table1)
TextConvert, ok := types.MapConvertID[TableName+"."+IDName]
if ok == false {
return Otvet
}
Otvet = strings.ReplaceAll(Otvet, "Request.ID", TextConvert+"(Request.ID)")
if TextConvert[:6] != "alias." {
return Otvet
}
Otvet = CheckAndAdd_ImportAlias(Otvet)
return Otvet
}

View File

@ -79,9 +79,9 @@ func CreateFilesCache(Table1 *types.Table) error {
TextCache = strings.ReplaceAll(TextCache, "LRU[int64", "LRU[string")
TextCache = create_files.Replace_PrimaryKeyOtvetID_Many(TextCache, Table1)
TextIDMany := "(ID)"
TextIDMany = create_files.Replace_IDtoID_Many(TextIDMany, Table1)
TextIDMany = Replace_IDtoID(TextIDMany, Table1)
TextCache = strings.ReplaceAll(TextCache, "int64(ID)", "("+Table1.Name+".StringIdentifier"+TextIDMany+")")
TextCache = create_files.Replace_IDtoID_Many(TextCache, Table1)
TextCache = Replace_IDtoID(TextCache, Table1)
}
//uuid
@ -263,3 +263,19 @@ func Replace_Postgres_ID_Test(Text string, Table1 *types.Table) string {
return Otvet
}
// Replace_IDtoID_Many - заменяет int64(ID) на ID, и остальные PrimaryKey
func Replace_IDtoID(Text string, Table1 *types.Table) string {
Otvet := Text
TextNames, TextNamesTypes, TextProtoNames := create_files.FindText_IDMany(Table1)
Otvet = strings.ReplaceAll(Otvet, "ReplaceManyID(ID)", TextNames)
Otvet = strings.ReplaceAll(Otvet, "int64(ID)", TextProtoNames)
Otvet = strings.ReplaceAll(Otvet, "(ID int64", "("+TextNamesTypes)
Otvet = strings.ReplaceAll(Otvet, "(ID)", "("+TextNames+")")
Otvet = strings.ReplaceAll(Otvet, ", ID)", ", "+TextNames+")")
Otvet = strings.ReplaceAll(Otvet, ", ID int64)", ", "+TextNamesTypes+")")
return Otvet
}

View File

@ -160,7 +160,7 @@ func CreateFilesModel_crud(Table1 *types.Table, DirTemplatesModel, DirReadyModel
TextModel = DeleteFromInterfaceReadFromCache(TextModel, Table1)
TextModel = DeleteFunc_ReadFromCache(TextModel, Table1)
}
TextModel = create_files.Replace_IDtoID(TextModel, Table1)
TextModel = Replace_IDtoID(TextModel, Table1)
//
TextModel = AddFunctionStringIdentifier(TextModel, Table1)
@ -569,3 +569,19 @@ func DeleteFunc_ReadFromCache(TextModel string, Table1 *types.Table) string {
return Otvet
}
// Replace_IDtoID_Many - заменяет int64(ID) на ID, и остальные PrimaryKey
func Replace_IDtoID(Text string, Table1 *types.Table) string {
Otvet := Text
TextNames, TextNamesTypes, TextProtoNames := create_files.FindText_IDMany(Table1)
Otvet = strings.ReplaceAll(Otvet, "ReplaceManyID(ID)", TextNames)
Otvet = strings.ReplaceAll(Otvet, "int64(ID)", TextProtoNames)
Otvet = strings.ReplaceAll(Otvet, "(ID int64", "("+TextNamesTypes)
Otvet = strings.ReplaceAll(Otvet, "(ID)", "("+TextNames+")")
Otvet = strings.ReplaceAll(Otvet, ", ID)", ", "+TextNames+")")
Otvet = strings.ReplaceAll(Otvet, ", ID int64)", ", "+TextNamesTypes+")")
return Otvet
}

View File

@ -5,6 +5,8 @@ import (
"github.com/ManyakRus/crud_generator/internal/create_files"
"github.com/ManyakRus/crud_generator/internal/types"
"github.com/ManyakRus/starter/log"
"sort"
"strings"
)
// CreateAllFiles - создаёт все файлы в папке grpc_client
@ -106,3 +108,205 @@ func CreateAllFiles(MapAll map[string]*types.Table) error {
return err
}
// Replace_PrimaryKey_ID - заменяет "m.ID" на название колонки PrimaryKey
func Replace_PrimaryKeyM_ID(Text string, Table1 *types.Table) string {
Otvet := Text
VariableName := "m"
//сортировка по названию таблиц
keys := make([]string, 0, len(Table1.MapColumns))
for k := range Table1.MapColumns {
keys = append(keys, k)
}
sort.Strings(keys)
TextOtvetIDAliasID := ""
TextIfMId := ""
TextIfMIdNot0 := ""
TextM2ID := ""
TextIDRequestID := ""
TextOtvetIDID := ""
TextRequestIDmID := ""
TextRequestIDInt64ID := ""
TextOtvetIDmID := ""
TextMID0 := ""
TextOR := ""
for _, key1 := range keys {
Column1, _ := Table1.MapColumns[key1]
if Column1.IsPrimaryKey != true {
continue
}
TextOtvetIDID = TextOtvetIDID + "\t" + VariableName + "." + Column1.NameGo + " = " + Column1.NameGo + "\n"
RequestColumnName := create_files.Find_RequestFieldName(Table1, Column1)
Value, GolangCode := create_files.Convert_ProtobufVariableToGolangVariable(Table1, Column1, "Request.")
if GolangCode == "" {
TextIDRequestID = TextIDRequestID + "\t" + Column1.NameGo + " := " + Value + "\n"
} else {
TextIDRequestID = TextIDRequestID + "\t" + GolangCode + "\n"
}
TextM := create_files.Convert_GolangVariableToProtobufVariable(Table1, Column1, "m")
TextRequestIDmID = TextRequestIDmID + "\t" + VariableName + "." + RequestColumnName + " = " + TextM + "\n"
TextInt64ID := create_files.Convert_GolangVariableToProtobufVariable(Table1, Column1, "")
TextRequestIDInt64ID = TextRequestIDInt64ID + "\t" + VariableName + "." + RequestColumnName + " = " + TextInt64ID + "\n"
TextOtvetIDmID = TextOtvetIDmID + "\t" + "Otvet." + Column1.NameGo + " = " + VariableName + "." + Column1.NameGo + "\n"
DefaultValue := create_files.FindText_DefaultValue(Column1.TypeGo)
TextM2ID = TextM2ID + "\t" + "m2." + Column1.NameGo + " = " + "m." + Column1.NameGo + "\n"
TextIfMId = TextIfMId + TextOR + "m." + Column1.NameGo + " == " + DefaultValue
TextIfMIdNot0 = TextIfMIdNot0 + TextOR + "m." + Column1.NameGo + " != " + DefaultValue
TextMID0 = TextMID0 + TextOR + " (" + VariableName + "." + Column1.NameGo + " == " + DefaultValue + ")"
TextAlias := create_files.Convert_IDToAlias(Table1, Column1, Column1.NameGo)
TextOtvetIDAliasID = TextOtvetIDAliasID + "\t" + VariableName + "." + Column1.NameGo + " = " + TextAlias + "\n"
TextOR = " || "
}
//Otvet = strings.ReplaceAll(Otvet, "\tRequest.ID = int64(ID)", TextRequestIDInt64ID)
Otvet = strings.ReplaceAll(Otvet, "\t"+VariableName+".ID = AliasFromInt(ID)", TextOtvetIDAliasID)
//заменим ID := Request.ID
Otvet = strings.ReplaceAll(Otvet, "\tID := Request.ID\n", TextIDRequestID)
return Otvet
}
// Replace_PrimaryKeyOtvetID - заменяет "Otvet.ID" на название колонки PrimaryKey
func Replace_PrimaryKeyOtvetID(Text string, Table1 *types.Table) string {
Otvet := Text
VariableName := "Otvet"
//сортировка по названию таблиц
keys := make([]string, 0, len(Table1.MapColumns))
for k := range Table1.MapColumns {
keys = append(keys, k)
}
sort.Strings(keys)
TextOtvetIDAliasID := ""
TextIfMId := ""
TextIfMIdNot0 := ""
TextM2ID := ""
TextIDRequestID := ""
TextOtvetIDID := ""
TextRequestIDmID := ""
TextRequestIDInt64ID := ""
TextOtvetIDVariableID := ""
TextOtvetIDmID := ""
TextMID0 := ""
TextOR := ""
for _, key1 := range keys {
Column1, _ := Table1.MapColumns[key1]
if Column1.IsPrimaryKey != true {
continue
}
TextOtvetIDID = TextOtvetIDID + "\t" + VariableName + "." + Column1.NameGo + " = " + Column1.NameGo + "\n"
RequestColumnName := create_files.Find_RequestFieldName(Table1, Column1)
Value, GolangCode := create_files.Convert_ProtobufVariableToGolangVariable(Table1, Column1, "Request.")
if GolangCode == "" {
TextIDRequestID = TextIDRequestID + "\t" + Column1.NameGo + " := " + Value + "\n"
} else {
TextIDRequestID = TextIDRequestID + "\t" + GolangCode + "\n"
}
TextM := create_files.Convert_GolangVariableToProtobufVariable(Table1, Column1, "m")
TextRequestIDmID = TextRequestIDmID + "\t" + VariableName + "." + RequestColumnName + " = " + TextM + "\n"
TextInt64ID := create_files.Convert_GolangVariableToProtobufVariable(Table1, Column1, "")
TextRequestIDInt64ID = TextRequestIDInt64ID + "\t" + VariableName + "." + RequestColumnName + " = " + TextInt64ID + "\n"
TextOtvetIDVariableID = TextOtvetIDVariableID + "\t" + VariableName + "." + Column1.NameGo + " = " + VariableName + "." + Column1.NameGo + "\n"
TextOtvetIDmID = TextOtvetIDmID + "\t" + VariableName + "." + Column1.NameGo + " = m." + Column1.NameGo + "\n"
DefaultValue := create_files.FindText_DefaultValue(Column1.TypeGo)
TextM2ID = TextM2ID + "\t" + "m2." + Column1.NameGo + " = " + "m." + Column1.NameGo + "\n"
TextIfMId = TextIfMId + TextOR + "m." + Column1.NameGo + " == " + DefaultValue
TextIfMIdNot0 = TextIfMIdNot0 + TextOR + VariableName + "." + Column1.NameGo + " != " + DefaultValue
TextMID0 = TextMID0 + TextOR + " (" + VariableName + "." + Column1.NameGo + " == " + DefaultValue + ")"
TextAlias := create_files.Convert_IDToAlias(Table1, Column1, Column1.NameGo)
TextOtvetIDAliasID = TextOtvetIDAliasID + "\t" + VariableName + "." + Column1.NameGo + " = " + TextAlias + "\n"
TextOR = " || "
}
//Otvet = strings.ReplaceAll(Otvet, "\t"+VariableName+".ID = AliasFromInt(ID)", TextOtvetIDAliasID)
Otvet = strings.ReplaceAll(Otvet, "\t"+VariableName+".ID = ProtoFromInt(m.ID)", TextRequestIDmID)
//Otvet = strings.ReplaceAll(Otvet, "\t"+VariableName+".ID = int64(ID)", TextRequestIDInt64ID)
//Otvet = strings.ReplaceAll(Otvet, "\tOtvet.ID = "+VariableName+".ID\n", TextOtvetIDVariableID)
Otvet = strings.ReplaceAll(Otvet, " IntFromAlias("+VariableName+".ID) == 0", TextMID0)
//Otvet = strings.ReplaceAll(Otvet, "\tm2.ID = int64(m.ID)", TextM2ID)
//Otvet = strings.ReplaceAll(Otvet, "int64(m.ID) == 0", TextIfMId)
//Otvet = strings.ReplaceAll(Otvet, "int64(m.ID) != 0", TextIfMIdNot0)
Otvet = strings.ReplaceAll(Otvet, " IntFromAlias("+VariableName+".ID) != 0", " "+TextIfMIdNot0)
//VariableName = "Request"
//Otvet = strings.ReplaceAll(Otvet, "\t"+VariableName+".ID = ProtoFromInt(m.ID)", TextRequestIDmID)
//Otvet = strings.ReplaceAll(Otvet, " IntFromAlias("+VariableName+".ID) == 0", TextMID0)
//m
Otvet = strings.ReplaceAll(Otvet, "\tOtvet.ID = m.ID\n", TextOtvetIDmID)
return Otvet
}
// Replace_PrimaryKeyRequest_ID - заменяет "m.ID" на название колонки PrimaryKey
func Replace_PrimaryKeyRequest_ID(Text string, Table1 *types.Table) string {
Otvet := Text
VariableName := "Request"
//сортировка по названию таблиц
keys := make([]string, 0, len(Table1.MapColumns))
for k := range Table1.MapColumns {
keys = append(keys, k)
}
sort.Strings(keys)
TextOtvetIDAliasID := ""
TextIfMId := ""
TextIfMIdNot0 := ""
TextM2ID := ""
TextIDRequestID := ""
TextOtvetIDID := ""
TextRequestIDmID := ""
TextRequestIDInt64ID := ""
TextOtvetIDmID := ""
TextMID0 := ""
TextOR := ""
for _, key1 := range keys {
Column1, _ := Table1.MapColumns[key1]
if Column1.IsPrimaryKey != true {
continue
}
TextOtvetIDID = TextOtvetIDID + "\t" + VariableName + "." + Column1.NameGo + " = " + Column1.NameGo + "\n"
RequestColumnName := create_files.Find_RequestFieldName(Table1, Column1)
Value, GolangCode := create_files.Convert_ProtobufVariableToGolangVariable(Table1, Column1, "Request.")
if GolangCode == "" {
TextIDRequestID = TextIDRequestID + "\t" + Column1.NameGo + " := " + Value + "\n"
} else {
TextIDRequestID = TextIDRequestID + "\t" + GolangCode + "\n"
}
TextM := create_files.Convert_GolangVariableToProtobufVariable(Table1, Column1, "m")
TextRequestIDmID = TextRequestIDmID + "\t" + VariableName + "." + RequestColumnName + " = " + TextM + "\n"
TextInt64ID := create_files.Convert_GolangVariableToProtobufVariable(Table1, Column1, "")
TextRequestIDInt64ID = TextRequestIDInt64ID + "\t" + VariableName + "." + RequestColumnName + " = " + TextInt64ID + "\n"
TextOtvetIDmID = TextOtvetIDmID + "\t" + "Otvet." + Column1.NameGo + " = " + VariableName + "." + Column1.NameGo + "\n"
DefaultValue := create_files.FindText_DefaultValue(Column1.TypeGo)
TextM2ID = TextM2ID + "\t" + "m2." + Column1.NameGo + " = " + "m." + Column1.NameGo + "\n"
TextIfMId = TextIfMId + TextOR + "m." + Column1.NameGo + " == " + DefaultValue
TextIfMIdNot0 = TextIfMIdNot0 + TextOR + "m." + Column1.NameGo + " != " + DefaultValue
TextMID0 = TextMID0 + TextOR + " (" + VariableName + "." + Column1.NameGo + " == " + DefaultValue + ")"
TextAlias := create_files.Convert_IDToAlias(Table1, Column1, Column1.NameGo)
TextOtvetIDAliasID = TextOtvetIDAliasID + "\t" + VariableName + "." + Column1.NameGo + " = " + TextAlias + "\n"
TextOR = " || "
}
Otvet = strings.ReplaceAll(Otvet, "\t"+VariableName+".ID = ProtoFromInt(m.ID)", TextRequestIDmID)
Otvet = strings.ReplaceAll(Otvet, "\tRequest.ID = int64(ID)", TextRequestIDInt64ID)
return Otvet
}

View File

@ -87,13 +87,13 @@ func CreateFiles_GRPC_Client_Cache(Table1 *types.Table) error {
TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPC_NRPC_URL)
//замена Request.ID = Int64(ID)
TextGRPCClient = create_files.Replace_PrimaryKeyM_ID(TextGRPCClient, Table1)
TextGRPCClient = Replace_PrimaryKeyRequest_ID(TextGRPCClient, Table1)
//замена RequestId{}
TextGRPCClient = create_files.ReplaceText_RequestID_PrimaryKey(TextGRPCClient, Table1)
TextGRPCClient = ReplaceText_RequestID_PrimaryKey(TextGRPCClient, Table1)
//замена int64(ID) на ID
TextGRPCClient = create_files.Replace_IDtoID(TextGRPCClient, Table1)
TextGRPCClient = Replace_IDtoID(TextGRPCClient, Table1)
//добавим импорт uuid
TextGRPCClient = create_files.CheckAndAdd_ImportUUID_FromText(TextGRPCClient)
@ -150,7 +150,7 @@ func CreateFiles_GRPC_Client_Cache_Test(Table1 *types.Table) error {
ModelTableName := create_files.Find_ModelTableURL(TableName)
TextGRPCClient = create_files.AddImport(TextGRPCClient, ModelTableName)
TextGRPCClient = create_files.Replace_Postgres_ID_Test(TextGRPCClient, Table1)
TextGRPCClient = Replace_Postgres_ID_Test(TextGRPCClient, Table1)
////proto
//RepositoryGRPCProtoURL := create_files.Find_ProtoURL()
//TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryGRPCProtoURL)
@ -174,7 +174,7 @@ func CreateFiles_GRPC_Client_Cache_Test(Table1 *types.Table) error {
//TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPClientFuncURL)
// замена ID на PrimaryKey
TextGRPCClient = create_files.Replace_PrimaryKeyOtvetID(TextGRPCClient, Table1)
TextGRPCClient = Replace_PrimaryKeyOtvetID(TextGRPCClient, Table1)
//добавим импорт uuid
TextGRPCClient = create_files.CheckAndAdd_ImportUUID_FromText(TextGRPCClient)
@ -207,3 +207,31 @@ func CreateFiles_GRPC_Client_Cache_Test(Table1 *types.Table) error {
return err
}
// ReplaceText_RequestID_PrimaryKey - заменяет RequestId{} на RequestString{}
func ReplaceText_RequestID_PrimaryKey(Text string, Table1 *types.Table) string {
Otvet := Text
TextRequestID := create_files.FindText_ProtobufRequest_ManyPK(Table1)
Otvet = strings.ReplaceAll(Otvet, "RequestId{}", TextRequestID+"{}")
Otvet = strings.ReplaceAll(Otvet, "*grpc_proto.RequestId", "*grpc_proto."+TextRequestID)
return Otvet
}
// Replace_IDtoID_Many - заменяет int64(ID) на ID, и остальные PrimaryKey
func Replace_IDtoID(Text string, Table1 *types.Table) string {
Otvet := Text
TextNames, TextNamesTypes, TextProtoNames := create_files.FindText_IDMany(Table1)
Otvet = strings.ReplaceAll(Otvet, "ReplaceManyID(ID)", TextNames)
Otvet = strings.ReplaceAll(Otvet, "int64(ID)", TextProtoNames)
Otvet = strings.ReplaceAll(Otvet, "(ID int64", "("+TextNamesTypes)
Otvet = strings.ReplaceAll(Otvet, "(ID)", "("+TextNames+")")
Otvet = strings.ReplaceAll(Otvet, ", ID)", ", "+TextNames+")")
Otvet = strings.ReplaceAll(Otvet, ", ID int64)", ", "+TextNamesTypes+")")
return Otvet
}

View File

@ -78,13 +78,14 @@ func CreateFiles(Table1 *types.Table) error {
TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPC_NRPC_URL)
//замена ID на PrimaryKey
//TextGRPCClient = create_files.Replace_PrimaryKeyOtvetID(TextGRPCClient, Table1)
TextGRPCClient = Replace_PrimaryKeyRequest_ID(TextGRPCClient, Table1)
TextGRPCClient = Replace_PrimaryKeyOtvetID(TextGRPCClient, Table1)
//замена ID на PrimaryKey
TextGRPCClient = create_files.Replace_PrimaryKeyM_ID(TextGRPCClient, Table1)
TextGRPCClient = Replace_PrimaryKeyM_ID(TextGRPCClient, Table1)
//замена RequestId{}
TextGRPCClient = create_files.ReplaceText_RequestID_PrimaryKey(TextGRPCClient, Table1)
TextGRPCClient = ReplaceText_RequestID_PrimaryKey_ManyPK(TextGRPCClient, Table1)
//добавим импорт uuid
TextGRPCClient = create_files.CheckAndAdd_ImportUUID_FromText(TextGRPCClient)
@ -163,16 +164,16 @@ func CreateFilesTest(Table1 *types.Table) error {
//TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPClientFuncURL)
//Postgres_ID_Test = ID Minimum
TextGRPCClient = create_files.Replace_Postgres_ID_Test(TextGRPCClient, Table1)
TextGRPCClient = Replace_Postgres_ID_Test(TextGRPCClient, Table1)
//замена Otvet.ID = -1
TextGRPCClient = create_files.Replace_OtvetIDEqual1(TextGRPCClient, Table1)
TextGRPCClient = Replace_OtvetIDEqual1(TextGRPCClient, Table1)
//замена Otvet.ID = 0
TextGRPCClient = create_files.Replace_OtvetIDEqual0(TextGRPCClient, Table1)
TextGRPCClient = Replace_OtvetIDEqual0(TextGRPCClient, Table1)
//замена ID на PrimaryKey
TextGRPCClient = create_files.Replace_PrimaryKeyOtvetID(TextGRPCClient, Table1)
TextGRPCClient = Replace_PrimaryKeyOtvetID(TextGRPCClient, Table1)
//добавим импорт uuid
TextGRPCClient = create_files.CheckAndAdd_ImportUUID_FromText(TextGRPCClient)
@ -328,3 +329,132 @@ func DeleteFuncTestFind_byExtID(Text, ModelName string, Table1 *types.Table) str
return Otvet
}
// ReplaceText_RequestID_PrimaryKey_ManyPK - заменяет RequestId{} на RequestString{}
func ReplaceText_RequestID_PrimaryKey_ManyPK(Text string, Table1 *types.Table) string {
Otvet := Text
TextRequestID := create_files.FindText_ProtobufRequest_ManyPK(Table1)
Otvet = strings.ReplaceAll(Otvet, "RequestId{}", TextRequestID+"{}")
Otvet = strings.ReplaceAll(Otvet, "*grpc_proto.RequestId", "*grpc_proto."+TextRequestID)
return Otvet
}
// Replace_Postgres_ID_Test - заменяет текст "const Postgres_ID_Test = 0" на нужные ИД, для много колонок PrimaryKey
func Replace_Postgres_ID_Test(Text string, Table1 *types.Table) string {
Otvet := Text
MassPK := create_files.Find_PrimaryKeyColumns(Table1)
if len(MassPK) == 0 {
return Otvet
}
//заменим const Postgres_ID_Test = 0
TextFind := "const Postgres_ID_Test = 0\n"
TextNew := ""
for _, PrimaryKey1 := range MassPK {
TextNew = TextNew + create_files.Replace_Postgres_ID_Test1(TextFind, Table1, PrimaryKey1)
}
Otvet = strings.ReplaceAll(Otvet, TextFind, TextNew)
//заменим Otvet.ID = Postgres_ID_Test
TextFind = "\tOtvet.ID = Postgres_ID_Test\n"
TextNew = ""
for _, PrimaryKey1 := range MassPK {
Text1 := create_files.FindText_VariableEqual_ColumnName_Test(PrimaryKey1, "Otvet."+PrimaryKey1.NameGo)
TextNew = TextNew + "\t" + Text1 + "\n"
}
Otvet = strings.ReplaceAll(Otvet, TextFind, TextNew)
//заменим m.ID = Postgres_ID_Test
TextFind = "\tm.ID = Postgres_ID_Test\n"
TextNew = ""
for _, PrimaryKey1 := range MassPK {
Text1 := create_files.FindText_VariableEqual_ColumnName_Test(PrimaryKey1, "m."+PrimaryKey1.NameGo)
TextNew = TextNew + "\t" + Text1 + "\n"
}
Otvet = strings.ReplaceAll(Otvet, TextFind, TextNew)
////заменим m1.ID = Postgres_ID_Test
//TextFind = "\tm1.ID = Postgres_ID_Test\n"
//TextNew = ""
//for _, PrimaryKey1 := range MassPK {
// Text1 := create_files.FindText_VariableEqual_ColumnName_Test(PrimaryKey1, "m1."+PrimaryKey1.NameGo)
// TextNew = TextNew + "\t" + Text1 + "\n"
//}
//Otvet = strings.ReplaceAll(Otvet, TextFind, TextNew)
//заменим ReadFromCache(Postgres_ID_Test)
TextFind = "ReadFromCache(Postgres_ID_Test)"
TextNew = "ReadFromCache("
Comma := ""
for _, PrimaryKey1 := range MassPK {
Name := create_files.FindText_ColumnNameTest(PrimaryKey1)
TextNew = TextNew + Comma + Name
Comma = ", "
}
TextNew = TextNew + ")"
Otvet = strings.ReplaceAll(Otvet, TextFind, TextNew)
////заменим ненужные Otvet.ID на Otvet.Name
PrimaryKey1 := MassPK[0]
//Otvet = strings.ReplaceAll(Otvet, " Otvet.ID ", " Otvet."+PrimaryKey1.NameGo+" ")
//Otvet = strings.ReplaceAll(Otvet, " Otvet.ID)", " Otvet."+PrimaryKey1.NameGo+")")
Name := create_files.FindText_ColumnNameTest(PrimaryKey1)
Otvet = strings.ReplaceAll(Otvet, "Postgres_ID_Test", Name)
return Otvet
}
// Replace_OtvetIDEqual1 - заменяет Otvet.ID = -1
func Replace_OtvetIDEqual1(Text string, Table1 *types.Table) string {
Otvet := Text
PrimaryKeyColumns := create_files.Find_PrimaryKeyColumns(Table1)
if len(PrimaryKeyColumns) == 0 {
return Otvet
}
TextFind := "\tOtvet.ID = -1\n"
TextNew := ""
for _, ColumnPK1 := range PrimaryKeyColumns {
Value := create_files.Find_NegativeValue(ColumnPK1.TypeGo)
TextNew = TextNew + "\tOtvet." + ColumnPK1.NameGo + " = " + Value + "\n"
}
Otvet = strings.ReplaceAll(Otvet, TextFind, TextNew)
return Otvet
}
// Replace_OtvetIDEqual0 - заменяет Otvet.ID = -1
func Replace_OtvetIDEqual0(Text string, Table1 *types.Table) string {
Otvet := Text
ColumnsPK := create_files.Find_PrimaryKeyColumns(Table1)
if len(ColumnsPK) == 0 {
return Otvet
}
//
TextFind := "\tOtvet.ID = 0\n"
TextNew := ""
for _, ColumnPK1 := range ColumnsPK {
Value := create_files.FindText_DefaultValue(ColumnPK1.TypeGo)
TextNew = TextNew + "\tOtvet." + ColumnPK1.NameGo + " = " + Value + "\n"
}
Otvet = strings.ReplaceAll(Otvet, TextFind, TextNew)
//
TextFind = " Otvet.ID == 0"
for _, ColumnPK1 := range ColumnsPK {
Value := create_files.FindText_DefaultValue(ColumnPK1.TypeGo)
TextNew = " Otvet." + ColumnPK1.NameGo + " == " + Value + ""
Otvet = strings.ReplaceAll(Otvet, TextFind, TextNew)
break
}
return Otvet
}

View File

@ -159,11 +159,11 @@ func FindTextUpdateEveryColumn1(TextGRPC_ClientUpdateFunc string, Table1 *types.
Otvet = strings.ReplaceAll(Otvet, "grpc_proto.RequestId", "grpc_proto."+TextRequest)
//замена RequestId{}
Otvet = create_files.ReplaceText_RequestID_and_Column(Otvet, Table1, Column1)
Otvet = ReplaceText_RequestID_and_Column(Otvet, Table1, Column1)
Otvet = create_files.ReplaceText_RequestID_PrimaryKey(Otvet, Table1)
//замена ID на PrimaryKey
Otvet = create_files.Replace_PrimaryKeyM_ID(Otvet, Table1)
Otvet = Replace_PrimaryKeyM_ID(Otvet, Table1)
//
ColumnNameGolang := create_files.Convert_GolangVariableToProtobufVariable(Table1, Column1, "m")
@ -184,6 +184,9 @@ func FindTextUpdateEveryColumn1(TextGRPC_ClientUpdateFunc string, Table1 *types.
Otvet = strings.ReplaceAll(Otvet, "ColumnName", ColumnName)
Otvet = strings.ReplaceAll(Otvet, "Request.FieldName", "Request."+TextRequestFieldName)
Otvet = Replace_PrimaryKeyRequest_ID(Otvet, Table1)
Otvet = Replace_PrimaryKeyOtvetID(Otvet, Table1)
return Otvet
}
@ -257,12 +260,12 @@ func CreateFilesUpdateEveryColumnTest(Table1 *types.Table) error {
//GRPClientFuncURL := create_files.Find_GRPCClient_func_URL()
//TextGRPC_Client = create_files.AddImport(TextGRPC_Client, GRPClientFuncURL)
TextGRPC_Client = create_files.Replace_Postgres_ID_Test(TextGRPC_Client, Table1)
TextGRPC_Client = Replace_Postgres_ID_Test(TextGRPC_Client, Table1)
TextGRPC_Client = create_files.Replace_PrimaryKeyOtvetID(TextGRPC_Client, Table1)
TextGRPC_Client = Replace_PrimaryKeyOtvetID(TextGRPC_Client, Table1)
//замена m.ID = Postgres_ID_Test
TextGRPC_Client = create_files.Replace_PrimaryKeyM_ID(TextGRPC_Client, Table1)
TextGRPC_Client = Replace_PrimaryKeyM_ID(TextGRPC_Client, Table1)
}
@ -334,11 +337,11 @@ func FindTextUpdateEveryColumnTest(TextGRPC_ClientUpdateFunc string, Table1 *typ
func FindTextUpdateEveryColumnTest1(TextGRPC_ClientUpdateFunc string, Table1 *types.Table, Column1 *types.Column) string {
Otvet := TextGRPC_ClientUpdateFunc
Otvet = create_files.Replace_Postgres_ID_Test(Otvet, Table1)
Otvet = Replace_Postgres_ID_Test(Otvet, Table1)
Otvet = create_files.ReplaceText_RequestID_and_Column(Otvet, Table1, Column1)
Otvet = create_files.Replace_PrimaryKeyM_ID(Otvet, Table1)
Otvet = create_files.Replace_PrimaryKeyOtvetID(Otvet, Table1)
Otvet = ReplaceText_RequestID_and_Column(Otvet, Table1, Column1)
Otvet = Replace_PrimaryKeyM_ID(Otvet, Table1)
Otvet = Replace_PrimaryKeyOtvetID(Otvet, Table1)
//ModelName := Table1.NameGo
ColumnName := Column1.NameGo
@ -362,3 +365,16 @@ func FindTextUpdateEveryColumnTest1(TextGRPC_ClientUpdateFunc string, Table1 *ty
return Otvet
}
// ReplaceText_RequestID_and_Column - заменяет RequestId{} на RequestString{}
func ReplaceText_RequestID_and_Column(Text string, Table1 *types.Table, Column1 *types.Column) string {
Otvet := Text
//TypeGo := Column1.TypeGo
TextRequestID, _, _, _ := create_files.FindText_ProtobufRequest_ID_Type(Table1, Column1, "Request")
Otvet = strings.ReplaceAll(Otvet, "RequestId{}", TextRequestID+"{}")
//Otvet = strings.ReplaceAll(Otvet, "Request.ID", "Request."+TextID)
return Otvet
}

View File

@ -169,3 +169,24 @@ func Replace_Model_ID_Test_ManyPK(Text string, Table1 *types.Table) string {
return Otvet
}
// Convert_RequestIdToAlias - заменяет ID на Alias
func Convert_RequestIdToAlias(Text string, Table1 *types.Table) string {
Otvet := Text
TableName := Table1.Name
IDName, _ := create_files.Find_PrimaryKeyNameType(Table1)
TextConvert, ok := types.MapConvertID[TableName+"."+IDName]
if ok == false {
return Otvet
}
Otvet = strings.ReplaceAll(Otvet, "Request.ID", TextConvert+"(Request.ID)")
if TextConvert[:6] != "alias." {
return Otvet
}
Otvet = create_files.CheckAndAdd_ImportAlias(Otvet)
return Otvet
}

View File

@ -61,11 +61,11 @@ func CreateFilesCache(Table1 *types.Table) error {
//TextGRPCServer = create_files.Replace_IntFromProtoRequest(TextGRPCServer, Table1)
//замена RequestId{}
TextGRPCServer = create_files.ReplaceText_RequestID_PrimaryKey(TextGRPCServer, Table1)
TextGRPCServer = ReplaceText_RequestID_PrimaryKey_ManyPK(TextGRPCServer, Table1)
TextGRPCServer = create_files.Replace_PrimaryKeyOtvetID(TextGRPCServer, Table1)
//TextGRPCServer = create_files.Replace_PrimaryKeyOtvetID(TextGRPCServer, Table1)
TextGRPCServer = create_files.Replace_PrimaryKeyM_ID(TextGRPCServer, Table1)
TextGRPCServer = Replace_PrimaryKeyM_ID(TextGRPCServer, Table1)
if Table1.PrimaryKeyColumnsCount == 1 {
ColumnPK := create_files.Find_PrimaryKeyColumn(Table1)
@ -73,10 +73,10 @@ func CreateFilesCache(Table1 *types.Table) error {
//ColumnPK := create_files.Find_PrimaryKeyColumn(Table1)
} else {
TextIDMany := "ReplaceManyID(ID)"
TextIDMany = create_files.Replace_IDtoID_Many(TextIDMany, Table1)
//TextIDMany = create_files.Replace_IDtoID_Many(TextIDMany, Table1)
TextGRPCServer = strings.ReplaceAll(TextGRPCServer, "ReplaceManyID(ID)", TextIDMany)
}
TextGRPCServer = create_files.Replace_IDtoID_Many(TextGRPCServer, Table1)
TextGRPCServer = Replace_IDtoID_Many(TextGRPCServer, Table1)
//добавим импорт uuid
TextGRPCServer = create_files.CheckAndAdd_ImportUUID_FromText(TextGRPCServer)
@ -158,7 +158,7 @@ func CreateFilesCacheTest(Table1 *types.Table) error {
TextGRPCServer = Replace_Model_ID_Test(TextGRPCServer, Table1)
//замена RequestId{}
TextGRPCServer = create_files.ReplaceText_RequestID_PrimaryKey(TextGRPCServer, Table1)
TextGRPCServer = ReplaceText_RequestID_PrimaryKey(TextGRPCServer, Table1)
//добавим импорт uuid
TextGRPCServer = create_files.CheckAndAdd_ImportUUID_FromText(TextGRPCServer)
@ -190,3 +190,31 @@ func CreateFilesCacheTest(Table1 *types.Table) error {
return err
}
// ReplaceText_RequestID_PrimaryKey_ManyPK - заменяет RequestId{} на RequestString{}
func ReplaceText_RequestID_PrimaryKey_ManyPK(Text string, Table1 *types.Table) string {
Otvet := Text
TextRequestID := create_files.FindText_ProtobufRequest_ManyPK(Table1)
Otvet = strings.ReplaceAll(Otvet, "RequestId{}", TextRequestID+"{}")
Otvet = strings.ReplaceAll(Otvet, "*grpc_proto.RequestId", "*grpc_proto."+TextRequestID)
return Otvet
}
// Replace_IDtoID_Many - заменяет int64(ID) на ID, и остальные PrimaryKey
func Replace_IDtoID_Many(Text string, Table1 *types.Table) string {
Otvet := Text
TextNames, _, _ := create_files.FindText_IDMany(Table1)
Otvet = strings.ReplaceAll(Otvet, "ReplaceManyID(ID)", TextNames)
//Otvet = strings.ReplaceAll(Otvet, "int64(ID)", TextProtoNames)
//Otvet = strings.ReplaceAll(Otvet, "(ID int64", "("+TextNamesTypes)
//Otvet = strings.ReplaceAll(Otvet, "(ID)", "("+TextNames+")")
//Otvet = strings.ReplaceAll(Otvet, ", ID)", ", "+TextNames+")")
//Otvet = strings.ReplaceAll(Otvet, ", ID int64)", ", "+TextNamesTypes+")")
return Otvet
}

View File

@ -90,7 +90,7 @@ func CreateFiles(Table1 *types.Table) error {
//TextGRPCServer = config.Settings.TEXT_MODULE_GENERATED + TextGRPCServer
if config.Settings.USE_DEFAULT_TEMPLATE == true {
TextGRPCServer = create_files.Convert_RequestIdToAlias(TextGRPCServer, Table1)
TextGRPCServer = Convert_RequestIdToAlias(TextGRPCServer, Table1)
}
//удаление пустого импорта

View File

@ -81,11 +81,11 @@ func CreateFilesUpdateEveryColumn(Table1 *types.Table) error {
TextGRPCServer = TextGRPCServer + TextUpdateEveryColumn
if config.Settings.USE_DEFAULT_TEMPLATE == true {
TextGRPCServer = create_files.Convert_RequestIdToAlias(TextGRPCServer, Table1)
TextGRPCServer = Convert_RequestIdToAlias(TextGRPCServer, Table1)
TextGRPCServer = create_files.CheckAndAdd_ImportAlias(TextGRPCServer)
//замена RequestId{}
TextGRPCServer = create_files.ReplaceText_RequestID_PrimaryKey(TextGRPCServer, Table1)
TextGRPCServer = ReplaceText_RequestID_PrimaryKey(TextGRPCServer, Table1)
//добавим импорт uuid
TextGRPCServer = create_files.CheckAndAdd_ImportUUID_FromText(TextGRPCServer)
@ -149,8 +149,8 @@ func FindTextUpdateEveryColumn1(TextGRPCServerUpdateFunc string, Table1 *types.T
IsPrimaryKey := create_files.IsPrimaryKeyColumn(Table1, Column1)
//замена ID на PrimaryKey
Otvet = create_files.Replace_PrimaryKeyOtvetID(Otvet, Table1)
Otvet = create_files.Replace_PrimaryKeyM_ID(Otvet, Table1)
//Otvet = create_files.Replace_PrimaryKeyOtvetID(Otvet, Table1)
Otvet = Replace_PrimaryKeyM_ID(Otvet, Table1)
//ColumnNameGolang := create_files.Convert_GolangVariableToProtobufVariable(Table1, Column1, "m")
@ -276,7 +276,7 @@ func CreateFilesUpdateEveryColumnTest(Table1 *types.Table) error {
TextGRPCServer = config.Settings.TEXT_MODULE_GENERATED + TextGRPCServer
//замена RequestId{}
TextGRPCServer = create_files.ReplaceText_RequestID_PrimaryKey(TextGRPCServer, Table1)
TextGRPCServer = ReplaceText_RequestID_PrimaryKey(TextGRPCServer, Table1)
//добавим импорт uuid
TextGRPCServer = create_files.CheckAndAdd_ImportUUID_FromText(TextGRPCServer)