1
0
mirror of https://github.com/ManyakRus/crud_generator.git synced 2025-01-20 09:09:22 +02:00

сделал grpc_client_func.go

This commit is contained in:
Nikitin Aleksandr 2024-08-13 15:22:46 +03:00
parent 6f4d3f077d
commit f5941fe82c
10 changed files with 87 additions and 41 deletions

View File

@ -71,6 +71,11 @@ TEMPLATE_FOLDERNAME_GRPC_SERVER="internal/app/grpc/server_grpc"
#TEMPLATE_FOLDERNAME_GRPC_CLIENT - folder name for create grpc client files
TEMPLATE_FOLDERNAME_GRPC_CLIENT="pkg/network/grpc/grpc_client"
#TEMPLATE_FOLDERNAME_GRPC_CLIENT_FUNC - folder name for create "grpc_client_func.go" files
TEMPLATE_FOLDERNAME_GRPC_CLIENT_FUNC="pkg/network/grpc/grpc_client_func"
#TEMPLATE_FOLDERNAME_NRPC_SERVER - folder name for create nrpc server files
TEMPLATE_FOLDERNAME_NRPC_SERVER="internal/app/nrpc/server_nrpc"

View File

@ -44,7 +44,7 @@ func (crud Crud_GRPC) Read(m *lawsuit_status_types.LawsuitStatusType) error {
var err error
// подключение
grpc_client.Connect_GRPC_NRPC()
grpc_client_func.Func_Connect_GRPC_NRPC.Connect_GRPC_NRPC()
// подготовка запроса
var versionModel = crud.GetVersionModel()
@ -62,10 +62,10 @@ func (crud Crud_GRPC) Read(m *lawsuit_status_types.LawsuitStatusType) error {
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_Read(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_Read(ctx, Request)
Response, err = grpc_client_func.Client.LawsuitStatusType_Read(ctx, Request)
}
if err != nil {
if grpc_client.IsErrorModelVersion(err) == true {
if grpc_client_func.IsErrorModelVersion(err) == true {
log.Panic(err)
}
return err
@ -86,7 +86,7 @@ func (crud Crud_GRPC) Create(m *lawsuit_status_types.LawsuitStatusType) error {
var err error
// подключение
grpc_client.Connect_GRPC_NRPC()
grpc_client_func.Func_Connect_GRPC_NRPC.Connect_GRPC_NRPC()
// подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -108,10 +108,10 @@ func (crud Crud_GRPC) Create(m *lawsuit_status_types.LawsuitStatusType) error {
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_Create(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_Create(ctx, Request)
Response, err = grpc_client_func.Client.LawsuitStatusType_Create(ctx, Request)
}
if err != nil {
if grpc_client.IsErrorModelVersion(err) == true {
if grpc_client_func.IsErrorModelVersion(err) == true {
log.Panic(err)
}
return err
@ -132,7 +132,7 @@ func (crud Crud_GRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
var err error
// подключение
grpc_client.Connect_GRPC_NRPC()
grpc_client_func.Func_Connect_GRPC_NRPC.Connect_GRPC_NRPC()
// подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -154,10 +154,10 @@ func (crud Crud_GRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_Update(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_Update(ctx, Request)
Response, err = grpc_client_func.Client.LawsuitStatusType_Update(ctx, Request)
}
if err != nil {
if grpc_client.IsErrorModelVersion(err) == true {
if grpc_client_func.IsErrorModelVersion(err) == true {
log.Panic(err)
}
return err
@ -178,7 +178,7 @@ func (crud Crud_GRPC) Save(m *lawsuit_status_types.LawsuitStatusType) error {
var err error
// подключение
grpc_client.Connect_GRPC_NRPC()
grpc_client_func.Func_Connect_GRPC_NRPC.Connect_GRPC_NRPC()
// подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -200,10 +200,10 @@ func (crud Crud_GRPC) Save(m *lawsuit_status_types.LawsuitStatusType) error {
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_Save(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_Save(ctx, Request)
Response, err = grpc_client_func.Client.LawsuitStatusType_Save(ctx, Request)
}
if err != nil {
if grpc_client.IsErrorModelVersion(err) == true {
if grpc_client_func.IsErrorModelVersion(err) == true {
log.Panic(err)
}
return err
@ -224,7 +224,7 @@ func (crud Crud_GRPC) Delete(m *lawsuit_status_types.LawsuitStatusType) error {
var err error
// подключение
grpc_client.Connect_GRPC_NRPC()
grpc_client_func.Func_Connect_GRPC_NRPC.Connect_GRPC_NRPC()
// подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -242,10 +242,10 @@ func (crud Crud_GRPC) Delete(m *lawsuit_status_types.LawsuitStatusType) error {
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_Delete(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_Delete(ctx, Request)
Response, err = grpc_client_func.Client.LawsuitStatusType_Delete(ctx, Request)
}
if err != nil {
if grpc_client.IsErrorModelVersion(err) == true {
if grpc_client_func.IsErrorModelVersion(err) == true {
log.Panic(err)
}
return err
@ -266,7 +266,7 @@ func (crud Crud_GRPC) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
var err error
// подключение
grpc_client.Connect_GRPC_NRPC()
grpc_client_func.Func_Connect_GRPC_NRPC.Connect_GRPC_NRPC()
// подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -284,10 +284,10 @@ func (crud Crud_GRPC) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_Restore(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_Restore(ctx, Request)
Response, err = grpc_client_func.Client.LawsuitStatusType_Restore(ctx, Request)
}
if err != nil {
if grpc_client.IsErrorModelVersion(err) == true {
if grpc_client_func.IsErrorModelVersion(err) == true {
log.Panic(err)
}
return err
@ -308,7 +308,7 @@ func (crud Crud_GRPC) Find_ByExtID(m *lawsuit_status_types.LawsuitStatusType) er
var err error
// подключение
grpc_client.Connect_GRPC_NRPC()
grpc_client_func.Func_Connect_GRPC_NRPC.Connect_GRPC_NRPC()
//подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -327,10 +327,10 @@ func (crud Crud_GRPC) Find_ByExtID(m *lawsuit_status_types.LawsuitStatusType) er
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_FindByExtID(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_FindByExtID(ctx, Request)
Response, err = grpc_client_func.Client.LawsuitStatusType_FindByExtID(ctx, Request)
}
if err != nil {
if grpc_client.IsErrorModelVersion(err) == true {
if grpc_client_func.IsErrorModelVersion(err) == true {
log.Panic(err)
}
return err

View File

@ -19,7 +19,7 @@ func (crud Crud_GRPC) ReadFromCache(ID int64) (lawsuit_status_types.LawsuitStatu
var err error
// подключение
grpc_client.Connect_GRPC_NRPC()
grpc_client_func.Func_Connect_GRPC_NRPC.Connect_GRPC_NRPC()
// подготовка запроса
var versionModel = crud.GetVersionModel()
@ -37,10 +37,10 @@ func (crud Crud_GRPC) ReadFromCache(ID int64) (lawsuit_status_types.LawsuitStatu
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_ReadFromCache(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_ReadFromCache(ctx, Request)
Response, err = grpc_client_func.Client.LawsuitStatusType_ReadFromCache(ctx, Request)
}
if err != nil {
if grpc_client.IsErrorModelVersion(err) == true {
if grpc_client_func.IsErrorModelVersion(err) == true {
log.Panic(err)
}
return Otvet, err

View File

@ -17,7 +17,7 @@ func (crud Crud_GRPC) UpdateManyFields(m *lawsuit_status_types.LawsuitStatusType
var err error
// подключение
grpc_client.Connect_GRPC_NRPC()
grpc_client_func.Func_Connect_GRPC_NRPC.Connect_GRPC_NRPC()
// подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -39,10 +39,10 @@ func (crud Crud_GRPC) UpdateManyFields(m *lawsuit_status_types.LawsuitStatusType
if grpc_nrpc.NeedNRPC == true {
_, err = nrpc_client.Client.LawsuitStatusType_UpdateManyFields(Request)
} else {
_, err = grpc_client.Client.LawsuitStatusType_UpdateManyFields(ctx, Request)
_, err = grpc_client_func.Client.LawsuitStatusType_UpdateManyFields(ctx, Request)
}
if err != nil {
if grpc_client.IsErrorModelVersion(err) == true {
if grpc_client_func.IsErrorModelVersion(err) == true {
log.Panic(err)
}
return err

View File

@ -3,7 +3,7 @@ func (crud Crud_GRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
var err error
// подключение
grpc_client.Connect_GRPC_NRPC()
grpc_client_func.Func_Connect_GRPC_NRPC.Connect_GRPC_NRPC()
// подготовка запроса
var versionModel = crud.GetVersionModel()
@ -21,10 +21,10 @@ func (crud Crud_GRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
if grpc_nrpc.NeedNRPC == true {
_, err = nrpc_client.Client.LawsuitStatusType_Update(Request)
} else {
_, err = grpc_client.Client.LawsuitStatusType_Update(ctx, Request)
_, err = grpc_client_func.Client.LawsuitStatusType_Update(ctx, Request)
}
if err != nil {
if grpc_client.IsErrorModelVersion(err) == true {
if grpc_client_func.IsErrorModelVersion(err) == true {
log.Panic(err)
}
return err

View File

@ -29,6 +29,7 @@ type SettingsINI struct {
TEMPLATE_FOLDERNAME_NRPC_SERVER string
TEMPLATE_FOLDERNAME_NRPC_CLIENT string
TEMPLATE_FOLDERNAME_GRPC_NRPC string
TEMPLATE_FOLDERNAME_GRPC_CLIENT_FUNC string
TEMPLATE_SERVICE_NAME string
TEMPLATE_FOLDERNAME_CRUD_STARTER string
TEMPLATE_FOLDERNAME_ALIAS string
@ -520,6 +521,11 @@ func FillSettings() {
s = Getenv(Name, true)
Settings.SINGULAR_TABLE_NAMES = BoolFromString(s)
//
Name = "TEMPLATE_FOLDERNAME_GRPC_CLIENT_FUNC"
s = Getenv(Name, true)
Settings.TEMPLATE_FOLDERNAME_GRPC_CLIENT_FUNC = s
}
// CurrentDirectory - возвращает текущую директорию ОС

View File

@ -846,6 +846,15 @@ func Find_GRPC_NRPC_URL() string {
return Otvet
}
// Find_grpc_client_func_URL - возвращает URL репозитория с пакетом "grpc_client_func"
func Find_grpc_client_func_URL() string {
Otvet := ""
Otvet = config.Settings.SERVICE_REPOSITORY_URL + "/" + config.Settings.TEMPLATE_FOLDERNAME_GRPC_CLIENT_FUNC
return Otvet
}
// FindCalcStructVersionURL - возвращает URL репозитория с пакетом "calc_struct_version"
func FindCalcStructVersionURL() string {
Otvet := ""

View File

@ -68,8 +68,8 @@ func CreateGRPCClient() error {
TextGRPCClient = create_files.AddImport(TextGRPCClient, ProtoURL)
//constants db
DBConstantsURL := create_files.FindDBConstantsURL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, DBConstantsURL)
//DBConstantsURL := create_files.FindDBConstantsURL()
//TextGRPCClient = create_files.AddImport(TextGRPCClient, DBConstantsURL)
//grpc_nrpc
GRPC_NRPC_URL := create_files.Find_GRPC_NRPC_URL()
@ -79,6 +79,14 @@ func CreateGRPCClient() error {
NRPC_CLIENT_URL := create_files.FindNRPC_Client_URL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, NRPC_CLIENT_URL)
//grpc_client_func
GRPC_CLIENT_FUNC_URL := create_files.Find_grpc_client_func_URL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPC_CLIENT_FUNC_URL)
//CRUD_STARTER_URL
CRUD_STARTER_URL := create_files.FindCrudStarterURL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, CRUD_STARTER_URL)
//constants GRPC
RepositoryGRPCConstantsURL := create_files.FindGRPCConstantsURL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryGRPCConstantsURL)

View File

@ -126,9 +126,13 @@ func CreateFiles(Table1 *types.Table) error {
RepositoryModelURL := create_files.FindModelTableURL(TableName)
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryModelURL)
//grpc client
RepositoryGRPCClientlURL := create_files.FindGRPClientURL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryGRPCClientlURL)
////grpc client
//RepositoryGRPCClientlURL := create_files.FindGRPClientURL()
//TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryGRPCClientlURL)
//grpc client func
GRPCClientFuncURL := create_files.Find_grpc_client_func_URL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPCClientFuncURL)
//nrpc client
RepositoryNRPCClientlURL := create_files.FindNRPClientURL()
@ -431,8 +435,12 @@ func CreateFilesUpdateEveryColumn(Table1 *types.Table) error {
ProtoURL := create_files.FindProtoURL()
TextGRPC_Client = create_files.AddImport(TextGRPC_Client, ProtoURL)
GRPCClientURL := create_files.FindGRPClientURL()
TextGRPC_Client = create_files.AddImport(TextGRPC_Client, GRPCClientURL)
//GRPCClientURL := create_files.FindGRPClientURL()
//TextGRPC_Client = create_files.AddImport(TextGRPC_Client, GRPCClientURL)
//grpc client func
GRPCClientFuncURL := create_files.Find_grpc_client_func_URL()
TextGRPC_Client = create_files.AddImport(TextGRPC_Client, GRPCClientFuncURL)
GRPCConstantsURL := create_files.FindGRPCConstantsURL()
TextGRPC_Client = create_files.AddImport(TextGRPC_Client, GRPCConstantsURL)
@ -762,8 +770,12 @@ func CreateFiles_GRPC_Client_Cache(Table1 *types.Table) error {
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryModelURL)
//grpc client
RepositoryGRPCClientlURL := create_files.FindGRPClientURL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryGRPCClientlURL)
//RepositoryGRPCClientlURL := create_files.FindGRPClientURL()
//TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryGRPCClientlURL)
//grpc client func
GRPCClientFuncURL := create_files.Find_grpc_client_func_URL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPCClientFuncURL)
//nrpc client
RepositoryNRPCClientlURL := create_files.FindNRPClientURL()

View File

@ -72,12 +72,18 @@ func CreateNRPCClient() error {
//GRPC_NRPC_URL := create_files.Find_GRPC_NRPC_URL()
//TextNRPCClient = create_files.AddImport(TextNRPCClient, GRPC_NRPC_URL)
DBConstantsURL := create_files.FindDBConstantsURL()
TextNRPCClient = create_files.AddImport(TextNRPCClient, DBConstantsURL)
//DBConstantsURL := create_files.FindDBConstantsURL()
//TextNRPCClient = create_files.AddImport(TextNRPCClient, DBConstantsURL)
NRPCConstantsURL := create_files.FindNRPCConstantsURL()
TextNRPCClient = create_files.AddImport(TextNRPCClient, NRPCConstantsURL)
GRPC_NRPC_URL := create_files.Find_GRPC_NRPC_URL()
TextNRPCClient = create_files.AddImport(TextNRPCClient, GRPC_NRPC_URL)
GRPC_func_URL := create_files.Find_grpc_client_func_URL()
TextNRPCClient = create_files.AddImport(TextNRPCClient, GRPC_func_URL)
}
//заменим имя сервиса на новое