mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2024-12-22 00:36:41 +02:00
parent
493e329b47
commit
be4e1501ba
@ -30,6 +30,9 @@ 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{}
|
||||||
|
|
||||||
@ -73,8 +76,7 @@ func Connect_err() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
FillClients()
|
Client = grpc_proto.NewSyncServiceClient(Conn)
|
||||||
|
|
||||||
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.LawsuitStatusTypeClient == nil {
|
if grpc_client.Client == 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.LawsuitStatusTypeClient.Read(ctx, Request)
|
Response, err := grpc_client.Client.LawsuitStatusType_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.LawsuitStatusTypeClient == nil {
|
if grpc_client.Client == 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.LawsuitStatusTypeClient.Create(ctx, Request)
|
Response, err := grpc_client.Client.LawsuitStatusType_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.LawsuitStatusTypeClient == nil {
|
if grpc_client.Client == 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.LawsuitStatusTypeClient.Update(ctx, Request)
|
Response, err := grpc_client.Client.LawsuitStatusType_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.LawsuitStatusTypeClient == nil {
|
if grpc_client.Client == 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.LawsuitStatusTypeClient.Save(ctx, Request)
|
Response, err := grpc_client.Client.LawsuitStatusType_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.LawsuitStatusTypeClient == nil {
|
if grpc_client.Client == 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.LawsuitStatusTypeClient.Delete(ctx, Request)
|
Response, err := grpc_client.Client.LawsuitStatusType_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.LawsuitStatusTypeClient == nil {
|
if grpc_client.Client == 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.LawsuitStatusTypeClient.Restore(ctx, Request)
|
Response, err := grpc_client.Client.LawsuitStatusType_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.LawsuitStatusTypeClient == nil {
|
if grpc_client.Client == 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.LawsuitStatusTypeClient.FindByExtID(ctx, Request)
|
Response, err := grpc_client.Client.LawsuitStatusType_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 {
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
package grpc_client
|
|
||||||
|
|
||||||
import (
|
|
||||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/api/grpc_proto"
|
|
||||||
)
|
|
||||||
|
|
@ -36,6 +36,9 @@ 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{}
|
||||||
|
|
||||||
@ -77,7 +80,8 @@ func Connect_err() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
FillClients()
|
// This is our generated client.
|
||||||
|
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.LawsuitStatusTypeClient == nil {
|
if nrpc_client.Client == 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.LawsuitStatusTypeClient.Read(Request)
|
Response, err := nrpc_client.Client.LawsuitStatusType_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.LawsuitStatusTypeClient == nil {
|
if nrpc_client.Client == 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.LawsuitStatusTypeClient.Create(Request)
|
Response, err := nrpc_client.Client.LawsuitStatusType_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.LawsuitStatusTypeClient == nil {
|
if nrpc_client.Client == 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.LawsuitStatusTypeClient.Update(Request)
|
Response, err := nrpc_client.Client.LawsuitStatusType_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.LawsuitStatusTypeClient == nil {
|
if nrpc_client.Client == 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.LawsuitStatusTypeClient.Save(Request)
|
Response, err := nrpc_client.Client.LawsuitStatusType_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.LawsuitStatusTypeClient == nil {
|
if nrpc_client.Client == 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.LawsuitStatusTypeClient.Delete(Request)
|
Response, err := nrpc_client.Client.LawsuitStatusType_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.LawsuitStatusTypeClient == nil {
|
if nrpc_client.Client == 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.LawsuitStatusTypeClient.Restore(Request)
|
Response, err := nrpc_client.Client.LawsuitStatusType_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.LawsuitStatusTypeClient == nil {
|
if nrpc_client.Client == 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.LawsuitStatusTypeClient.FindByExtID(Request)
|
Response, err := nrpc_client.Client.LawsuitStatusType_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 {
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
package nrpc_client
|
|
||||||
|
|
||||||
import (
|
|
||||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/api/nrpc/grpc_proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
@ -42,7 +42,3 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindGRPCProtoURL - возвращает URL репозитория с пакетом "grpc_proto"
|
// FindProtoURL - возвращает URL репозитория с пакетом "grpc_proto"
|
||||||
func FindGRPCProtoURL() string {
|
func FindProtoURL() 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,16 +322,6 @@ func FindGRPCProtoURL() 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.FindGRPCProtoURL()
|
ProtoURL := create_files.FindProtoURL()
|
||||||
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.FindGRPCProtoURL()
|
RepositoryGRPCProtoURL := create_files.FindProtoURL()
|
||||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryGRPCProtoURL)
|
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryGRPCProtoURL)
|
||||||
|
|
||||||
//model
|
//model
|
||||||
|
@ -1,205 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
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.FindGRPCProtoURL()
|
ProtoURL := create_files.FindProtoURL()
|
||||||
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.FindGRPCProtoURL()
|
//RepositoryGRPCProtoURL := create_files.FindProtoURL()
|
||||||
//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.FindGRPCProtoURL()
|
ProtoURL := create_files.FindProtoURL()
|
||||||
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.FindGRPCProtoURL()
|
ProtoURL := create_files.FindProtoURL()
|
||||||
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.FindGRPCProtoURL()
|
GRPCProtoURL := create_files.FindProtoURL()
|
||||||
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,34 +82,27 @@ func CreateFileProto(MapAll map[string]*types.Table) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
Comments1 := create_files.FindModelComment(Table1)
|
TextProtoNew = TextProtoNew + FindTextProtoTable1(TextProto, Table1)
|
||||||
TextFuncStart := `
|
|
||||||
` + Comments1 + `
|
|
||||||
service ` + Table1.NameGo + ` {`
|
|
||||||
TextFunctions := FindTextProtoTable1(TextProto, Table1)
|
|
||||||
TextProtoNew = TextProtoNew + TextFuncStart + TextFunctions + "}\n\n"
|
|
||||||
|
|
||||||
//найдём куда вставить текст
|
|
||||||
PosStart := 0
|
|
||||||
sFind := "\nservice " + Table1.NameGo + " "
|
|
||||||
pos1 := strings.Index(TextProto, 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
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
TextProto = TextProto[:PosStart] + TextProtoNew + TextProto[PosStart:]
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//найдём куда вставить текст
|
||||||
|
sFind := "\nservice "
|
||||||
|
pos1 := strings.Index(TextProto, sFind)
|
||||||
|
if pos1 < 0 {
|
||||||
|
log.Panic("Not found text ", sFind)
|
||||||
|
}
|
||||||
|
|
||||||
|
s2 := TextProto[pos1+1:]
|
||||||
|
sFind = "\n"
|
||||||
|
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)
|
||||||
|
|
||||||
@ -155,26 +148,13 @@ 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)
|
||||||
|
|
||||||
//проверка такой текст уже есть
|
//проверка такой текст уже есть
|
||||||
TextService := FindTextService(TextProto, ModelName)
|
pos1 := strings.Index(TextProto, Otvet2)
|
||||||
pos1 := strings.Index(TextService, Otvet2)
|
|
||||||
if pos1 >= 0 {
|
if pos1 >= 0 {
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
@ -190,8 +170,7 @@ func FindTextCreate(TextProto string, ModelName string) string {
|
|||||||
Otvet2 := TextCreate(ModelName)
|
Otvet2 := TextCreate(ModelName)
|
||||||
|
|
||||||
//проверка такой текст уже есть
|
//проверка такой текст уже есть
|
||||||
TextService := FindTextService(TextProto, ModelName)
|
pos1 := strings.Index(TextProto, Otvet2)
|
||||||
pos1 := strings.Index(TextService, Otvet2)
|
|
||||||
if pos1 >= 0 {
|
if pos1 >= 0 {
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
@ -207,8 +186,7 @@ func FindTextUpdate(TextProto string, ModelName string) string {
|
|||||||
Otvet2 := TextUpdate(ModelName)
|
Otvet2 := TextUpdate(ModelName)
|
||||||
|
|
||||||
//проверка такой текст уже есть
|
//проверка такой текст уже есть
|
||||||
TextService := FindTextService(TextProto, ModelName)
|
pos1 := strings.Index(TextProto, Otvet2)
|
||||||
pos1 := strings.Index(TextService, Otvet2)
|
|
||||||
if pos1 >= 0 {
|
if pos1 >= 0 {
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
@ -224,8 +202,7 @@ func FindTextSave(TextProto string, ModelName string) string {
|
|||||||
Otvet2 := TextSave(ModelName)
|
Otvet2 := TextSave(ModelName)
|
||||||
|
|
||||||
//проверка такой текст уже есть
|
//проверка такой текст уже есть
|
||||||
TextService := FindTextService(TextProto, ModelName)
|
pos1 := strings.Index(TextProto, Otvet2)
|
||||||
pos1 := strings.Index(TextService, Otvet2)
|
|
||||||
if pos1 >= 0 {
|
if pos1 >= 0 {
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
@ -241,8 +218,7 @@ func FindTextDelete(TextProto string, ModelName string) string {
|
|||||||
Otvet2 := TextDelete(ModelName)
|
Otvet2 := TextDelete(ModelName)
|
||||||
|
|
||||||
//проверка такой текст уже есть
|
//проверка такой текст уже есть
|
||||||
TextService := FindTextService(TextProto, ModelName)
|
pos1 := strings.Index(TextProto, Otvet2)
|
||||||
pos1 := strings.Index(TextService, Otvet2)
|
|
||||||
if pos1 >= 0 {
|
if pos1 >= 0 {
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
@ -258,8 +234,7 @@ func FindTextRestore(TextProto string, ModelName string) string {
|
|||||||
Otvet2 := TextRestore(ModelName)
|
Otvet2 := TextRestore(ModelName)
|
||||||
|
|
||||||
//проверка такой текст уже есть
|
//проверка такой текст уже есть
|
||||||
TextService := FindTextService(TextProto, ModelName)
|
pos1 := strings.Index(TextProto, Otvet2)
|
||||||
pos1 := strings.Index(TextService, Otvet2)
|
|
||||||
if pos1 >= 0 {
|
if pos1 >= 0 {
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
@ -275,8 +250,7 @@ func FindTextFindByExtId(TextProto string, ModelName string) string {
|
|||||||
Otvet2 := TextFindByExtId(ModelName)
|
Otvet2 := TextFindByExtId(ModelName)
|
||||||
|
|
||||||
//проверка такой текст уже есть
|
//проверка такой текст уже есть
|
||||||
TextService := FindTextService(TextProto, ModelName)
|
pos1 := strings.Index(TextProto, Otvet2)
|
||||||
pos1 := strings.Index(TextService, Otvet2)
|
|
||||||
if pos1 >= 0 {
|
if pos1 >= 0 {
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
@ -288,49 +262,49 @@ func FindTextFindByExtId(TextProto string, ModelName string) string {
|
|||||||
|
|
||||||
// TextRead - возвращает текст .proto
|
// TextRead - возвращает текст .proto
|
||||||
func TextRead(ModelName string) string {
|
func TextRead(ModelName string) string {
|
||||||
Otvet := "rpc Read(RequestId) returns (Response) {}"
|
Otvet := "rpc " + ModelName + "_Read(RequestId) returns (Response) {}"
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextCreate - возвращает текст .proto
|
// TextCreate - возвращает текст .proto
|
||||||
func TextCreate(ModelName string) string {
|
func TextCreate(ModelName string) string {
|
||||||
Otvet := "rpc Create(RequestModel) returns (Response) {}"
|
Otvet := "rpc " + ModelName + "_Create(RequestModel) returns (Response) {}"
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextUpdate - возвращает текст .proto
|
// TextUpdate - возвращает текст .proto
|
||||||
func TextUpdate(ModelName string) string {
|
func TextUpdate(ModelName string) string {
|
||||||
Otvet := "rpc Update(RequestModel) returns (Response) {}"
|
Otvet := "rpc " + ModelName + "_Update(RequestModel) returns (Response) {}"
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextSave - возвращает текст .proto
|
// TextSave - возвращает текст .proto
|
||||||
func TextSave(ModelName string) string {
|
func TextSave(ModelName string) string {
|
||||||
Otvet := "rpc Save(RequestModel) returns (Response) {}"
|
Otvet := "rpc " + ModelName + "_Save(RequestModel) returns (Response) {}"
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextDelete - возвращает текст .proto
|
// TextDelete - возвращает текст .proto
|
||||||
func TextDelete(ModelName string) string {
|
func TextDelete(ModelName string) string {
|
||||||
Otvet := "rpc Delete(RequestId) returns (Response) {}"
|
Otvet := "rpc " + ModelName + "_Delete(RequestId) returns (Response) {}"
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextRestore - возвращает текст .proto
|
// TextRestore - возвращает текст .proto
|
||||||
func TextRestore(ModelName string) string {
|
func TextRestore(ModelName string) string {
|
||||||
Otvet := "rpc Restore(RequestId) returns (Response) {}"
|
Otvet := "rpc " + ModelName + "_Restore(RequestId) returns (Response) {}"
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextFindByExtId - возвращает текст .proto
|
// TextFindByExtId - возвращает текст .proto
|
||||||
func TextFindByExtId(ModelName string) string {
|
func TextFindByExtId(ModelName string) string {
|
||||||
Otvet := "rpc FindByExtID(RequestExtID) returns (Response) {}"
|
Otvet := "rpc " + ModelName + "_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.FindGRPCProtoURL()
|
ProtoURL := create_files.FindProtoURL()
|
||||||
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.FindGRPCProtoURL()
|
RepositoryProtoURL := create_files.FindProtoURL()
|
||||||
TextNRPCStarter = create_files.AddImport(TextNRPCStarter, RepositoryProtoURL)
|
TextNRPCStarter = create_files.AddImport(TextNRPCStarter, RepositoryProtoURL)
|
||||||
|
|
||||||
//server grpc URL
|
//server grpc URL
|
||||||
|
@ -10,7 +10,6 @@ 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"
|
||||||
@ -178,12 +177,5 @@ 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