1
0
mirror of https://github.com/ManyakRus/crud_generator.git synced 2024-12-22 00:36:41 +02:00

сделал убрал grpc_client_tables

This commit is contained in:
Nikitin Aleksandr 2024-02-08 15:33:06 +03:00
parent 3a8f0d7149
commit f2b482c820
21 changed files with 347 additions and 150 deletions

View File

@ -52,6 +52,7 @@ conn:
image_connections ./internal docs/connections.graphml $(SERVICENAME)
init:
clear
rm ./go.mod
go mod init gitlab.aescorp.ru/dsp_dev/claim/sync_service
$(GENERATION_PROTO)
go mod tidy

View File

@ -9,13 +9,15 @@ import (
"github.com/ManyakRus/starter/stopapp"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/api/grpc_proto"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants"
grpc_constants "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/nrpc/nrpc_client"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"os"
"strings"
"sync"
"time"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc_nrpc"
)
// SettingsINI - тип структуры для хранения настроек подключени
@ -77,6 +79,9 @@ func Connect_err() error {
}
Client = grpc_proto.NewSyncServiceClient(Conn)
grpc_nrpc.NeedNRPC = false
return err
}
@ -235,3 +240,16 @@ func GetTimeoutSeconds() int {
func SetTimeoutSeconds(seconds int) {
grpc_constants.SetTimeoutSeconds(seconds)
}
// Connect_GRPC_NRPC - подключается к серверу GRPC или NRPC, при ошибке вызывает панику
func Connect_GRPC_NRPC() {
if grpc_nrpc.NeedNRPC == true {
if nrpc_client.Client == nil {
nrpc_client.Connect()
}
} else {
if Client == nil {
Connect()
}
}
}

View File

@ -1,12 +1,18 @@
//Файл создан автоматически кодогенератором crud_generator
//Не изменяйте ничего здесь.
package grpc_lawsuit_status_types
import (
"context"
"encoding/json"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/api/grpc_proto"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_client"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_client/constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_proto"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/nrpc/nrpc_client"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc_nrpc"
"log"
"sync"
"time"
@ -18,13 +24,13 @@ var VersionModel uint32
// TableName - имя таблицы в БД Postgres
const TableName string = "lawsuit_status_types"
// mutex_GetVersionModel - защита от многопоточности GetVersionModel()
var mutex_GetVersionModel = sync.Mutex{}
// объект для CRUD операций через GRPC
type Crud_GRPC struct {
}
// mutex_GetVersionModel - защита от многопоточности GetVersionModel()
var mutex_GetVersionModel = sync.Mutex{}
// GetVersionModel - возвращает хэш версии структуры модели
func (crud Crud_GRPC) GetVersionModel() uint32 {
mutex_GetVersionModel.Lock()
@ -38,12 +44,10 @@ func (crud Crud_GRPC) GetVersionModel() uint32 {
// Read - возвращает модель из БД
func (crud Crud_GRPC) Read(m *lawsuit_status_types.LawsuitStatusType) error {
// var Otvet lawsuit_status_types.LawsuitStatusType
var err error
// подключение
if grpc_client.Client == nil {
grpc_client.Connect()
}
grpc_client.Connect_GRPC_NRPC()
// подготовка запроса
var versionModel = crud.GetVersionModel()
@ -53,14 +57,19 @@ func (crud Crud_GRPC) Read(m *lawsuit_status_types.LawsuitStatusType) error {
Request.VersionModel = versionModel
ctxMain := context.Background()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.GetTimeoutSeconds()))
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(grpc_constants.GetTimeoutSeconds()))
defer ctxCancelFunc()
// запрос
Response, err := grpc_client.Client.LawsuitStatusType_Read(ctx, Request)
var Response *grpc_proto.Response
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_Read(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_Read(ctx, Request)
}
if err != nil {
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(grpc_constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(grpc_constants.TEXT_ERROR_MODEL_VERSION)] == grpc_constants.TEXT_ERROR_MODEL_VERSION {
log.Panic("table: ", TableName, " error: ", err)
}
return err
@ -78,12 +87,10 @@ func (crud Crud_GRPC) Read(m *lawsuit_status_types.LawsuitStatusType) error {
// Create - записывает новую модель в БД
func (crud Crud_GRPC) Create(m *lawsuit_status_types.LawsuitStatusType) error {
// var Otvet lawsuit_status_types.LawsuitStatusType
var err error
// подключение
if grpc_client.Client == nil {
grpc_client.Connect()
}
grpc_client.Connect_GRPC_NRPC()
// подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -97,14 +104,19 @@ func (crud Crud_GRPC) Create(m *lawsuit_status_types.LawsuitStatusType) error {
Request.VersionModel = VersionModel
ctxMain := context.Background()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.GetTimeoutSeconds()))
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(grpc_constants.GetTimeoutSeconds()))
defer ctxCancelFunc()
// запрос
Response, err := grpc_client.Client.LawsuitStatusType_Create(ctx, Request)
var Response *grpc_proto.Response
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_Create(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_Create(ctx, Request)
}
if err != nil {
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(grpc_constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(grpc_constants.TEXT_ERROR_MODEL_VERSION)] == grpc_constants.TEXT_ERROR_MODEL_VERSION {
log.Panic("table: ", TableName, " error: ", err)
}
return err
@ -122,12 +134,10 @@ func (crud Crud_GRPC) Create(m *lawsuit_status_types.LawsuitStatusType) error {
// Update - обновляет модель в БД
func (crud Crud_GRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
// var Otvet lawsuit_status_types.LawsuitStatusType
var err error
// подключение
if grpc_client.Client == nil {
grpc_client.Connect()
}
grpc_client.Connect_GRPC_NRPC()
// подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -141,14 +151,19 @@ func (crud Crud_GRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
Request.VersionModel = VersionModel
ctxMain := context.Background()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.GetTimeoutSeconds()))
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(grpc_constants.GetTimeoutSeconds()))
defer ctxCancelFunc()
// запрос
Response, err := grpc_client.Client.LawsuitStatusType_Update(ctx, Request)
var Response *grpc_proto.Response
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_Update(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_Update(ctx, Request)
}
if err != nil {
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(grpc_constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(grpc_constants.TEXT_ERROR_MODEL_VERSION)] == grpc_constants.TEXT_ERROR_MODEL_VERSION {
log.Panic("table: ", TableName, " error: ", err)
}
return err
@ -166,12 +181,10 @@ func (crud Crud_GRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
// Save - обновляет (или создаёт) модель в БД
func (crud Crud_GRPC) Save(m *lawsuit_status_types.LawsuitStatusType) error {
// var Otvet lawsuit_status_types.LawsuitStatusType
var err error
// подключение
if grpc_client.Client == nil {
grpc_client.Connect()
}
grpc_client.Connect_GRPC_NRPC()
// подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -185,14 +198,19 @@ func (crud Crud_GRPC) Save(m *lawsuit_status_types.LawsuitStatusType) error {
Request.VersionModel = VersionModel
ctxMain := context.Background()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.GetTimeoutSeconds()))
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(grpc_constants.GetTimeoutSeconds()))
defer ctxCancelFunc()
// запрос
Response, err := grpc_client.Client.LawsuitStatusType_Save(ctx, Request)
var Response *grpc_proto.Response
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_Save(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_Save(ctx, Request)
}
if err != nil {
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(grpc_constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(grpc_constants.TEXT_ERROR_MODEL_VERSION)] == grpc_constants.TEXT_ERROR_MODEL_VERSION {
log.Panic("table: ", TableName, " error: ", err)
}
return err
@ -210,12 +228,10 @@ func (crud Crud_GRPC) Save(m *lawsuit_status_types.LawsuitStatusType) error {
// Delete - устанавливает is_deleted = true в БД
func (crud Crud_GRPC) Delete(m *lawsuit_status_types.LawsuitStatusType) error {
// var Otvet lawsuit_status_types.LawsuitStatusType
var err error
// подключение
if grpc_client.Client == nil {
grpc_client.Connect()
}
grpc_client.Connect_GRPC_NRPC()
// подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -225,14 +241,19 @@ func (crud Crud_GRPC) Delete(m *lawsuit_status_types.LawsuitStatusType) error {
Request.VersionModel = VersionModel
ctxMain := context.Background()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.GetTimeoutSeconds()))
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(grpc_constants.GetTimeoutSeconds()))
defer ctxCancelFunc()
// запрос
Response, err := grpc_client.Client.LawsuitStatusType_Delete(ctx, Request)
var Response *grpc_proto.Response
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_Delete(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_Delete(ctx, Request)
}
if err != nil {
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(grpc_constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(grpc_constants.TEXT_ERROR_MODEL_VERSION)] == grpc_constants.TEXT_ERROR_MODEL_VERSION {
log.Panic("table: ", TableName, " error: ", err)
}
return err
@ -250,12 +271,10 @@ func (crud Crud_GRPC) Delete(m *lawsuit_status_types.LawsuitStatusType) error {
// Restore - устанавливает is_deleted = false в БД
func (crud Crud_GRPC) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
// var Otvet lawsuit_status_types.LawsuitStatusType
var err error
// подключение
if grpc_client.Client == nil {
grpc_client.Connect()
}
grpc_client.Connect_GRPC_NRPC()
// подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -265,14 +284,19 @@ func (crud Crud_GRPC) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
Request.VersionModel = VersionModel
ctxMain := context.Background()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.GetTimeoutSeconds()))
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(grpc_constants.GetTimeoutSeconds()))
defer ctxCancelFunc()
// запрос
Response, err := grpc_client.Client.LawsuitStatusType_Restore(ctx, Request)
var Response *grpc_proto.Response
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_Restore(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_Restore(ctx, Request)
}
if err != nil {
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(grpc_constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(grpc_constants.TEXT_ERROR_MODEL_VERSION)] == grpc_constants.TEXT_ERROR_MODEL_VERSION {
log.Panic("table: ", TableName, " error: ", err)
}
return err
@ -290,10 +314,10 @@ func (crud Crud_GRPC) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
// Find_ByExtID - находит модель в БД по ext_id и connection_id
func (crud Crud_GRPC) Find_ByExtID(m *lawsuit_status_types.LawsuitStatusType) error {
//подключение
if grpc_client.Client == nil {
grpc_client.Connect()
}
var err error
// подключение
grpc_client.Connect_GRPC_NRPC()
//подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -304,14 +328,19 @@ func (crud Crud_GRPC) Find_ByExtID(m *lawsuit_status_types.LawsuitStatusType) er
Request.VersionModel = VersionModel
ctxMain := context.Background()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.GetTimeoutSeconds()))
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(grpc_constants.GetTimeoutSeconds()))
defer ctxCancelFunc()
//запрос
Response, err := grpc_client.Client.LawsuitStatusType_FindByExtID(ctx, Request)
var Response *grpc_proto.Response
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_FindByExtID(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_FindByExtID(ctx, Request)
}
if err != nil {
sError := err.Error()
if sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
if sError[0:len(grpc_constants.TEXT_ERROR_MODEL_VERSION)] == grpc_constants.TEXT_ERROR_MODEL_VERSION {
log.Panic("table: ", TableName, " error: ", err)
}
return err

View File

@ -1,4 +1,4 @@
package constants
package grpc_constants
import "sync"

View File

@ -0,0 +1,4 @@
package grpc_nrpc
// NeedNRPC - нужно ли использовать NRPC или GRPC
var NeedNRPC bool

View File

@ -4,7 +4,8 @@ import (
"encoding/json"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_proto"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/nrpc/nrpc_client"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/nrpc/grpc_client/constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/nrpc/nrpc_client/nrpc_constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
"log"
"sync"
@ -39,7 +40,7 @@ func (crud Crud_NRPC) Read(m *lawsuit_status_types.LawsuitStatusType) error {
// var Otvet lawsuit_status_types.LawsuitStatusType
// подключение
if nrpc_client.Client == nil {
if nrpc_client.LawsuitStatusTypeClient == nil {
nrpc_client.Connect()
}
@ -51,7 +52,7 @@ func (crud Crud_NRPC) Read(m *lawsuit_status_types.LawsuitStatusType) error {
Request.VersionModel = versionModel
// запрос
Response, err := nrpc_client.Client.LawsuitStatusType_Read(Request)
Response, err := nrpc_client.LawsuitStatusTypeClient.Read(Request)
if err != nil {
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 {
@ -75,7 +76,7 @@ func (crud Crud_NRPC) Create(m *lawsuit_status_types.LawsuitStatusType) error {
// var Otvet lawsuit_status_types.LawsuitStatusType
// подключение
if nrpc_client.Client == nil {
if nrpc_client.LawsuitStatusTypeClient == nil {
nrpc_client.Connect()
}
@ -91,7 +92,7 @@ func (crud Crud_NRPC) Create(m *lawsuit_status_types.LawsuitStatusType) error {
Request.VersionModel = VersionModel
// запрос
Response, err := nrpc_client.Client.LawsuitStatusType_Create(Request)
Response, err := nrpc_client.LawsuitStatusTypeClient.Create(Request)
if err != nil {
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 {
@ -115,7 +116,7 @@ func (crud Crud_NRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
// var Otvet lawsuit_status_types.LawsuitStatusType
// подключение
if nrpc_client.Client == nil {
if nrpc_client.LawsuitStatusTypeClient == nil {
nrpc_client.Connect()
}
@ -131,7 +132,7 @@ func (crud Crud_NRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
Request.VersionModel = VersionModel
// запрос
Response, err := nrpc_client.Client.LawsuitStatusType_Update(Request)
Response, err := nrpc_client.LawsuitStatusTypeClient.Update(Request)
if err != nil {
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 {
@ -155,7 +156,7 @@ func (crud Crud_NRPC) Save(m *lawsuit_status_types.LawsuitStatusType) error {
// var Otvet lawsuit_status_types.LawsuitStatusType
// подключение
if nrpc_client.Client == nil {
if nrpc_client.LawsuitStatusTypeClient == nil {
nrpc_client.Connect()
}
@ -171,7 +172,7 @@ func (crud Crud_NRPC) Save(m *lawsuit_status_types.LawsuitStatusType) error {
Request.VersionModel = VersionModel
// запрос
Response, err := nrpc_client.Client.LawsuitStatusType_Save(Request)
Response, err := nrpc_client.LawsuitStatusTypeClient.Save(Request)
if err != nil {
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 {
@ -195,7 +196,7 @@ func (crud Crud_NRPC) Delete(m *lawsuit_status_types.LawsuitStatusType) error {
// var Otvet lawsuit_status_types.LawsuitStatusType
// подключение
if nrpc_client.Client == nil {
if nrpc_client.LawsuitStatusTypeClient == nil {
nrpc_client.Connect()
}
@ -207,7 +208,7 @@ func (crud Crud_NRPC) Delete(m *lawsuit_status_types.LawsuitStatusType) error {
Request.VersionModel = VersionModel
// запрос
Response, err := nrpc_client.Client.LawsuitStatusType_Delete(Request)
Response, err := nrpc_client.LawsuitStatusTypeClient.Delete(Request)
if err != nil {
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 {
@ -231,7 +232,7 @@ func (crud Crud_NRPC) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
// var Otvet lawsuit_status_types.LawsuitStatusType
// подключение
if nrpc_client.Client == nil {
if nrpc_client.LawsuitStatusTypeClient == nil {
nrpc_client.Connect()
}
@ -243,7 +244,7 @@ func (crud Crud_NRPC) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
Request.VersionModel = VersionModel
// запрос
Response, err := nrpc_client.Client.LawsuitStatusType_Restore(Request)
Response, err := nrpc_client.LawsuitStatusTypeClient.Restore(Request)
if err != nil {
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 {
@ -265,7 +266,7 @@ func (crud Crud_NRPC) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
// Find_ByExtID - находит модель в БД по ext_id и connection_id
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()
}
@ -278,7 +279,7 @@ func (crud Crud_NRPC) Find_ByExtID(m *lawsuit_status_types.LawsuitStatusType) er
Request.VersionModel = VersionModel
//запрос
Response, err := nrpc_client.Client.LawsuitStatusType_FindByExtID(Request)
Response, err := nrpc_client.LawsuitStatusTypeClient.FindByExtID(Request)
if err != nil {
sError := err.Error()
if sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {

View File

@ -5,7 +5,6 @@ import (
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/nrpc/nrpc_client"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
"testing"
"math"
)
// Postgres_ID_Test - ID таблицы для тестирования
@ -111,11 +110,45 @@ func TestDelete(t *testing.T) {
crud := Crud_NRPC{}
Otvet := lawsuit_status_types.LawsuitStatusType{}
Otvet.ID = math.MinInt64
err := crud.Delete(&Otvet)
Otvet.ID = Postgres_ID_Test
err := crud.Read(&Otvet)
if err != nil {
t.Error("TestRead() error: ", err)
}
if Otvet.IsDeleted == false {
err = crud.Delete(&Otvet)
if err != nil {
t.Error("TestDelete() error: ", err)
}
if Otvet.ID == 0 {
t.Error("TestDelete() error: ID =0")
}
err = crud.Restore(&Otvet)
if err != nil {
t.Error("TestDelete() error: ", err)
}
if Otvet.ID == 0 {
t.Error("TestDelete() error: ID =0")
}
} else {
err = crud.Restore(&Otvet)
if err != nil {
t.Error("TestDelete() error: ", err)
}
if Otvet.ID == 0 {
t.Error("TestDelete() error: ID =0")
}
err = crud.Delete(&Otvet)
if err != nil {
t.Error("TestDelete() error: ", err)
}
if Otvet.ID == 0 {
t.Error("TestDelete() error: ID =0")
}
}
}
func TestFindByExtID(t *testing.T) {

View File

@ -1,4 +1,4 @@
package constants
package nrpc_constants
import "sync"

View File

@ -53,6 +53,7 @@ conn:
image_connections ./internal docs/connections.graphml $(SERVICENAME)
init:
clear
rm ./go.mod
go mod init gitlab.aescorp.ru/dsp_dev/claim/sync_service
$(CD_GENERATION_PROTO)
$(GENERATION_PROTO)

View File

@ -9,13 +9,15 @@ import (
"github.com/ManyakRus/starter/stopapp"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/api/grpc_proto"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants"
grpc_constants "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/nrpc/nrpc_client"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"os"
"strings"
"sync"
"time"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc_nrpc"
)
// SettingsINI - тип структуры для хранения настроек подключени
@ -77,6 +79,9 @@ func Connect_err() error {
}
Client = grpc_proto.NewSyncServiceClient(Conn)
grpc_nrpc.NeedNRPC = false
return err
}
@ -235,3 +240,16 @@ func GetTimeoutSeconds() int {
func SetTimeoutSeconds(seconds int) {
grpc_constants.SetTimeoutSeconds(seconds)
}
// Connect_GRPC_NRPC - подключается к серверу GRPC или NRPC, при ошибке вызывает панику
func Connect_GRPC_NRPC() {
if grpc_nrpc.NeedNRPC == true {
if nrpc_client.Client == nil {
nrpc_client.Connect()
}
} else {
if Client == nil {
Connect()
}
}
}

View File

@ -1,12 +1,18 @@
//Файл создан автоматически кодогенератором crud_generator
//Не изменяйте ничего здесь.
package grpc_lawsuit_status_types
import (
"context"
"encoding/json"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/api/grpc_proto"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_client"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_client/constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_proto"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/nrpc/nrpc_client"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc_nrpc"
"log"
"sync"
"time"
@ -38,12 +44,10 @@ func (crud Crud_GRPC) GetVersionModel() uint32 {
// Read - возвращает модель из БД
func (crud Crud_GRPC) Read(m *lawsuit_status_types.LawsuitStatusType) error {
// var Otvet lawsuit_status_types.LawsuitStatusType
var err error
// подключение
if grpc_client.LawsuitStatusTypeClient == nil {
grpc_client.Connect()
}
grpc_client.Connect_GRPC_NRPC()
// подготовка запроса
var versionModel = crud.GetVersionModel()
@ -53,14 +57,19 @@ func (crud Crud_GRPC) Read(m *lawsuit_status_types.LawsuitStatusType) error {
Request.VersionModel = versionModel
ctxMain := context.Background()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.GetTimeoutSeconds()))
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(grpc_constants.GetTimeoutSeconds()))
defer ctxCancelFunc()
// запрос
Response, err := grpc_client.LawsuitStatusTypeClient.Read(ctx, Request)
var Response *grpc_proto.Response
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_Read(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_Read(ctx, Request)
}
if err != nil {
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(grpc_constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(grpc_constants.TEXT_ERROR_MODEL_VERSION)] == grpc_constants.TEXT_ERROR_MODEL_VERSION {
log.Panic("table: ", TableName, " error: ", err)
}
return err
@ -78,12 +87,10 @@ func (crud Crud_GRPC) Read(m *lawsuit_status_types.LawsuitStatusType) error {
// Create - записывает новую модель в БД
func (crud Crud_GRPC) Create(m *lawsuit_status_types.LawsuitStatusType) error {
// var Otvet lawsuit_status_types.LawsuitStatusType
var err error
// подключение
if grpc_client.LawsuitStatusTypeClient == nil {
grpc_client.Connect()
}
grpc_client.Connect_GRPC_NRPC()
// подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -97,14 +104,19 @@ func (crud Crud_GRPC) Create(m *lawsuit_status_types.LawsuitStatusType) error {
Request.VersionModel = VersionModel
ctxMain := context.Background()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.GetTimeoutSeconds()))
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(grpc_constants.GetTimeoutSeconds()))
defer ctxCancelFunc()
// запрос
Response, err := grpc_client.LawsuitStatusTypeClient.Create(ctx, Request)
var Response *grpc_proto.Response
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_Create(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_Create(ctx, Request)
}
if err != nil {
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(grpc_constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(grpc_constants.TEXT_ERROR_MODEL_VERSION)] == grpc_constants.TEXT_ERROR_MODEL_VERSION {
log.Panic("table: ", TableName, " error: ", err)
}
return err
@ -122,12 +134,10 @@ func (crud Crud_GRPC) Create(m *lawsuit_status_types.LawsuitStatusType) error {
// Update - обновляет модель в БД
func (crud Crud_GRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
// var Otvet lawsuit_status_types.LawsuitStatusType
var err error
// подключение
if grpc_client.LawsuitStatusTypeClient == nil {
grpc_client.Connect()
}
grpc_client.Connect_GRPC_NRPC()
// подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -141,14 +151,19 @@ func (crud Crud_GRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
Request.VersionModel = VersionModel
ctxMain := context.Background()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.GetTimeoutSeconds()))
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(grpc_constants.GetTimeoutSeconds()))
defer ctxCancelFunc()
// запрос
Response, err := grpc_client.LawsuitStatusTypeClient.Update(ctx, Request)
var Response *grpc_proto.Response
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_Update(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_Update(ctx, Request)
}
if err != nil {
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(grpc_constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(grpc_constants.TEXT_ERROR_MODEL_VERSION)] == grpc_constants.TEXT_ERROR_MODEL_VERSION {
log.Panic("table: ", TableName, " error: ", err)
}
return err
@ -166,12 +181,10 @@ func (crud Crud_GRPC) Update(m *lawsuit_status_types.LawsuitStatusType) error {
// Save - обновляет (или создаёт) модель в БД
func (crud Crud_GRPC) Save(m *lawsuit_status_types.LawsuitStatusType) error {
// var Otvet lawsuit_status_types.LawsuitStatusType
var err error
// подключение
if grpc_client.LawsuitStatusTypeClient == nil {
grpc_client.Connect()
}
grpc_client.Connect_GRPC_NRPC()
// подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -185,14 +198,19 @@ func (crud Crud_GRPC) Save(m *lawsuit_status_types.LawsuitStatusType) error {
Request.VersionModel = VersionModel
ctxMain := context.Background()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.GetTimeoutSeconds()))
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(grpc_constants.GetTimeoutSeconds()))
defer ctxCancelFunc()
// запрос
Response, err := grpc_client.LawsuitStatusTypeClient.Save(ctx, Request)
var Response *grpc_proto.Response
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_Save(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_Save(ctx, Request)
}
if err != nil {
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(grpc_constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(grpc_constants.TEXT_ERROR_MODEL_VERSION)] == grpc_constants.TEXT_ERROR_MODEL_VERSION {
log.Panic("table: ", TableName, " error: ", err)
}
return err
@ -210,12 +228,10 @@ func (crud Crud_GRPC) Save(m *lawsuit_status_types.LawsuitStatusType) error {
// Delete - устанавливает is_deleted = true в БД
func (crud Crud_GRPC) Delete(m *lawsuit_status_types.LawsuitStatusType) error {
// var Otvet lawsuit_status_types.LawsuitStatusType
var err error
// подключение
if grpc_client.LawsuitStatusTypeClient == nil {
grpc_client.Connect()
}
grpc_client.Connect_GRPC_NRPC()
// подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -225,14 +241,19 @@ func (crud Crud_GRPC) Delete(m *lawsuit_status_types.LawsuitStatusType) error {
Request.VersionModel = VersionModel
ctxMain := context.Background()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.GetTimeoutSeconds()))
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(grpc_constants.GetTimeoutSeconds()))
defer ctxCancelFunc()
// запрос
Response, err := grpc_client.LawsuitStatusTypeClient.Delete(ctx, Request)
var Response *grpc_proto.Response
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_Delete(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_Delete(ctx, Request)
}
if err != nil {
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(grpc_constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(grpc_constants.TEXT_ERROR_MODEL_VERSION)] == grpc_constants.TEXT_ERROR_MODEL_VERSION {
log.Panic("table: ", TableName, " error: ", err)
}
return err
@ -250,12 +271,10 @@ func (crud Crud_GRPC) Delete(m *lawsuit_status_types.LawsuitStatusType) error {
// Restore - устанавливает is_deleted = false в БД
func (crud Crud_GRPC) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
// var Otvet lawsuit_status_types.LawsuitStatusType
var err error
// подключение
if grpc_client.LawsuitStatusTypeClient == nil {
grpc_client.Connect()
}
grpc_client.Connect_GRPC_NRPC()
// подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -265,14 +284,19 @@ func (crud Crud_GRPC) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
Request.VersionModel = VersionModel
ctxMain := context.Background()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.GetTimeoutSeconds()))
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(grpc_constants.GetTimeoutSeconds()))
defer ctxCancelFunc()
// запрос
Response, err := grpc_client.LawsuitStatusTypeClient.Restore(ctx, Request)
var Response *grpc_proto.Response
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_Restore(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_Restore(ctx, Request)
}
if err != nil {
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(grpc_constants.TEXT_ERROR_MODEL_VERSION) && sError[0:len(grpc_constants.TEXT_ERROR_MODEL_VERSION)] == grpc_constants.TEXT_ERROR_MODEL_VERSION {
log.Panic("table: ", TableName, " error: ", err)
}
return err
@ -290,10 +314,10 @@ func (crud Crud_GRPC) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
// Find_ByExtID - находит модель в БД по ext_id и connection_id
func (crud Crud_GRPC) Find_ByExtID(m *lawsuit_status_types.LawsuitStatusType) error {
//подключение
if grpc_client.LawsuitStatusTypeClient == nil {
grpc_client.Connect()
}
var err error
// подключение
grpc_client.Connect_GRPC_NRPC()
//подготовка запроса
var VersionModel = crud.GetVersionModel()
@ -304,14 +328,19 @@ func (crud Crud_GRPC) Find_ByExtID(m *lawsuit_status_types.LawsuitStatusType) er
Request.VersionModel = VersionModel
ctxMain := context.Background()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.GetTimeoutSeconds()))
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(grpc_constants.GetTimeoutSeconds()))
defer ctxCancelFunc()
//запрос
Response, err := grpc_client.LawsuitStatusTypeClient.FindByExtID(ctx, Request)
var Response *grpc_proto.Response
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_FindByExtID(Request)
} else {
Response, err = grpc_client.Client.LawsuitStatusType_FindByExtID(ctx, Request)
}
if err != nil {
sError := err.Error()
if sError[0:len(constants.TEXT_ERROR_MODEL_VERSION)] == constants.TEXT_ERROR_MODEL_VERSION {
if sError[0:len(grpc_constants.TEXT_ERROR_MODEL_VERSION)] == grpc_constants.TEXT_ERROR_MODEL_VERSION {
log.Panic("table: ", TableName, " error: ", err)
}
return err

View File

@ -0,0 +1,4 @@
package grpc_nrpc
// NeedNRPC - нужно ли использовать NRPC или GRPC
var NeedNRPC bool

View File

@ -4,7 +4,8 @@ import (
"encoding/json"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_proto"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/nrpc/nrpc_client"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/nrpc/grpc_client/constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/nrpc/nrpc_client/nrpc_constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
"log"
"sync"

View File

@ -267,11 +267,20 @@ func FindGRPClientURL() string {
return Otvet
}
// FindNRPClientURL - возвращает URL репозитория с пакетом "client_nrpc"
func FindNRPClientURL() string {
Otvet := ""
Otvet = config.Settings.SERVICE_REPOSITORY_URL + "/" + config.Settings.TEMPLATE_FOLDERNAME_NRPC_CLIENT
return Otvet
}
// FindGRPCConstantsURL - возвращает URL репозитория с пакетом "client_grpc"
func FindGRPCConstantsURL() string {
Otvet := ""
Otvet = config.Settings.SERVICE_REPOSITORY_URL + "/" + config.Settings.TEMPLATE_FOLDERNAME_GRPC + "/" + "constants"
Otvet = config.Settings.SERVICE_REPOSITORY_URL + "/" + config.Settings.TEMPLATE_FOLDERNAME_GRPC + "/" + "grpc_constants"
return Otvet
}
@ -349,8 +358,8 @@ func FindCrudTableURL(TableName string) string {
return Otvet
}
// FindNRPCClientURL - возвращает URL репозитория с пакетом "nrpc_client"
func FindNRPCClientURL() string {
// FindNRPC_Client_URL - возвращает URL репозитория с пакетом "nrpc_client"
func FindNRPC_Client_URL() string {
Otvet := ""
Otvet = config.Settings.SERVICE_REPOSITORY_URL + "/" + config.Settings.TEMPLATE_FOLDERNAME_NRPC_CLIENT
@ -376,6 +385,15 @@ func FindCrudStarterURL() string {
return Otvet
}
// Find_GRPC_NRPC_URL - возвращает URL репозитория с пакетом "crud_starter"
func Find_GRPC_NRPC_URL() string {
Otvet := ""
Otvet = config.Settings.SERVICE_REPOSITORY_URL + "/pkg/network/grpc_nrpc"
return Otvet
}
// FindCalcStructVersionURL - возвращает URL репозитория с пакетом "calc_struct_version"
func FindCalcStructVersionURL() string {
Otvet := ""

View File

@ -301,7 +301,8 @@ func InitCrudTransport_NRPC() {`
continue
}
Otvet = Otvet + FindTextNRPC1(Table1)
Otvet = Otvet + FindTextGRPC1(Table1) //GRPC будет делать функции NRPC
//Otvet = Otvet + FindTextNRPC1(Table1)
}
Otvet = Otvet + "\n}"

View File

@ -63,12 +63,26 @@ func CreateGRPCClient() error {
if config.Settings.USE_DEFAULT_TEMPLATE == true {
TextGRPCClient = create_files.DeleteTemplateRepositoryImports(TextGRPCClient)
//grpc_proto
ProtoURL := create_files.FindProtoURL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, ProtoURL)
//constants db
DBConstantsURL := create_files.FindDBConstantsURL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, DBConstantsURL)
//grpc_nrpc
GRPC_NRPC_URL := create_files.Find_GRPC_NRPC_URL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPC_NRPC_URL)
//nrpc_client
NRPC_CLIENT_URL := create_files.FindNRPC_Client_URL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, NRPC_CLIENT_URL)
//constants GRPC
RepositoryGRPCConstantsURL := create_files.FindGRPCConstantsURL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryGRPCConstantsURL)
//заменим имя сервиса на новое
ServiceNameTemplate := config.Settings.TEMPLATE_SERVICE_NAME
ServiceName := config.Settings.SERVICE_NAME

View File

@ -72,18 +72,24 @@ func CreateFiles(Table1 *types.Table) error {
//заменим имя пакета на новое
TextGRPCClient = create_files.ReplacePackageName(TextGRPCClient, DirReadyTable)
//заменим импорты
if config.Settings.USE_DEFAULT_TEMPLATE == true {
TextGRPCClient = create_files.DeleteTemplateRepositoryImports(TextGRPCClient)
ConstantsURL := create_files.FindGRPCConstantsURL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, ConstantsURL)
//удалим лишние функции
TextGRPCClient = create_files.DeleteFuncDelete(TextGRPCClient, Table1)
TextGRPCClient = create_files.DeleteFuncRestore(TextGRPCClient, Table1)
TextGRPCClient = create_files.DeleteFuncFind_byExtID(TextGRPCClient, Table1)
}
////заменим импорты
//if config.Settings.USE_DEFAULT_TEMPLATE == true {
// TextGRPCClient = create_files.DeleteTemplateRepositoryImports(TextGRPCClient)
//
// ConstantsURL := create_files.FindGRPCConstantsURL()
// TextGRPCClient = create_files.AddImport(TextGRPCClient, ConstantsURL)
//
// GRPC_NRPC_URL := create_files.Find_GRPC_NRPC_URL()
// TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPC_NRPC_URL)
//
// DBConstantsURL := create_files.FindDBConstantsURL()
// TextGRPCClient = create_files.AddImport(TextGRPCClient, DBConstantsURL)
//
// //удалим лишние функции
// TextGRPCClient = create_files.DeleteFuncDelete(TextGRPCClient, Table1)
// TextGRPCClient = create_files.DeleteFuncRestore(TextGRPCClient, Table1)
// TextGRPCClient = create_files.DeleteFuncFind_byExtID(TextGRPCClient, Table1)
//}
//создание текста
ModelName := Table1.NameGo
@ -107,11 +113,27 @@ func CreateFiles(Table1 *types.Table) error {
RepositoryGRPCClientlURL := create_files.FindGRPClientURL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryGRPCClientlURL)
//constants
//nrpc client
RepositoryNRPCClientlURL := create_files.FindNRPClientURL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryNRPCClientlURL)
//constants GRPC
RepositoryGRPCConstantsURL := create_files.FindGRPCConstantsURL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryGRPCConstantsURL)
//DBConstantsURL := create_files.FindDBConstantsURL()
//TextGRPCClient = create_files.AddImport(TextGRPCClient, DBConstantsURL)
//grpc_nrpc
GRPC_NRPC_URL := create_files.Find_GRPC_NRPC_URL()
TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPC_NRPC_URL)
}
//удалим лишние функции
TextGRPCClient = create_files.DeleteFuncDelete(TextGRPCClient, Table1)
TextGRPCClient = create_files.DeleteFuncRestore(TextGRPCClient, Table1)
TextGRPCClient = create_files.DeleteFuncFind_byExtID(TextGRPCClient, Table1)
//удаление пустого импорта
TextGRPCClient = create_files.DeleteEmptyImport(TextGRPCClient)

View File

@ -69,6 +69,9 @@ func CreateNRPCClient() error {
ProtoURL := create_files.FindProtoURL()
TextNRPCClient = create_files.AddImport(TextNRPCClient, ProtoURL)
GRPC_NRPC_URL := create_files.Find_GRPC_NRPC_URL()
TextNRPCClient = create_files.AddImport(TextNRPCClient, GRPC_NRPC_URL)
DBConstantsURL := create_files.FindDBConstantsURL()
TextNRPCClient = create_files.AddImport(TextNRPCClient, DBConstantsURL)

View File

@ -78,7 +78,7 @@ func CreateFiles(Table1 *types.Table) error {
GRPCProtoURL := create_files.FindProtoURL()
TextNRPCClient = create_files.AddImport(TextNRPCClient, GRPCProtoURL)
NRPCClientURL := create_files.FindNRPCClientURL()
NRPCClientURL := create_files.FindNRPC_Client_URL()
TextNRPCClient = create_files.AddImport(TextNRPCClient, NRPCClientURL)
GRPCConstantsURL := create_files.FindGRPCConstantsURL()
@ -149,7 +149,7 @@ func CreateTestFiles(Table1 *types.Table) error {
if config.Settings.USE_DEFAULT_TEMPLATE == true {
TextNRPCClient = create_files.DeleteTemplateRepositoryImports(TextNRPCClient)
NRPCClientURL := create_files.FindNRPCClientURL()
NRPCClientURL := create_files.FindNRPC_Client_URL()
TextNRPCClient = create_files.AddImport(TextNRPCClient, NRPCClientURL)
TableURL := create_files.FindModelTableURL(TableName)