mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2024-12-22 00:36:41 +02:00
сделал pkg
This commit is contained in:
parent
2266b2f578
commit
4640e5f302
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,3 +15,4 @@
|
||||
/database.graphml0
|
||||
/bin/ready/pkg/model/
|
||||
/bin/ready/
|
||||
/bin/sync_service/
|
||||
|
@ -1,95 +0,0 @@
|
||||
package crud_starter
|
||||
|
||||
import (
|
||||
model "gitlab.aescorp.ru/dsp_dev/claim/common/object_model"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/db/db_connections"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/db/db_employees"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/db/db_files"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/db/db_lawsuit_status_states"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/db/db_lawsuit_status_types"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/db/db_lawsuits"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/db/db_message_attachements"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/db/db_message_send_statuses"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/db/db_message_types"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/db/db_messages"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/db/db_organization_casebook"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/db/db_organizations"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_client/grpc_connections"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_client/grpc_employees"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_client/grpc_files"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_client/grpc_lawsuit_status_states"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_client/grpc_lawsuit_status_types"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_client/grpc_lawsuits"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_client/grpc_message_attachements"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_client/grpc_message_send_statuses"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_client/grpc_message_types"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_client/grpc_messages"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_client/grpc_organization_casebook"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_client/grpc_organizations"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/nrpc/nrpc_client/nrpc_connections"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/nrpc/nrpc_client/nrpc_employees"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/nrpc/nrpc_client/nrpc_files"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/nrpc/nrpc_client/nrpc_lawsuit_status_states"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/nrpc/nrpc_client/nrpc_lawsuit_status_types"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/nrpc/nrpc_client/nrpc_lawsuits"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/nrpc/nrpc_client/nrpc_message_attachements"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/nrpc/nrpc_client/nrpc_message_send_statuses"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/nrpc/nrpc_client/nrpc_message_types"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/nrpc/nrpc_client/nrpc_messages"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/nrpc/nrpc_client/nrpc_organization_casebook"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/nrpc/nrpc_client/nrpc_organizations"
|
||||
)
|
||||
|
||||
// InitCrudTransport_DB - заполняет объекты crud для работы с БД напрямую
|
||||
func InitCrudTransport_DB() {
|
||||
|
||||
model.Connection{}.SetCrudInterface(db_connections.Crud_DB{})
|
||||
model.Employee{}.SetCrudInterface(db_employees.Crud_DB{})
|
||||
model.File{}.SetCrudInterface(db_files.Crud_DB{})
|
||||
model.LawsuitStatusState{}.SetCrudInterface(db_lawsuit_status_states.Crud_DB{})
|
||||
model.LawsuitStatusType{}.SetCrudInterface(db_lawsuit_status_types.Crud_DB{})
|
||||
model.Lawsuit{}.SetCrudInterface(db_lawsuits.Crud_DB{})
|
||||
model.MessageAttachement{}.SetCrudInterface(db_message_attachements.Crud_DB{})
|
||||
model.MessageSendStatus{}.SetCrudInterface(db_message_send_statuses.Crud_DB{})
|
||||
model.MessageType{}.SetCrudInterface(db_message_types.Crud_DB{})
|
||||
model.Message{}.SetCrudInterface(db_messages.Crud_DB{})
|
||||
model.OrganizationCasebook{}.SetCrudInterface(db_organization_casebook.Crud_DB{})
|
||||
model.Organization{}.SetCrudInterface(db_organizations.Crud_DB{})
|
||||
|
||||
}
|
||||
|
||||
// InitCrudTransport_GRPC - заполняет объекты crud для работы с БД напрямую
|
||||
func InitCrudTransport_GRPC() {
|
||||
|
||||
model.Connection{}.SetCrudInterface(grpc_connections.Crud_GRPC{})
|
||||
model.Employee{}.SetCrudInterface(grpc_employees.Crud_GRPC{})
|
||||
model.File{}.SetCrudInterface(grpc_files.Crud_GRPC{})
|
||||
model.LawsuitStatusState{}.SetCrudInterface(grpc_lawsuit_status_states.Crud_GRPC{})
|
||||
model.LawsuitStatusType{}.SetCrudInterface(grpc_lawsuit_status_types.Crud_GRPC{})
|
||||
model.Lawsuit{}.SetCrudInterface(grpc_lawsuits.Crud_GRPC{})
|
||||
model.MessageAttachement{}.SetCrudInterface(grpc_message_attachements.Crud_GRPC{})
|
||||
model.MessageSendStatus{}.SetCrudInterface(grpc_message_send_statuses.Crud_GRPC{})
|
||||
model.MessageType{}.SetCrudInterface(grpc_message_types.Crud_GRPC{})
|
||||
model.Message{}.SetCrudInterface(grpc_messages.Crud_GRPC{})
|
||||
model.OrganizationCasebook{}.SetCrudInterface(grpc_organization_casebook.Crud_GRPC{})
|
||||
model.Organization{}.SetCrudInterface(grpc_organizations.Crud_GRPC{})
|
||||
|
||||
}
|
||||
|
||||
// InitCrudTransport_NRPC - заполняет объекты crud для работы с БД напрямую
|
||||
func InitCrudTransport_NRPC() {
|
||||
|
||||
model.Connection{}.SetCrudInterface(nrpc_connections.Crud_NRPC{})
|
||||
model.Employee{}.SetCrudInterface(nrpc_employees.Crud_NRPC{})
|
||||
model.File{}.SetCrudInterface(nrpc_files.Crud_NRPC{})
|
||||
model.LawsuitStatusState{}.SetCrudInterface(nrpc_lawsuit_status_states.Crud_NRPC{})
|
||||
model.LawsuitStatusType{}.SetCrudInterface(nrpc_lawsuit_status_types.Crud_NRPC{})
|
||||
model.Lawsuit{}.SetCrudInterface(nrpc_lawsuits.Crud_NRPC{})
|
||||
model.MessageAttachement{}.SetCrudInterface(nrpc_message_attachements.Crud_NRPC{})
|
||||
model.MessageSendStatus{}.SetCrudInterface(nrpc_message_send_statuses.Crud_NRPC{})
|
||||
model.MessageType{}.SetCrudInterface(nrpc_message_types.Crud_NRPC{})
|
||||
model.Message{}.SetCrudInterface(nrpc_messages.Crud_NRPC{})
|
||||
model.OrganizationCasebook{}.SetCrudInterface(nrpc_organization_casebook.Crud_NRPC{})
|
||||
model.Organization{}.SetCrudInterface(nrpc_organizations.Crud_NRPC{})
|
||||
|
||||
}
|
@ -2,8 +2,8 @@ package server_grpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
model "gitlab.aescorp.ru/dsp_dev/claim/common/object_model"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_proto"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_proto"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
|
||||
)
|
||||
|
||||
// LawsuitStatusType_Read - читает и возвращает модель из БД
|
||||
@ -11,23 +11,23 @@ func (s *ServerGRPC) LawsuitStatusType_Read(ctx context.Context, Request *grpc_p
|
||||
var Otvet grpc_proto.Response
|
||||
var err error
|
||||
|
||||
//проверим совпадения версии модели
|
||||
VersionServer := model.LawsuitStatusType{}.GetStructVersion()
|
||||
// проверим совпадения версии модели
|
||||
VersionServer := lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||
VersionClient := Request.VersionModel
|
||||
if VersionServer != VersionClient {
|
||||
err = ErrorModelVersion(model.LawsuitStatusType{})
|
||||
err = ErrorModelVersion(lawsuit_status_types.LawsuitStatusType{})
|
||||
return &Otvet, err
|
||||
}
|
||||
|
||||
//запрос в БД
|
||||
Model := &model.LawsuitStatusType{}
|
||||
// запрос в БД
|
||||
Model := &lawsuit_status_types.LawsuitStatusType{}
|
||||
Model.ID = Request.Id
|
||||
err = Model.Read()
|
||||
if err != nil {
|
||||
return &Otvet, err
|
||||
}
|
||||
|
||||
//заполяем ответ
|
||||
// заполяем ответ
|
||||
ModelString, err := Model.GetJSON()
|
||||
if err != nil {
|
||||
return &Otvet, err
|
||||
@ -42,23 +42,23 @@ func (s *ServerGRPC) LawsuitStatusType_Delete(ctx context.Context, Request *grpc
|
||||
var Otvet grpc_proto.Response
|
||||
var err error
|
||||
|
||||
//проверим совпадения версии модели
|
||||
VersionServer := model.LawsuitStatusType{}.GetStructVersion()
|
||||
// проверим совпадения версии модели
|
||||
VersionServer := lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||
VersionClient := Request.VersionModel
|
||||
if VersionServer != VersionClient {
|
||||
err = ErrorModelVersion(model.LawsuitStatusType{})
|
||||
err = ErrorModelVersion(lawsuit_status_types.LawsuitStatusType{})
|
||||
return &Otvet, err
|
||||
}
|
||||
|
||||
//запрос в БД
|
||||
Model := &model.LawsuitStatusType{}
|
||||
// запрос в БД
|
||||
Model := &lawsuit_status_types.LawsuitStatusType{}
|
||||
Model.ID = Request.Id
|
||||
err = Model.Delete()
|
||||
if err != nil {
|
||||
return &Otvet, err
|
||||
}
|
||||
|
||||
//заполяем ответ
|
||||
// заполяем ответ
|
||||
ModelString, err := Model.GetJSON()
|
||||
if err != nil {
|
||||
return &Otvet, err
|
||||
@ -73,23 +73,23 @@ func (s *ServerGRPC) LawsuitStatusType_Restore(ctx context.Context, Request *grp
|
||||
var Otvet grpc_proto.Response
|
||||
var err error
|
||||
|
||||
//проверим совпадения версии модели
|
||||
VersionServer := model.LawsuitStatusType{}.GetStructVersion()
|
||||
// проверим совпадения версии модели
|
||||
VersionServer := lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||
VersionClient := Request.VersionModel
|
||||
if VersionServer != VersionClient {
|
||||
err = ErrorModelVersion(model.LawsuitStatusType{})
|
||||
err = ErrorModelVersion(lawsuit_status_types.LawsuitStatusType{})
|
||||
return &Otvet, err
|
||||
}
|
||||
|
||||
//запрос в БД
|
||||
Model := &model.LawsuitStatusType{}
|
||||
// запрос в БД
|
||||
Model := &lawsuit_status_types.LawsuitStatusType{}
|
||||
Model.ID = Request.Id
|
||||
err = Model.Restore()
|
||||
if err != nil {
|
||||
return &Otvet, err
|
||||
}
|
||||
|
||||
//заполяем ответ
|
||||
// заполяем ответ
|
||||
ModelString, err := Model.GetJSON()
|
||||
if err != nil {
|
||||
return &Otvet, err
|
||||
@ -104,28 +104,28 @@ func (s *ServerGRPC) LawsuitStatusType_Create(ctx context.Context, Request *grpc
|
||||
var Otvet grpc_proto.Response
|
||||
var err error
|
||||
|
||||
//проверим совпадения версии модели
|
||||
VersionServer := model.LawsuitStatusType{}.GetStructVersion()
|
||||
// проверим совпадения версии модели
|
||||
VersionServer := lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||
VersionClient := Request.VersionModel
|
||||
if VersionServer != VersionClient {
|
||||
err = ErrorModelVersion(model.LawsuitStatusType{})
|
||||
err = ErrorModelVersion(lawsuit_status_types.LawsuitStatusType{})
|
||||
return &Otvet, err
|
||||
}
|
||||
|
||||
//получим модель из строки JSON
|
||||
Model := &model.LawsuitStatusType{}
|
||||
// получим модель из строки JSON
|
||||
Model := &lawsuit_status_types.LawsuitStatusType{}
|
||||
err = Model.GetModelFromJSON(Request.ModelString)
|
||||
if err != nil {
|
||||
return &Otvet, err
|
||||
}
|
||||
|
||||
//запрос в БД
|
||||
// запрос в БД
|
||||
err = Model.Create()
|
||||
if err != nil {
|
||||
return &Otvet, err
|
||||
}
|
||||
|
||||
//заполяем ответ
|
||||
// заполяем ответ
|
||||
ModelString, err := Model.GetJSON()
|
||||
if err != nil {
|
||||
return &Otvet, err
|
||||
@ -140,28 +140,28 @@ func (s *ServerGRPC) LawsuitStatusType_Update(ctx context.Context, Request *grpc
|
||||
var Otvet grpc_proto.Response
|
||||
var err error
|
||||
|
||||
//проверим совпадения версии модели
|
||||
VersionServer := model.LawsuitStatusType{}.GetStructVersion()
|
||||
// проверим совпадения версии модели
|
||||
VersionServer := lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||
VersionClient := Request.VersionModel
|
||||
if VersionServer != VersionClient {
|
||||
err = ErrorModelVersion(model.LawsuitStatusType{})
|
||||
err = ErrorModelVersion(lawsuit_status_types.LawsuitStatusType{})
|
||||
return &Otvet, err
|
||||
}
|
||||
|
||||
//получим модель из строки JSON
|
||||
Model := &model.LawsuitStatusType{}
|
||||
// получим модель из строки JSON
|
||||
Model := &lawsuit_status_types.LawsuitStatusType{}
|
||||
err = Model.GetModelFromJSON(Request.ModelString)
|
||||
if err != nil {
|
||||
return &Otvet, err
|
||||
}
|
||||
|
||||
//запрос в БД
|
||||
// запрос в БД
|
||||
err = Model.Update()
|
||||
if err != nil {
|
||||
return &Otvet, err
|
||||
}
|
||||
|
||||
//заполяем ответ
|
||||
// заполяем ответ
|
||||
ModelString, err := Model.GetJSON()
|
||||
if err != nil {
|
||||
return &Otvet, err
|
||||
@ -176,28 +176,28 @@ func (s *ServerGRPC) LawsuitStatusType_Save(ctx context.Context, Request *grpc_p
|
||||
var Otvet grpc_proto.Response
|
||||
var err error
|
||||
|
||||
//проверим совпадения версии модели
|
||||
VersionServer := model.LawsuitStatusType{}.GetStructVersion()
|
||||
// проверим совпадения версии модели
|
||||
VersionServer := lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||
VersionClient := Request.VersionModel
|
||||
if VersionServer != VersionClient {
|
||||
err = ErrorModelVersion(model.LawsuitStatusType{})
|
||||
err = ErrorModelVersion(lawsuit_status_types.LawsuitStatusType{})
|
||||
return &Otvet, err
|
||||
}
|
||||
|
||||
//получим модель из строки JSON
|
||||
Model := model.LawsuitStatusType{}
|
||||
// получим модель из строки JSON
|
||||
Model := lawsuit_status_types.LawsuitStatusType{}
|
||||
err = Model.GetModelFromJSON(Request.ModelString)
|
||||
if err != nil {
|
||||
return &Otvet, err
|
||||
}
|
||||
|
||||
//запрос в БД
|
||||
// запрос в БД
|
||||
err = Model.Save()
|
||||
if err != nil {
|
||||
return &Otvet, err
|
||||
}
|
||||
|
||||
//заполяем ответ
|
||||
// заполяем ответ
|
||||
ModelString, err := Model.GetJSON()
|
||||
if err != nil {
|
||||
return &Otvet, err
|
||||
@ -213,7 +213,7 @@ func (s *ServerGRPC) LawsuitStatusType_FindByExtID(ctx context.Context, Request
|
||||
var err error
|
||||
|
||||
//проверим совпадения версии модели
|
||||
VersionServer := model.LawsuitStatusType{}.GetStructVersion()
|
||||
VersionServer := lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||
VersionClient := Request.VersionModel
|
||||
if VersionServer != VersionClient {
|
||||
err = ErrorModelVersion(model.Employee{})
|
||||
@ -221,7 +221,7 @@ func (s *ServerGRPC) LawsuitStatusType_FindByExtID(ctx context.Context, Request
|
||||
}
|
||||
|
||||
//запрос в БД
|
||||
Model := &model.LawsuitStatusType{}
|
||||
Model := &lawsuit_status_types.LawsuitStatusType{}
|
||||
Model.ExtID = Request.ExtId
|
||||
Model.ConnectionID = Request.ConnectionId
|
||||
err = Model.Find_ByExtID()
|
@ -2,10 +2,10 @@ package server_grpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
model "gitlab.aescorp.ru/dsp_dev/claim/common/object_model"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/crud_starter"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_proto"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/nikitin/config"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/crud_starter"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_proto"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@ -13,14 +13,14 @@ import (
|
||||
const LawsuitStatusType_ID_Test = 1
|
||||
|
||||
func Test_server_LawsuitStatusType_Read(t *testing.T) {
|
||||
//t.SkipNow()
|
||||
// t.SkipNow()
|
||||
config.LoadEnv()
|
||||
crud_starter.InitCrudTransport_DB()
|
||||
|
||||
ctx := context.Background()
|
||||
Request := grpc_proto.RequestId{}
|
||||
Request.Id = LawsuitStatusType_ID_Test
|
||||
Request.VersionModel = model.LawsuitStatusType{}.GetStructVersion()
|
||||
Request.VersionModel = lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||
|
||||
server1 := &ServerGRPC{}
|
||||
Otvet, err := server1.LawsuitStatusType_Read(ctx, &Request)
|
||||
@ -39,7 +39,7 @@ func Test_server_LawsuitStatusType_Delete(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
Request := grpc_proto.RequestId{}
|
||||
Request.Id = LawsuitStatusType_ID_Test
|
||||
Request.VersionModel = model.LawsuitStatusType{}.GetStructVersion()
|
||||
Request.VersionModel = lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||
|
||||
server1 := &ServerGRPC{}
|
||||
Otvet, err := server1.LawsuitStatusType_Delete(ctx, &Request)
|
||||
@ -57,7 +57,7 @@ func Test_server_LawsuitStatusType_Create(t *testing.T) {
|
||||
crud_starter.InitCrudTransport_DB()
|
||||
|
||||
var ModelString string
|
||||
Model := model.LawsuitStatusType{}
|
||||
Model := lawsuit_status_types.LawsuitStatusType{}
|
||||
Model.ID = 1
|
||||
ModelString, err := Model.GetJSON()
|
||||
if err != nil {
|
||||
@ -66,7 +66,7 @@ func Test_server_LawsuitStatusType_Create(t *testing.T) {
|
||||
}
|
||||
|
||||
RequestModel := grpc_proto.RequestModel{}
|
||||
RequestModel.VersionModel = model.LawsuitStatusType{}.GetStructVersion()
|
||||
RequestModel.VersionModel = lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||
RequestModel.ModelString = ModelString
|
||||
|
||||
ctx := context.Background()
|
||||
@ -87,7 +87,7 @@ func Test_server_LawsuitStatusType_Update(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
Request := grpc_proto.RequestId{}
|
||||
Request.Id = LawsuitStatusType_ID_Test
|
||||
Request.VersionModel = model.LawsuitStatusType{}.GetStructVersion()
|
||||
Request.VersionModel = lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||
|
||||
server1 := &ServerGRPC{}
|
||||
Response1, err := server1.LawsuitStatusType_Read(ctx, &Request)
|
||||
@ -103,7 +103,7 @@ func Test_server_LawsuitStatusType_Update(t *testing.T) {
|
||||
ModelString = Response1.ModelString
|
||||
|
||||
RequestModel := grpc_proto.RequestModel{}
|
||||
RequestModel.VersionModel = model.LawsuitStatusType{}.GetStructVersion()
|
||||
RequestModel.VersionModel = lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||
RequestModel.ModelString = ModelString
|
||||
|
||||
Otvet, err := server1.LawsuitStatusType_Update(ctx, &RequestModel)
|
||||
@ -120,12 +120,12 @@ func Test_server_LawsuitStatusType_Save(t *testing.T) {
|
||||
config.LoadEnv()
|
||||
crud_starter.InitCrudTransport_DB()
|
||||
|
||||
//Model := model.LawsuitStatusType{}
|
||||
// Model := lawsuit_status_types.LawsuitStatusType{}
|
||||
|
||||
ctx := context.Background()
|
||||
Request := grpc_proto.RequestId{}
|
||||
Request.Id = LawsuitStatusType_ID_Test
|
||||
Request.VersionModel = model.LawsuitStatusType{}.GetStructVersion()
|
||||
Request.VersionModel = lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||
|
||||
server1 := &ServerGRPC{}
|
||||
Response1, err := server1.LawsuitStatusType_Read(ctx, &Request)
|
||||
@ -137,9 +137,9 @@ func Test_server_LawsuitStatusType_Save(t *testing.T) {
|
||||
var ModelString string
|
||||
ModelString = Response1.ModelString
|
||||
|
||||
//sModel, _ := GetJSON(Otvet)
|
||||
// sModel, _ := GetJSON(Otvet)
|
||||
RequestModel := grpc_proto.RequestModel{}
|
||||
RequestModel.VersionModel = model.LawsuitStatusType{}.GetStructVersion()
|
||||
RequestModel.VersionModel = lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||
RequestModel.ModelString = ModelString
|
||||
|
||||
Otvet, err := server1.LawsuitStatusType_Save(ctx, &RequestModel)
|
||||
@ -160,7 +160,7 @@ func Test_server_LawsuitStatusType_FindByExtID(t *testing.T) {
|
||||
Request := grpc_proto.RequestExtId{}
|
||||
Request.ExtId = 1
|
||||
Request.ConnectionId = 3
|
||||
Request.VersionModel = model.Employee{}.GetStructVersion()
|
||||
Request.VersionModel = lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||
|
||||
server1 := &ServerGRPC{}
|
||||
Otvet, err := server1.LawsuitStatusType_FindByExtId(ctx, &Request)
|
@ -2,11 +2,11 @@ package server_grpc
|
||||
|
||||
import (
|
||||
"github.com/nats-io/nats.go"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_proto"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/nikitin/contextmain"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/nikitin/log"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/nikitin/stopapp"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/internal/app/grpc/server_grpc"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_proto"
|
||||
"os"
|
||||
"time"
|
||||
)
|
@ -4,10 +4,10 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
model "gitlab.aescorp.ru/dsp_dev/claim/common/object_model"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/db/constants"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/nikitin/micro"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/nikitin/postgres_gorm"
|
||||
"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"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
@ -20,11 +20,11 @@ type Crud_DB struct {
|
||||
}
|
||||
|
||||
// Read - находит запись в БД по ID
|
||||
func (crud Crud_DB) Read(m *model.LawsuitStatusType) error {
|
||||
//var Otvet model.LawsuitStatusType
|
||||
func (crud Crud_DB) Read(m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
var err error
|
||||
|
||||
//log.Trace("start Read() ", TableName, " id: ", id)
|
||||
// log.Trace("start Read() ", TableName, " id: ", id)
|
||||
ctxMain := context.Background()
|
||||
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS))
|
||||
defer ctxCancelFunc()
|
||||
@ -34,8 +34,8 @@ func (crud Crud_DB) Read(m *model.LawsuitStatusType) error {
|
||||
}
|
||||
|
||||
// Read_ctx - находит запись в БД по ID
|
||||
func (crud Crud_DB) Read_ctx(ctx context.Context, m *model.LawsuitStatusType) error {
|
||||
//var Otvet model.LawsuitStatusType
|
||||
func (crud Crud_DB) Read_ctx(ctx context.Context, m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
var err error
|
||||
|
||||
id := m.ID
|
||||
@ -50,7 +50,7 @@ func (crud Crud_DB) Read_ctx(ctx context.Context, m *model.LawsuitStatusType) er
|
||||
}
|
||||
|
||||
// Save - записывает новый или существующий объект в базу данных
|
||||
func (crud Crud_DB) Save(m *model.LawsuitStatusType) error {
|
||||
func (crud Crud_DB) Save(m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
ctxMain := context.Background()
|
||||
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS))
|
||||
defer ctxCancelFunc()
|
||||
@ -60,14 +60,14 @@ func (crud Crud_DB) Save(m *model.LawsuitStatusType) error {
|
||||
}
|
||||
|
||||
// Save_ctx - записывает новый или существующий объект в базу данных
|
||||
func (crud Crud_DB) Save_ctx(ctx context.Context, m *model.LawsuitStatusType) error {
|
||||
func (crud Crud_DB) Save_ctx(ctx context.Context, m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
is_create := !micro.BoolFromInt64(m.ID)
|
||||
err := crud.create_update_ctx(ctx, m, is_create)
|
||||
return err
|
||||
}
|
||||
|
||||
// Update - записывает существующий объект в базу данных
|
||||
func (crud Crud_DB) Update(m *model.LawsuitStatusType) error {
|
||||
func (crud Crud_DB) Update(m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
ctxMain := context.Background()
|
||||
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS))
|
||||
defer ctxCancelFunc()
|
||||
@ -77,13 +77,13 @@ func (crud Crud_DB) Update(m *model.LawsuitStatusType) error {
|
||||
}
|
||||
|
||||
// Update_ctx - записывает существующий объект в базу данных
|
||||
func (crud Crud_DB) Update_ctx(ctx context.Context, m *model.LawsuitStatusType) error {
|
||||
func (crud Crud_DB) Update_ctx(ctx context.Context, m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
err := crud.create_update_ctx(ctx, m, false)
|
||||
return err
|
||||
}
|
||||
|
||||
// Create - записывает новый объект в базу данных
|
||||
func (crud Crud_DB) Create(m *model.LawsuitStatusType) error {
|
||||
func (crud Crud_DB) Create(m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
ctxMain := context.Background()
|
||||
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS))
|
||||
defer ctxCancelFunc()
|
||||
@ -93,16 +93,16 @@ func (crud Crud_DB) Create(m *model.LawsuitStatusType) error {
|
||||
}
|
||||
|
||||
// Create_ctx - записывает новый объект в базу данных
|
||||
func (crud Crud_DB) Create_ctx(ctx context.Context, m *model.LawsuitStatusType) error {
|
||||
func (crud Crud_DB) Create_ctx(ctx context.Context, m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
err := crud.create_update_ctx(ctx, m, true)
|
||||
return err
|
||||
}
|
||||
|
||||
// create_update - записывает объект в базу данных
|
||||
func (crud Crud_DB) create_update(m *model.LawsuitStatusType, is_create bool) error {
|
||||
func (crud Crud_DB) create_update(m *lawsuit_status_types.LawsuitStatusType, is_create bool) error {
|
||||
var err error
|
||||
|
||||
//log.Trace("start Save() ", TableName, " id: ", m.ID)
|
||||
// log.Trace("start Save() ", TableName, " id: ", m.ID)
|
||||
|
||||
ctxMain := context.Background()
|
||||
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS))
|
||||
@ -113,23 +113,23 @@ func (crud Crud_DB) create_update(m *model.LawsuitStatusType, is_create bool) er
|
||||
}
|
||||
|
||||
// create_update_ctx - записывает объект в базу данных
|
||||
func (crud Crud_DB) create_update_ctx(ctx context.Context, m *model.LawsuitStatusType, is_create bool) error {
|
||||
func (crud Crud_DB) create_update_ctx(ctx context.Context, m *lawsuit_status_types.LawsuitStatusType, is_create bool) error {
|
||||
var err error
|
||||
|
||||
//log.Trace("start Save() ", TableName, " id: ", m.ID)
|
||||
// log.Trace("start Save() ", TableName, " id: ", m.ID)
|
||||
|
||||
// проверка ID
|
||||
if is_create == true {
|
||||
if m.ID != 0 {
|
||||
TextError := fmt.Sprint("db.Save() ", TableName, " error: id !=0")
|
||||
//log.Panic(sError)
|
||||
// log.Panic(sError)
|
||||
err = errors.New(TextError)
|
||||
return err
|
||||
}
|
||||
} else if m.ID == 0 {
|
||||
TextError := fmt.Sprint("db.Save() ", TableName, " error: id =0")
|
||||
err = errors.New(TextError)
|
||||
//log.Panic(sError)
|
||||
// log.Panic(sError)
|
||||
return err
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ func (crud Crud_DB) create_update_ctx(ctx context.Context, m *model.LawsuitStatu
|
||||
db := postgres_gorm.GetConnection()
|
||||
db.WithContext(ctx)
|
||||
|
||||
//заполним даты
|
||||
// заполним даты
|
||||
Now := time.Now()
|
||||
m.ModifiedAt = Now
|
||||
if m.IsDeleted == true && m.DeletedAt.IsZero() == true {
|
||||
@ -146,7 +146,7 @@ func (crud Crud_DB) create_update_ctx(ctx context.Context, m *model.LawsuitStatu
|
||||
m.DeletedAt = time.Time{}
|
||||
}
|
||||
|
||||
//колонки с null
|
||||
// колонки с null
|
||||
tx := db
|
||||
MassOmit := make([]string, 0)
|
||||
var ColumnName string
|
||||
@ -161,10 +161,10 @@ func (crud Crud_DB) create_update_ctx(ctx context.Context, m *model.LawsuitStatu
|
||||
MassOmit = append(MassOmit, ColumnName)
|
||||
}
|
||||
|
||||
//игнор пустых колонок
|
||||
// игнор пустых колонок
|
||||
tx = tx.Omit(MassOmit...)
|
||||
|
||||
//запись
|
||||
// запись
|
||||
if is_create == true {
|
||||
tx = tx.Create(&m)
|
||||
} else {
|
||||
@ -175,7 +175,7 @@ func (crud Crud_DB) create_update_ctx(ctx context.Context, m *model.LawsuitStatu
|
||||
return err
|
||||
}
|
||||
|
||||
//запишем NULL в пустые колонки
|
||||
// запишем NULL в пустые колонки
|
||||
for f := 0; f < len(MassOmit); f++ {
|
||||
ColumnName := MassOmit[f]
|
||||
tx = db.Model(&m).Update(ColumnName, gorm.Expr("NULL"))
|
||||
@ -185,7 +185,7 @@ func (crud Crud_DB) create_update_ctx(ctx context.Context, m *model.LawsuitStatu
|
||||
TextError := fmt.Sprint("db.Update() ", TableName, " id: ", m.ID, " error: ", err)
|
||||
err = errors.New(TextError)
|
||||
return err
|
||||
//log.Panic(sError)
|
||||
// log.Panic(sError)
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,8 +193,8 @@ func (crud Crud_DB) create_update_ctx(ctx context.Context, m *model.LawsuitStatu
|
||||
}
|
||||
|
||||
// Delete - записывает is_deleted = true
|
||||
func (crud Crud_DB) Delete(m *model.LawsuitStatusType) error {
|
||||
//var Otvet model.LawsuitStatusType
|
||||
func (crud Crud_DB) Delete(m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
var err error
|
||||
|
||||
ctxMain := context.Background()
|
||||
@ -206,11 +206,11 @@ func (crud Crud_DB) Delete(m *model.LawsuitStatusType) error {
|
||||
}
|
||||
|
||||
// Delete_ctx - записывает is_deleted = true
|
||||
func (crud Crud_DB) Delete_ctx(ctx context.Context, m *model.LawsuitStatusType) error {
|
||||
//var Otvet model.LawsuitStatusType
|
||||
func (crud Crud_DB) Delete_ctx(ctx context.Context, m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
var err error
|
||||
|
||||
m2 := model.LawsuitStatusType{}
|
||||
m2 := lawsuit_status_types.LawsuitStatusType{}
|
||||
m2.ID = m.ID
|
||||
err = crud.Read_ctx(ctx, &m2)
|
||||
if err != nil {
|
||||
@ -226,8 +226,8 @@ func (crud Crud_DB) Delete_ctx(ctx context.Context, m *model.LawsuitStatusType)
|
||||
}
|
||||
|
||||
// Restore - записывает is_deleted = true
|
||||
func (crud Crud_DB) Restore(m *model.LawsuitStatusType) error {
|
||||
//var Otvet model.LawsuitStatusType
|
||||
func (crud Crud_DB) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
var err error
|
||||
|
||||
ctxMain := context.Background()
|
||||
@ -239,11 +239,11 @@ func (crud Crud_DB) Restore(m *model.LawsuitStatusType) error {
|
||||
}
|
||||
|
||||
// Restore_ctx - записывает is_deleted = true
|
||||
func (crud Crud_DB) Restore_ctx(ctx context.Context, m *model.LawsuitStatusType) error {
|
||||
//var Otvet model.LawsuitStatusType
|
||||
func (crud Crud_DB) Restore_ctx(ctx context.Context, m *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
var err error
|
||||
|
||||
m2 := model.LawsuitStatusType{}
|
||||
m2 := lawsuit_status_types.LawsuitStatusType{}
|
||||
m2.ID = m.ID
|
||||
err = crud.Read_ctx(ctx, &m2)
|
||||
if err != nil {
|
||||
@ -259,8 +259,8 @@ func (crud Crud_DB) Restore_ctx(ctx context.Context, m *model.LawsuitStatusType)
|
||||
}
|
||||
|
||||
// Find_ByExtID - находит запись в БД по ext_id и connection_id
|
||||
func Find_ByExtID(ext_id int64, connection_id int64) (model.LawsuitStatusType, error) {
|
||||
var Otvet model.LawsuitStatusType
|
||||
func Find_ByExtID(ext_id int64, connection_id int64) (lawsuit_status_types.LawsuitStatusType, error) {
|
||||
var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
var err error
|
||||
|
||||
if ext_id <= 0 {
|
||||
@ -279,8 +279,8 @@ func Find_ByExtID(ext_id int64, connection_id int64) (model.LawsuitStatusType, e
|
||||
}
|
||||
|
||||
// Find_ByExtID_ctx - находит запись в БД по ext_id и connection_id
|
||||
func Find_ByExtID_ctx(ctx context.Context, ext_id int64, connection_id int64) (model.LawsuitStatusType, error) {
|
||||
var Otvet model.LawsuitStatusType
|
||||
func Find_ByExtID_ctx(ctx context.Context, ext_id int64, connection_id int64) (lawsuit_status_types.LawsuitStatusType, error) {
|
||||
var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
var err error
|
||||
//log.Trace("start Find_ByExtID() ", TableName, " ext_id: ", ext_id)
|
||||
|
@ -1,9 +1,9 @@
|
||||
package db_lawsuit_status_types
|
||||
|
||||
import (
|
||||
model "gitlab.aescorp.ru/dsp_dev/claim/common/object_model"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/nikitin/config"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/nikitin/postgres_gorm"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@ -16,7 +16,7 @@ func TestRead(t *testing.T) {
|
||||
defer postgres_gorm.CloseConnection()
|
||||
|
||||
crud := Crud_DB{}
|
||||
Otvet := model.LawsuitStatusType{}
|
||||
Otvet := lawsuit_status_types.LawsuitStatusType{}
|
||||
Otvet.ID = Postgres_ID_Test
|
||||
err := crud.Read(&Otvet)
|
||||
if err != nil {
|
||||
@ -37,7 +37,7 @@ func TestSave(t *testing.T) {
|
||||
defer postgres_gorm.CloseConnection()
|
||||
|
||||
crud := Crud_DB{}
|
||||
Otvet := model.LawsuitStatusType{}
|
||||
Otvet := lawsuit_status_types.LawsuitStatusType{}
|
||||
Otvet.ID = Postgres_ID_Test
|
||||
err := crud.Read(&Otvet)
|
||||
if err != nil {
|
||||
@ -63,7 +63,7 @@ func TestDelete(t *testing.T) {
|
||||
defer postgres_gorm.CloseConnection()
|
||||
|
||||
crud := Crud_DB{}
|
||||
Otvet := model.LawsuitStatusType{}
|
||||
Otvet := lawsuit_status_types.LawsuitStatusType{}
|
||||
Otvet.ID = Postgres_ID_Test
|
||||
err := crud.Read(&Otvet)
|
||||
if err != nil {
|
||||
@ -95,6 +95,7 @@ func TestDelete(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
func TestFind_ByExtID(t *testing.T) {
|
||||
config.LoadEnv()
|
||||
postgres_gorm.Connect()
|
@ -3,10 +3,10 @@ package grpc_lawsuit_status_types
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
model "gitlab.aescorp.ru/dsp_dev/claim/common/object_model"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_client"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_client/constants"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_proto"
|
||||
"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/object_model/entities/lawsuit_status_types"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
@ -24,21 +24,21 @@ type Crud_GRPC struct {
|
||||
// GetVersionModel - возвращает хэш версии структуры модели
|
||||
func (crud Crud_GRPC) GetVersionModel() uint32 {
|
||||
if VersionModel == 0 {
|
||||
VersionModel = model.LawsuitStatusType{}.GetStructVersion()
|
||||
VersionModel = lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||
}
|
||||
return VersionModel
|
||||
}
|
||||
|
||||
// Read - возвращает модель из БД
|
||||
func (crud Crud_GRPC) Read(m *model.LawsuitStatusType) error {
|
||||
//var Otvet model.LawsuitStatusType
|
||||
func (crud Crud_GRPC) Read(l *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
|
||||
//подключение
|
||||
// подключение
|
||||
if grpc_client.Client == nil {
|
||||
grpc_client.Connect()
|
||||
}
|
||||
|
||||
//подготовка запроса
|
||||
// подготовка запроса
|
||||
var VersionModel = crud.GetVersionModel()
|
||||
|
||||
Request := &grpc_proto.RequestId{}
|
||||
@ -49,17 +49,17 @@ func (crud Crud_GRPC) Read(m *model.LawsuitStatusType) error {
|
||||
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_SECONDS))
|
||||
defer ctxCancelFunc()
|
||||
|
||||
//запрос
|
||||
Response, err := grpc_client.Client.LawsuitStatusTypes_Read(ctx, Request)
|
||||
// запрос
|
||||
Response, err := grpc_client.Client.LawsuitStatusType_Read(ctx, Request)
|
||||
if err != nil {
|
||||
sError := err.Error()
|
||||
if 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 {
|
||||
log.Panic("table: ", TableName, " error: ", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
//ответ
|
||||
// ответ
|
||||
sModel := Response.ModelString
|
||||
err = json.Unmarshal([]byte(sModel), l)
|
||||
if err != nil {
|
||||
@ -70,15 +70,15 @@ func (crud Crud_GRPC) Read(m *model.LawsuitStatusType) error {
|
||||
}
|
||||
|
||||
// Create - записывает новую модель в БД
|
||||
func (crud Crud_GRPC) Create(m *model.LawsuitStatusType) error {
|
||||
//var Otvet model.LawsuitStatusType
|
||||
func (crud Crud_GRPC) Create(l *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
|
||||
//подключение
|
||||
// подключение
|
||||
if grpc_client.Client == nil {
|
||||
grpc_client.Connect()
|
||||
}
|
||||
|
||||
//подготовка запроса
|
||||
// подготовка запроса
|
||||
var VersionModel = crud.GetVersionModel()
|
||||
|
||||
ModelString, err := l.GetJSON()
|
||||
@ -93,17 +93,17 @@ func (crud Crud_GRPC) Create(m *model.LawsuitStatusType) error {
|
||||
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_SECONDS))
|
||||
defer ctxCancelFunc()
|
||||
|
||||
//запрос
|
||||
Response, err := grpc_client.Client.LawsuitStatusTypes_Create(ctx, Request)
|
||||
// запрос
|
||||
Response, err := grpc_client.Client.LawsuitStatusType_Create(ctx, Request)
|
||||
if err != nil {
|
||||
sError := err.Error()
|
||||
if 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 {
|
||||
log.Panic("table: ", TableName, " error: ", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
//ответ
|
||||
// ответ
|
||||
sModel := Response.ModelString
|
||||
err = json.Unmarshal([]byte(sModel), l)
|
||||
if err != nil {
|
||||
@ -114,15 +114,15 @@ func (crud Crud_GRPC) Create(m *model.LawsuitStatusType) error {
|
||||
}
|
||||
|
||||
// Update - обновляет модель в БД
|
||||
func (crud Crud_GRPC) Update(m *model.LawsuitStatusType) error {
|
||||
//var Otvet model.LawsuitStatusType
|
||||
func (crud Crud_GRPC) Update(l *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
|
||||
//подключение
|
||||
// подключение
|
||||
if grpc_client.Client == nil {
|
||||
grpc_client.Connect()
|
||||
}
|
||||
|
||||
//подготовка запроса
|
||||
// подготовка запроса
|
||||
var VersionModel = crud.GetVersionModel()
|
||||
|
||||
ModelString, err := l.GetJSON()
|
||||
@ -137,17 +137,17 @@ func (crud Crud_GRPC) Update(m *model.LawsuitStatusType) error {
|
||||
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_SECONDS))
|
||||
defer ctxCancelFunc()
|
||||
|
||||
//запрос
|
||||
Response, err := grpc_client.Client.LawsuitStatusTypes_Update(ctx, Request)
|
||||
// запрос
|
||||
Response, err := grpc_client.Client.LawsuitStatusType_Update(ctx, Request)
|
||||
if err != nil {
|
||||
sError := err.Error()
|
||||
if 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 {
|
||||
log.Panic("table: ", TableName, " error: ", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
//ответ
|
||||
// ответ
|
||||
sModel := Response.ModelString
|
||||
err = json.Unmarshal([]byte(sModel), l)
|
||||
if err != nil {
|
||||
@ -158,15 +158,15 @@ func (crud Crud_GRPC) Update(m *model.LawsuitStatusType) error {
|
||||
}
|
||||
|
||||
// Save - обновляет (или создаёт) модель в БД
|
||||
func (crud Crud_GRPC) Save(m *model.LawsuitStatusType) error {
|
||||
//var Otvet model.LawsuitStatusType
|
||||
func (crud Crud_GRPC) Save(l *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
|
||||
//подключение
|
||||
// подключение
|
||||
if grpc_client.Client == nil {
|
||||
grpc_client.Connect()
|
||||
}
|
||||
|
||||
//подготовка запроса
|
||||
// подготовка запроса
|
||||
var VersionModel = crud.GetVersionModel()
|
||||
|
||||
ModelString, err := l.GetJSON()
|
||||
@ -181,17 +181,17 @@ func (crud Crud_GRPC) Save(m *model.LawsuitStatusType) error {
|
||||
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_SECONDS))
|
||||
defer ctxCancelFunc()
|
||||
|
||||
//запрос
|
||||
Response, err := grpc_client.Client.LawsuitStatusTypes_Save(ctx, Request)
|
||||
// запрос
|
||||
Response, err := grpc_client.Client.LawsuitStatusType_Save(ctx, Request)
|
||||
if err != nil {
|
||||
sError := err.Error()
|
||||
if 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 {
|
||||
log.Panic("table: ", TableName, " error: ", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
//ответ
|
||||
// ответ
|
||||
sModel := Response.ModelString
|
||||
err = json.Unmarshal([]byte(sModel), l)
|
||||
if err != nil {
|
||||
@ -202,15 +202,15 @@ func (crud Crud_GRPC) Save(m *model.LawsuitStatusType) error {
|
||||
}
|
||||
|
||||
// Delete - устанавливает is_deleted = true в БД
|
||||
func (crud Crud_GRPC) Delete(m *model.LawsuitStatusType) error {
|
||||
//var Otvet model.LawsuitStatusType
|
||||
func (crud Crud_GRPC) Delete(l *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
|
||||
//подключение
|
||||
// подключение
|
||||
if grpc_client.Client == nil {
|
||||
grpc_client.Connect()
|
||||
}
|
||||
|
||||
//подготовка запроса
|
||||
// подготовка запроса
|
||||
var VersionModel = crud.GetVersionModel()
|
||||
|
||||
Request := &grpc_proto.RequestId{}
|
||||
@ -221,17 +221,17 @@ func (crud Crud_GRPC) Delete(m *model.LawsuitStatusType) error {
|
||||
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_SECONDS))
|
||||
defer ctxCancelFunc()
|
||||
|
||||
//запрос
|
||||
Response, err := grpc_client.Client.LawsuitStatusTypes_Delete(ctx, Request)
|
||||
// запрос
|
||||
Response, err := grpc_client.Client.LawsuitStatusType_Delete(ctx, Request)
|
||||
if err != nil {
|
||||
sError := err.Error()
|
||||
if 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 {
|
||||
log.Panic("table: ", TableName, " error: ", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
//ответ
|
||||
// ответ
|
||||
sModel := Response.ModelString
|
||||
err = json.Unmarshal([]byte(sModel), l)
|
||||
if err != nil {
|
||||
@ -242,15 +242,15 @@ func (crud Crud_GRPC) Delete(m *model.LawsuitStatusType) error {
|
||||
}
|
||||
|
||||
// Restore - устанавливает is_deleted = false в БД
|
||||
func (crud Crud_GRPC) Restore(m *model.LawsuitStatusType) error {
|
||||
//var Otvet model.LawsuitStatusType
|
||||
func (crud Crud_GRPC) Restore(l *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
|
||||
//подключение
|
||||
// подключение
|
||||
if grpc_client.Client == nil {
|
||||
grpc_client.Connect()
|
||||
}
|
||||
|
||||
//подготовка запроса
|
||||
// подготовка запроса
|
||||
var VersionModel = crud.GetVersionModel()
|
||||
|
||||
Request := &grpc_proto.RequestId{}
|
||||
@ -261,17 +261,17 @@ func (crud Crud_GRPC) Restore(m *model.LawsuitStatusType) error {
|
||||
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_SECONDS))
|
||||
defer ctxCancelFunc()
|
||||
|
||||
//запрос
|
||||
Response, err := grpc_client.Client.LawsuitStatusTypes_Restore(ctx, Request)
|
||||
// запрос
|
||||
Response, err := grpc_client.Client.LawsuitStatusType_Restore(ctx, Request)
|
||||
if err != nil {
|
||||
sError := err.Error()
|
||||
if 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 {
|
||||
log.Panic("table: ", TableName, " error: ", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
//ответ
|
||||
// ответ
|
||||
sModel := Response.ModelString
|
||||
err = json.Unmarshal([]byte(sModel), l)
|
||||
if err != nil {
|
||||
@ -282,7 +282,7 @@ func (crud Crud_GRPC) Restore(m *model.LawsuitStatusType) error {
|
||||
}
|
||||
|
||||
// Find_ByExtID - находит модель в БД по ext_id и connection_id
|
||||
func (crud Crud_GRPC) Find_ByExtID(e *model.LawsuitStatusType) error {
|
||||
func (crud Crud_GRPC) Find_ByExtID(e *lawsuit_status_types.LawsuitStatusType) error {
|
||||
//подключение
|
||||
if grpc_client.Client == nil {
|
||||
grpc_client.Connect()
|
@ -1,9 +1,9 @@
|
||||
package grpc_lawsuit_status_types
|
||||
|
||||
import (
|
||||
model "gitlab.aescorp.ru/dsp_dev/claim/common/object_model"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_client"
|
||||
config "gitlab.aescorp.ru/dsp_dev/claim/nikitin/config"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_client"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@ -25,7 +25,7 @@ func TestRead(t *testing.T) {
|
||||
defer grpc_client.CloseConnection()
|
||||
|
||||
crud := Crud_GRPC{}
|
||||
Otvet := model.LawsuitStatusType{}
|
||||
Otvet := lawsuit_status_types.LawsuitStatusType{}
|
||||
Otvet.ID = Postgres_ID_Test
|
||||
err := crud.Read(&Otvet)
|
||||
|
||||
@ -43,7 +43,7 @@ func TestCreate(t *testing.T) {
|
||||
grpc_client.Connect()
|
||||
defer grpc_client.CloseConnection()
|
||||
|
||||
Model := model.LawsuitStatusType{}
|
||||
Model := lawsuit_status_types.LawsuitStatusType{}
|
||||
Model.ID = -1
|
||||
|
||||
crud := Crud_GRPC{}
|
||||
@ -63,7 +63,7 @@ func TestUpdate(t *testing.T) {
|
||||
grpc_client.Connect()
|
||||
defer grpc_client.CloseConnection()
|
||||
|
||||
Model := model.LawsuitStatusType{}
|
||||
Model := lawsuit_status_types.LawsuitStatusType{}
|
||||
Model.ID = 0
|
||||
|
||||
crud := Crud_GRPC{}
|
||||
@ -84,7 +84,7 @@ func TestSave(t *testing.T) {
|
||||
defer grpc_client.CloseConnection()
|
||||
|
||||
crud := Crud_GRPC{}
|
||||
Otvet := model.LawsuitStatusType{}
|
||||
Otvet := lawsuit_status_types.LawsuitStatusType{}
|
||||
Otvet.ID = Postgres_ID_Test
|
||||
err := crud.Read(&Otvet)
|
||||
if err != nil {
|
||||
@ -109,7 +109,7 @@ func TestDelete(t *testing.T) {
|
||||
defer grpc_client.CloseConnection()
|
||||
|
||||
crud := Crud_GRPC{}
|
||||
Otvet := model.LawsuitStatusType{}
|
||||
Otvet := lawsuit_status_types.LawsuitStatusType{}
|
||||
Otvet.ID = Postgres_ID_Test
|
||||
err := crud.Read(&Otvet)
|
||||
if err != nil {
|
||||
@ -157,7 +157,7 @@ func TestFindByExtID(t *testing.T) {
|
||||
defer grpc_client.CloseConnection()
|
||||
|
||||
crud := Crud_GRPC{}
|
||||
Otvet := model.LawsuitStatusType{}
|
||||
Otvet := lawsuit_status_types.LawsuitStatusType{}
|
||||
Otvet.ExtID = 1
|
||||
Otvet.ConnectionID = constants.CONNECTION_ID_TEST
|
||||
err := crud.Find_ByExtID(&Otvet)
|
@ -2,10 +2,10 @@ package nrpc_lawsuit_status_types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
model "gitlab.aescorp.ru/dsp_dev/claim/common/object_model"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/grpc/grpc_proto"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/nrpc/nrpc_client"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/nrpc/nrpc_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/network/nrpc/nrpc_client/constants"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
|
||||
"log"
|
||||
)
|
||||
|
||||
@ -22,38 +22,38 @@ type Crud_NRPC struct {
|
||||
// GetVersionModel - возвращает хэш версии структуры модели
|
||||
func (crud Crud_NRPC) GetVersionModel() uint32 {
|
||||
if VersionModel == 0 {
|
||||
VersionModel = model.LawsuitStatusType{}.GetStructVersion()
|
||||
VersionModel = lawsuit_status_types.LawsuitStatusType{}.GetStructVersion()
|
||||
}
|
||||
return VersionModel
|
||||
}
|
||||
|
||||
// Read - возвращает модель из БД
|
||||
func (crud Crud_NRPC) Read(l *model.LawsuitStatusType) error {
|
||||
//var Otvet model.LawsuitStatusType
|
||||
func (crud Crud_NRPC) Read(l *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
|
||||
//подключение
|
||||
// подключение
|
||||
if nrpc_client.Client == nil {
|
||||
nrpc_client.Connect()
|
||||
}
|
||||
|
||||
//подготовка запроса
|
||||
// подготовка запроса
|
||||
var VersionModel = crud.GetVersionModel()
|
||||
|
||||
Request := &grpc_proto.RequestId{}
|
||||
Request.Id = l.ID
|
||||
Request.VersionModel = VersionModel
|
||||
|
||||
//запрос
|
||||
Response, err := nrpc_client.Client.LawsuitStatusTypes_Read(Request)
|
||||
// запрос
|
||||
Response, err := nrpc_client.Client.LawsuitStatusType_Read(Request)
|
||||
if err != nil {
|
||||
sError := err.Error()
|
||||
if 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 {
|
||||
log.Panic("table: ", TableName, " error: ", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
//ответ
|
||||
// ответ
|
||||
sModel := Response.ModelString
|
||||
err = json.Unmarshal([]byte(sModel), l)
|
||||
if err != nil {
|
||||
@ -64,15 +64,15 @@ func (crud Crud_NRPC) Read(l *model.LawsuitStatusType) error {
|
||||
}
|
||||
|
||||
// Create - записывает новую модель в БД
|
||||
func (crud Crud_NRPC) Create(l *model.LawsuitStatusType) error {
|
||||
//var Otvet model.LawsuitStatusType
|
||||
func (crud Crud_NRPC) Create(l *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
|
||||
//подключение
|
||||
// подключение
|
||||
if nrpc_client.Client == nil {
|
||||
nrpc_client.Connect()
|
||||
}
|
||||
|
||||
//подготовка запроса
|
||||
// подготовка запроса
|
||||
var VersionModel = crud.GetVersionModel()
|
||||
|
||||
ModelString, err := l.GetJSON()
|
||||
@ -83,17 +83,17 @@ func (crud Crud_NRPC) Create(l *model.LawsuitStatusType) error {
|
||||
Request.ModelString = ModelString
|
||||
Request.VersionModel = VersionModel
|
||||
|
||||
//запрос
|
||||
Response, err := nrpc_client.Client.LawsuitStatusTypes_Create(Request)
|
||||
// запрос
|
||||
Response, err := nrpc_client.Client.LawsuitStatusType_Create(Request)
|
||||
if err != nil {
|
||||
sError := err.Error()
|
||||
if 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 {
|
||||
log.Panic("table: ", TableName, " error: ", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
//ответ
|
||||
// ответ
|
||||
sModel := Response.ModelString
|
||||
err = json.Unmarshal([]byte(sModel), l)
|
||||
if err != nil {
|
||||
@ -104,15 +104,15 @@ func (crud Crud_NRPC) Create(l *model.LawsuitStatusType) error {
|
||||
}
|
||||
|
||||
// Update - обновляет модель в БД
|
||||
func (crud Crud_NRPC) Update(l *model.LawsuitStatusType) error {
|
||||
//var Otvet model.LawsuitStatusType
|
||||
func (crud Crud_NRPC) Update(l *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
|
||||
//подключение
|
||||
// подключение
|
||||
if nrpc_client.Client == nil {
|
||||
nrpc_client.Connect()
|
||||
}
|
||||
|
||||
//подготовка запроса
|
||||
// подготовка запроса
|
||||
var VersionModel = crud.GetVersionModel()
|
||||
|
||||
ModelString, err := l.GetJSON()
|
||||
@ -123,17 +123,17 @@ func (crud Crud_NRPC) Update(l *model.LawsuitStatusType) error {
|
||||
Request.ModelString = ModelString
|
||||
Request.VersionModel = VersionModel
|
||||
|
||||
//запрос
|
||||
Response, err := nrpc_client.Client.LawsuitStatusTypes_Update(Request)
|
||||
// запрос
|
||||
Response, err := nrpc_client.Client.LawsuitStatusType_Update(Request)
|
||||
if err != nil {
|
||||
sError := err.Error()
|
||||
if 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 {
|
||||
log.Panic("table: ", TableName, " error: ", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
//ответ
|
||||
// ответ
|
||||
sModel := Response.ModelString
|
||||
err = json.Unmarshal([]byte(sModel), l)
|
||||
if err != nil {
|
||||
@ -144,15 +144,15 @@ func (crud Crud_NRPC) Update(l *model.LawsuitStatusType) error {
|
||||
}
|
||||
|
||||
// Save - обновляет (или создаёт) модель в БД
|
||||
func (crud Crud_NRPC) Save(l *model.LawsuitStatusType) error {
|
||||
//var Otvet model.LawsuitStatusType
|
||||
func (crud Crud_NRPC) Save(l *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
|
||||
//подключение
|
||||
// подключение
|
||||
if nrpc_client.Client == nil {
|
||||
nrpc_client.Connect()
|
||||
}
|
||||
|
||||
//подготовка запроса
|
||||
// подготовка запроса
|
||||
var VersionModel = crud.GetVersionModel()
|
||||
|
||||
ModelString, err := l.GetJSON()
|
||||
@ -163,17 +163,17 @@ func (crud Crud_NRPC) Save(l *model.LawsuitStatusType) error {
|
||||
Request.ModelString = ModelString
|
||||
Request.VersionModel = VersionModel
|
||||
|
||||
//запрос
|
||||
Response, err := nrpc_client.Client.LawsuitStatusTypes_Save(Request)
|
||||
// запрос
|
||||
Response, err := nrpc_client.Client.LawsuitStatusType_Save(Request)
|
||||
if err != nil {
|
||||
sError := err.Error()
|
||||
if 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 {
|
||||
log.Panic("table: ", TableName, " error: ", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
//ответ
|
||||
// ответ
|
||||
sModel := Response.ModelString
|
||||
err = json.Unmarshal([]byte(sModel), l)
|
||||
if err != nil {
|
||||
@ -184,32 +184,32 @@ func (crud Crud_NRPC) Save(l *model.LawsuitStatusType) error {
|
||||
}
|
||||
|
||||
// Delete - устанавливает is_deleted = true в БД
|
||||
func (crud Crud_NRPC) Delete(l *model.LawsuitStatusType) error {
|
||||
//var Otvet model.LawsuitStatusType
|
||||
func (crud Crud_NRPC) Delete(l *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
|
||||
//подключение
|
||||
// подключение
|
||||
if nrpc_client.Client == nil {
|
||||
nrpc_client.Connect()
|
||||
}
|
||||
|
||||
//подготовка запроса
|
||||
// подготовка запроса
|
||||
var VersionModel = crud.GetVersionModel()
|
||||
|
||||
Request := &grpc_proto.RequestId{}
|
||||
Request.Id = l.ID
|
||||
Request.VersionModel = VersionModel
|
||||
|
||||
//запрос
|
||||
Response, err := nrpc_client.Client.LawsuitStatusTypes_Delete(Request)
|
||||
// запрос
|
||||
Response, err := nrpc_client.Client.LawsuitStatusType_Delete(Request)
|
||||
if err != nil {
|
||||
sError := err.Error()
|
||||
if 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 {
|
||||
log.Panic("table: ", TableName, " error: ", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
//ответ
|
||||
// ответ
|
||||
sModel := Response.ModelString
|
||||
err = json.Unmarshal([]byte(sModel), l)
|
||||
if err != nil {
|
||||
@ -220,32 +220,32 @@ func (crud Crud_NRPC) Delete(l *model.LawsuitStatusType) error {
|
||||
}
|
||||
|
||||
// Restore - устанавливает is_deleted = false в БД
|
||||
func (crud Crud_NRPC) Restore(l *model.LawsuitStatusType) error {
|
||||
//var Otvet model.LawsuitStatusType
|
||||
func (crud Crud_NRPC) Restore(l *lawsuit_status_types.LawsuitStatusType) error {
|
||||
// var Otvet lawsuit_status_types.LawsuitStatusType
|
||||
|
||||
//подключение
|
||||
// подключение
|
||||
if nrpc_client.Client == nil {
|
||||
nrpc_client.Connect()
|
||||
}
|
||||
|
||||
//подготовка запроса
|
||||
// подготовка запроса
|
||||
var VersionModel = crud.GetVersionModel()
|
||||
|
||||
Request := &grpc_proto.RequestId{}
|
||||
Request.Id = l.ID
|
||||
Request.VersionModel = VersionModel
|
||||
|
||||
//запрос
|
||||
Response, err := nrpc_client.Client.LawsuitStatusTypes_Restore(Request)
|
||||
// запрос
|
||||
Response, err := nrpc_client.Client.LawsuitStatusType_Restore(Request)
|
||||
if err != nil {
|
||||
sError := err.Error()
|
||||
if 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 {
|
||||
log.Panic("table: ", TableName, " error: ", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
//ответ
|
||||
// ответ
|
||||
sModel := Response.ModelString
|
||||
err = json.Unmarshal([]byte(sModel), l)
|
||||
if err != nil {
|
||||
@ -256,7 +256,7 @@ func (crud Crud_NRPC) Restore(l *model.LawsuitStatusType) error {
|
||||
}
|
||||
|
||||
// Find_ByExtID - находит модель в БД по ext_id и connection_id
|
||||
func (crud Crud_NRPC) Find_ByExtID(e *model.LawsuitStatusType) error {
|
||||
func (crud Crud_NRPC) Find_ByExtID(e *lawsuit_status_types.LawsuitStatusType) error {
|
||||
//подключение
|
||||
if nrpc_client.Client == nil {
|
||||
nrpc_client.Connect()
|
@ -1,9 +1,9 @@
|
||||
package nrpc_lawsuit_status_types
|
||||
|
||||
import (
|
||||
model "gitlab.aescorp.ru/dsp_dev/claim/common/object_model"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/common/object_model/pkg/nrpc/nrpc_client"
|
||||
config "gitlab.aescorp.ru/dsp_dev/claim/nikitin/config"
|
||||
"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"
|
||||
)
|
||||
|
||||
@ -25,7 +25,7 @@ func TestRead(t *testing.T) {
|
||||
defer nrpc_client.CloseConnection()
|
||||
|
||||
crud := Crud_NRPC{}
|
||||
Otvet := model.LawsuitStatusType{}
|
||||
Otvet := lawsuit_status_types.LawsuitStatusType{}
|
||||
Otvet.ID = Postgres_ID_Test
|
||||
err := crud.Read(&Otvet)
|
||||
|
||||
@ -43,7 +43,7 @@ func TestCreate(t *testing.T) {
|
||||
nrpc_client.Connect()
|
||||
defer nrpc_client.CloseConnection()
|
||||
|
||||
Model := model.LawsuitStatusType{}
|
||||
Model := lawsuit_status_types.LawsuitStatusType{}
|
||||
Model.ID = -1
|
||||
|
||||
crud := Crud_NRPC{}
|
||||
@ -63,7 +63,7 @@ func TestUpdate(t *testing.T) {
|
||||
nrpc_client.Connect()
|
||||
defer nrpc_client.CloseConnection()
|
||||
|
||||
Model := model.LawsuitStatusType{}
|
||||
Model := lawsuit_status_types.LawsuitStatusType{}
|
||||
Model.ID = 0
|
||||
|
||||
crud := Crud_NRPC{}
|
||||
@ -84,7 +84,7 @@ func TestSave(t *testing.T) {
|
||||
defer nrpc_client.CloseConnection()
|
||||
|
||||
crud := Crud_NRPC{}
|
||||
Otvet := model.LawsuitStatusType{}
|
||||
Otvet := lawsuit_status_types.LawsuitStatusType{}
|
||||
Otvet.ID = Postgres_ID_Test
|
||||
err := crud.Read(&Otvet)
|
||||
if err != nil {
|
||||
@ -109,7 +109,7 @@ func TestDelete(t *testing.T) {
|
||||
defer nrpc_client.CloseConnection()
|
||||
|
||||
crud := Crud_NRPC{}
|
||||
Otvet := model.LawsuitStatusType{}
|
||||
Otvet := lawsuit_status_types.LawsuitStatusType{}
|
||||
Otvet.ID = Postgres_ID_Test
|
||||
err := crud.Read(&Otvet)
|
||||
if err != nil {
|
||||
@ -157,7 +157,7 @@ func TestFindByExtID(t *testing.T) {
|
||||
defer nrpc_client.CloseConnection()
|
||||
|
||||
crud := Crud_NRPC{}
|
||||
Otvet := model.LawsuitStatusType{}
|
||||
Otvet := lawsuit_status_types.LawsuitStatusType{}
|
||||
Otvet.ExtID = 1
|
||||
Otvet.ConnectionID = constants.CONNECTION_ID_TEST
|
||||
err := crud.Find_ByExtID(&Otvet)
|
@ -1,8 +1,10 @@
|
||||
package object_model
|
||||
package lawsuit_status_types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/vmihailenco/msgpack/v5"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/functions/calc_struct_version"
|
||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
@ -14,8 +16,8 @@ var crud_LawsuitStatusType ICrud_LawsuitStatusType
|
||||
|
||||
// LawsuitStatusType Статусы дел (справочник).
|
||||
type LawsuitStatusType struct {
|
||||
CommonStruct
|
||||
NameStruct
|
||||
entities.CommonStruct
|
||||
entities.NameStruct
|
||||
Code string `json:"code" gorm:"column:code;default:0"`
|
||||
}
|
||||
|
||||
@ -26,7 +28,6 @@ type ICrud_LawsuitStatusType interface {
|
||||
Create(*LawsuitStatusType) error
|
||||
Delete(*LawsuitStatusType) error
|
||||
Restore(*LawsuitStatusType) error
|
||||
Find_ByExtID(*LawsuitStatusType) error
|
||||
}
|
||||
|
||||
// TableName - возвращает имя таблицы в БД, нужен для gorm
|
||||
@ -61,7 +62,7 @@ func LawsuitStatusTypeAsBytes(m *LawsuitStatusType) ([]byte, error) {
|
||||
// GetStructVersion - возвращает версию модели
|
||||
func (m LawsuitStatusType) GetStructVersion() uint32 {
|
||||
if versionLawsuitStatusType == 0 {
|
||||
versionLawsuitStatusType = CalcStructVersion(reflect.TypeOf(m))
|
||||
versionLawsuitStatusType = calc_struct_version.CalcStructVersion(reflect.TypeOf(m))
|
||||
}
|
||||
|
||||
return versionLawsuitStatusType
|
||||
@ -92,7 +93,7 @@ func (m LawsuitStatusType) GetJSON() (string, error) {
|
||||
return ReturnVar, err
|
||||
}
|
||||
|
||||
//---------------------------- CRUD операции ------------------------------------------------------------
|
||||
// ---------------------------- CRUD операции ------------------------------------------------------------
|
||||
|
||||
// Read - находит запись в БД по ID, и заполняет в объект
|
||||
func (m *LawsuitStatusType) Read() error {
|
||||
@ -150,4 +151,4 @@ func (m LawsuitStatusType) SetCrudInterface(crud ICrud_LawsuitStatusType) {
|
||||
return
|
||||
}
|
||||
|
||||
//---------------------------- конец CRUD операции ------------------------------------------------------------
|
||||
// ---------------------------- конец CRUD операции ------------------------------------------------------------
|
@ -32,11 +32,13 @@ type SettingsINI struct {
|
||||
TEXT_TEMPLATE_MODEL string
|
||||
TEXT_TEMPLATE_TABLENAME string
|
||||
HAS_IS_DELETED bool
|
||||
NEED_MODEL_ONE_FOLDER bool
|
||||
READY_FOLDERNAME string
|
||||
}
|
||||
|
||||
// FillSettings загружает переменные окружения в структуру из переменных окружения
|
||||
func FillSettings() {
|
||||
//dir := micro.ProgramDir_bin()
|
||||
|
||||
Settings = SettingsINI{}
|
||||
Settings.INCLUDE_TABLES = os.Getenv("INCLUDE_TABLES")
|
||||
Settings.EXCLUDE_TABLES = os.Getenv("EXCLUDE_TABLES")
|
||||
@ -66,10 +68,8 @@ func FillSettings() {
|
||||
sNEED_NRPC := os.Getenv("NEED_NRPC")
|
||||
Settings.NEED_NRPC = BoolFromString(sNEED_NRPC)
|
||||
|
||||
sNEED_MODEL_ONE_FOLDER := os.Getenv("NEED_MODEL_ONE_FOLDER")
|
||||
Settings.NEED_MODEL_ONE_FOLDER = BoolFromString(sNEED_MODEL_ONE_FOLDER)
|
||||
|
||||
Settings.SERVICE_NAME = os.Getenv("SERVICE_NAME")
|
||||
Settings.READY_FOLDERNAME = strings.ToLower(Settings.SERVICE_NAME)
|
||||
|
||||
if Settings.TEMPLATE_FOLDERNAME == "" {
|
||||
log.Panic("Need fill TEMPLATE_FOLDERNAME")
|
||||
|
@ -4,9 +4,9 @@ const TEXT_HELP = `
|
||||
Need create .env file with settings
|
||||
`
|
||||
|
||||
const FolderTemplates string = "templates"
|
||||
|
||||
const FolderReady string = "ready"
|
||||
//const FolderTemplates string = "templates"
|
||||
//
|
||||
//const FolderReady string = "ready"
|
||||
|
||||
const FILE_PERMISSIONS = 0666
|
||||
|
||||
|
@ -35,10 +35,10 @@ func CreateFileCrudStarter(MapAll map[string]*types.Table) error {
|
||||
//чтение файлов
|
||||
DirBin := micro.ProgramDir_bin()
|
||||
//DirTemplates := DirBin + constants.FolderTemplates + micro.SeparatorFile()
|
||||
DirReady := DirBin + constants.FolderReady + micro.SeparatorFile()
|
||||
DirReady := DirBin + config.Settings.READY_FOLDERNAME + micro.SeparatorFile()
|
||||
//DirTemplatesCrudStarter := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_CRUD_STARTER + micro.SeparatorFile()
|
||||
//FilenameTemplateCrudStarter := DirTemplatesCrudStarter + "crud_starter.go_"
|
||||
DirReadyCrudStarter := DirReady + "pkg" + micro.SeparatorFile() + "crud_starter" + micro.SeparatorFile()
|
||||
DirReadyCrudStarter := DirReady + config.Settings.TEMPLATE_FOLDERNAME_CRUD_STARTER + micro.SeparatorFile()
|
||||
FilenameReadyCrudStarter := DirReadyCrudStarter + "crud_starter.go"
|
||||
|
||||
//bytes, err := os.ReadFile(FilenameTemplateCrudStarter)
|
||||
@ -53,17 +53,15 @@ func CreateFileCrudStarter(MapAll map[string]*types.Table) error {
|
||||
TextCrudStarter := constants.TEXT_GENERATED + `package crud_starter`
|
||||
|
||||
//найдём новый текст для каждой таблицы
|
||||
ModelURL := config.Settings.SERVICE_REPOSITORY_URL
|
||||
if config.Settings.NEED_MODEL_ONE_FOLDER == false {
|
||||
ModelURL = ModelURL + "/pkg/model"
|
||||
}
|
||||
RepositoryURL := config.Settings.SERVICE_REPOSITORY_URL
|
||||
ModelURL := RepositoryURL + config.Settings.TEMPLATE_FOLDERNAME_MODEL
|
||||
|
||||
//импорт
|
||||
TextImport := FindTextImport(MapAll, ModelURL)
|
||||
TextCrudStarter = TextCrudStarter + "\n" + TextImport
|
||||
|
||||
//DB
|
||||
TextDB := FindTextDB(MapAll, ModelURL)
|
||||
TextDB := FindText_InitCrudTransport_DB(MapAll, ModelURL)
|
||||
TextCrudStarter = TextCrudStarter + "\n" + TextDB
|
||||
|
||||
//GRPC
|
||||
@ -88,7 +86,7 @@ func CreateFileCrudStarter(MapAll map[string]*types.Table) error {
|
||||
func FindTextImport(MapAll map[string]*types.Table, ModelURL string) string {
|
||||
Otvet := `
|
||||
import (
|
||||
model "` + ModelURL + `"`
|
||||
`
|
||||
//сортировка по названию таблиц
|
||||
keys := make([]string, 0, len(MapAll))
|
||||
for k := range MapAll {
|
||||
@ -96,6 +94,7 @@ import (
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
TextModel := ""
|
||||
TextDB := ""
|
||||
TextGRPC := ""
|
||||
TextNRPC := ""
|
||||
@ -104,44 +103,57 @@ import (
|
||||
if ok == false {
|
||||
log.Panic("MapAll[key1] not found, key: ", key1)
|
||||
}
|
||||
TextDB = TextDB + FindTextImportDB1(Table1, ModelURL)
|
||||
TextGRPC = TextGRPC + FindTextImportGRPC1(Table1, ModelURL)
|
||||
TextNRPC = TextNRPC + FindTextImportNRPC1(Table1, ModelURL)
|
||||
TextModel = TextModel + FindTextImportModel1(Table1)
|
||||
TextDB = TextDB + FindTextImportDB1(Table1)
|
||||
TextGRPC = TextGRPC + FindTextImportGRPC1(Table1)
|
||||
TextNRPC = TextNRPC + FindTextImportNRPC1(Table1)
|
||||
}
|
||||
|
||||
Otvet = Otvet + TextDB + "\n" + TextGRPC + "\n" + TextNRPC
|
||||
Otvet = Otvet + TextModel + "\n" + TextDB + "\n" + TextGRPC + "\n" + TextNRPC
|
||||
|
||||
Otvet = Otvet + "\n)"
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// FindTextImportDB1 - возвращает текст всех функций .proto для таблицы
|
||||
func FindTextImportDB1(Table1 *types.Table, ModelURL string) string {
|
||||
// FindTextImportModel1 - возвращает текст импорта Model для 1 таблицы
|
||||
func FindTextImportModel1(Table1 *types.Table) string {
|
||||
TableName := strings.ToLower(Table1.Name)
|
||||
Otvet := "\n\t\"" + ModelURL + "/pkg/db/" + TableName + `"`
|
||||
DB_URL := config.Settings.SERVICE_REPOSITORY_URL + config.Settings.TEMPLATE_FOLDERNAME_MODEL + "/" + TableName
|
||||
Otvet := "\n\t\"" + DB_URL
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// FindTextImportGRPC1 - возвращает текст всех функций .proto для таблицы
|
||||
func FindTextImportGRPC1(Table1 *types.Table, ModelURL string) string {
|
||||
// FindTextImportDB1 - возвращает текст импорта DB для 1 таблицы
|
||||
func FindTextImportDB1(Table1 *types.Table) string {
|
||||
TableName := strings.ToLower(Table1.Name)
|
||||
Otvet := "\n\t\"" + ModelURL + "/pkg/grpc/grpc_client/grpc_" + TableName + `"`
|
||||
DB_URL := config.Settings.SERVICE_REPOSITORY_URL + config.Settings.TEMPLATE_FOLDERNAME_DB
|
||||
Otvet := "\n\t\"" + DB_URL + "/db_" + TableName
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// FindTextImportNRPC1 - возвращает текст всех функций .proto для таблицы
|
||||
func FindTextImportNRPC1(Table1 *types.Table, ModelURL string) string {
|
||||
// FindTextImportGRPC1 - возвращает текст импорта GRPC для 1 таблицы
|
||||
func FindTextImportGRPC1(Table1 *types.Table) string {
|
||||
GRPC_URL := config.Settings.SERVICE_REPOSITORY_URL + config.Settings.TEMPLATE_FOLDERNAME_GRPC
|
||||
TableName := strings.ToLower(Table1.Name)
|
||||
Otvet := "\n\t\"" + ModelURL + "/pkg/nrpc/grpc_client/nrpc_" + TableName + `"`
|
||||
Otvet := "\n\t\"" + GRPC_URL + "/" + config.Settings.TEMPLATE_FOLDERNAME_GRPC_CLIENT + "/grpc_" + TableName + `"`
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// FindTextNRPC - возвращает текст всех функций .proto для таблицы
|
||||
func FindTextDB(MapAll map[string]*types.Table, ModelURL string) string {
|
||||
// FindTextImportNRPC1 - возвращает текст импорта NRPC для 1 таблицы
|
||||
func FindTextImportNRPC1(Table1 *types.Table) string {
|
||||
NRPC_URL := config.Settings.SERVICE_REPOSITORY_URL + config.Settings.TEMPLATE_FOLDERNAME_NRPC
|
||||
TableName := strings.ToLower(Table1.Name)
|
||||
Otvet := "\n\t\"" + NRPC_URL + "/" + config.Settings.TEMPLATE_FOLDERNAME_NRPC_CLIENT + "/nrpc_" + TableName + `"`
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// FindText_InitCrudTransport_DB - возвращает текст всех функций .proto для таблицы
|
||||
func FindText_InitCrudTransport_DB(MapAll map[string]*types.Table, ModelURL string) string {
|
||||
Otvet := `
|
||||
// InitCrudTransport_DB - заполняет объекты crud для работы с БД напрямую
|
||||
func InitCrudTransport_DB() {`
|
||||
@ -169,7 +181,7 @@ func InitCrudTransport_DB() {`
|
||||
func FindTextDB1(Table1 *types.Table) string {
|
||||
TableName := strings.ToLower(Table1.Name)
|
||||
ModelName := Table1.NameGo
|
||||
Otvet := "\n\t" + "model." + ModelName + "{}.SetCrudInterface(db_" + TableName + ".Crud_DB{})"
|
||||
Otvet := "\n\t" + TableName + "." + ModelName + "{}.SetCrudInterface(db_" + TableName + ".Crud_DB{})"
|
||||
|
||||
return Otvet
|
||||
}
|
||||
@ -203,7 +215,7 @@ func InitCrudTransport_GRPC() {`
|
||||
func FindTextGRPC1(Table1 *types.Table) string {
|
||||
TableName := strings.ToLower(Table1.Name)
|
||||
ModelName := Table1.NameGo
|
||||
Otvet := "\n\t" + "model." + ModelName + "{}.SetCrudInterface(grpc_" + TableName + ".Crud_GRPC{})"
|
||||
Otvet := "\n\t" + "grpc_" + TableName + "." + ModelName + "{}.SetCrudInterface(grpc_" + TableName + ".Crud_GRPC{})"
|
||||
|
||||
return Otvet
|
||||
}
|
||||
@ -237,7 +249,7 @@ func InitCrudTransport_NRPC() {`
|
||||
func FindTextNRPC1(Table1 *types.Table) string {
|
||||
TableName := strings.ToLower(Table1.Name)
|
||||
ModelName := Table1.NameGo
|
||||
Otvet := "\n\t" + "model." + ModelName + "{}.SetCrudInterface(nrpc_" + TableName + ".Crud_NRPC{})"
|
||||
Otvet := "\n\t" + "nrpc_" + TableName + "." + ModelName + "{}.SetCrudInterface(nrpc_" + TableName + ".Crud_NRPC{})"
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
@ -41,10 +41,10 @@ func CreateFiles(Table1 *types.Table) error {
|
||||
|
||||
//чтение файлов
|
||||
DirBin := micro.ProgramDir_bin()
|
||||
DirTemplates := DirBin + constants.FolderTemplates + micro.SeparatorFile()
|
||||
DirReady := DirBin + constants.FolderReady + micro.SeparatorFile()
|
||||
DirTemplates := DirBin + config.Settings.TEMPLATE_FOLDERNAME + micro.SeparatorFile()
|
||||
DirReady := DirBin + config.Settings.READY_FOLDERNAME + micro.SeparatorFile()
|
||||
DirTemplatesDB := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_DB + micro.SeparatorFile()
|
||||
DirReadyDB := DirReady + "pkg" + micro.SeparatorFile() + "db" + micro.SeparatorFile()
|
||||
DirReadyDB := DirReady + config.Settings.TEMPLATE_FOLDERNAME_DB + micro.SeparatorFile()
|
||||
|
||||
FilenameTemplateDB := DirTemplatesDB + "db.go_"
|
||||
TableName := strings.ToLower(Table1.Name)
|
||||
@ -54,7 +54,7 @@ func CreateFiles(Table1 *types.Table) error {
|
||||
//создадим каталог
|
||||
ok, err := micro.FileExists(DirTable)
|
||||
if ok == false {
|
||||
err = os.Mkdir(DirTable, 0777)
|
||||
err = os.MkdirAll(DirTable, 0777)
|
||||
if err != nil {
|
||||
log.Panic("Mkdir() ", DirTable, " error: ", err)
|
||||
}
|
||||
@ -92,15 +92,16 @@ func CreateFiles(Table1 *types.Table) error {
|
||||
func CreateTestFiles(Table1 *types.Table) error {
|
||||
var err error
|
||||
|
||||
TableName := strings.ToLower(Table1.Name)
|
||||
|
||||
//чтение файлов
|
||||
DirBin := micro.ProgramDir_bin()
|
||||
DirTemplates := DirBin + constants.FolderTemplates + micro.SeparatorFile()
|
||||
DirReady := DirBin + constants.FolderReady + micro.SeparatorFile()
|
||||
DirTemplates := DirBin + config.Settings.TEMPLATE_FOLDERNAME + micro.SeparatorFile()
|
||||
DirReady := DirBin + config.Settings.READY_FOLDERNAME + micro.SeparatorFile()
|
||||
DirTemplatesDB := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_DB + micro.SeparatorFile()
|
||||
DirReadyDB := DirReady + "pkg" + micro.SeparatorFile() + "db" + micro.SeparatorFile()
|
||||
DirReadyDB := DirReady + config.Settings.TEMPLATE_FOLDERNAME_DB + micro.SeparatorFile()
|
||||
|
||||
FilenameTemplateDB := DirTemplatesDB + "db_test.go_"
|
||||
TableName := strings.ToLower(Table1.Name)
|
||||
DirTable := DirReadyDB + "db_" + TableName
|
||||
FilenameReadyDB := DirTable + micro.SeparatorFile() + "db_" + TableName + "_test.go"
|
||||
|
||||
|
@ -40,20 +40,20 @@ func CreateFiles(Table1 *types.Table) error {
|
||||
|
||||
//чтение файлов
|
||||
DirBin := micro.ProgramDir_bin()
|
||||
DirTemplates := DirBin + constants.FolderTemplates + micro.SeparatorFile()
|
||||
DirReady := DirBin + constants.FolderReady + micro.SeparatorFile()
|
||||
DirTemplatesGRPCClient := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_GRPC_CLIENT + micro.SeparatorFile()
|
||||
DirReadyGRPCClient := DirReady + "pkg" + micro.SeparatorFile() + "grpc" + micro.SeparatorFile() + "grpc_client" + micro.SeparatorFile()
|
||||
DirTemplates := DirBin + config.Settings.TEMPLATE_FOLDERNAME + micro.SeparatorFile()
|
||||
DirReady := DirBin + config.Settings.READY_FOLDERNAME + micro.SeparatorFile()
|
||||
DirTemplatesGRPCClient := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_GRPC + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_GRPC_CLIENT + micro.SeparatorFile()
|
||||
DirReadyGRPCClient := DirReady + config.Settings.TEMPLATE_FOLDERNAME_GRPC + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_GRPC_CLIENT + micro.SeparatorFile()
|
||||
|
||||
FilenameTemplateGRPCClient := DirTemplatesGRPCClient + "grpc_client.go_"
|
||||
TableName := strings.ToLower(Table1.Name)
|
||||
DirTable := DirReadyGRPCClient + TableName + micro.SeparatorFile()
|
||||
FilenameReadyGRPCClient := DirTable + TableName + ".go"
|
||||
DirTable := DirReadyGRPCClient + "grpc_" + TableName + micro.SeparatorFile()
|
||||
FilenameReadyGRPCClient := DirTable + "grpc_" + TableName + ".go"
|
||||
|
||||
//создадим каталог
|
||||
ok, err := micro.FileExists(DirTable)
|
||||
if ok == false {
|
||||
err = os.Mkdir(DirTable, 0777)
|
||||
err = os.MkdirAll(DirTable, 0777)
|
||||
if err != nil {
|
||||
log.Panic("Mkdir() ", DirTable, " error: ", err)
|
||||
}
|
||||
@ -91,15 +91,15 @@ func CreateTestFiles(Table1 *types.Table) error {
|
||||
|
||||
//чтение файлов
|
||||
DirBin := micro.ProgramDir_bin()
|
||||
DirTemplates := DirBin + constants.FolderTemplates + micro.SeparatorFile()
|
||||
DirReady := DirBin + constants.FolderReady + micro.SeparatorFile()
|
||||
DirTemplatesGRPCClient := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_GRPC_CLIENT + micro.SeparatorFile()
|
||||
DirReadyGRPCClient := DirReady + "pkg" + micro.SeparatorFile() + "grpc" + micro.SeparatorFile() + "grpc_client" + micro.SeparatorFile()
|
||||
DirTemplates := DirBin + config.Settings.TEMPLATE_FOLDERNAME + micro.SeparatorFile()
|
||||
DirReady := DirBin + config.Settings.READY_FOLDERNAME + micro.SeparatorFile()
|
||||
DirTemplatesGRPCClient := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_GRPC + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_GRPC_CLIENT + micro.SeparatorFile()
|
||||
DirReadyGRPCClient := DirReady + config.Settings.TEMPLATE_FOLDERNAME_GRPC + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_GRPC_CLIENT + micro.SeparatorFile()
|
||||
|
||||
FilenameTemplateGRPCClient := DirTemplatesGRPCClient + "grpc_client_test.go_"
|
||||
TableName := strings.ToLower(Table1.Name)
|
||||
DirTable := DirReadyGRPCClient + TableName + micro.SeparatorFile()
|
||||
FilenameReadyGRPCClient := DirTable + TableName + "_test.go"
|
||||
DirTable := DirReadyGRPCClient + "grpc_" + TableName + micro.SeparatorFile()
|
||||
FilenameReadyGRPCClient := DirTable + "grpc_" + TableName + "_test.go"
|
||||
|
||||
//создадим каталог
|
||||
ok, err := micro.FileExists(DirTable)
|
||||
|
@ -31,10 +31,10 @@ func CreateFileProto(MapAll map[string]*types.Table) error {
|
||||
|
||||
//чтение файлов
|
||||
DirBin := micro.ProgramDir_bin()
|
||||
DirTemplates := DirBin + constants.FolderTemplates + micro.SeparatorFile()
|
||||
DirReady := DirBin + constants.FolderReady + micro.SeparatorFile()
|
||||
DirTemplates := DirBin + config.Settings.TEMPLATE_FOLDERNAME + micro.SeparatorFile()
|
||||
DirReady := DirBin + config.Settings.READY_FOLDERNAME + micro.SeparatorFile()
|
||||
DirTemplatesProto := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_GRPC + micro.SeparatorFile()
|
||||
DirReadyProto := DirReady + "pkg" + micro.SeparatorFile() + "grpc" + micro.SeparatorFile()
|
||||
DirReadyProto := DirReady + config.Settings.TEMPLATE_FOLDERNAME_GRPC + micro.SeparatorFile()
|
||||
FilenameReadyProto := DirReadyProto + config.Settings.SERVICE_NAME + ".proto"
|
||||
|
||||
FilenameTemplateProto := DirTemplatesProto + "service.proto"
|
||||
|
@ -40,8 +40,8 @@ func CreateFiles(Table1 *types.Table) error {
|
||||
|
||||
//чтение файлов
|
||||
DirBin := micro.ProgramDir_bin()
|
||||
DirTemplates := DirBin + constants.FolderTemplates + micro.SeparatorFile()
|
||||
DirReady := DirBin + constants.FolderReady + micro.SeparatorFile()
|
||||
DirTemplates := DirBin + config.Settings.TEMPLATE_FOLDERNAME + micro.SeparatorFile()
|
||||
DirReady := DirBin + config.Settings.READY_FOLDERNAME + micro.SeparatorFile()
|
||||
DirTemplatesGRPCServer := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_GRPC_SERVER + micro.SeparatorFile()
|
||||
DirReadyGRPCServer := DirReady + "internal" + micro.SeparatorFile() + "grpc_server" + micro.SeparatorFile()
|
||||
|
||||
@ -82,8 +82,8 @@ func CreateTestFiles(Table1 *types.Table) error {
|
||||
|
||||
//чтение файлов
|
||||
DirBin := micro.ProgramDir_bin()
|
||||
DirTemplates := DirBin + constants.FolderTemplates + micro.SeparatorFile()
|
||||
DirReady := DirBin + constants.FolderReady + micro.SeparatorFile()
|
||||
DirTemplates := DirBin + config.Settings.TEMPLATE_FOLDERNAME + micro.SeparatorFile()
|
||||
DirReady := DirBin + config.Settings.READY_FOLDERNAME + micro.SeparatorFile()
|
||||
DirTemplatesGRPCServer := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_GRPC_SERVER + micro.SeparatorFile()
|
||||
DirReadyGRPCServer := DirReady + "internal" + micro.SeparatorFile() + "grpc_server" + micro.SeparatorFile()
|
||||
|
||||
|
@ -31,15 +31,26 @@ func CreateAllFiles(MapAll map[string]*types.Table) error {
|
||||
func CreateFiles(Table1 *types.Table) error {
|
||||
var err error
|
||||
|
||||
TableName := strings.ToLower(Table1.Name)
|
||||
|
||||
//чтение файлов
|
||||
DirBin := micro.ProgramDir_bin()
|
||||
DirTemplates := DirBin + constants.FolderTemplates + micro.SeparatorFile()
|
||||
DirReady := DirBin + constants.FolderReady + micro.SeparatorFile()
|
||||
DirTemplates := DirBin + config.Settings.TEMPLATE_FOLDERNAME + micro.SeparatorFile()
|
||||
DirReady := DirBin + config.Settings.READY_FOLDERNAME + micro.SeparatorFile()
|
||||
DirTemplatesModel := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_MODEL + micro.SeparatorFile()
|
||||
DirReadyModel := DirReady + "pkg" + micro.SeparatorFile() + "model" + micro.SeparatorFile()
|
||||
DirReadyModel := DirReady + config.Settings.TEMPLATE_FOLDERNAME_MODEL + micro.SeparatorFile() + TableName + micro.SeparatorFile()
|
||||
|
||||
FilenameTemplateModel := DirTemplatesModel + "model.go_"
|
||||
FilenameReadyModel := DirReadyModel + strings.ToLower(Table1.Name) + ".go"
|
||||
FilenameTemplateModel := DirTemplatesModel + "entities.go_"
|
||||
FilenameReadyModel := DirReadyModel + TableName + ".go"
|
||||
|
||||
//создадим каталог
|
||||
ok, err := micro.FileExists(DirReadyModel)
|
||||
if ok == false {
|
||||
err = os.MkdirAll(DirReadyModel, 0777)
|
||||
if err != nil {
|
||||
log.Panic("Mkdir() ", DirReadyModel, " error: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
bytes, err := os.ReadFile(FilenameTemplateModel)
|
||||
if err != nil {
|
||||
|
@ -40,20 +40,20 @@ func CreateFiles(Table1 *types.Table) error {
|
||||
|
||||
//чтение файлов
|
||||
DirBin := micro.ProgramDir_bin()
|
||||
DirTemplates := DirBin + constants.FolderTemplates + micro.SeparatorFile()
|
||||
DirReady := DirBin + constants.FolderReady + micro.SeparatorFile()
|
||||
DirTemplatesNRPCClient := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_NRPC_CLIENT + micro.SeparatorFile()
|
||||
DirReadyNRPCClient := DirReady + "pkg" + micro.SeparatorFile() + "nrpc" + micro.SeparatorFile() + "nrpc_client" + micro.SeparatorFile()
|
||||
DirTemplates := DirBin + config.Settings.TEMPLATE_FOLDERNAME + micro.SeparatorFile()
|
||||
DirReady := DirBin + config.Settings.READY_FOLDERNAME + micro.SeparatorFile()
|
||||
DirTemplatesNRPCClient := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_NRPC + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_NRPC_CLIENT + micro.SeparatorFile()
|
||||
DirReadyNRPCClient := DirReady + config.Settings.TEMPLATE_FOLDERNAME_NRPC + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_NRPC_CLIENT + micro.SeparatorFile()
|
||||
|
||||
FilenameTemplateNRPCClient := DirTemplatesNRPCClient + "nrpc_client.go_"
|
||||
TableName := strings.ToLower(Table1.Name)
|
||||
DirTable := DirReadyNRPCClient + TableName + micro.SeparatorFile()
|
||||
FilenameReadyNRPCClient := DirTable + TableName + ".go"
|
||||
DirTable := DirReadyNRPCClient + "nrpc_" + TableName + micro.SeparatorFile()
|
||||
FilenameReadyNRPCClient := DirTable + "nrpc_" + TableName + ".go"
|
||||
|
||||
//создадим каталог
|
||||
ok, err := micro.FileExists(DirTable)
|
||||
if ok == false {
|
||||
err = os.Mkdir(DirTable, 0777)
|
||||
err = os.MkdirAll(DirTable, 0777)
|
||||
if err != nil {
|
||||
log.Panic("Mkdir() ", DirTable, " error: ", err)
|
||||
}
|
||||
@ -91,20 +91,20 @@ func CreateTestFiles(Table1 *types.Table) error {
|
||||
|
||||
//чтение файлов
|
||||
DirBin := micro.ProgramDir_bin()
|
||||
DirTemplates := DirBin + constants.FolderTemplates + micro.SeparatorFile()
|
||||
DirReady := DirBin + constants.FolderReady + micro.SeparatorFile()
|
||||
DirTemplatesNRPCClient := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_NRPC_CLIENT + micro.SeparatorFile()
|
||||
DirReadyNRPCClient := DirReady + "pkg" + micro.SeparatorFile() + "nrpc" + micro.SeparatorFile() + "nrpc_client" + micro.SeparatorFile()
|
||||
DirTemplates := DirBin + config.Settings.TEMPLATE_FOLDERNAME + micro.SeparatorFile()
|
||||
DirReady := DirBin + config.Settings.READY_FOLDERNAME + micro.SeparatorFile()
|
||||
DirTemplatesNRPCClient := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_NRPC + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_NRPC_CLIENT + micro.SeparatorFile()
|
||||
DirReadyNRPCClient := DirReady + config.Settings.TEMPLATE_FOLDERNAME_NRPC + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_NRPC_CLIENT + micro.SeparatorFile()
|
||||
|
||||
FilenameTemplateNRPCClient := DirTemplatesNRPCClient + "nrpc_client_test.go_"
|
||||
TableName := strings.ToLower(Table1.Name)
|
||||
DirTable := DirReadyNRPCClient + TableName + micro.SeparatorFile()
|
||||
FilenameReadyNRPCClient := DirTable + TableName + "_test.go"
|
||||
DirTable := DirReadyNRPCClient + "nrpc_" + TableName + micro.SeparatorFile()
|
||||
FilenameReadyNRPCClient := DirTable + "nrpc_" + TableName + "_test.go"
|
||||
|
||||
//создадим каталог
|
||||
ok, err := micro.FileExists(DirTable)
|
||||
if ok == false {
|
||||
err = os.Mkdir(DirTable, 0777)
|
||||
err = os.MkdirAll(DirTable, 0777)
|
||||
if err != nil {
|
||||
log.Panic("Mkdir() ", DirTable, " error: ", err)
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ func CreateFolder(FilenameFull string, FilePermissions uint32) error {
|
||||
}
|
||||
|
||||
if _, err := os.Stat(FilenameFull); errors.Is(err, os.ErrNotExist) {
|
||||
err := os.Mkdir(FilenameFull, FileMode1)
|
||||
err := os.MkdirAll(FilenameFull, FileMode1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -72,18 +72,18 @@ func CreateAllFolders() {
|
||||
}
|
||||
|
||||
//
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + "pkg"
|
||||
ok, err = micro.FileExists(Filename)
|
||||
if ok == false || err != nil {
|
||||
err = CreateFolder(Filename, 0777)
|
||||
if err != nil {
|
||||
log.Panic("CreateFolder() ", Filename, " error: ", err)
|
||||
}
|
||||
log.Info("CreateFolder() ", Filename)
|
||||
}
|
||||
//Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + "pkg"
|
||||
//ok, err = micro.FileExists(Filename)
|
||||
//if ok == false || err != nil {
|
||||
// err = CreateFolder(Filename, 0777)
|
||||
// if err != nil {
|
||||
// log.Panic("CreateFolder() ", Filename, " error: ", err)
|
||||
// }
|
||||
// log.Info("CreateFolder() ", Filename)
|
||||
//}
|
||||
|
||||
//model
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + "pkg" + micro.SeparatorFile() + "model"
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_MODEL
|
||||
ok, err = micro.FileExists(Filename)
|
||||
if ok == false || err != nil {
|
||||
err = CreateFolder(Filename, 0777)
|
||||
@ -95,7 +95,7 @@ func CreateAllFolders() {
|
||||
|
||||
if config.Settings.NEED_CRUD == true {
|
||||
//db
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + "pkg" + micro.SeparatorFile() + "db"
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_DB
|
||||
ok, err = micro.FileExists(Filename)
|
||||
if ok == false || err != nil {
|
||||
err = CreateFolder(Filename, 0777)
|
||||
@ -106,7 +106,7 @@ func CreateAllFolders() {
|
||||
}
|
||||
|
||||
//crud_starter
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + "pkg" + micro.SeparatorFile() + "crud_starter"
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_CRUD_STARTER
|
||||
ok, err = micro.FileExists(Filename)
|
||||
if ok == false || err != nil {
|
||||
err = CreateFolder(Filename, 0777)
|
||||
@ -120,7 +120,7 @@ func CreateAllFolders() {
|
||||
|
||||
if config.Settings.NEED_GRPC == true {
|
||||
//
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + "pkg" + micro.SeparatorFile() + "grpc"
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_GRPC
|
||||
ok, err = micro.FileExists(Filename)
|
||||
if ok == false || err != nil {
|
||||
err = CreateFolder(Filename, 0777)
|
||||
@ -142,7 +142,7 @@ func CreateAllFolders() {
|
||||
}
|
||||
|
||||
//
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + "pkg" + micro.SeparatorFile() + "grpc" + micro.SeparatorFile() + "grpc_client"
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_GRPC + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_GRPC_CLIENT
|
||||
ok, err = micro.FileExists(Filename)
|
||||
if ok == false || err != nil {
|
||||
err = CreateFolder(Filename, 0777)
|
||||
@ -153,7 +153,7 @@ func CreateAllFolders() {
|
||||
}
|
||||
|
||||
//
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + "pkg" + micro.SeparatorFile() + "grpc" + micro.SeparatorFile() + "grpc_proto"
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_GRPC + micro.SeparatorFile() + "grpc_proto"
|
||||
ok, err = micro.FileExists(Filename)
|
||||
if ok == false || err != nil {
|
||||
err = CreateFolder(Filename, 0777)
|
||||
@ -166,7 +166,7 @@ func CreateAllFolders() {
|
||||
|
||||
if config.Settings.NEED_NRPC == true {
|
||||
//
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + "pkg" + micro.SeparatorFile() + "nrpc"
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_NRPC
|
||||
ok, err = micro.FileExists(Filename)
|
||||
if ok == false || err != nil {
|
||||
err = CreateFolder(Filename, 0777)
|
||||
@ -188,7 +188,7 @@ func CreateAllFolders() {
|
||||
}
|
||||
|
||||
//
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + "pkg" + micro.SeparatorFile() + "nrpc" + micro.SeparatorFile() + "nrpc_client"
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_NRPC + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_NRPC_CLIENT
|
||||
ok, err = micro.FileExists(Filename)
|
||||
if ok == false || err != nil {
|
||||
err = CreateFolder(Filename, 0777)
|
||||
@ -199,7 +199,7 @@ func CreateAllFolders() {
|
||||
}
|
||||
|
||||
//
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + "pkg" + micro.SeparatorFile() + "grpc" + micro.SeparatorFile() + "grpc_proto"
|
||||
Filename = dir + config.Settings.SERVICE_NAME + micro.SeparatorFile() + config.Settings.TEMPLATE_FOLDERNAME_GRPC + micro.SeparatorFile() + "grpc_proto"
|
||||
ok, err = micro.FileExists(Filename)
|
||||
if ok == false || err != nil {
|
||||
err = CreateFolder(Filename, 0777)
|
||||
|
Loading…
Reference in New Issue
Block a user