mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2024-11-24 08:22:42 +02:00
сделал objects
This commit is contained in:
parent
61d9969d2c
commit
e403cc1261
@ -3,4 +3,4 @@
|
||||
ADAPT_PATH=./
|
||||
|
||||
clear
|
||||
protoc --go_out=${ADAPT_PATH} --nrpc_out=./ --go_opt=paths=import --go-grpc_out=${ADAPT_PATH} --go-grpc_opt=paths=import ${ADAPT_PATH}sync_service.proto
|
||||
protoc --go_out=${ADAPT_PATH} --go_opt=paths=import --go-grpc_out=${ADAPT_PATH} --go-grpc_opt=paths=import ${ADAPT_PATH}sync_service.proto
|
||||
|
6
bin/templates/api/generation_code_nrpc.sh_
Executable file
6
bin/templates/api/generation_code_nrpc.sh_
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
ADAPT_PATH=./
|
||||
|
||||
clear
|
||||
protoc --go_out=${ADAPT_PATH} --nrpc_out=./ --go_opt=paths=import --go-grpc_out=${ADAPT_PATH} --go-grpc_opt=paths=import ${ADAPT_PATH}sync_service.proto
|
@ -137,7 +137,7 @@ NEED_CREATE_CRUD=true
|
||||
NEED_CREATE_GRPC=true
|
||||
|
||||
#NEED_CREATE_NRPC - fill "true" if you want create nrpc operations files (need NATS message query server)
|
||||
NEED_CREATE_NRPC=true
|
||||
NEED_CREATE_NRPC=false
|
||||
|
||||
#NEED_CREATE_MODEL_CRUD - fill "true" if you want create crud operations in model files
|
||||
NEED_CREATE_MODEL_CRUD=true
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_constants"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_client"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/nrpc/nrpc_client"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc_nrpc"
|
||||
"github.com/ManyakRus/starter/log"
|
||||
@ -60,7 +59,7 @@ func (crud Crud_GRPC) Read(m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// запрос
|
||||
var Response *grpc_proto.Response
|
||||
if grpc_nrpc.NeedNRPC == true {
|
||||
Response, err = nrpc_client.Client.LawsuitStatusType_Read(Request)
|
||||
//Response, err = nrpc_client.Client.LawsuitStatusType_Read(Request)
|
||||
} else {
|
||||
Response, err = grpc_client_func.Client.LawsuitStatusType_Read(ctx, Request)
|
||||
}
|
||||
@ -106,7 +105,7 @@ func (crud Crud_GRPC) Create(m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// запрос
|
||||
var Response *grpc_proto.Response
|
||||
if grpc_nrpc.NeedNRPC == true {
|
||||
Response, err = nrpc_client.Client.LawsuitStatusType_Create(Request)
|
||||
//Response, err = nrpc_client.Client.LawsuitStatusType_Create(Request)
|
||||
} else {
|
||||
Response, err = grpc_client_func.Client.LawsuitStatusType_Create(ctx, Request)
|
||||
}
|
||||
@ -152,7 +151,7 @@ func (crud Crud_GRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// запрос
|
||||
var Response *grpc_proto.Response
|
||||
if grpc_nrpc.NeedNRPC == true {
|
||||
Response, err = nrpc_client.Client.LawsuitStatusType_Update(Request)
|
||||
//Response, err = nrpc_client.Client.LawsuitStatusType_Update(Request)
|
||||
} else {
|
||||
Response, err = grpc_client_func.Client.LawsuitStatusType_Update(ctx, Request)
|
||||
}
|
||||
@ -198,7 +197,7 @@ func (crud Crud_GRPC) Save(m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// запрос
|
||||
var Response *grpc_proto.Response
|
||||
if grpc_nrpc.NeedNRPC == true {
|
||||
Response, err = nrpc_client.Client.LawsuitStatusType_Save(Request)
|
||||
//Response, err = nrpc_client.Client.LawsuitStatusType_Save(Request)
|
||||
} else {
|
||||
Response, err = grpc_client_func.Client.LawsuitStatusType_Save(ctx, Request)
|
||||
}
|
||||
@ -240,7 +239,7 @@ func (crud Crud_GRPC) Delete(m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// запрос
|
||||
var Response *grpc_proto.Response
|
||||
if grpc_nrpc.NeedNRPC == true {
|
||||
Response, err = nrpc_client.Client.LawsuitStatusType_Delete(Request)
|
||||
//Response, err = nrpc_client.Client.LawsuitStatusType_Delete(Request)
|
||||
} else {
|
||||
Response, err = grpc_client_func.Client.LawsuitStatusType_Delete(ctx, Request)
|
||||
}
|
||||
@ -282,7 +281,7 @@ func (crud Crud_GRPC) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// запрос
|
||||
var Response *grpc_proto.Response
|
||||
if grpc_nrpc.NeedNRPC == true {
|
||||
Response, err = nrpc_client.Client.LawsuitStatusType_Restore(Request)
|
||||
//Response, err = nrpc_client.Client.LawsuitStatusType_Restore(Request)
|
||||
} else {
|
||||
Response, err = grpc_client_func.Client.LawsuitStatusType_Restore(ctx, Request)
|
||||
}
|
||||
@ -325,7 +324,7 @@ func (crud Crud_GRPC) Find_ByExtID(m *lawsuit_status_types.LawsuitStatusType) er
|
||||
//запрос
|
||||
var Response *grpc_proto.Response
|
||||
if grpc_nrpc.NeedNRPC == true {
|
||||
Response, err = nrpc_client.Client.LawsuitStatusType_FindByExtID(Request)
|
||||
//Response, err = nrpc_client.Client.LawsuitStatusType_FindByExtID(Request)
|
||||
} else {
|
||||
Response, err = grpc_client_func.Client.LawsuitStatusType_FindByExtID(ctx, Request)
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_client"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_constants"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc_nrpc"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/nrpc/nrpc_client"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
|
||||
"time"
|
||||
)
|
||||
@ -35,7 +34,7 @@ func (crud Crud_GRPC) ReadFromCache(ID int64) (lawsuit_status_types.LawsuitStatu
|
||||
// запрос
|
||||
var Response *grpc_proto.Response
|
||||
if grpc_nrpc.NeedNRPC == true {
|
||||
Response, err = nrpc_client.Client.LawsuitStatusType_ReadFromCache(Request)
|
||||
//Response, err = nrpc_client.Client.LawsuitStatusType_ReadFromCache(Request)
|
||||
} else {
|
||||
Response, err = grpc_client_func.Client.LawsuitStatusType_ReadFromCache(ctx, Request)
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ func (crud Crud_GRPC) FindBy_FieldNamesWithUnderline(m *lawsuit_status_types.Law
|
||||
// запрос
|
||||
var Response *grpc_proto.Response
|
||||
if grpc_nrpc.NeedNRPC == true {
|
||||
Response, err = nrpc_client.Client.LawsuitStatusType_FindBy_FieldNamesWithUnderline(Request)
|
||||
//Response, err = nrpc_client.Client.LawsuitStatusType_FindBy_FieldNamesWithUnderline(Request)
|
||||
} else {
|
||||
Response, err = grpc_client_func.Client.LawsuitStatusType_FindBy_FieldNamesWithUnderline(ctx, Request)
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ func (crud Crud_GRPC) FindMassBy_FieldNamesWithUnderline(m *lawsuit_status_types
|
||||
// запрос
|
||||
var Response *grpc_proto.ResponseMass
|
||||
if grpc_nrpc.NeedNRPC == true {
|
||||
Response, err = nrpc_client.Client.LawsuitStatusType_FindMassBy_FieldNamesWithUnderline(Request)
|
||||
//Response, err = nrpc_client.Client.LawsuitStatusType_FindMassBy_FieldNamesWithUnderline(Request)
|
||||
} else {
|
||||
Response, err = grpc_client_func.Client.LawsuitStatusType_FindMassBy_FieldNamesWithUnderline(ctx, Request)
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ func (crud Crud_GRPC) FindModelBy_FieldNamesWithUnderline(m *lawsuit_status_type
|
||||
// запрос
|
||||
var Response *grpc_proto.Response
|
||||
if grpc_nrpc.NeedNRPC == true {
|
||||
Response, err = nrpc_client.Client.LawsuitStatusType_FindModelBy_FieldNamesWithUnderline(Request)
|
||||
//Response, err = nrpc_client.Client.LawsuitStatusType_FindModelBy_FieldNamesWithUnderline(Request)
|
||||
} else {
|
||||
Response, err = grpc_client_func.Client.LawsuitStatusType_FindModelBy_FieldNamesWithUnderline(ctx, Request)
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ func (crud Crud_GRPC) ReadAll() ([]lawsuit_status_types.LawsuitStatusType, error
|
||||
// запрос
|
||||
var Response *grpc_proto.ResponseMass
|
||||
if grpc_nrpc.NeedNRPC == true {
|
||||
Response, err = nrpc_client.Client.LawsuitStatusType_ReadAll(Request)
|
||||
//Response, err = nrpc_client.Client.LawsuitStatusType_ReadAll(Request)
|
||||
} else {
|
||||
Response, err = grpc_client_func.Client.LawsuitStatusType_ReadAll(ctx, Request)
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_constants"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_client"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/nrpc/nrpc_client"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/objects/object_lawsuit_status_types"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc_nrpc"
|
||||
"github.com/ManyakRus/starter/log"
|
||||
@ -35,7 +34,7 @@ func (crud Crud_GRPC) ReadObject(m *object_lawsuit_status_types.ObjectLawsuitSta
|
||||
// запрос
|
||||
var Response *grpc_proto.Response
|
||||
if grpc_nrpc.NeedNRPC == true {
|
||||
Response, err = nrpc_client.Client.LawsuitStatusType_ReadObject(Request)
|
||||
//Response, err = nrpc_client.Client.LawsuitStatusType_ReadObject(Request)
|
||||
} else {
|
||||
Response, err = grpc_client_func.Client.LawsuitStatusType_ReadObject(ctx, Request)
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_client"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_constants"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc_nrpc"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/nrpc/nrpc_client"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
|
||||
)
|
||||
|
||||
@ -37,7 +36,7 @@ func (crud Crud_GRPC) UpdateManyFields(m *lawsuit_status_types.LawsuitStatusType
|
||||
|
||||
// запрос
|
||||
if grpc_nrpc.NeedNRPC == true {
|
||||
_, err = nrpc_client.Client.LawsuitStatusType_UpdateManyFields(Request)
|
||||
//_, err = nrpc_client.Client.LawsuitStatusType_UpdateManyFields(Request)
|
||||
} else {
|
||||
_, err = grpc_client_func.Client.LawsuitStatusType_UpdateManyFields(ctx, Request)
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ func (crud Crud_GRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
|
||||
// запрос
|
||||
if grpc_nrpc.NeedNRPC == true {
|
||||
_, err = nrpc_client.Client.LawsuitStatusType_Update(Request)
|
||||
//_, err = nrpc_client.Client.LawsuitStatusType_Update(Request)
|
||||
} else {
|
||||
_, err = grpc_client_func.Client.LawsuitStatusType_Update(ctx, Request)
|
||||
}
|
||||
|
@ -1,12 +1,3 @@
|
||||
//Файл создан автоматически кодогенератором crud_generator
|
||||
//Не изменяйте ничего здесь.
|
||||
|
||||
//Файл создан автоматически кодогенератором crud_generator
|
||||
//Не изменяйте ничего здесь.
|
||||
|
||||
//Файл создан автоматически кодогенератором crud_generator
|
||||
//Не изменяйте ничего здесь.
|
||||
|
||||
package nrpc_client
|
||||
|
||||
import (
|
||||
|
@ -1,6 +1,3 @@
|
||||
//Файл создан автоматически кодогенератором crud_generator
|
||||
//Не изменяйте ничего здесь.
|
||||
|
||||
package nrpc_client
|
||||
|
||||
import (
|
||||
|
@ -53,8 +53,10 @@ func CreateGRPCClient() error {
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPC_NRPC_URL)
|
||||
|
||||
//nrpc_client
|
||||
if config.Settings.NEED_CREATE_NRPC == false {
|
||||
NRPC_CLIENT_URL := create_files.Find_NRPC_Client_URL()
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, NRPC_CLIENT_URL)
|
||||
}
|
||||
|
||||
//grpc_client_func
|
||||
GRPC_CLIENT_FUNC_URL := create_files.Find_GRPCClient_func_URL()
|
||||
|
@ -355,3 +355,13 @@ func Replace_PrimaryKeyRequest_ID(Text string, Table1 *types.Table) string {
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// Replace_NRPC_CLIENT - включает NRPC, заменяет //Response, err = nrpc_client. на Response, err = nrpc_client.
|
||||
func Replace_NRPC_CLIENT(Text string) string {
|
||||
Otvet := Text
|
||||
|
||||
Otvet = strings.ReplaceAll(Otvet, "//Response, err = nrpc_client.", "Response, err = nrpc_client.")
|
||||
Otvet = strings.ReplaceAll(Otvet, "//_, err = nrpc_client.Client.", "_, err = nrpc_client.Client.")
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
@ -71,9 +71,15 @@ func CreateFiles_GRPC_Client_Cache(Table1 *types.Table) error {
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPCClientFuncURL)
|
||||
|
||||
//nrpc client
|
||||
if config.Settings.NEED_CREATE_NRPC == true {
|
||||
//
|
||||
RepositoryNRPCClientlURL := create_files.Find_NRPClientURL()
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryNRPCClientlURL)
|
||||
|
||||
//уберём "//"
|
||||
TextGRPCClient = Replace_NRPC_CLIENT(TextGRPCClient)
|
||||
}
|
||||
|
||||
//constants GRPC
|
||||
RepositoryGRPCConstantsURL := create_files.Find_GRPCConstantsURL()
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryGRPCConstantsURL)
|
||||
|
@ -62,9 +62,14 @@ func CreateFiles(Table1 *types.Table) error {
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPCClientFuncURL)
|
||||
|
||||
//nrpc client
|
||||
if config.Settings.NEED_CREATE_NRPC == true {
|
||||
RepositoryNRPCClientlURL := create_files.Find_NRPClientURL()
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryNRPCClientlURL)
|
||||
|
||||
//уберём "//"
|
||||
TextGRPCClient = Replace_NRPC_CLIENT(TextGRPCClient)
|
||||
}
|
||||
|
||||
//constants GRPC
|
||||
RepositoryGRPCConstantsURL := create_files.Find_GRPCConstantsURL()
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryGRPCConstantsURL)
|
||||
|
@ -71,9 +71,12 @@ func CreateFiles_FindBy(Table1 *types.Table) error {
|
||||
GRPC_NRPC_URL := create_files.Find_GRPC_NRPC_URL()
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPC_NRPC_URL)
|
||||
|
||||
//NRPC
|
||||
if config.Settings.NEED_CREATE_NRPC == true {
|
||||
//
|
||||
NRPC_Client_URL := create_files.Find_NRPC_Client_URL()
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, NRPC_Client_URL)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//создание функций
|
||||
@ -83,6 +86,12 @@ func CreateFiles_FindBy(Table1 *types.Table) error {
|
||||
}
|
||||
TextGRPCClient = TextGRPCClient + TextClientGRPCFunc
|
||||
|
||||
//NRPC
|
||||
if config.Settings.NEED_CREATE_NRPC == true {
|
||||
//уберём "//"
|
||||
TextGRPCClient = Replace_NRPC_CLIENT(TextGRPCClient)
|
||||
}
|
||||
|
||||
//создание текста
|
||||
TextGRPCClient = create_files.Replace_TemplateModel_to_Model(TextGRPCClient, Table1.NameGo)
|
||||
TextGRPCClient = create_files.Replace_TemplateTableName_to_TableName(TextGRPCClient, Table1.Name)
|
||||
|
@ -71,8 +71,12 @@ func CreateFiles_FindMassBy(Table1 *types.Table) error {
|
||||
GRPC_NRPC_URL := create_files.Find_GRPC_NRPC_URL()
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPC_NRPC_URL)
|
||||
|
||||
//NRPC
|
||||
if config.Settings.NEED_CREATE_NRPC == true {
|
||||
//
|
||||
NRPC_Client_URL := create_files.Find_NRPC_Client_URL()
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, NRPC_Client_URL)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -83,6 +87,12 @@ func CreateFiles_FindMassBy(Table1 *types.Table) error {
|
||||
}
|
||||
TextGRPCClient = TextGRPCClient + TextGRPCClientFunc
|
||||
|
||||
//NRPC
|
||||
if config.Settings.NEED_CREATE_NRPC == true {
|
||||
//уберём "//"
|
||||
TextGRPCClient = Replace_NRPC_CLIENT(TextGRPCClient)
|
||||
}
|
||||
|
||||
//создание текста
|
||||
TextGRPCClient = create_files.Replace_TemplateModel_to_Model(TextGRPCClient, Table1.NameGo)
|
||||
TextGRPCClient = create_files.Replace_TemplateTableName_to_TableName(TextGRPCClient, Table1.Name)
|
||||
|
@ -71,9 +71,15 @@ func CreateFiles_FindModelBy(MapAll map[string]*types.Table, Table1 *types.Table
|
||||
GRPC_NRPC_URL := create_files.Find_GRPC_NRPC_URL()
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPC_NRPC_URL)
|
||||
|
||||
//NRPC
|
||||
if config.Settings.NEED_CREATE_NRPC == true {
|
||||
//
|
||||
NRPC_Client_URL := create_files.Find_NRPC_Client_URL()
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, NRPC_Client_URL)
|
||||
|
||||
//уберём "//"
|
||||
TextGRPCClient = Replace_NRPC_CLIENT(TextGRPCClient)
|
||||
}
|
||||
}
|
||||
|
||||
//создание функций
|
||||
|
@ -71,9 +71,15 @@ func CreateFiles_ReadAll(Table1 *types.Table) error {
|
||||
GRPC_NRPC_URL := create_files.Find_GRPC_NRPC_URL()
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPC_NRPC_URL)
|
||||
|
||||
//NRPC
|
||||
if config.Settings.NEED_CREATE_NRPC == true {
|
||||
//
|
||||
NRPC_Client_URL := create_files.Find_NRPC_Client_URL()
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, NRPC_Client_URL)
|
||||
|
||||
//уберём "//"
|
||||
TextGRPCClient = Replace_NRPC_CLIENT(TextGRPCClient)
|
||||
}
|
||||
}
|
||||
|
||||
//создание функций
|
||||
|
@ -66,9 +66,15 @@ func CreateFiles_ReadObject(Table1 *types.Table) error {
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPCClientFuncURL)
|
||||
|
||||
//nrpc client
|
||||
if config.Settings.NEED_CREATE_NRPC == true {
|
||||
//
|
||||
RepositoryNRPCClientlURL := create_files.Find_NRPClientURL()
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryNRPCClientlURL)
|
||||
|
||||
//уберём "//"
|
||||
TextGRPCClient = Replace_NRPC_CLIENT(TextGRPCClient)
|
||||
}
|
||||
|
||||
//constants GRPC
|
||||
RepositoryGRPCConstantsURL := create_files.Find_GRPCConstantsURL()
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryGRPCConstantsURL)
|
||||
|
@ -73,8 +73,10 @@ func CreateFiles_UpdateEveryColumn(Table1 *types.Table) error {
|
||||
GRPC_NRPC_URL := create_files.Find_GRPC_NRPC_URL()
|
||||
TextGRPC_Client = create_files.AddImport(TextGRPC_Client, GRPC_NRPC_URL)
|
||||
|
||||
if config.Settings.NEED_CREATE_NRPC == true {
|
||||
NRPCClientURL := create_files.Find_NRPClientURL()
|
||||
TextGRPC_Client = create_files.AddImport(TextGRPC_Client, NRPCClientURL)
|
||||
}
|
||||
|
||||
ModelTableURL := create_files.Find_ModelTableURL(TableName)
|
||||
TextGRPC_Client = create_files.AddImport(TextGRPC_Client, ModelTableURL)
|
||||
@ -89,6 +91,12 @@ func CreateFiles_UpdateEveryColumn(Table1 *types.Table) error {
|
||||
// return err
|
||||
//}
|
||||
|
||||
//NRPC
|
||||
if config.Settings.NEED_CREATE_NRPC == true {
|
||||
//уберём "//"
|
||||
TextGRPC_Client = Replace_NRPC_CLIENT(TextGRPC_Client)
|
||||
}
|
||||
|
||||
//ModelName := Table1.NameGo
|
||||
//TextGRPC_Client = strings.ReplaceAll(TextGRPC_Client, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
||||
//TextGRPC_Client = strings.ReplaceAll(TextGRPC_Client, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
func CreateAllFiles() error {
|
||||
var err error
|
||||
|
||||
if config.Settings.NEED_CREATE_GRPC == false {
|
||||
if config.Settings.NEED_CREATE_NRPC == false {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -2,90 +2,30 @@ package server_nrpc_starter
|
||||
|
||||
import (
|
||||
"github.com/ManyakRus/crud_generator/internal/config"
|
||||
"github.com/ManyakRus/crud_generator/internal/create_files"
|
||||
"github.com/ManyakRus/crud_generator/internal/folders"
|
||||
"github.com/ManyakRus/starter/log"
|
||||
"github.com/ManyakRus/starter/micro"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// CreateAllFiles - создаёт все файлы в папке grpc proto
|
||||
func CreateAllFiles() error {
|
||||
var err error
|
||||
|
||||
if config.Settings.NEED_CREATE_GRPC == false {
|
||||
if config.Settings.NEED_CREATE_NRPC == false {
|
||||
return err
|
||||
}
|
||||
|
||||
//
|
||||
err = CreateFile_ServerGRPCStarter()
|
||||
if err != nil {
|
||||
log.Error("CreateFile_ServerGRPCStarter() error: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// CreateFile_ServerGRPCStarter - создаёт 1 файл в папке server_grpc
|
||||
func CreateFile_ServerGRPCStarter() error {
|
||||
var err error
|
||||
|
||||
//чтение файлов
|
||||
DirBin := micro.ProgramDir_bin()
|
||||
DirTemplates := DirBin + config.Settings.TEMPLATE_FOLDERNAME + micro.SeparatorFile()
|
||||
DirReady := DirBin + config.Settings.READY_FOLDERNAME + micro.SeparatorFile()
|
||||
DirTemplatesServerNRPC := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_NRPC_SERVER + micro.SeparatorFile()
|
||||
DirReadyServerNRPC := DirReady + config.Settings.TEMPLATE_FOLDERNAME_NRPC_SERVER + micro.SeparatorFile()
|
||||
FilenameReadyMain := DirReadyServerNRPC + "server_nrpc_starter.go"
|
||||
FilenameTemplateMain := DirTemplatesServerNRPC + "server_nrpc_starter.go_"
|
||||
|
||||
//создадим папку готовых файлов
|
||||
folders.CreateFolder(DirReadyServerNRPC)
|
||||
|
||||
bytes, err := os.ReadFile(FilenameTemplateMain)
|
||||
//
|
||||
err = CreateFile_ServerGRPCStarter_Test()
|
||||
if err != nil {
|
||||
log.Panic("ReadFile() ", FilenameTemplateMain, " error: ", err)
|
||||
log.Error("CreateFile_ServerGRPCStarter_Test() error: ", err)
|
||||
return err
|
||||
}
|
||||
TextNRPCStarter := string(bytes)
|
||||
|
||||
//заменим имя пакета на новое
|
||||
TextNRPCStarter = create_files.Replace_PackageName(TextNRPCStarter, DirReadyServerNRPC)
|
||||
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextNRPCStarter = create_files.Delete_TemplateRepositoryImports(TextNRPCStarter)
|
||||
|
||||
//Proto URL
|
||||
RepositoryProtoURL := create_files.Find_ProtoURL()
|
||||
TextNRPCStarter = create_files.AddImport(TextNRPCStarter, RepositoryProtoURL)
|
||||
|
||||
//server grpc URL
|
||||
RepositoryServerGRPCURL := create_files.Find_GRPCServerURL()
|
||||
TextNRPCStarter = create_files.AddImport(TextNRPCStarter, RepositoryServerGRPCURL)
|
||||
}
|
||||
|
||||
//найдём текст после конца импортов
|
||||
TextAfterImport := ""
|
||||
pos1 := strings.Index(TextNRPCStarter, "\n)")
|
||||
if pos1 >= 0 {
|
||||
TextAfterImport = TextNRPCStarter[pos1+2:]
|
||||
}
|
||||
|
||||
//заменим название сервиса
|
||||
ServiceName := config.Settings.SERVICE_NAME
|
||||
ServiceNameProto := micro.StringFromUpperCase(ServiceName)
|
||||
TEMPLATE_SERVICE_NAME := config.Settings.TEMPLATE_SERVICE_NAME
|
||||
TextAfterImport = strings.ReplaceAll(TextAfterImport, TEMPLATE_SERVICE_NAME, ServiceNameProto)
|
||||
//заменим ещё раз с большой буквы
|
||||
TEMPLATE_SERVICE_NAME = micro.StringFromUpperCase(TEMPLATE_SERVICE_NAME)
|
||||
TextAfterImport = strings.ReplaceAll(TextAfterImport, TEMPLATE_SERVICE_NAME, ServiceNameProto)
|
||||
TextNRPCStarter = TextNRPCStarter[:pos1+2] + TextAfterImport
|
||||
|
||||
//удаление пустого импорта
|
||||
TextNRPCStarter = create_files.Delete_EmptyImport(TextNRPCStarter)
|
||||
|
||||
//запись файла
|
||||
err = os.WriteFile(FilenameReadyMain, []byte(TextNRPCStarter), config.Settings.FILE_PERMISSIONS)
|
||||
|
||||
return err
|
||||
}
|
||||
|
@ -0,0 +1,130 @@
|
||||
package server_nrpc_starter
|
||||
|
||||
import (
|
||||
"github.com/ManyakRus/crud_generator/internal/config"
|
||||
"github.com/ManyakRus/crud_generator/internal/create_files"
|
||||
"github.com/ManyakRus/crud_generator/internal/folders"
|
||||
"github.com/ManyakRus/starter/log"
|
||||
"github.com/ManyakRus/starter/micro"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// CreateFile_ServerGRPCStarter - создаёт 1 файл в папке server_grpc
|
||||
func CreateFile_ServerGRPCStarter() error {
|
||||
var err error
|
||||
|
||||
//чтение файлов
|
||||
DirBin := micro.ProgramDir_bin()
|
||||
DirTemplates := DirBin + config.Settings.TEMPLATE_FOLDERNAME + micro.SeparatorFile()
|
||||
DirReady := DirBin + config.Settings.READY_FOLDERNAME + micro.SeparatorFile()
|
||||
DirTemplatesServerNRPC := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_NRPC_SERVER + micro.SeparatorFile()
|
||||
DirReadyServerNRPC := DirReady + config.Settings.TEMPLATE_FOLDERNAME_NRPC_SERVER + micro.SeparatorFile()
|
||||
FilenameReadyMain := DirReadyServerNRPC + "server_nrpc_starter.go"
|
||||
FilenameTemplateMain := DirTemplatesServerNRPC + "server_nrpc_starter.go_"
|
||||
|
||||
//создадим папку готовых файлов
|
||||
folders.CreateFolder(DirReadyServerNRPC)
|
||||
|
||||
bytes, err := os.ReadFile(FilenameTemplateMain)
|
||||
if err != nil {
|
||||
log.Panic("ReadFile() ", FilenameTemplateMain, " error: ", err)
|
||||
}
|
||||
TextNRPCStarter := string(bytes)
|
||||
|
||||
//заменим имя пакета на новое
|
||||
TextNRPCStarter = create_files.Replace_PackageName(TextNRPCStarter, DirReadyServerNRPC)
|
||||
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextNRPCStarter = create_files.Delete_TemplateRepositoryImports(TextNRPCStarter)
|
||||
|
||||
//Proto URL
|
||||
RepositoryProtoURL := create_files.Find_ProtoURL()
|
||||
TextNRPCStarter = create_files.AddImport(TextNRPCStarter, RepositoryProtoURL)
|
||||
|
||||
//server grpc URL
|
||||
RepositoryServerGRPCURL := create_files.Find_GRPCServerURL()
|
||||
TextNRPCStarter = create_files.AddImport(TextNRPCStarter, RepositoryServerGRPCURL)
|
||||
}
|
||||
|
||||
//найдём текст после конца импортов
|
||||
TextAfterImport := ""
|
||||
pos1 := strings.Index(TextNRPCStarter, "\n)")
|
||||
if pos1 >= 0 {
|
||||
TextAfterImport = TextNRPCStarter[pos1+2:]
|
||||
}
|
||||
|
||||
//заменим название сервиса
|
||||
ServiceName := config.Settings.SERVICE_NAME
|
||||
ServiceNameProto := micro.StringFromUpperCase(ServiceName)
|
||||
TEMPLATE_SERVICE_NAME := config.Settings.TEMPLATE_SERVICE_NAME
|
||||
TextAfterImport = strings.ReplaceAll(TextAfterImport, TEMPLATE_SERVICE_NAME, ServiceNameProto)
|
||||
//заменим ещё раз с большой буквы
|
||||
TEMPLATE_SERVICE_NAME = micro.StringFromUpperCase(TEMPLATE_SERVICE_NAME)
|
||||
TextAfterImport = strings.ReplaceAll(TextAfterImport, TEMPLATE_SERVICE_NAME, ServiceNameProto)
|
||||
TextNRPCStarter = TextNRPCStarter[:pos1+2] + TextAfterImport
|
||||
|
||||
//удаление пустого импорта
|
||||
TextNRPCStarter = create_files.Delete_EmptyImport(TextNRPCStarter)
|
||||
|
||||
//запись файла
|
||||
err = os.WriteFile(FilenameReadyMain, []byte(TextNRPCStarter), config.Settings.FILE_PERMISSIONS)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// CreateFile_ServerGRPCStarter_Test - создаёт 1 файл в папке server_grpc
|
||||
func CreateFile_ServerGRPCStarter_Test() error {
|
||||
var err error
|
||||
|
||||
//чтение файлов
|
||||
DirBin := micro.ProgramDir_bin()
|
||||
DirTemplates := DirBin + config.Settings.TEMPLATE_FOLDERNAME + micro.SeparatorFile()
|
||||
DirReady := DirBin + config.Settings.READY_FOLDERNAME + micro.SeparatorFile()
|
||||
DirTemplatesServerNRPC := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_NRPC_SERVER + micro.SeparatorFile()
|
||||
DirReadyServerNRPC := DirReady + config.Settings.TEMPLATE_FOLDERNAME_NRPC_SERVER + micro.SeparatorFile()
|
||||
FilenameReadyMain := DirReadyServerNRPC + "server_nrpc_starter_test.go"
|
||||
FilenameTemplateMain := DirTemplatesServerNRPC + "server_nrpc_starter_test.go_"
|
||||
|
||||
//создадим папку готовых файлов
|
||||
folders.CreateFolder(DirReadyServerNRPC)
|
||||
|
||||
bytes, err := os.ReadFile(FilenameTemplateMain)
|
||||
if err != nil {
|
||||
log.Panic("ReadFile() ", FilenameTemplateMain, " error: ", err)
|
||||
}
|
||||
TextNRPCStarter := string(bytes)
|
||||
|
||||
//заменим имя пакета на новое
|
||||
TextNRPCStarter = create_files.Replace_PackageName(TextNRPCStarter, DirReadyServerNRPC)
|
||||
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextNRPCStarter = create_files.Delete_TemplateRepositoryImports(TextNRPCStarter)
|
||||
|
||||
}
|
||||
|
||||
//найдём текст после конца импортов
|
||||
TextAfterImport := ""
|
||||
pos1 := strings.Index(TextNRPCStarter, "\n)")
|
||||
if pos1 >= 0 {
|
||||
TextAfterImport = TextNRPCStarter[pos1+2:]
|
||||
}
|
||||
|
||||
//заменим название сервиса
|
||||
ServiceName := config.Settings.SERVICE_NAME
|
||||
ServiceNameProto := micro.StringFromUpperCase(ServiceName)
|
||||
TEMPLATE_SERVICE_NAME := config.Settings.TEMPLATE_SERVICE_NAME
|
||||
TextAfterImport = strings.ReplaceAll(TextAfterImport, TEMPLATE_SERVICE_NAME, ServiceNameProto)
|
||||
//заменим ещё раз с большой буквы
|
||||
TEMPLATE_SERVICE_NAME = micro.StringFromUpperCase(TEMPLATE_SERVICE_NAME)
|
||||
TextAfterImport = strings.ReplaceAll(TextAfterImport, TEMPLATE_SERVICE_NAME, ServiceNameProto)
|
||||
TextNRPCStarter = TextNRPCStarter[:pos1+2] + TextAfterImport
|
||||
|
||||
//удаление пустого импорта
|
||||
TextNRPCStarter = create_files.Delete_EmptyImport(TextNRPCStarter)
|
||||
|
||||
//запись файла
|
||||
err = os.WriteFile(FilenameReadyMain, []byte(TextNRPCStarter), config.Settings.FILE_PERMISSIONS)
|
||||
|
||||
return err
|
||||
}
|
Loading…
Reference in New Issue
Block a user