mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2024-12-13 21:42:33 +02:00
сделал ExtID
This commit is contained in:
parent
3f2d295f82
commit
ec6b35f307
@ -444,8 +444,8 @@ func Is_Need_Сolumn(Column1 *types.Column) bool {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// GetColumn_ExtID - возвращает колонку ExtID
|
||||
func GetColumn_ExtID(Table1 *types.Table) *types.Column {
|
||||
// FindColumn_ExtID - возвращает колонку ExtID
|
||||
func FindColumn_ExtID(Table1 *types.Table) *types.Column {
|
||||
Column1, ok := Table1.MapColumns["ext_id"]
|
||||
if ok == false {
|
||||
return nil
|
||||
|
@ -550,7 +550,7 @@ func DeleteFunc_DeleteCtx(TextModel string, Table1 *types.Table) string {
|
||||
func ReplaceText_ExtID0(TextDB string, Table1 *types.Table) string {
|
||||
Otvet := TextDB
|
||||
|
||||
ColumnExtID := create_files.GetColumn_ExtID(Table1)
|
||||
ColumnExtID := create_files.FindColumn_ExtID(Table1)
|
||||
if ColumnExtID == nil {
|
||||
return Otvet
|
||||
}
|
||||
|
@ -365,3 +365,34 @@ func Replace_NRPC_CLIENT(Text string) string {
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// Replace_RequestExtID - заменяет RequestExtID{} на Request_Int64_String{}
|
||||
func Replace_RequestExtID(TextGRPCServer string, Table1 *types.Table) string {
|
||||
Otvet := TextGRPCServer
|
||||
|
||||
//если нет таких колонок - ничего не делаем
|
||||
if create_files.Has_Column_ExtID_ConnectionID(Table1) == false {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
//если обе колонки Int64 - ничего не делаем
|
||||
if create_files.Has_Column_ExtID_ConnectionID_Int64(Table1) == true {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
//
|
||||
ColumnExtID := create_files.FindColumn_ExtID(Table1)
|
||||
if ColumnExtID == nil {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
//
|
||||
if ColumnExtID.TypeGo != "string" {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
//
|
||||
Otvet = strings.ReplaceAll(Otvet, "grpc_proto.RequestExtID", "grpc_proto.RequestExtIDString")
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
@ -110,6 +110,8 @@ func CreateFiles(Table1 *types.Table) error {
|
||||
TextGRPCClient = create_files.Replace_TemplateTableName_to_TableName(TextGRPCClient, Table1.Name)
|
||||
TextGRPCClient = create_files.AddText_ModuleGenerated(TextGRPCClient)
|
||||
|
||||
TextGRPCClient = Replace_RequestExtID(TextGRPCClient, Table1)
|
||||
|
||||
//ModelName := Table1.NameGo
|
||||
//TextGRPCClient = strings.ReplaceAll(TextGRPCClient, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
||||
//TextGRPCClient = strings.ReplaceAll(TextGRPCClient, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
|
||||
|
@ -19,7 +19,7 @@ func FindText_ProtoTable1(TextProto string, Table1 *types.Table) string {
|
||||
Otvet = Otvet + FindText_Update(TextProto, ModelName)
|
||||
Otvet = Otvet + FindText_Save(TextProto, ModelName)
|
||||
if create_files.Has_Column_ExtID_ConnectionID(Table1) == true {
|
||||
Otvet = Otvet + FindText_FindByExtId(TextProto, ModelName)
|
||||
Otvet = Otvet + FindText_FindByExtId(TextProto, Table1)
|
||||
}
|
||||
|
||||
if create_files.Has_Column_IsDeleted_Bool(Table1) == true {
|
||||
@ -130,9 +130,9 @@ func FindText_Restore(TextProto string, Table1 *types.Table) string {
|
||||
}
|
||||
|
||||
// FindText_FindByExtId - возвращает текст .proto
|
||||
func FindText_FindByExtId(TextProto string, ModelName string) string {
|
||||
func FindText_FindByExtId(TextProto string, Table1 *types.Table) string {
|
||||
Otvet := ""
|
||||
Otvet2 := Text_FindByExtId(ModelName)
|
||||
Otvet2 := Text_FindByExtId(Table1)
|
||||
|
||||
//проверка такой текст уже есть
|
||||
pos1 := strings.Index(TextProto, Otvet2)
|
||||
@ -215,8 +215,18 @@ func Text_Restore(Table1 *types.Table) string {
|
||||
}
|
||||
|
||||
// Text_FindByExtId - возвращает текст .proto
|
||||
func Text_FindByExtId(ModelName string) string {
|
||||
Otvet := "rpc " + ModelName + "_FindByExtID(RequestExtID) returns (Response) {}"
|
||||
func Text_FindByExtId(Table1 *types.Table) string {
|
||||
Otvet := ""
|
||||
ModelName := Table1.NameGo_translit
|
||||
ColumnExtID := create_files.FindColumn_ExtID(Table1)
|
||||
if ColumnExtID == nil {
|
||||
return Otvet
|
||||
}
|
||||
if ColumnExtID.TypeGo == "string" {
|
||||
Otvet = "rpc " + ModelName + "_FindByExtID(RequestExtIDString) returns (Response) {}"
|
||||
} else {
|
||||
Otvet = "rpc " + ModelName + "_FindByExtID(RequestExtID) returns (Response) {}"
|
||||
}
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
@ -86,6 +86,7 @@ func CreateFiles(Table1 *types.Table) error {
|
||||
TextGRPCServer = create_files.Replace_TemplateModel_to_Model(TextGRPCServer, Table1.NameGo)
|
||||
TextGRPCServer = create_files.Replace_TemplateTableName_to_TableName(TextGRPCServer, Table1.Name)
|
||||
TextGRPCServer = create_files.AddText_ModuleGenerated(TextGRPCServer)
|
||||
TextGRPCServer = Replace_RequestExtID(TextGRPCServer, Table1)
|
||||
|
||||
//ModelName := Table1.NameGo
|
||||
//TextGRPCServer = strings.ReplaceAll(TextGRPCServer, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
||||
@ -520,3 +521,34 @@ func Replace_OtvetIDEqual0(Text string, Table1 *types.Table) string {
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// Replace_RequestExtID - заменяет RequestExtID{} на Request_Int64_String{}
|
||||
func Replace_RequestExtID(TextGRPCServer string, Table1 *types.Table) string {
|
||||
Otvet := TextGRPCServer
|
||||
|
||||
//если нет таких колонок - ничего не делаем
|
||||
if create_files.Has_Column_ExtID_ConnectionID(Table1) == false {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
//если обе колонки Int64 - ничего не делаем
|
||||
if create_files.Has_Column_ExtID_ConnectionID_Int64(Table1) == true {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
//
|
||||
ColumnExtID := create_files.FindColumn_ExtID(Table1)
|
||||
if ColumnExtID == nil {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
//
|
||||
if ColumnExtID.TypeGo != "string" {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
//
|
||||
Otvet = strings.ReplaceAll(Otvet, "grpc_proto.RequestExtID", "grpc_proto.RequestExtIDString")
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user