mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2025-01-07 13:39:43 +02:00
сделал CreateFilesUpdateEveryColumn()
This commit is contained in:
parent
33b784ca4f
commit
acad10242c
@ -1,5 +1,5 @@
|
|||||||
// LawsuitStatusType_Read - изменяет колонку ColumnName в базе данных
|
// LawsuitStatusType_Update - изменяет колонку ColumnName в базе данных
|
||||||
func (s *ServerGRPC) LawsuitStatusType_Read(ctx context.Context, Request *grpc_proto.RequestId) (*grpc_proto.ResponseEmpty, error) {
|
func (s *ServerGRPC) LawsuitStatusType_Update(ctx context.Context, Request *grpc_proto.RequestId) (*grpc_proto.ResponseEmpty, error) {
|
||||||
var Otvet grpc_proto.ResponseEmpty
|
var Otvet grpc_proto.ResponseEmpty
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
@ -20,7 +20,8 @@ func (s *ServerGRPC) LawsuitStatusType_Read(ctx context.Context, Request *grpc_p
|
|||||||
//запрос в БД
|
//запрос в БД
|
||||||
Model := &lawsuit_status_types.LawsuitStatusType{}
|
Model := &lawsuit_status_types.LawsuitStatusType{}
|
||||||
Model.ID = Request.ID
|
Model.ID = Request.ID
|
||||||
err = Model.Read()
|
Model.ColumnName = Request.FieldName
|
||||||
|
err = Model.Update()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &Otvet, err
|
return &Otvet, err
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,29 @@
|
|||||||
func Test_server_LawsuitStatusType_Read(t *testing.T) {
|
func Test_server_LawsuitStatusType_Update(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
crud_starter.InitCrudTransport_DB()
|
crud_starter.InitCrudTransport_DB()
|
||||||
|
|
||||||
|
server1 := &ServerGRPC{}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
|
//прочитаем из БД
|
||||||
Request := grpc_proto.RequestId{}
|
Request := grpc_proto.RequestId{}
|
||||||
Request.ID = LawsuitStatusType_ID_Test
|
Request.ID = LawsuitStatusType_ID_Test
|
||||||
Request.VersionModel = lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
Request.VersionModel = lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||||
|
Model, err := server1.LawsuitStatusType_Read(ctx, &Request)
|
||||||
server1 := &ServerGRPC{}
|
|
||||||
Otvet, err := server1.LawsuitStatusType_Read(ctx, &Request)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("Test_server_LawsuitStatusType_Read() error: ", err)
|
t.Error("Test_server_LawsuitStatusType_Update() Read() error: ", err)
|
||||||
}
|
}
|
||||||
if Otvet.ModelString == "" {
|
if Otvet.ModelString == "" {
|
||||||
t.Error("Test_server_LawsuitStatusType_Read() error: ModelString=''")
|
t.Error("Test_server_LawsuitStatusType_Update() Read() error: ModelString=''")
|
||||||
|
}
|
||||||
|
|
||||||
|
//запишем в БД это же значение
|
||||||
|
Request := grpc_proto.RequestString{}
|
||||||
|
Request.ID = LawsuitStatusType_ID_Test
|
||||||
|
Request.ColumnName = Model.ColumnName
|
||||||
|
Request.VersionModel = lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||||
|
_, err := server1.LawsuitStatusType_Update(ctx, &Request)
|
||||||
|
if err != nil {
|
||||||
|
t.Error("Test_server_LawsuitStatusType_Update() Update() error: ", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,16 +1,24 @@
|
|||||||
func TestRead(t *testing.T) {
|
func TestUpdate(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
|
|
||||||
postgres_gorm.Connect()
|
postgres_gorm.Connect()
|
||||||
defer postgres_gorm.CloseConnection()
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
|
//прочитаем из БД
|
||||||
crud := Crud_DB{}
|
crud := Crud_DB{}
|
||||||
Otvet := lawsuit_status_types.LawsuitStatusType{}
|
Model := lawsuit_status_types.LawsuitStatusType{}
|
||||||
Otvet.ID = Postgres_ID_Test
|
Model.ID = Postgres_ID_Test
|
||||||
Otvet.ColumnName = DefaultValue
|
err := crud.Read(&Model)
|
||||||
err := crud.Read(&Otvet)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("TestRead() error: ", err)
|
t.Error("TestUpdate() Read() error: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//запишем в БД это же значение
|
||||||
|
Otvet := lawsuit_status_types.LawsuitStatusType{}
|
||||||
|
Otvet.ID = Postgres_ID_Test
|
||||||
|
Otvet.ColumnName = Model.ColumnName
|
||||||
|
err = crud.Update(&Otvet)
|
||||||
|
if err != nil {
|
||||||
|
t.Error("TestUpdate() Update() error: ", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Read - изменяет 1 поле Name в базе данных
|
// Update - изменяет 1 поле Name в базе данных
|
||||||
func (crud Crud_GRPC) Read(m *lawsuit_status_types.LawsuitStatusType) error {
|
func (crud Crud_GRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// подключение
|
// подключение
|
||||||
@ -10,6 +10,7 @@ func (crud Crud_GRPC) Read(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
|
|
||||||
Request := &grpc_proto.RequestId{}
|
Request := &grpc_proto.RequestId{}
|
||||||
Request.ID = m.ID
|
Request.ID = m.ID
|
||||||
|
Request.FieldName = m.ColumnName
|
||||||
Request.VersionModel = versionModel
|
Request.VersionModel = versionModel
|
||||||
|
|
||||||
ctxMain := context.Background()
|
ctxMain := context.Background()
|
||||||
@ -18,9 +19,9 @@ func (crud Crud_GRPC) Read(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
|
|
||||||
// запрос
|
// запрос
|
||||||
if grpc_nrpc.NeedNRPC == true {
|
if grpc_nrpc.NeedNRPC == true {
|
||||||
_, err = nrpc_client.Client.LawsuitStatusType_Read(Request)
|
_, err = nrpc_client.Client.LawsuitStatusType_Update(Request)
|
||||||
} else {
|
} else {
|
||||||
_, err = grpc_client.Client.LawsuitStatusType_Read(ctx, Request)
|
_, err = grpc_client.Client.LawsuitStatusType_Update(ctx, Request)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sError := err.Error()
|
sError := err.Error()
|
||||||
|
@ -1,14 +1,26 @@
|
|||||||
func TestCrud_GRPC_Read(t *testing.T) {
|
func TestCrud_GRPC_Update(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
|
|
||||||
grpc_client.Connect()
|
grpc_client.Connect()
|
||||||
defer grpc_client.CloseConnection()
|
defer grpc_client.CloseConnection()
|
||||||
|
|
||||||
crud := Crud_GRPC{}
|
crud := Crud_GRPC{}
|
||||||
Otvet := lawsuit_status_types.LawsuitStatusType{}
|
|
||||||
Otvet.ID = Postgres_ID_Test
|
//прочитаем из БД
|
||||||
err := crud.Read(&Otvet)
|
Model := lawsuit_status_types.LawsuitStatusType{}
|
||||||
|
Model.ID = Postgres_ID_Test
|
||||||
|
err := crud.LawsuitStatusType_Read(&Model)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("TestRead() error: ", err)
|
t.Error("TestCrud_GRPC_Update() Read() error: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
//запишем в БД это же значение
|
||||||
|
Otvet := lawsuit_status_types.LawsuitStatusType{}
|
||||||
|
Otvet.ID = Model.ID
|
||||||
|
Otvet.ColumnName = Model.ColumnName
|
||||||
|
err = crud.LawsuitStatusType_Update(&Otvet)
|
||||||
|
if err != nil {
|
||||||
|
t.Error("TestCrud_GRPC_Update() Update() error: ", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -957,6 +957,53 @@ func FindTextProtobufRequest(TypeGo string) (string, string) {
|
|||||||
return Otvet, TextRequestFieldName
|
return Otvet, TextRequestFieldName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FindTextProtobufRequest_ID_Type - возвращает имя message из .proto для двух параметров ID + Type,в зависимости от типа, а также название поля
|
||||||
|
func FindTextProtobufRequest_ID_Type(TypeGo string) (string, string) {
|
||||||
|
Otvet := "RequestID"
|
||||||
|
TextRequestFieldName := "ID"
|
||||||
|
|
||||||
|
switch TypeGo {
|
||||||
|
case "int", "int64":
|
||||||
|
{
|
||||||
|
Otvet = "Request_ID_Int64"
|
||||||
|
TextRequestFieldName = "Int64"
|
||||||
|
}
|
||||||
|
|
||||||
|
case "int32":
|
||||||
|
{
|
||||||
|
Otvet = "Request_ID_Int32"
|
||||||
|
TextRequestFieldName = "Int32"
|
||||||
|
}
|
||||||
|
case "string":
|
||||||
|
{
|
||||||
|
Otvet = "Request_ID_String"
|
||||||
|
TextRequestFieldName = "StringFind"
|
||||||
|
}
|
||||||
|
case "time.Time":
|
||||||
|
{
|
||||||
|
Otvet = "Request_ID_Date"
|
||||||
|
TextRequestFieldName = "Date"
|
||||||
|
}
|
||||||
|
case "float32":
|
||||||
|
{
|
||||||
|
Otvet = "Request_ID_Float32"
|
||||||
|
TextRequestFieldName = "Float32"
|
||||||
|
}
|
||||||
|
case "float64":
|
||||||
|
{
|
||||||
|
Otvet = "Request_ID_Float64"
|
||||||
|
TextRequestFieldName = "Float64"
|
||||||
|
}
|
||||||
|
case "bool":
|
||||||
|
{
|
||||||
|
Otvet = "Request_ID_Bool"
|
||||||
|
TextRequestFieldName = "Bool"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Otvet, TextRequestFieldName
|
||||||
|
}
|
||||||
|
|
||||||
// ConvertIdToAlias - заменяет ID на Alias
|
// ConvertIdToAlias - заменяет ID на Alias
|
||||||
func ConvertIdToAlias(Text string, Table1 *types.Table) string {
|
func ConvertIdToAlias(Text string, Table1 *types.Table) string {
|
||||||
Otvet := Text
|
Otvet := Text
|
||||||
|
@ -695,17 +695,15 @@ func FindTextUpdateEveryColumnTest1(TextCrudUpdateFunc string, Table1 *types.Tab
|
|||||||
TextRequest, TextRequestFieldName := create_files.FindTextProtobufRequest(Column1.TypeGo)
|
TextRequest, TextRequestFieldName := create_files.FindTextProtobufRequest(Column1.TypeGo)
|
||||||
DefaultValue := create_files.FindTextDefaultValue(Column1.TypeGo)
|
DefaultValue := create_files.FindTextDefaultValue(Column1.TypeGo)
|
||||||
|
|
||||||
Otvet = strings.ReplaceAll(Otvet, " TestCrud_GRPC_Read(", " TestCrud_GRPC_"+FuncName+"(")
|
|
||||||
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
|
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
|
||||||
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "grpc_proto.RequestId", "grpc_proto."+TextRequest)
|
Otvet = strings.ReplaceAll(Otvet, "grpc_proto.RequestId", "grpc_proto."+TextRequest)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "ColumnName", ColumnName)
|
Otvet = strings.ReplaceAll(Otvet, "ColumnName", ColumnName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "Model.ID", "Model."+ColumnName)
|
|
||||||
Otvet = strings.ReplaceAll(Otvet, "Request.ID", "Request."+TextRequestFieldName)
|
Otvet = strings.ReplaceAll(Otvet, "Request.ID", "Request."+TextRequestFieldName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "Otvet.Name", "Otvet."+ColumnName)
|
Otvet = strings.ReplaceAll(Otvet, "Otvet.Name", "Otvet."+ColumnName)
|
||||||
//Otvet = strings.ReplaceAll(Otvet, "Postgres_ID_Test", DefaultValue)
|
//Otvet = strings.ReplaceAll(Otvet, "Postgres_ID_Test", DefaultValue)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "TestRead(", "Test"+FuncName+"(")
|
Otvet = strings.ReplaceAll(Otvet, "TestUpdate(", "Test"+FuncName+"(")
|
||||||
Otvet = strings.ReplaceAll(Otvet, ".Read(", "."+FuncName+"(")
|
Otvet = strings.ReplaceAll(Otvet, ".Update(", "."+FuncName+"(")
|
||||||
Otvet = strings.ReplaceAll(Otvet, " DefaultValue", " "+DefaultValue)
|
Otvet = strings.ReplaceAll(Otvet, " DefaultValue", " "+DefaultValue)
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
|
@ -471,19 +471,17 @@ func FindTextUpdateEveryColumn1(TextGRPC_ClientUpdateFunc string, Table1 *types.
|
|||||||
ModelName := Table1.NameGo
|
ModelName := Table1.NameGo
|
||||||
ColumnName := Column1.NameGo
|
ColumnName := Column1.NameGo
|
||||||
FuncName := "Update_" + ColumnName
|
FuncName := "Update_" + ColumnName
|
||||||
TextRequest, TextRequestFieldName := create_files.FindTextProtobufRequest(Column1.TypeGo)
|
TextRequest, TextRequestFieldName := create_files.FindTextProtobufRequest_ID_Type(Column1.TypeGo)
|
||||||
|
|
||||||
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_MODEL+"_Read", ModelName+"_"+FuncName)
|
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_MODEL+"_Update", ModelName+"_"+FuncName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, " Read ", " "+FuncName+" ")
|
Otvet = strings.ReplaceAll(Otvet, " Update ", " "+FuncName+" ")
|
||||||
Otvet = strings.ReplaceAll(Otvet, " Read(", " "+FuncName+"(")
|
Otvet = strings.ReplaceAll(Otvet, " Update(", " "+FuncName+"(")
|
||||||
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
|
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "grpc_proto.RequestId", "grpc_proto."+TextRequest)
|
Otvet = strings.ReplaceAll(Otvet, "grpc_proto.RequestId", "grpc_proto."+TextRequest)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "ColumnName", ColumnName)
|
Otvet = strings.ReplaceAll(Otvet, "ColumnName", ColumnName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "Model.ID", "Model."+ColumnName)
|
Otvet = strings.ReplaceAll(Otvet, "m.ColumnName", "m."+ColumnName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "Request.ID", "Request."+TextRequestFieldName)
|
Otvet = strings.ReplaceAll(Otvet, "Request.FieldName", "Request."+TextRequestFieldName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, " Name ", " "+ColumnName+" ")
|
|
||||||
Otvet = strings.ReplaceAll(Otvet, "m.ID", "m."+ColumnName)
|
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
@ -592,21 +590,18 @@ func FindTextUpdateEveryColumnTest1(TextGRPC_ClientUpdateFunc string, Table1 *ty
|
|||||||
ModelName := Table1.NameGo
|
ModelName := Table1.NameGo
|
||||||
ColumnName := Column1.NameGo
|
ColumnName := Column1.NameGo
|
||||||
FuncName := "Update_" + ColumnName
|
FuncName := "Update_" + ColumnName
|
||||||
TextRequest, TextRequestFieldName := create_files.FindTextProtobufRequest(Column1.TypeGo)
|
TextRequest, TextRequestFieldName := create_files.FindTextProtobufRequest_ID_Type(Column1.TypeGo)
|
||||||
DefaultValue := create_files.FindTextDefaultValue(Column1.TypeGo)
|
DefaultValue := create_files.FindTextDefaultValue(Column1.TypeGo)
|
||||||
|
|
||||||
Otvet = strings.ReplaceAll(Otvet, " TestCrud_GRPC_Read(", " TestCrud_GRPC_"+FuncName+"(")
|
Otvet = strings.ReplaceAll(Otvet, "TestCrud_GRPC_Update(", "TestCrud_GRPC_"+FuncName+"(")
|
||||||
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
|
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
|
||||||
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "grpc_proto.RequestId", "grpc_proto."+TextRequest)
|
Otvet = strings.ReplaceAll(Otvet, "grpc_proto.RequestId", "grpc_proto."+TextRequest)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "ColumnName", ColumnName)
|
Otvet = strings.ReplaceAll(Otvet, "ColumnName", ColumnName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "Model.ID", "Model."+ColumnName)
|
|
||||||
Otvet = strings.ReplaceAll(Otvet, "Request.ID", "Request."+TextRequestFieldName)
|
Otvet = strings.ReplaceAll(Otvet, "Request.ID", "Request."+TextRequestFieldName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "Otvet.ID", "Otvet."+ColumnName)
|
|
||||||
Otvet = strings.ReplaceAll(Otvet, "Postgres_ID_Test", DefaultValue)
|
|
||||||
Otvet = strings.ReplaceAll(Otvet, "TestRead(", "Test"+FuncName+"(")
|
Otvet = strings.ReplaceAll(Otvet, "TestRead(", "Test"+FuncName+"(")
|
||||||
Otvet = strings.ReplaceAll(Otvet, "Otvet.ID == 0", "Otvet."+ColumnName+" == "+DefaultValue)
|
|
||||||
Otvet = strings.ReplaceAll(Otvet, "error: ID =0", "error: "+ColumnName+" ="+DefaultValue)
|
Otvet = strings.ReplaceAll(Otvet, "error: ID =0", "error: "+ColumnName+" ="+DefaultValue)
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, "_Update(", "_"+FuncName+"(")
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
@ -363,7 +363,7 @@ func CreateFilesUpdateEveryColumn(Table1 *types.Table) error {
|
|||||||
}
|
}
|
||||||
TextGRPCServerUpdateFunc := string(bytes)
|
TextGRPCServerUpdateFunc := string(bytes)
|
||||||
|
|
||||||
TextGRPCServer := "package " + config.Settings.TEMPLATE_FOLDERNAME_GRPC + "\n\n"
|
TextGRPCServer := "package " + config.Settings.PREFIX_CLIENT_GRPC + TableName + "\n\n"
|
||||||
TextGRPCServer = TextGRPCServer + `import (
|
TextGRPCServer = TextGRPCServer + `import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/ManyakRus/starter/micro"
|
"github.com/ManyakRus/starter/micro"
|
||||||
@ -445,15 +445,16 @@ func FindTextUpdateEveryColumn1(TextGRPCServerUpdateFunc string, Table1 *types.T
|
|||||||
ModelName := Table1.NameGo
|
ModelName := Table1.NameGo
|
||||||
ColumnName := Column1.NameGo
|
ColumnName := Column1.NameGo
|
||||||
FuncName := "Update_" + ColumnName
|
FuncName := "Update_" + ColumnName
|
||||||
TextRequest, TextRequestFieldName := create_files.FindTextProtobufRequest(Column1.TypeGo)
|
TextRequest, TextRequestFieldName := create_files.FindTextProtobufRequest_ID_Type(Column1.TypeGo)
|
||||||
|
|
||||||
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_MODEL+"_Read", ModelName+"_"+FuncName)
|
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_MODEL+"_Update", ModelName+"_"+FuncName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
|
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "grpc_proto.RequestId", "grpc_proto."+TextRequest)
|
Otvet = strings.ReplaceAll(Otvet, "grpc_proto.RequestId", "grpc_proto."+TextRequest)
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, "Request.FieldName", "Request."+TextRequestFieldName)
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, "Model.ColumnName", "Model."+ColumnName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "ColumnName", ColumnName)
|
Otvet = strings.ReplaceAll(Otvet, "ColumnName", ColumnName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "Model.ID", "Model."+ColumnName)
|
Otvet = strings.ReplaceAll(Otvet, "Model.Update()", "Model."+FuncName+"()")
|
||||||
Otvet = strings.ReplaceAll(Otvet, "Request.ID", "Request."+TextRequestFieldName)
|
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
@ -483,7 +484,7 @@ func CreateTestFilesUpdateEveryColumn(Table1 *types.Table) error {
|
|||||||
}
|
}
|
||||||
TextGRPCServerUpdateFunc := string(bytes)
|
TextGRPCServerUpdateFunc := string(bytes)
|
||||||
|
|
||||||
TextGRPCServer := "package " + config.Settings.TEMPLATE_FOLDERNAME_GRPC + "\n\n"
|
TextGRPCServer := "package " + config.Settings.PREFIX_CLIENT_GRPC + TableName + "\n\n"
|
||||||
TextGRPCServer = TextGRPCServer + `import (
|
TextGRPCServer = TextGRPCServer + `import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/ManyakRus/starter/config_main"
|
"github.com/ManyakRus/starter/config_main"
|
||||||
@ -567,15 +568,15 @@ func FindTextUpdateEveryColumnTest1(TextGRPCServerUpdateFunc string, Table1 *typ
|
|||||||
ModelName := Table1.NameGo
|
ModelName := Table1.NameGo
|
||||||
ColumnName := Column1.NameGo
|
ColumnName := Column1.NameGo
|
||||||
FuncName := "Update_" + ColumnName
|
FuncName := "Update_" + ColumnName
|
||||||
TextRequest, TextRequestFieldName := create_files.FindTextProtobufRequest(Column1.TypeGo)
|
TextRequest, TextRequestFieldName := create_files.FindTextProtobufRequest_ID_Type(Column1.TypeGo)
|
||||||
|
|
||||||
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_MODEL+"_Read", ModelName+"_"+FuncName)
|
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_MODEL+"_Update(", ModelName+"_"+FuncName+"(")
|
||||||
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
|
Otvet = strings.ReplaceAll(Otvet, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "grpc_proto.RequestId", "grpc_proto."+TextRequest)
|
Otvet = strings.ReplaceAll(Otvet, "grpc_proto.RequestString", "grpc_proto."+TextRequest)
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, "Model.ColumnName", "Model."+TextRequestFieldName)
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, "ColumnName", ColumnName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "ColumnName", ColumnName)
|
Otvet = strings.ReplaceAll(Otvet, "ColumnName", ColumnName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "Model.ID", "Model."+ColumnName)
|
|
||||||
Otvet = strings.ReplaceAll(Otvet, "Request.ID", "Request."+TextRequestFieldName)
|
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user