mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2024-12-22 00:36:41 +02:00
сделал .proto 70
This commit is contained in:
parent
6690afbf63
commit
493e329b47
@ -30,9 +30,6 @@ var Settings SettingsINI
|
|||||||
// Conn - подключение к серверу GRPC
|
// Conn - подключение к серверу GRPC
|
||||||
var Conn *grpc.ClientConn
|
var Conn *grpc.ClientConn
|
||||||
|
|
||||||
// Client - подключение к клиенту GRPC
|
|
||||||
var Client grpc_proto.SyncServiceClient
|
|
||||||
|
|
||||||
// mutex_Connect - защита от многопоточности Reconnect()
|
// mutex_Connect - защита от многопоточности Reconnect()
|
||||||
var mutex_Connect = &sync.Mutex{}
|
var mutex_Connect = &sync.Mutex{}
|
||||||
|
|
||||||
@ -76,7 +73,8 @@ func Connect_err() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
Client = grpc_proto.NewSyncServiceClient(Conn)
|
FillClients()
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ func (crud Crud_GRPC) Read(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||||
|
|
||||||
// подключение
|
// подключение
|
||||||
if grpc_client.Client == nil {
|
if grpc_client.LawsuitStatusTypeClient == nil {
|
||||||
grpc_client.Connect()
|
grpc_client.Connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ func (crud Crud_GRPC) Read(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
defer ctxCancelFunc()
|
defer ctxCancelFunc()
|
||||||
|
|
||||||
// запрос
|
// запрос
|
||||||
Response, err := grpc_client.Client.LawsuitStatusType_Read(ctx, Request)
|
Response, err := grpc_client.LawsuitStatusTypeClient.Read(ctx, Request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sError := err.Error()
|
sError := err.Error()
|
||||||
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
||||||
@ -81,7 +81,7 @@ func (crud Crud_GRPC) Create(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||||
|
|
||||||
// подключение
|
// подключение
|
||||||
if grpc_client.Client == nil {
|
if grpc_client.LawsuitStatusTypeClient == nil {
|
||||||
grpc_client.Connect()
|
grpc_client.Connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ func (crud Crud_GRPC) Create(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
defer ctxCancelFunc()
|
defer ctxCancelFunc()
|
||||||
|
|
||||||
// запрос
|
// запрос
|
||||||
Response, err := grpc_client.Client.LawsuitStatusType_Create(ctx, Request)
|
Response, err := grpc_client.LawsuitStatusTypeClient.Create(ctx, Request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sError := err.Error()
|
sError := err.Error()
|
||||||
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
||||||
@ -125,7 +125,7 @@ func (crud Crud_GRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||||
|
|
||||||
// подключение
|
// подключение
|
||||||
if grpc_client.Client == nil {
|
if grpc_client.LawsuitStatusTypeClient == nil {
|
||||||
grpc_client.Connect()
|
grpc_client.Connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ func (crud Crud_GRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
defer ctxCancelFunc()
|
defer ctxCancelFunc()
|
||||||
|
|
||||||
// запрос
|
// запрос
|
||||||
Response, err := grpc_client.Client.LawsuitStatusType_Update(ctx, Request)
|
Response, err := grpc_client.LawsuitStatusTypeClient.Update(ctx, Request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sError := err.Error()
|
sError := err.Error()
|
||||||
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
||||||
@ -169,7 +169,7 @@ func (crud Crud_GRPC) Save(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||||
|
|
||||||
// подключение
|
// подключение
|
||||||
if grpc_client.Client == nil {
|
if grpc_client.LawsuitStatusTypeClient == nil {
|
||||||
grpc_client.Connect()
|
grpc_client.Connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ func (crud Crud_GRPC) Save(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
defer ctxCancelFunc()
|
defer ctxCancelFunc()
|
||||||
|
|
||||||
// запрос
|
// запрос
|
||||||
Response, err := grpc_client.Client.LawsuitStatusType_Save(ctx, Request)
|
Response, err := grpc_client.LawsuitStatusTypeClient.Save(ctx, Request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sError := err.Error()
|
sError := err.Error()
|
||||||
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
||||||
@ -213,7 +213,7 @@ func (crud Crud_GRPC) Delete(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||||
|
|
||||||
// подключение
|
// подключение
|
||||||
if grpc_client.Client == nil {
|
if grpc_client.LawsuitStatusTypeClient == nil {
|
||||||
grpc_client.Connect()
|
grpc_client.Connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ func (crud Crud_GRPC) Delete(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
defer ctxCancelFunc()
|
defer ctxCancelFunc()
|
||||||
|
|
||||||
// запрос
|
// запрос
|
||||||
Response, err := grpc_client.Client.LawsuitStatusType_Delete(ctx, Request)
|
Response, err := grpc_client.LawsuitStatusTypeClient.Delete(ctx, Request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sError := err.Error()
|
sError := err.Error()
|
||||||
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
||||||
@ -253,7 +253,7 @@ func (crud Crud_GRPC) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||||
|
|
||||||
// подключение
|
// подключение
|
||||||
if grpc_client.Client == nil {
|
if grpc_client.LawsuitStatusTypeClient == nil {
|
||||||
grpc_client.Connect()
|
grpc_client.Connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ func (crud Crud_GRPC) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
defer ctxCancelFunc()
|
defer ctxCancelFunc()
|
||||||
|
|
||||||
// запрос
|
// запрос
|
||||||
Response, err := grpc_client.Client.LawsuitStatusType_Restore(ctx, Request)
|
Response, err := grpc_client.LawsuitStatusTypeClient.Restore(ctx, Request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sError := err.Error()
|
sError := err.Error()
|
||||||
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
||||||
@ -291,7 +291,7 @@ func (crud Crud_GRPC) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
// Find_ByExtID - находит модель в БД по ext_id и connection_id
|
// Find_ByExtID - находит модель в БД по ext_id и connection_id
|
||||||
func (crud Crud_GRPC) Find_ByExtID(m *lawsuit_status_types.LawsuitStatusType) error {
|
func (crud Crud_GRPC) Find_ByExtID(m *lawsuit_status_types.LawsuitStatusType) error {
|
||||||
//подключение
|
//подключение
|
||||||
if grpc_client.Client == nil {
|
if grpc_client.LawsuitStatusTypeClient == nil {
|
||||||
grpc_client.Connect()
|
grpc_client.Connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ func (crud Crud_GRPC) Find_ByExtID(m *lawsuit_status_types.LawsuitStatusType) er
|
|||||||
defer ctxCancelFunc()
|
defer ctxCancelFunc()
|
||||||
|
|
||||||
//запрос
|
//запрос
|
||||||
Response, err := grpc_client.Client.LawsuitStatusType_FindByExtID(ctx, Request)
|
Response, err := grpc_client.LawsuitStatusTypeClient.FindByExtID(ctx, Request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sError := err.Error()
|
sError := err.Error()
|
||||||
if sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
if sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
package grpc_client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/api/grpc_proto"
|
||||||
|
)
|
||||||
|
|
@ -36,9 +36,6 @@ var Settings SettingsINI
|
|||||||
// Conn - подключение к NATS
|
// Conn - подключение к NATS
|
||||||
var Conn *nats.Conn
|
var Conn *nats.Conn
|
||||||
|
|
||||||
// Client - подключение к клиенту NRPC
|
|
||||||
var Client *grpc_proto.Sync_serviceClient
|
|
||||||
|
|
||||||
// mutex_Connect - защита от многопоточности Reconnect()
|
// mutex_Connect - защита от многопоточности Reconnect()
|
||||||
var mutex_Connect = &sync.Mutex{}
|
var mutex_Connect = &sync.Mutex{}
|
||||||
|
|
||||||
@ -80,8 +77,7 @@ func Connect_err() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is our generated client.
|
FillClients()
|
||||||
Client = grpc_proto.NewSync_serviceClient(Conn)
|
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ func (crud Crud_NRPC) Read(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||||
|
|
||||||
// подключение
|
// подключение
|
||||||
if nrpc_client.Client == nil {
|
if nrpc_client.LawsuitStatusTypeClient == nil {
|
||||||
nrpc_client.Connect()
|
nrpc_client.Connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ func (crud Crud_NRPC) Read(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
Request.VersionModel = versionModel
|
Request.VersionModel = versionModel
|
||||||
|
|
||||||
// запрос
|
// запрос
|
||||||
Response, err := nrpc_client.Client.LawsuitStatusType_Read(Request)
|
Response, err := nrpc_client.LawsuitStatusTypeClient.Read(Request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sError := err.Error()
|
sError := err.Error()
|
||||||
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
||||||
@ -75,7 +75,7 @@ func (crud Crud_NRPC) Create(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||||
|
|
||||||
// подключение
|
// подключение
|
||||||
if nrpc_client.Client == nil {
|
if nrpc_client.LawsuitStatusTypeClient == nil {
|
||||||
nrpc_client.Connect()
|
nrpc_client.Connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ func (crud Crud_NRPC) Create(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
Request.VersionModel = VersionModel
|
Request.VersionModel = VersionModel
|
||||||
|
|
||||||
// запрос
|
// запрос
|
||||||
Response, err := nrpc_client.Client.LawsuitStatusType_Create(Request)
|
Response, err := nrpc_client.LawsuitStatusTypeClient.Create(Request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sError := err.Error()
|
sError := err.Error()
|
||||||
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
||||||
@ -115,7 +115,7 @@ func (crud Crud_NRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||||
|
|
||||||
// подключение
|
// подключение
|
||||||
if nrpc_client.Client == nil {
|
if nrpc_client.LawsuitStatusTypeClient == nil {
|
||||||
nrpc_client.Connect()
|
nrpc_client.Connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ func (crud Crud_NRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
Request.VersionModel = VersionModel
|
Request.VersionModel = VersionModel
|
||||||
|
|
||||||
// запрос
|
// запрос
|
||||||
Response, err := nrpc_client.Client.LawsuitStatusType_Update(Request)
|
Response, err := nrpc_client.LawsuitStatusTypeClient.Update(Request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sError := err.Error()
|
sError := err.Error()
|
||||||
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
||||||
@ -155,7 +155,7 @@ func (crud Crud_NRPC) Save(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||||
|
|
||||||
// подключение
|
// подключение
|
||||||
if nrpc_client.Client == nil {
|
if nrpc_client.LawsuitStatusTypeClient == nil {
|
||||||
nrpc_client.Connect()
|
nrpc_client.Connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ func (crud Crud_NRPC) Save(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
Request.VersionModel = VersionModel
|
Request.VersionModel = VersionModel
|
||||||
|
|
||||||
// запрос
|
// запрос
|
||||||
Response, err := nrpc_client.Client.LawsuitStatusType_Save(Request)
|
Response, err := nrpc_client.LawsuitStatusTypeClient.Save(Request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sError := err.Error()
|
sError := err.Error()
|
||||||
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
||||||
@ -195,7 +195,7 @@ func (crud Crud_NRPC) Delete(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||||
|
|
||||||
// подключение
|
// подключение
|
||||||
if nrpc_client.Client == nil {
|
if nrpc_client.LawsuitStatusTypeClient == nil {
|
||||||
nrpc_client.Connect()
|
nrpc_client.Connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ func (crud Crud_NRPC) Delete(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
Request.VersionModel = VersionModel
|
Request.VersionModel = VersionModel
|
||||||
|
|
||||||
// запрос
|
// запрос
|
||||||
Response, err := nrpc_client.Client.LawsuitStatusType_Delete(Request)
|
Response, err := nrpc_client.LawsuitStatusTypeClient.Delete(Request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sError := err.Error()
|
sError := err.Error()
|
||||||
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
||||||
@ -231,7 +231,7 @@ func (crud Crud_NRPC) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||||
|
|
||||||
// подключение
|
// подключение
|
||||||
if nrpc_client.Client == nil {
|
if nrpc_client.LawsuitStatusTypeClient == nil {
|
||||||
nrpc_client.Connect()
|
nrpc_client.Connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ func (crud Crud_NRPC) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
Request.VersionModel = VersionModel
|
Request.VersionModel = VersionModel
|
||||||
|
|
||||||
// запрос
|
// запрос
|
||||||
Response, err := nrpc_client.Client.LawsuitStatusType_Restore(Request)
|
Response, err := nrpc_client.LawsuitStatusTypeClient.Restore(Request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sError := err.Error()
|
sError := err.Error()
|
||||||
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
if len(sError) >= len(constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
||||||
@ -265,7 +265,7 @@ func (crud Crud_NRPC) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
|
|||||||
// Find_ByExtID - находит модель в БД по ext_id и connection_id
|
// Find_ByExtID - находит модель в БД по ext_id и connection_id
|
||||||
func (crud Crud_NRPC) Find_ByExtID(m *lawsuit_status_types.LawsuitStatusType) error {
|
func (crud Crud_NRPC) Find_ByExtID(m *lawsuit_status_types.LawsuitStatusType) error {
|
||||||
//подключение
|
//подключение
|
||||||
if nrpc_client.Client == nil {
|
if nrpc_client.LawsuitStatusTypeClient == nil {
|
||||||
nrpc_client.Connect()
|
nrpc_client.Connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ func (crud Crud_NRPC) Find_ByExtID(m *lawsuit_status_types.LawsuitStatusType) er
|
|||||||
Request.VersionModel = VersionModel
|
Request.VersionModel = VersionModel
|
||||||
|
|
||||||
//запрос
|
//запрос
|
||||||
Response, err := nrpc_client.Client.LawsuitStatusType_FindByExtID(Request)
|
Response, err := nrpc_client.LawsuitStatusTypeClient.FindByExtID(Request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sError := err.Error()
|
sError := err.Error()
|
||||||
if sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
if sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package nrpc_client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/api/nrpc/grpc_proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
@ -42,3 +42,7 @@ const STARTER_TABLES_FILENAME = "starter_tables.go_"
|
|||||||
const STARTER_TABLES_FILENAME_TEST = "starter_tables_test.go_"
|
const STARTER_TABLES_FILENAME_TEST = "starter_tables_test.go_"
|
||||||
const STARTER_TABLES_PREFIX = "crud_starter_"
|
const STARTER_TABLES_PREFIX = "crud_starter_"
|
||||||
const CRUD_TABLES_FREFIX = "crud_"
|
const CRUD_TABLES_FREFIX = "crud_"
|
||||||
|
|
||||||
|
const GRPC_CLIENT_VARS_FILENAME = "grpc_client_vars.go"
|
||||||
|
|
||||||
|
const NRPC_CLIENT_VARS_FILENAME = "nrpc_client_vars.go"
|
||||||
|
@ -312,8 +312,8 @@ func FindTableNameURL(TableName string) string {
|
|||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindProtoURL - возвращает URL репозитория с пакетом "grpc_proto"
|
// FindGRPCProtoURL - возвращает URL репозитория с пакетом "grpc_proto"
|
||||||
func FindProtoURL() string {
|
func FindGRPCProtoURL() string {
|
||||||
Otvet := ""
|
Otvet := ""
|
||||||
|
|
||||||
TEMPLATE_FOLDERNAME_GRPC_PROTO := strings.ToLower(config.Settings.TEMPLATE_FOLDERNAME_GRPC_PROTO)
|
TEMPLATE_FOLDERNAME_GRPC_PROTO := strings.ToLower(config.Settings.TEMPLATE_FOLDERNAME_GRPC_PROTO)
|
||||||
@ -322,6 +322,16 @@ func FindProtoURL() string {
|
|||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FindNRPCProtoURL - возвращает URL репозитория с пакетом "grpc_proto"
|
||||||
|
func FindNRPCProtoURL() string {
|
||||||
|
Otvet := ""
|
||||||
|
|
||||||
|
TEMPLATE_FOLDERNAME_NRPC_PROTO := strings.ToLower(config.Settings.TEMPLATE_FOLDERNAME_GRPC_PROTO)
|
||||||
|
Otvet = config.Settings.SERVICE_REPOSITORY_URL + "/" + TEMPLATE_FOLDERNAME_NRPC_PROTO + "/nrpc/" + "grpc_proto"
|
||||||
|
|
||||||
|
return Otvet
|
||||||
|
}
|
||||||
|
|
||||||
// FindModelTableURL - возвращает URL репозитория model для таблицы TableName
|
// FindModelTableURL - возвращает URL репозитория model для таблицы TableName
|
||||||
func FindModelTableURL(TableName string) string {
|
func FindModelTableURL(TableName string) string {
|
||||||
Otvet := ""
|
Otvet := ""
|
||||||
|
@ -63,7 +63,7 @@ func CreateGRPCClient() error {
|
|||||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||||
TextGRPCClient = create_files.DeleteTemplateRepositoryImports(TextGRPCClient)
|
TextGRPCClient = create_files.DeleteTemplateRepositoryImports(TextGRPCClient)
|
||||||
|
|
||||||
ProtoURL := create_files.FindProtoURL()
|
ProtoURL := create_files.FindGRPCProtoURL()
|
||||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, ProtoURL)
|
TextGRPCClient = create_files.AddImport(TextGRPCClient, ProtoURL)
|
||||||
|
|
||||||
DBConstantsURL := create_files.FindDBConstantsURL()
|
DBConstantsURL := create_files.FindDBConstantsURL()
|
||||||
|
@ -96,7 +96,7 @@ func CreateFiles(Table1 *types.Table) error {
|
|||||||
TextGRPCClient = create_files.DeleteTemplateRepositoryImports(TextGRPCClient)
|
TextGRPCClient = create_files.DeleteTemplateRepositoryImports(TextGRPCClient)
|
||||||
|
|
||||||
//proto
|
//proto
|
||||||
RepositoryGRPCProtoURL := create_files.FindProtoURL()
|
RepositoryGRPCProtoURL := create_files.FindGRPCProtoURL()
|
||||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryGRPCProtoURL)
|
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryGRPCProtoURL)
|
||||||
|
|
||||||
//model
|
//model
|
||||||
|
205
internal/create_files/grpc_client_vars/grpc_client_vars.go
Normal file
205
internal/create_files/grpc_client_vars/grpc_client_vars.go
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
package grpc_client_vars
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ManyakRus/crud_generator/internal/config"
|
||||||
|
"github.com/ManyakRus/crud_generator/internal/constants"
|
||||||
|
"github.com/ManyakRus/crud_generator/internal/create_files"
|
||||||
|
"github.com/ManyakRus/crud_generator/internal/folders"
|
||||||
|
"github.com/ManyakRus/crud_generator/internal/types"
|
||||||
|
"github.com/ManyakRus/starter/log"
|
||||||
|
"github.com/ManyakRus/starter/micro"
|
||||||
|
"os"
|
||||||
|
"sort"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CreateAllFiles - создаёт все файлы в папке grpc proto
|
||||||
|
func CreateAllFiles(MapAll map[string]*types.Table) error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
err = CreateFileGRPCClientVars(MapAll)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("CreateFileGRPCClientVars() error: ", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = CreateFileNRPCClientVars(MapAll)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("CreateFileNRPCClientVars() error: ", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateFileGRPCClientVars - создаёт 1 файл в папке grpc
|
||||||
|
func CreateFileGRPCClientVars(MapAll map[string]*types.Table) error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
if config.Settings.NEED_CREATE_GRPC == false {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
//чтение файлов
|
||||||
|
DirBin := micro.ProgramDir_bin()
|
||||||
|
DirTemplates := DirBin + config.Settings.TEMPLATE_FOLDERNAME + micro.SeparatorFile()
|
||||||
|
DirReady := DirBin + config.Settings.READY_FOLDERNAME + micro.SeparatorFile()
|
||||||
|
DirTemplatesGRPCClient := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_GRPC_CLIENT + micro.SeparatorFile()
|
||||||
|
DirReadyGRPCClient := DirReady + config.Settings.TEMPLATE_FOLDERNAME_GRPC_CLIENT + micro.SeparatorFile()
|
||||||
|
FilenameReadyGRPCClientVars := DirReadyGRPCClient + constants.GRPC_CLIENT_VARS_FILENAME
|
||||||
|
|
||||||
|
//создадим папку готовых файлов
|
||||||
|
folders.CreateFolder(DirReadyGRPCClient)
|
||||||
|
|
||||||
|
FilenameTemplateVars := DirTemplatesGRPCClient + constants.GRPC_CLIENT_VARS_FILENAME + "_"
|
||||||
|
bytes, err := os.ReadFile(FilenameTemplateVars)
|
||||||
|
if err != nil {
|
||||||
|
log.Panic("ReadFile() ", FilenameTemplateVars, " error: ", err)
|
||||||
|
}
|
||||||
|
TextGRPCClientVars := string(bytes)
|
||||||
|
|
||||||
|
//заменим импорты
|
||||||
|
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||||
|
TextGRPCClientVars = create_files.DeleteTemplateRepositoryImports(TextGRPCClientVars)
|
||||||
|
|
||||||
|
GRPCProtoURL := create_files.FindGRPCProtoURL()
|
||||||
|
TextGRPCClientVars = create_files.AddImport(TextGRPCClientVars, GRPCProtoURL)
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
TextVars := FindTextVars(MapAll, false)
|
||||||
|
TextGRPCClientVars = TextGRPCClientVars + TextVars
|
||||||
|
|
||||||
|
//
|
||||||
|
TextFuncFillClients := FindTextFuncFillClients(MapAll)
|
||||||
|
TextGRPCClientVars = TextGRPCClientVars + `
|
||||||
|
// FillClients - создание клиентов GRPC` + TextFuncFillClients
|
||||||
|
|
||||||
|
//
|
||||||
|
TextGRPCClientVars = TextGRPCClientVars + "\n}\n"
|
||||||
|
|
||||||
|
//
|
||||||
|
TextGRPCClientVars = create_files.DeleteEmptyLines(TextGRPCClientVars)
|
||||||
|
|
||||||
|
//запись файла
|
||||||
|
err = os.WriteFile(FilenameReadyGRPCClientVars, []byte(TextGRPCClientVars), constants.FILE_PERMISSIONS)
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateFileNRPCClientVars - создаёт 1 файл в папке grpc
|
||||||
|
func CreateFileNRPCClientVars(MapAll map[string]*types.Table) error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
if config.Settings.NEED_CREATE_NRPC == false {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
//чтение файлов
|
||||||
|
DirBin := micro.ProgramDir_bin()
|
||||||
|
DirTemplates := DirBin + config.Settings.TEMPLATE_FOLDERNAME + micro.SeparatorFile()
|
||||||
|
DirReady := DirBin + config.Settings.READY_FOLDERNAME + micro.SeparatorFile()
|
||||||
|
DirTemplatesNRPCClient := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_NRPC_CLIENT + micro.SeparatorFile()
|
||||||
|
DirReadyNRPCClient := DirReady + config.Settings.TEMPLATE_FOLDERNAME_NRPC_CLIENT + micro.SeparatorFile()
|
||||||
|
FilenameReadyGRPCClientVars := DirReadyNRPCClient + constants.NRPC_CLIENT_VARS_FILENAME
|
||||||
|
|
||||||
|
//создадим папку готовых файлов
|
||||||
|
folders.CreateFolder(DirReadyNRPCClient)
|
||||||
|
|
||||||
|
FilenameTemplateVars := DirTemplatesNRPCClient + constants.NRPC_CLIENT_VARS_FILENAME + "_"
|
||||||
|
bytes, err := os.ReadFile(FilenameTemplateVars)
|
||||||
|
if err != nil {
|
||||||
|
log.Panic("ReadFile() ", FilenameTemplateVars, " error: ", err)
|
||||||
|
}
|
||||||
|
TextNRPCClientVars := string(bytes)
|
||||||
|
|
||||||
|
//заменим импорты
|
||||||
|
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||||
|
TextNRPCClientVars = create_files.DeleteTemplateRepositoryImports(TextNRPCClientVars)
|
||||||
|
|
||||||
|
NRPCProtoURL := create_files.FindNRPCProtoURL()
|
||||||
|
TextNRPCClientVars = create_files.AddImport(TextNRPCClientVars, NRPCProtoURL)
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
TextVars := FindTextVars(MapAll, true)
|
||||||
|
TextNRPCClientVars = TextNRPCClientVars + TextVars
|
||||||
|
|
||||||
|
//
|
||||||
|
TextFuncFillClients := FindTextFuncFillClients(MapAll)
|
||||||
|
TextNRPCClientVars = TextNRPCClientVars + `
|
||||||
|
// FillClients - создание клиентов NRPC` + TextFuncFillClients
|
||||||
|
|
||||||
|
//
|
||||||
|
TextNRPCClientVars = TextNRPCClientVars + "\n}\n"
|
||||||
|
|
||||||
|
//
|
||||||
|
TextNRPCClientVars = create_files.DeleteEmptyLines(TextNRPCClientVars)
|
||||||
|
|
||||||
|
//запись файла
|
||||||
|
err = os.WriteFile(FilenameReadyGRPCClientVars, []byte(TextNRPCClientVars), constants.FILE_PERMISSIONS)
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindTextVars - возвращает текст создания переменных
|
||||||
|
func FindTextVars(MapAll map[string]*types.Table, IsNRPC bool) string {
|
||||||
|
Otvet := ""
|
||||||
|
|
||||||
|
//сортировка
|
||||||
|
keys := make([]string, 0, len(MapAll))
|
||||||
|
for k := range MapAll {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
|
||||||
|
TextStar := ""
|
||||||
|
if IsNRPC == true {
|
||||||
|
TextStar = "*"
|
||||||
|
}
|
||||||
|
|
||||||
|
//создание переменных
|
||||||
|
for _, key1 := range keys {
|
||||||
|
Table1 := MapAll[key1]
|
||||||
|
//проверка что таблица нормальная
|
||||||
|
err1 := create_files.CheckGoodTable(Table1)
|
||||||
|
if err1 != nil {
|
||||||
|
log.Warn(err1)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
Comment := create_files.FindModelComment(Table1)
|
||||||
|
Text1 := Comment + "\n" + "var " + Table1.NameGo + "Client " + TextStar + "grpc_proto." + Table1.NameGo + "Client"
|
||||||
|
Otvet = Otvet + "\n" + Text1 + "\n"
|
||||||
|
}
|
||||||
|
return Otvet
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindTextFuncFillClients - возвращает текст создания функции FillClients
|
||||||
|
func FindTextFuncFillClients(MapAll map[string]*types.Table) string {
|
||||||
|
Otvet := ""
|
||||||
|
|
||||||
|
//сортировка
|
||||||
|
keys := make([]string, 0, len(MapAll))
|
||||||
|
for k := range MapAll {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
|
||||||
|
//создание функции
|
||||||
|
Otvet = Otvet + `
|
||||||
|
func FillClients() {`
|
||||||
|
|
||||||
|
for _, key1 := range keys {
|
||||||
|
Table1 := MapAll[key1]
|
||||||
|
//проверка что таблица нормальная
|
||||||
|
err1 := create_files.CheckGoodTable(Table1)
|
||||||
|
if err1 != nil {
|
||||||
|
log.Warn(err1)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
Text1 := "\t" + Table1.NameGo + "Client = " + "grpc_proto.New" + Table1.NameGo + "Client(Conn)"
|
||||||
|
Otvet = Otvet + "\n" + Text1
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return Otvet
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
package grpc_client_vars
|
@ -78,7 +78,7 @@ func CreateFiles(Table1 *types.Table) error {
|
|||||||
ModelTableURL := create_files.FindModelTableURL(TableName)
|
ModelTableURL := create_files.FindModelTableURL(TableName)
|
||||||
TextGRPCServer = create_files.AddImport(TextGRPCServer, ModelTableURL)
|
TextGRPCServer = create_files.AddImport(TextGRPCServer, ModelTableURL)
|
||||||
|
|
||||||
ProtoURL := create_files.FindProtoURL()
|
ProtoURL := create_files.FindGRPCProtoURL()
|
||||||
TextGRPCServer = create_files.AddImport(TextGRPCServer, ProtoURL)
|
TextGRPCServer = create_files.AddImport(TextGRPCServer, ProtoURL)
|
||||||
|
|
||||||
//удалим лишние функции
|
//удалим лишние функции
|
||||||
@ -101,7 +101,7 @@ func CreateFiles(Table1 *types.Table) error {
|
|||||||
//TextGRPCServer = create_files.DeleteTemplateRepositoryImports(TextGRPCServer)
|
//TextGRPCServer = create_files.DeleteTemplateRepositoryImports(TextGRPCServer)
|
||||||
|
|
||||||
////proto
|
////proto
|
||||||
//RepositoryGRPCProtoURL := create_files.FindProtoURL()
|
//RepositoryGRPCProtoURL := create_files.FindGRPCProtoURL()
|
||||||
//TextGRPCServer = create_files.AddImport(TextGRPCServer, RepositoryGRPCProtoURL)
|
//TextGRPCServer = create_files.AddImport(TextGRPCServer, RepositoryGRPCProtoURL)
|
||||||
//
|
//
|
||||||
////model
|
////model
|
||||||
@ -153,7 +153,7 @@ func CreateTestFiles(Table1 *types.Table) error {
|
|||||||
ModelTableURL := create_files.FindModelTableURL(TableName)
|
ModelTableURL := create_files.FindModelTableURL(TableName)
|
||||||
TextGRPCServer = create_files.AddImport(TextGRPCServer, ModelTableURL)
|
TextGRPCServer = create_files.AddImport(TextGRPCServer, ModelTableURL)
|
||||||
|
|
||||||
ProtoURL := create_files.FindProtoURL()
|
ProtoURL := create_files.FindGRPCProtoURL()
|
||||||
TextGRPCServer = create_files.AddImport(TextGRPCServer, ProtoURL)
|
TextGRPCServer = create_files.AddImport(TextGRPCServer, ProtoURL)
|
||||||
|
|
||||||
CrudStarterURL := create_files.FindCrudStarterURL()
|
CrudStarterURL := create_files.FindCrudStarterURL()
|
||||||
|
@ -66,7 +66,7 @@ func CreateNRPCClient() error {
|
|||||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||||
TextNRPCClient = create_files.DeleteTemplateRepositoryImports(TextNRPCClient)
|
TextNRPCClient = create_files.DeleteTemplateRepositoryImports(TextNRPCClient)
|
||||||
|
|
||||||
ProtoURL := create_files.FindProtoURL()
|
ProtoURL := create_files.FindGRPCProtoURL()
|
||||||
TextNRPCClient = create_files.AddImport(TextNRPCClient, ProtoURL)
|
TextNRPCClient = create_files.AddImport(TextNRPCClient, ProtoURL)
|
||||||
|
|
||||||
DBConstantsURL := create_files.FindDBConstantsURL()
|
DBConstantsURL := create_files.FindDBConstantsURL()
|
||||||
|
@ -75,7 +75,7 @@ func CreateFiles(Table1 *types.Table) error {
|
|||||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||||
TextNRPCClient = create_files.DeleteTemplateRepositoryImports(TextNRPCClient)
|
TextNRPCClient = create_files.DeleteTemplateRepositoryImports(TextNRPCClient)
|
||||||
|
|
||||||
GRPCProtoURL := create_files.FindProtoURL()
|
GRPCProtoURL := create_files.FindGRPCProtoURL()
|
||||||
TextNRPCClient = create_files.AddImport(TextNRPCClient, GRPCProtoURL)
|
TextNRPCClient = create_files.AddImport(TextNRPCClient, GRPCProtoURL)
|
||||||
|
|
||||||
NRPCClientURL := create_files.FindNRPCClientURL()
|
NRPCClientURL := create_files.FindNRPCClientURL()
|
||||||
|
@ -68,8 +68,8 @@ func CreateFileProto(MapAll map[string]*types.Table) error {
|
|||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
|
|
||||||
//найдём новый текст для каждой таблицы
|
//найдём новый текст для каждой таблицы
|
||||||
TextProtoNew := ""
|
|
||||||
for _, key1 := range keys {
|
for _, key1 := range keys {
|
||||||
|
TextProtoNew := ""
|
||||||
Table1, ok := MapAll[key1]
|
Table1, ok := MapAll[key1]
|
||||||
if ok == false {
|
if ok == false {
|
||||||
log.Panic("MapAll[key1] not found")
|
log.Panic("MapAll[key1] not found")
|
||||||
@ -82,26 +82,33 @@ func CreateFileProto(MapAll map[string]*types.Table) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
TextProtoNew = TextProtoNew + FindTextProtoTable1(TextProto, Table1)
|
Comments1 := create_files.FindModelComment(Table1)
|
||||||
}
|
TextFuncStart := `
|
||||||
|
` + Comments1 + `
|
||||||
|
service ` + Table1.NameGo + ` {`
|
||||||
|
TextFunctions := FindTextProtoTable1(TextProto, Table1)
|
||||||
|
TextProtoNew = TextProtoNew + TextFuncStart + TextFunctions + "}\n\n"
|
||||||
|
|
||||||
//найдём куда вставить текст
|
//найдём куда вставить текст
|
||||||
sFind := "\nservice "
|
PosStart := 0
|
||||||
pos1 := strings.Index(TextProto, sFind)
|
sFind := "\nservice " + Table1.NameGo + " "
|
||||||
if pos1 < 0 {
|
pos1 := strings.Index(TextProto, sFind)
|
||||||
log.Panic("Not found text ", sFind)
|
if pos1 < 0 {
|
||||||
}
|
PosStart = len(TextProto) - 1 //в конец
|
||||||
|
} else {
|
||||||
|
s2 := TextProto[pos1+1:]
|
||||||
|
sFind = "\n"
|
||||||
|
posEnd := strings.Index(s2, sFind)
|
||||||
|
if posEnd < 0 {
|
||||||
|
log.Panic("Not found text ", sFind)
|
||||||
|
}
|
||||||
|
PosStart = pos1 + posEnd + 1
|
||||||
|
}
|
||||||
|
|
||||||
s2 := TextProto[pos1+1:]
|
//
|
||||||
sFind = "\n"
|
TextProto = TextProto[:PosStart] + TextProtoNew + TextProto[PosStart:]
|
||||||
posEnd := strings.Index(s2, sFind)
|
|
||||||
if posEnd < 0 {
|
|
||||||
log.Panic("Not found text ", sFind)
|
|
||||||
}
|
|
||||||
PosStart := pos1 + posEnd + 1
|
|
||||||
|
|
||||||
//
|
}
|
||||||
TextProto = TextProto[:PosStart] + TextProtoNew + TextProto[PosStart:]
|
|
||||||
|
|
||||||
//
|
//
|
||||||
TextProto = create_files.DeleteEmptyLines(TextProto)
|
TextProto = create_files.DeleteEmptyLines(TextProto)
|
||||||
@ -148,13 +155,26 @@ func FindTextProtoTable1(TextProto string, Table1 *types.Table) string {
|
|||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FindTextService - возвращает текст одного сервиса
|
||||||
|
func FindTextService(TextProto string, ModelName string) string {
|
||||||
|
Otvet := ""
|
||||||
|
|
||||||
|
TextFind1 := "\nservice " + ModelName + " "
|
||||||
|
TextFind2 := "\n}"
|
||||||
|
|
||||||
|
Otvet = micro.StringBetween(TextProto, TextFind1, TextFind2)
|
||||||
|
|
||||||
|
return Otvet
|
||||||
|
}
|
||||||
|
|
||||||
// FindTextRead - возвращает текст .proto
|
// FindTextRead - возвращает текст .proto
|
||||||
func FindTextRead(TextProto string, ModelName string) string {
|
func FindTextRead(TextProto string, ModelName string) string {
|
||||||
Otvet := ""
|
Otvet := ""
|
||||||
Otvet2 := TextRead(ModelName)
|
Otvet2 := TextRead(ModelName)
|
||||||
|
|
||||||
//проверка такой текст уже есть
|
//проверка такой текст уже есть
|
||||||
pos1 := strings.Index(TextProto, Otvet2)
|
TextService := FindTextService(TextProto, ModelName)
|
||||||
|
pos1 := strings.Index(TextService, Otvet2)
|
||||||
if pos1 >= 0 {
|
if pos1 >= 0 {
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
@ -170,7 +190,8 @@ func FindTextCreate(TextProto string, ModelName string) string {
|
|||||||
Otvet2 := TextCreate(ModelName)
|
Otvet2 := TextCreate(ModelName)
|
||||||
|
|
||||||
//проверка такой текст уже есть
|
//проверка такой текст уже есть
|
||||||
pos1 := strings.Index(TextProto, Otvet2)
|
TextService := FindTextService(TextProto, ModelName)
|
||||||
|
pos1 := strings.Index(TextService, Otvet2)
|
||||||
if pos1 >= 0 {
|
if pos1 >= 0 {
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
@ -186,7 +207,8 @@ func FindTextUpdate(TextProto string, ModelName string) string {
|
|||||||
Otvet2 := TextUpdate(ModelName)
|
Otvet2 := TextUpdate(ModelName)
|
||||||
|
|
||||||
//проверка такой текст уже есть
|
//проверка такой текст уже есть
|
||||||
pos1 := strings.Index(TextProto, Otvet2)
|
TextService := FindTextService(TextProto, ModelName)
|
||||||
|
pos1 := strings.Index(TextService, Otvet2)
|
||||||
if pos1 >= 0 {
|
if pos1 >= 0 {
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
@ -202,7 +224,8 @@ func FindTextSave(TextProto string, ModelName string) string {
|
|||||||
Otvet2 := TextSave(ModelName)
|
Otvet2 := TextSave(ModelName)
|
||||||
|
|
||||||
//проверка такой текст уже есть
|
//проверка такой текст уже есть
|
||||||
pos1 := strings.Index(TextProto, Otvet2)
|
TextService := FindTextService(TextProto, ModelName)
|
||||||
|
pos1 := strings.Index(TextService, Otvet2)
|
||||||
if pos1 >= 0 {
|
if pos1 >= 0 {
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
@ -218,7 +241,8 @@ func FindTextDelete(TextProto string, ModelName string) string {
|
|||||||
Otvet2 := TextDelete(ModelName)
|
Otvet2 := TextDelete(ModelName)
|
||||||
|
|
||||||
//проверка такой текст уже есть
|
//проверка такой текст уже есть
|
||||||
pos1 := strings.Index(TextProto, Otvet2)
|
TextService := FindTextService(TextProto, ModelName)
|
||||||
|
pos1 := strings.Index(TextService, Otvet2)
|
||||||
if pos1 >= 0 {
|
if pos1 >= 0 {
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
@ -234,7 +258,8 @@ func FindTextRestore(TextProto string, ModelName string) string {
|
|||||||
Otvet2 := TextRestore(ModelName)
|
Otvet2 := TextRestore(ModelName)
|
||||||
|
|
||||||
//проверка такой текст уже есть
|
//проверка такой текст уже есть
|
||||||
pos1 := strings.Index(TextProto, Otvet2)
|
TextService := FindTextService(TextProto, ModelName)
|
||||||
|
pos1 := strings.Index(TextService, Otvet2)
|
||||||
if pos1 >= 0 {
|
if pos1 >= 0 {
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
@ -250,7 +275,8 @@ func FindTextFindByExtId(TextProto string, ModelName string) string {
|
|||||||
Otvet2 := TextFindByExtId(ModelName)
|
Otvet2 := TextFindByExtId(ModelName)
|
||||||
|
|
||||||
//проверка такой текст уже есть
|
//проверка такой текст уже есть
|
||||||
pos1 := strings.Index(TextProto, Otvet2)
|
TextService := FindTextService(TextProto, ModelName)
|
||||||
|
pos1 := strings.Index(TextService, Otvet2)
|
||||||
if pos1 >= 0 {
|
if pos1 >= 0 {
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
@ -262,49 +288,49 @@ func FindTextFindByExtId(TextProto string, ModelName string) string {
|
|||||||
|
|
||||||
// TextRead - возвращает текст .proto
|
// TextRead - возвращает текст .proto
|
||||||
func TextRead(ModelName string) string {
|
func TextRead(ModelName string) string {
|
||||||
Otvet := "rpc " + ModelName + "_Read(RequestId) returns (Response) {}"
|
Otvet := "rpc Read(RequestId) returns (Response) {}"
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextCreate - возвращает текст .proto
|
// TextCreate - возвращает текст .proto
|
||||||
func TextCreate(ModelName string) string {
|
func TextCreate(ModelName string) string {
|
||||||
Otvet := "rpc " + ModelName + "_Create(RequestModel) returns (Response) {}"
|
Otvet := "rpc Create(RequestModel) returns (Response) {}"
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextUpdate - возвращает текст .proto
|
// TextUpdate - возвращает текст .proto
|
||||||
func TextUpdate(ModelName string) string {
|
func TextUpdate(ModelName string) string {
|
||||||
Otvet := "rpc " + ModelName + "_Update(RequestModel) returns (Response) {}"
|
Otvet := "rpc Update(RequestModel) returns (Response) {}"
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextSave - возвращает текст .proto
|
// TextSave - возвращает текст .proto
|
||||||
func TextSave(ModelName string) string {
|
func TextSave(ModelName string) string {
|
||||||
Otvet := "rpc " + ModelName + "_Save(RequestModel) returns (Response) {}"
|
Otvet := "rpc Save(RequestModel) returns (Response) {}"
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextDelete - возвращает текст .proto
|
// TextDelete - возвращает текст .proto
|
||||||
func TextDelete(ModelName string) string {
|
func TextDelete(ModelName string) string {
|
||||||
Otvet := "rpc " + ModelName + "_Delete(RequestId) returns (Response) {}"
|
Otvet := "rpc Delete(RequestId) returns (Response) {}"
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextRestore - возвращает текст .proto
|
// TextRestore - возвращает текст .proto
|
||||||
func TextRestore(ModelName string) string {
|
func TextRestore(ModelName string) string {
|
||||||
Otvet := "rpc " + ModelName + "_Restore(RequestId) returns (Response) {}"
|
Otvet := "rpc Restore(RequestId) returns (Response) {}"
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextFindByExtId - возвращает текст .proto
|
// TextFindByExtId - возвращает текст .proto
|
||||||
func TextFindByExtId(ModelName string) string {
|
func TextFindByExtId(ModelName string) string {
|
||||||
Otvet := "rpc " + ModelName + "_FindByExtID(RequestExtID) returns (Response) {}"
|
Otvet := "rpc FindByExtID(RequestExtID) returns (Response) {}"
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ func CreateServerGRPCStarter() error {
|
|||||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||||
TextGRPCStarter = create_files.DeleteTemplateRepositoryImports(TextGRPCStarter)
|
TextGRPCStarter = create_files.DeleteTemplateRepositoryImports(TextGRPCStarter)
|
||||||
|
|
||||||
ProtoURL := create_files.FindProtoURL()
|
ProtoURL := create_files.FindGRPCProtoURL()
|
||||||
TextGRPCStarter = create_files.AddImport(TextGRPCStarter, ProtoURL)
|
TextGRPCStarter = create_files.AddImport(TextGRPCStarter, ProtoURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ func CreateServerGRPCStarter() error {
|
|||||||
TextNRPCStarter = create_files.DeleteTemplateRepositoryImports(TextNRPCStarter)
|
TextNRPCStarter = create_files.DeleteTemplateRepositoryImports(TextNRPCStarter)
|
||||||
|
|
||||||
//Proto URL
|
//Proto URL
|
||||||
RepositoryProtoURL := create_files.FindProtoURL()
|
RepositoryProtoURL := create_files.FindGRPCProtoURL()
|
||||||
TextNRPCStarter = create_files.AddImport(TextNRPCStarter, RepositoryProtoURL)
|
TextNRPCStarter = create_files.AddImport(TextNRPCStarter, RepositoryProtoURL)
|
||||||
|
|
||||||
//server grpc URL
|
//server grpc URL
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/ManyakRus/crud_generator/internal/create_files/generation_code_sh"
|
"github.com/ManyakRus/crud_generator/internal/create_files/generation_code_sh"
|
||||||
"github.com/ManyakRus/crud_generator/internal/create_files/grpc_client"
|
"github.com/ManyakRus/crud_generator/internal/create_files/grpc_client"
|
||||||
"github.com/ManyakRus/crud_generator/internal/create_files/grpc_client_tables"
|
"github.com/ManyakRus/crud_generator/internal/create_files/grpc_client_tables"
|
||||||
|
"github.com/ManyakRus/crud_generator/internal/create_files/grpc_client_vars"
|
||||||
"github.com/ManyakRus/crud_generator/internal/create_files/grpc_server_tables"
|
"github.com/ManyakRus/crud_generator/internal/create_files/grpc_server_tables"
|
||||||
"github.com/ManyakRus/crud_generator/internal/create_files/main_file"
|
"github.com/ManyakRus/crud_generator/internal/create_files/main_file"
|
||||||
"github.com/ManyakRus/crud_generator/internal/create_files/makefile"
|
"github.com/ManyakRus/crud_generator/internal/create_files/makefile"
|
||||||
@ -177,5 +178,12 @@ func StartFillAll() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//grpc_client_vars
|
||||||
|
err = grpc_client_vars.CreateAllFiles(MapAll)
|
||||||
|
if err != nil {
|
||||||
|
//log.Error("env_file.CreateAllFiles() error: ", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user