1
0
mirror of https://github.com/ManyakRus/crud_generator.git synced 2024-11-30 08:47:02 +02:00

сделал constants_

This commit is contained in:
Nikitin Aleksandr 2024-05-13 18:07:32 +03:00
parent 52eae99e07
commit c93a0ef977
16 changed files with 313 additions and 149 deletions

View File

@ -257,7 +257,7 @@
"sql_type": "timestamp", "sql_type": "timestamp",
"go_type": "time.Time", "go_type": "time.Time",
"json_type": "Text", "json_type": "Text",
"protobuf_type": "uint64", "protobuf_type": "google.protobuf.Timestamp",
"guregu_type": "null.Time", "guregu_type": "null.Time",
"go_nullable_type": "time.Time", "go_nullable_type": "time.Time",
"swagger_type": "time.Time" "swagger_type": "time.Time"
@ -266,7 +266,7 @@
"sql_type": "timestamptz", "sql_type": "timestamptz",
"go_type": "time.Time", "go_type": "time.Time",
"json_type": "Text", "json_type": "Text",
"protobuf_type": "uint64", "protobuf_type": "google.protobuf.Timestamp",
"guregu_type": "null.Time", "guregu_type": "null.Time",
"go_nullable_type": "time.Time", "go_nullable_type": "time.Time",
"swagger_type": "time.Time" "swagger_type": "time.Time"

View File

@ -7,6 +7,7 @@ import (
"github.com/ManyakRus/starter/contextmain" "github.com/ManyakRus/starter/contextmain"
"github.com/ManyakRus/starter/postgres_gorm" "github.com/ManyakRus/starter/postgres_gorm"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/api/grpc_proto" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/api/grpc_proto"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/db_constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
) )
@ -30,7 +31,7 @@ func (s *ServerGRPC) LawsuitStatusType_ReadFromCache(ctx context.Context, Reques
} }
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
//запрос в БД //запрос в БД

View File

@ -7,7 +7,7 @@ import (
"github.com/ManyakRus/starter/postgres_gorm" "github.com/ManyakRus/starter/postgres_gorm"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/api/grpc_proto" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/api/grpc_proto"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/db_constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/crud/crud_lawsuit_status_types" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/crud/crud_lawsuit_status_types"
"time" "time"
) )

View File

@ -18,7 +18,7 @@ func (s *ServerGRPC) LawsuitStatusType_Update(ctx context.Context, Request *grpc
} }
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
//запрос в БД //запрос в БД

View File

@ -5,7 +5,7 @@ import (
"time" "time"
"github.com/ManyakRus/starter/contextmain" "github.com/ManyakRus/starter/contextmain"
"github.com/hashicorp/golang-lru/v2/expirable" "github.com/hashicorp/golang-lru/v2/expirable"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/db_constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
"github.com/ManyakRus/starter/postgres_gorm" "github.com/ManyakRus/starter/postgres_gorm"
"gorm.io/gorm" "gorm.io/gorm"
@ -38,7 +38,7 @@ func (crud Crud_DB) ReadFromCache(ID int64) (lawsuit_status_types.LawsuitStatusT
// поищем в БД // поищем в БД
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()

View File

@ -7,7 +7,7 @@ import (
"github.com/ManyakRus/starter/contextmain" "github.com/ManyakRus/starter/contextmain"
"github.com/ManyakRus/starter/micro" "github.com/ManyakRus/starter/micro"
"github.com/ManyakRus/starter/postgres_gorm" "github.com/ManyakRus/starter/postgres_gorm"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/db_constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
"gorm.io/gorm" "gorm.io/gorm"
"time" "time"
@ -19,7 +19,7 @@ func (crud Crud_DB) UpdateManyFields(m *lawsuit_status_types.LawsuitStatusType,
var err error var err error
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()

View File

@ -3,7 +3,7 @@ func (crud Crud_DB) Read(m *lawsuit_status_types.LawsuitStatusType) error {
var err error var err error
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()

View File

@ -6,7 +6,7 @@ import (
"fmt" "fmt"
"github.com/ManyakRus/starter/micro" "github.com/ManyakRus/starter/micro"
"github.com/ManyakRus/starter/postgres_gorm" "github.com/ManyakRus/starter/postgres_gorm"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/db_constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
"time" "time"
"github.com/ManyakRus/starter/contextmain" "github.com/ManyakRus/starter/contextmain"
@ -26,7 +26,7 @@ func (crud Crud_DB) Read(m *lawsuit_status_types.LawsuitStatusType) error {
var err error var err error
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()
@ -60,7 +60,7 @@ func Read_ctx(ctx context.Context, db *gorm.DB, m *lawsuit_status_types.LawsuitS
// Save - записывает новый или существующий объект в базу данных // Save - записывает новый или существующий объект в базу данных
func (crud Crud_DB) Save(m *lawsuit_status_types.LawsuitStatusType) error { func (crud Crud_DB) Save(m *lawsuit_status_types.LawsuitStatusType) error {
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()
@ -84,7 +84,7 @@ func Save_ctx(ctx context.Context, db *gorm.DB, m *lawsuit_status_types.LawsuitS
// Update - записывает существующий объект в базу данных // Update - записывает существующий объект в базу данных
func (crud Crud_DB) Update(m *lawsuit_status_types.LawsuitStatusType) error { func (crud Crud_DB) Update(m *lawsuit_status_types.LawsuitStatusType) error {
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()
@ -115,7 +115,7 @@ func Update_ctx(ctx context.Context, db *gorm.DB, m *lawsuit_status_types.Lawsui
// Create - записывает новый объект в базу данных // Create - записывает новый объект в базу данных
func (crud Crud_DB) Create(m *lawsuit_status_types.LawsuitStatusType) error { func (crud Crud_DB) Create(m *lawsuit_status_types.LawsuitStatusType) error {
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()
@ -148,7 +148,7 @@ func (crud Crud_DB) create_update(m *lawsuit_status_types.LawsuitStatusType) err
var err error var err error
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()
@ -218,7 +218,7 @@ func (crud Crud_DB) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
var err error var err error
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()
@ -265,7 +265,7 @@ func (crud Crud_DB) Find_ByExtID(m *lawsuit_status_types.LawsuitStatusType) erro
// //
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()
@ -307,7 +307,7 @@ func (crud Crud_DB) Delete(m *lawsuit_status_types.LawsuitStatusType) error {
var err error var err error
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()

View File

@ -6,7 +6,7 @@ import (
"fmt" "fmt"
"github.com/ManyakRus/starter/micro" "github.com/ManyakRus/starter/micro"
"github.com/ManyakRus/starter/postgres_gorm" "github.com/ManyakRus/starter/postgres_gorm"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/db_constants"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
"time" "time"
"github.com/ManyakRus/starter/contextmain" "github.com/ManyakRus/starter/contextmain"
@ -26,7 +26,7 @@ func (crud Crud_DB) Read(m *lawsuit_status_types.LawsuitStatusType) error {
var err error var err error
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()
@ -60,7 +60,7 @@ func Read_ctx(ctx context.Context, db *gorm.DB, m *lawsuit_status_types.LawsuitS
// Save - записывает новый или существующий объект в базу данных // Save - записывает новый или существующий объект в базу данных
func (crud Crud_DB) Save(m *lawsuit_status_types.LawsuitStatusType) error { func (crud Crud_DB) Save(m *lawsuit_status_types.LawsuitStatusType) error {
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()
@ -84,7 +84,7 @@ func Save_ctx(ctx context.Context, db *gorm.DB, m *lawsuit_status_types.LawsuitS
// Update - записывает существующий объект в базу данных // Update - записывает существующий объект в базу данных
func (crud Crud_DB) Update(m *lawsuit_status_types.LawsuitStatusType) error { func (crud Crud_DB) Update(m *lawsuit_status_types.LawsuitStatusType) error {
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()
@ -115,7 +115,7 @@ func Update_ctx(ctx context.Context, db *gorm.DB, m *lawsuit_status_types.Lawsui
// Create - записывает новый объект в базу данных // Create - записывает новый объект в базу данных
func (crud Crud_DB) Create(m *lawsuit_status_types.LawsuitStatusType) error { func (crud Crud_DB) Create(m *lawsuit_status_types.LawsuitStatusType) error {
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()
@ -148,7 +148,7 @@ func (crud Crud_DB) create_update(m *lawsuit_status_types.LawsuitStatusType) err
var err error var err error
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()
@ -218,7 +218,7 @@ func (crud Crud_DB) Delete(m *lawsuit_status_types.LawsuitStatusType) error {
var err error var err error
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()
@ -259,7 +259,7 @@ func (crud Crud_DB) Restore(m *lawsuit_status_types.LawsuitStatusType) error {
var err error var err error
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()
@ -306,7 +306,7 @@ func (crud Crud_DB) Find_ByExtID(m *lawsuit_status_types.LawsuitStatusType) erro
// //
ctxMain := contextmain.GetContext() ctxMain := contextmain.GetContext()
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(constants.TIMEOUT_DB_SECONDS)) ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
defer ctxCancelFunc() defer ctxCancelFunc()
db := postgres_gorm.GetConnection() db := postgres_gorm.GetConnection()

View File

@ -1,4 +1,4 @@
package constants package db_constants
import ( import (
"errors" "errors"

View File

@ -5,7 +5,7 @@ import (
"github.com/vmihailenco/msgpack/v5" "github.com/vmihailenco/msgpack/v5"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/calc_struct_version" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/calc_struct_version"
"reflect" "reflect"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/db_constants"
) )
// versionLawsuitStatusType - версия структуры модели, с учётом имен и типов полей // versionLawsuitStatusType - версия структуры модели, с учётом имен и типов полей
@ -95,7 +95,7 @@ func (m LawsuitStatusType) GetJSON() (string, error) {
// Read - находит запись в БД по ID, и заполняет в объект // Read - находит запись в БД по ID, и заполняет в объект
func (m *LawsuitStatusType) Read() error { func (m *LawsuitStatusType) Read() error {
if Crud_LawsuitStatusType == nil { if Crud_LawsuitStatusType == nil {
return constants.ErrorCrudIsNotInit return db_constants.ErrorCrudIsNotInit
} }
err := Crud_LawsuitStatusType.Read(m) err := Crud_LawsuitStatusType.Read(m)
@ -106,7 +106,7 @@ func (m *LawsuitStatusType) Read() error {
// Save - записывает объект в БД по ID // Save - записывает объект в БД по ID
func (m *LawsuitStatusType) Save() error { func (m *LawsuitStatusType) Save() error {
if Crud_LawsuitStatusType == nil { if Crud_LawsuitStatusType == nil {
return constants.ErrorCrudIsNotInit return db_constants.ErrorCrudIsNotInit
} }
err := Crud_LawsuitStatusType.Save(m) err := Crud_LawsuitStatusType.Save(m)
@ -117,7 +117,7 @@ func (m *LawsuitStatusType) Save() error {
// Update - обновляет объект в БД по ID // Update - обновляет объект в БД по ID
func (m *LawsuitStatusType) Update() error { func (m *LawsuitStatusType) Update() error {
if Crud_LawsuitStatusType == nil { if Crud_LawsuitStatusType == nil {
return constants.ErrorCrudIsNotInit return db_constants.ErrorCrudIsNotInit
} }
err := Crud_LawsuitStatusType.Update(m) err := Crud_LawsuitStatusType.Update(m)
@ -128,7 +128,7 @@ func (m *LawsuitStatusType) Update() error {
// Create - создаёт объект в БД с новым ID // Create - создаёт объект в БД с новым ID
func (m *LawsuitStatusType) Create() error { func (m *LawsuitStatusType) Create() error {
if Crud_LawsuitStatusType == nil { if Crud_LawsuitStatusType == nil {
return constants.ErrorCrudIsNotInit return db_constants.ErrorCrudIsNotInit
} }
err := Crud_LawsuitStatusType.Create(m) err := Crud_LawsuitStatusType.Create(m)
@ -139,7 +139,7 @@ func (m *LawsuitStatusType) Create() error {
// Delete - устанавливает признак пометки удаления в БД // Delete - устанавливает признак пометки удаления в БД
func (m *LawsuitStatusType) Delete() error { func (m *LawsuitStatusType) Delete() error {
if Crud_LawsuitStatusType == nil { if Crud_LawsuitStatusType == nil {
return constants.ErrorCrudIsNotInit return db_constants.ErrorCrudIsNotInit
} }
err := Crud_LawsuitStatusType.Delete(m) err := Crud_LawsuitStatusType.Delete(m)
@ -150,7 +150,7 @@ func (m *LawsuitStatusType) Delete() error {
// Restore - снимает признак пометки удаления в БД // Restore - снимает признак пометки удаления в БД
func (m *LawsuitStatusType) Restore() error { func (m *LawsuitStatusType) Restore() error {
if Crud_LawsuitStatusType == nil { if Crud_LawsuitStatusType == nil {
return constants.ErrorCrudIsNotInit return db_constants.ErrorCrudIsNotInit
} }
err := Crud_LawsuitStatusType.Restore(m) err := Crud_LawsuitStatusType.Restore(m)
@ -161,7 +161,7 @@ func (m *LawsuitStatusType) Restore() error {
// Find_ByExtID - находит объект по ExtID // Find_ByExtID - находит объект по ExtID
func (m *LawsuitStatusType) Find_ByExtID() error { func (m *LawsuitStatusType) Find_ByExtID() error {
if Crud_LawsuitStatusType == nil { if Crud_LawsuitStatusType == nil {
return constants.ErrorCrudIsNotInit return db_constants.ErrorCrudIsNotInit
} }
err := Crud_LawsuitStatusType.Find_ByExtID(m) err := Crud_LawsuitStatusType.Find_ByExtID(m)
@ -175,7 +175,7 @@ func (m *LawsuitStatusType) ReadFromCache(ID int64) (LawsuitStatusType, error) {
var err error var err error
if Crud_LawsuitStatusType == nil { if Crud_LawsuitStatusType == nil {
return Otvet, constants.ErrorCrudIsNotInit return Otvet, db_constants.ErrorCrudIsNotInit
} }
Otvet, err = Crud_LawsuitStatusType.ReadFromCache(ID) Otvet, err = Crud_LawsuitStatusType.ReadFromCache(ID)
@ -193,7 +193,7 @@ func (m LawsuitStatusType) SetCrudInterface(crud ICrud_LawsuitStatusType) {
// UpdateManyFields - находит запись в БД по ID, и изменяет только нужные колонки // UpdateManyFields - находит запись в БД по ID, и изменяет только нужные колонки
func (m *LawsuitStatusType) UpdateManyFields(MassNeedUpdateFields []string) error { func (m *LawsuitStatusType) UpdateManyFields(MassNeedUpdateFields []string) error {
if Crud_LawsuitStatusType == nil { if Crud_LawsuitStatusType == nil {
return constants.ErrorCrudIsNotInit return db_constants.ErrorCrudIsNotInit
} }
err := Crud_LawsuitStatusType.UpdateManyFields(m, MassNeedUpdateFields) err := Crud_LawsuitStatusType.UpdateManyFields(m, MassNeedUpdateFields)

View File

@ -1,6 +1,6 @@
package lawsuit_status_types package lawsuit_status_types
import ( import (
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/db_constants"
) )

View File

@ -1266,10 +1266,11 @@ func AddInterfaceFunction(s, TextAdd string) string {
} }
// FindTextProtobufRequest - возвращает "RequestID" и "ID" - имя message из .proto, в зависимости от типа, а также название поля // FindTextProtobufRequest - возвращает "RequestID" и "ID" - имя message из .proto, в зависимости от типа, а также название поля
func FindTextProtobufRequest(Table1 *types.Table, TypeGo string) (string, string) { func FindTextProtobufRequest(Table1 *types.Table) (string, string) {
Otvet := "RequestId" Otvet := ""
TextRequestFieldName := "ID" TextRequestFieldName := ""
TextRequest := "Request"
TextRequest := "Request_"
PrimaryKeyColumn := FindPrimaryKeyColumn(Table1) PrimaryKeyColumn := FindPrimaryKeyColumn(Table1)
if PrimaryKeyColumn == nil { if PrimaryKeyColumn == nil {
@ -1277,60 +1278,74 @@ func FindTextProtobufRequest(Table1 *types.Table, TypeGo string) (string, string
} }
PrimaryKeyTypeGo := PrimaryKeyColumn.TypeGo PrimaryKeyTypeGo := PrimaryKeyColumn.TypeGo
//switch PrimaryKeyTypeGo {
//case "string", "uuid.UUID":
// TextRequest = "Request"
//}
TextRequestFieldName = PrimaryKeyColumn.TypeGo
TextRequestFieldName = micro.StringFromUpperCase(TextRequestFieldName)
Otvet = TextRequest + TextRequestFieldName
switch PrimaryKeyTypeGo { switch PrimaryKeyTypeGo {
case "string", "uuid.UUID": case "string", "uuid.UUID":
TextRequest = "Request" TextRequestFieldName = "String_1"
} Otvet = TextRequest + "String"
switch TypeGo {
case "int", "int64":
{
if PrimaryKeyTypeGo == "int64" {
Otvet = TextRequest + "Id"
TextRequestFieldName = "ID"
} else {
Otvet = TextRequest + "Int64"
TextRequestFieldName = "Int64"
}
}
case "int32":
{
Otvet = TextRequest + "Int32"
TextRequestFieldName = "Int32"
}
case "string":
{
Otvet = TextRequest + "String"
TextRequestFieldName = "String_1"
}
case "uuid.UUID":
{
Otvet = TextRequest + "String"
TextRequestFieldName = "String_1"
}
case "time.Time": case "time.Time":
{ TextRequestFieldName = "Date"
Otvet = TextRequest + "Date" Otvet = TextRequest + "Date"
TextRequestFieldName = "Date"
}
case "float32":
{
Otvet = TextRequest + "Float32"
TextRequestFieldName = "Float32"
}
case "float64":
{
Otvet = TextRequest + "Float64"
TextRequestFieldName = "Float64"
}
case "bool":
{
Otvet = TextRequest + "Bool"
TextRequestFieldName = "Bool"
}
} }
//switch TypeGo {
//case "int", "int64":
// {
// if PrimaryKeyTypeGo == "int64" {
// Otvet = TextRequest + "Id"
// TextRequestFieldName = "ID"
// } else {
// Otvet = TextRequest + "Int64"
// TextRequestFieldName = "Int64"
// }
// }
//
//case "int32":
// {
// Otvet = TextRequest + "Int32"
// TextRequestFieldName = "Int32"
// }
//case "string":
// {
// Otvet = TextRequest + "String"
// TextRequestFieldName = "String_1"
// }
//case "uuid.UUID":
// {
// Otvet = TextRequest + "String"
// TextRequestFieldName = "String_1"
// }
//case "time.Time":
// {
// Otvet = TextRequest + "Date"
// TextRequestFieldName = "Date"
// }
//case "float32":
// {
// Otvet = TextRequest + "Float32"
// TextRequestFieldName = "Float32"
// }
//case "float64":
// {
// Otvet = TextRequest + "Float64"
// TextRequestFieldName = "Float64"
// }
//case "bool":
// {
// Otvet = TextRequest + "Bool"
// TextRequestFieldName = "Bool"
// }
//}
return Otvet, TextRequestFieldName return Otvet, TextRequestFieldName
} }
@ -1412,7 +1427,7 @@ func FindTextProtobufRequest_ID_Type(Table1 *types.Table, Column1 *types.Column,
PrimaryKey_TypeGo := PrimaryKeyColumn.TypeGo PrimaryKey_TypeGo := PrimaryKeyColumn.TypeGo
//Text_Request_ID := "Request_ID" //Text_Request_ID := "Request_ID"
Otvet, _ = FindTextProtobufRequest(Table1, PrimaryKey_TypeGo) Otvet, _ = FindTextProtobufRequest(Table1)
//Text_Request_ID = "Request_" + TextID //Text_Request_ID = "Request_" + TextID
TextRequestProtoName := "" TextRequestProtoName := ""
@ -1423,44 +1438,34 @@ func FindTextProtobufRequest_ID_Type(Table1 *types.Table, Column1 *types.Column,
{ {
TextRequestProtoName = "Int64" TextRequestProtoName = "Int64"
TextRequestFieldName = "Int64" TextRequestFieldName = "Int64"
TextRequestFieldGolang = VariableName + "Int64" if PrimaryKey_TypeGo == "int64" {
TextRequestFieldName = "Int64_2"
}
TextRequestFieldGolang = VariableName + TextRequestFieldName
} }
case "int32": case "int32":
{ {
if Column1.TypeGo == "Int32" && PrimaryKeyColumn.TypeGo == "Int32" { TextRequestProtoName = "Int32"
TextRequestProtoName = "Int32" TextRequestFieldName = "Int32"
if PrimaryKey_TypeGo == "int32" {
TextRequestFieldName = "Int32_2" TextRequestFieldName = "Int32_2"
TextRequestFieldGolang = VariableName + "Int32"
} else {
TextRequestProtoName = "Int32"
TextRequestFieldName = "Int32"
TextRequestFieldGolang = VariableName + "Int32"
} }
TextRequestFieldGolang = VariableName + TextRequestFieldName
} }
case "string": case "string":
{ {
if Column1.TypeGo == "string" && PrimaryKeyColumn.TypeGo == "string" { TextRequestProtoName = "String"
TextRequestProtoName = "String" TextRequestFieldName = "String_1"
if PrimaryKey_TypeGo == "string" || PrimaryKey_TypeGo == "uuid.UUID" {
TextRequestFieldName = "String_2" TextRequestFieldName = "String_2"
TextRequestFieldGolang = VariableName + "String_2"
} else {
TextRequestProtoName = "String"
TextRequestFieldName = "String_1"
TextRequestFieldGolang = VariableName + "String_1"
} }
TextRequestFieldGolang = VariableName + TextRequestFieldName
} }
case "uuid.UUID": case "uuid.UUID":
{ {
if PrimaryKeyColumn.TypeGo == "string" || PrimaryKeyColumn.TypeGo == "uuid.UUID" { TextRequestProtoName = "String"
TextRequestProtoName = "String" TextRequestFieldName = "String_1"
TextRequestFieldName = "String_2"
TextRequestFieldGolang = VariableName + "String_2"
} else {
TextRequestProtoName = "String"
TextRequestFieldName = "String_1"
TextRequestFieldGolang = VariableName + "String_1"
}
TextGolangLine = "value, err := uuid.Parse(" + VariableName + "" + TextRequestFieldName + ")" + ` TextGolangLine = "value, err := uuid.Parse(" + VariableName + "" + TextRequestFieldName + ")" + `
if Request.` + TextRequestFieldName + ` == "" { if Request.` + TextRequestFieldName + ` == "" {
value = uuid.Nil value = uuid.Nil
@ -1470,30 +1475,46 @@ func FindTextProtobufRequest_ID_Type(Table1 *types.Table, Column1 *types.Column,
return &Otvet, err return &Otvet, err
} }
` `
if PrimaryKey_TypeGo == "string" || PrimaryKey_TypeGo == "uuid.UUID" {
TextRequestFieldName = "String_2"
}
TextRequestFieldGolang = VariableName + TextRequestFieldName
} }
case "time.Time": case "time.Time":
{ {
TextRequestProtoName = "Date" TextRequestProtoName = "Date"
TextRequestFieldName = "Date" TextRequestFieldName = "Date"
TextRequestFieldGolang = VariableName + "Date.AsTime()" if PrimaryKey_TypeGo == "time.Time" {
TextRequestFieldName = "Date_2"
}
TextRequestFieldGolang = VariableName + TextRequestFieldName + ".AsTime()"
} }
case "float32": case "float32":
{ {
TextRequestProtoName = "Float32" TextRequestProtoName = "Float32"
TextRequestFieldName = "Float32" TextRequestFieldName = "Float32"
TextRequestFieldGolang = VariableName + "Float32" if PrimaryKey_TypeGo == "float32" {
TextRequestFieldName = "Float32_2"
}
TextRequestFieldGolang = VariableName + TextRequestFieldName
} }
case "float64": case "float64":
{ {
TextRequestProtoName = "Float64" TextRequestProtoName = "Float64"
TextRequestFieldName = "Float64" TextRequestFieldName = "Float64"
TextRequestFieldGolang = VariableName + "Float64" if PrimaryKey_TypeGo == "float64" {
TextRequestFieldName = "Float64_2"
}
TextRequestFieldGolang = VariableName + TextRequestFieldName
} }
case "bool": case "bool":
{ {
TextRequestProtoName = "Bool" TextRequestProtoName = "Bool"
TextRequestFieldName = "Bool" TextRequestFieldName = "Bool"
TextRequestFieldGolang = VariableName + "Bool" if PrimaryKey_TypeGo == "bool" {
TextRequestFieldName = "Bool_2"
}
TextRequestFieldGolang = VariableName + TextRequestFieldName
} }
} }
@ -1797,14 +1818,23 @@ func Replace_Postgres_ID_Test(Text string, Table1 *types.Table) string {
IDMinimum = FindTextDefaultValue(PrimaryKeyColumn.TypeGo) IDMinimum = FindTextDefaultValue(PrimaryKeyColumn.TypeGo)
} }
if PrimaryKeyColumn.TypeGo == "uuid.UUID" { switch PrimaryKeyColumn.TypeGo {
if Table1.IDMinimum == "" { case "uuid.UUID":
Otvet = strings.ReplaceAll(Otvet, TextFind, `var Postgres_ID_Test = `+IDMinimum+``) {
} else { if Table1.IDMinimum == "" {
Otvet = strings.ReplaceAll(Otvet, TextFind, `var Postgres_ID_Test, _ = uuid.Parse("`+IDMinimum+`")`) Otvet = strings.ReplaceAll(Otvet, TextFind, `var Postgres_ID_Test = `+IDMinimum+``)
} else {
Otvet = strings.ReplaceAll(Otvet, TextFind, `var Postgres_ID_Test, _ = uuid.Parse("`+IDMinimum+`")`)
}
}
case "string":
{
Otvet = strings.ReplaceAll(Otvet, TextFind, `const Postgres_ID_Test = "`+IDMinimum+`"`)
}
default:
{
Otvet = strings.ReplaceAll(Otvet, TextFind, "const Postgres_ID_Test = "+IDMinimum)
} }
} else {
Otvet = strings.ReplaceAll(Otvet, TextFind, "const Postgres_ID_Test = "+IDMinimum)
} }
return Otvet return Otvet
@ -1828,15 +1858,24 @@ func Replace_Model_ID_Test(Text string, Table1 *types.Table) string {
} }
DefaultModelName := config.Settings.TEXT_TEMPLATE_MODEL DefaultModelName := config.Settings.TEXT_TEMPLATE_MODEL
if PrimaryKeyColumn.TypeGo == "uuid.UUID" { switch PrimaryKeyColumn.TypeGo {
if Table1.IDMinimum == "" { case "uuid.UUID":
Otvet = strings.ReplaceAll(Otvet, TextFind, `var `+ModelName+`_ID_Test = `+IDMinimum+``) {
} else { if Table1.IDMinimum == "" {
Otvet = strings.ReplaceAll(Otvet, TextFind, `var `+ModelName+`_ID_Test, _ = uuid.Parse("`+IDMinimum+`")`) Otvet = strings.ReplaceAll(Otvet, TextFind, `var `+ModelName+`_ID_Test = `+IDMinimum+``)
} else {
Otvet = strings.ReplaceAll(Otvet, TextFind, `var `+ModelName+`_ID_Test, _ = uuid.Parse("`+IDMinimum+`")`)
}
Otvet = strings.ReplaceAll(Otvet, ``+DefaultModelName+`_ID_Test`, ``+ModelName+`_ID_Test.String()`)
}
case "string":
{
Otvet = strings.ReplaceAll(Otvet, TextFind, `const `+ModelName+`_ID_Test = "`+IDMinimum+`"`)
}
default:
{
Otvet = strings.ReplaceAll(Otvet, TextFind, `const `+ModelName+`_ID_Test = `+IDMinimum)
} }
Otvet = strings.ReplaceAll(Otvet, ``+DefaultModelName+`_ID_Test`, ``+ModelName+`_ID_Test.String()`)
} else {
Otvet = strings.ReplaceAll(Otvet, TextFind, `const `+ModelName+`_ID_Test = `+IDMinimum)
} }
return Otvet return Otvet
@ -1877,9 +1916,9 @@ func ReplaceTextRequestID_PrimaryKey1(Text string, Table1 *types.Table, TextRequ
return Otvet return Otvet
} }
TypeGo := PrimaryKeyColumn.TypeGo //TypeGo := PrimaryKeyColumn.TypeGo
TextRequestID, TextID := FindTextProtobufRequest(Table1, TypeGo) TextRequestID, TextID := FindTextProtobufRequest(Table1)
_, GolangCode := FindTextConvertProtobufTypeToGolangType(Table1, PrimaryKeyColumn, "Request.") _, GolangCode := FindTextConvertProtobufTypeToGolangType(Table1, PrimaryKeyColumn, "Request.")
if GolangCode != "" { if GolangCode != "" {
@ -1960,7 +1999,7 @@ func FindNegativeValue(TypeGo string) string {
func FindRequestColumnName(Table1 *types.Table, Column1 *types.Column) string { func FindRequestColumnName(Table1 *types.Table, Column1 *types.Column) string {
Otvet := "" Otvet := ""
_, Otvet = FindTextProtobufRequest(Table1, Column1.TypeGo) _, Otvet = FindTextProtobufRequest(Table1)
return Otvet return Otvet
} }

View File

@ -631,7 +631,7 @@ func FindTextUpdateEveryColumn1(TextCrudUpdateFunc string, Table1 *types.Table,
ModelName := Table1.NameGo ModelName := Table1.NameGo
ColumnName := Column1.NameGo ColumnName := Column1.NameGo
FuncName := "Update_" + ColumnName FuncName := "Update_" + ColumnName
TextRequest, TextRequestFieldName := create_files.FindTextProtobufRequest(Table1, Column1.TypeGo) TextRequest, TextRequestFieldName := create_files.FindTextProtobufRequest(Table1)
//запись null в nullable колонки //запись null в nullable колонки
if Column1.IsNullable == true && (Column1.TableKey != "" || Column1.TypeGo == "time.Time") { if Column1.IsNullable == true && (Column1.TableKey != "" || Column1.TypeGo == "time.Time") {
@ -795,7 +795,7 @@ func FindTextUpdateEveryColumnTest1(TextCrudUpdateFunc string, Table1 *types.Tab
ModelName := Table1.NameGo ModelName := Table1.NameGo
ColumnName := Column1.NameGo ColumnName := Column1.NameGo
FuncName := "Update_" + ColumnName FuncName := "Update_" + ColumnName
TextRequest, TextRequestFieldName := create_files.FindTextProtobufRequest(Table1, Column1.TypeGo) TextRequest, TextRequestFieldName := create_files.FindTextProtobufRequest(Table1)
DefaultValue := create_files.FindTextDefaultValue(Column1.TypeGo) DefaultValue := create_files.FindTextDefaultValue(Column1.TypeGo)
Otvet = create_files.ReplacePrimaryKeyM_ID(Otvet, Table1) Otvet = create_files.ReplacePrimaryKeyM_ID(Otvet, Table1)

View File

@ -631,7 +631,7 @@ func FindTextUpdateEveryColumn(Table1 *types.Table, Column1 *types.Column) strin
// Update_` + ColumnName + ` - изменяет объект в БД по ID, присваивает ` + ColumnName + ` // Update_` + ColumnName + ` - изменяет объект в БД по ID, присваивает ` + ColumnName + `
func (m *` + ModelName + `) Update_` + ColumnName + `() error { func (m *` + ModelName + `) Update_` + ColumnName + `() error {
if Crud_` + ModelName + ` == nil { if Crud_` + ModelName + ` == nil {
return constants.ErrorCrudIsNotInit return db_constants.ErrorCrudIsNotInit
} }
err := Crud_` + ModelName + `.Update_` + ColumnName + `(m) err := Crud_` + ModelName + `.Update_` + ColumnName + `(m)

View File

@ -6,6 +6,7 @@ import (
"github.com/ManyakRus/crud_generator/internal/create_files" "github.com/ManyakRus/crud_generator/internal/create_files"
"github.com/ManyakRus/crud_generator/internal/folders" "github.com/ManyakRus/crud_generator/internal/folders"
"github.com/ManyakRus/crud_generator/internal/types" "github.com/ManyakRus/crud_generator/internal/types"
"github.com/ManyakRus/crud_generator/pkg/dbmeta"
"github.com/ManyakRus/starter/log" "github.com/ManyakRus/starter/log"
"github.com/ManyakRus/starter/micro" "github.com/ManyakRus/starter/micro"
"os" "os"
@ -89,6 +90,7 @@ func CreateFileProto(MapAll map[string]*types.Table) error {
if config.Settings.NEED_CREATE_CACHE_API == true { if config.Settings.NEED_CREATE_CACHE_API == true {
TextProtoNew = TextProtoNew + FindTextProtoTable1_Cache(TextProto, Table1) TextProtoNew = TextProtoNew + FindTextProtoTable1_Cache(TextProto, Table1)
} }
TextProto = AddTextMessageRequestID(TextProto, Table1)
} }
//найдём куда вставить текст //найдём куда вставить текст
@ -135,6 +137,8 @@ func FindTextProtoTable1(TextProto string, Table1 *types.Table) string {
Otvet := "\n" //"\n\t//\n" Otvet := "\n" //"\n\t//\n"
ModelName := Table1.NameGo ModelName := Table1.NameGo
//Otvet = Otvet + AddTextMessageRequestID(TextProto, Table1)
Otvet = Otvet + FindTextRead(TextProto, Table1) Otvet = Otvet + FindTextRead(TextProto, Table1)
Otvet = Otvet + FindTextCreate(TextProto, ModelName) Otvet = Otvet + FindTextCreate(TextProto, ModelName)
Otvet = Otvet + FindTextUpdate(TextProto, ModelName) Otvet = Otvet + FindTextUpdate(TextProto, ModelName)
@ -276,9 +280,7 @@ func TextRead(Table1 *types.Table) string {
return Otvet return Otvet
} }
TypeGo := PrimaryKeyColumn.TypeGo TextRequest, _ := create_files.FindTextProtobufRequest(Table1)
TextRequest := "RequestId"
TextRequest, _ = create_files.FindTextProtobufRequest(Table1, TypeGo)
Otvet = "rpc " + ModelName + "_Read(" + TextRequest + ") returns (Response) {}" Otvet = "rpc " + ModelName + "_Read(" + TextRequest + ") returns (Response) {}"
return Otvet return Otvet
@ -332,14 +334,14 @@ func FindTextProtoTable1_UpdateEveryColumn(TextProto string, Table1 *types.Table
//ModelName := Table1.NameGo //ModelName := Table1.NameGo
//сортировка по названию таблиц //сортировка по названию колонок
keys := make([]string, 0, len(Table1.MapColumns)) keys := make([]string, 0, len(Table1.MapColumns))
for k := range Table1.MapColumns { for k := range Table1.MapColumns {
keys = append(keys, k) keys = append(keys, k)
} }
sort.Strings(keys) sort.Strings(keys)
//найдём новый текст для каждой таблицы //найдём новый текст для каждой колонки
for _, key1 := range keys { for _, key1 := range keys {
Column1, ok := Table1.MapColumns[key1] Column1, ok := Table1.MapColumns[key1]
if ok == false { if ok == false {
@ -368,6 +370,9 @@ func FindTextUpdateEveryColumn(TextProto string, Table1 *types.Table, Column1 *t
Otvet := "" Otvet := ""
Otvet2 := TextUpdateEveryColumn(Table1, Column1) Otvet2 := TextUpdateEveryColumn(Table1, Column1)
//добавим текст message RequestId_Float64 {
//Otvet = Otvet + AddTextMessageRequestID_ColumnType(TextProto, Table1, Column1)
//проверка такой текст уже есть //проверка такой текст уже есть
pos1 := strings.Index(TextProto, Otvet2) pos1 := strings.Index(TextProto, Otvet2)
if pos1 >= 0 { if pos1 >= 0 {
@ -430,7 +435,7 @@ func TextReadFromCache(Table1 *types.Table) string {
return Otvet return Otvet
} }
TextRequestId, _ := create_files.FindTextProtobufRequest(Table1, PrimaryKeyColumn.TypeGo) TextRequestId, _ := create_files.FindTextProtobufRequest(Table1)
ModelName := Table1.NameGo ModelName := Table1.NameGo
Otvet = "rpc " + ModelName + "_ReadFromCache(" + TextRequestId + ") returns (Response) {}" Otvet = "rpc " + ModelName + "_ReadFromCache(" + TextRequestId + ") returns (Response) {}"
@ -469,3 +474,122 @@ func TextUpdateManyFields(ModelName string) string {
return Otvet return Otvet
} }
// AddTextMessageRequestID - в текст .proto добавляет message с RequestID
func AddTextMessageRequestID1(Text string, Table1 *types.Table) string {
Otvet := Text
//найдём текст RequestID
PrimaryKeyColumn := create_files.FindPrimaryKeyColumn(Table1)
if PrimaryKeyColumn == nil {
return Otvet
}
TextRequest, TextFieldName := create_files.FindTextProtobufRequest(Table1)
//найдём уже есть message
TextFind := "message " + TextRequest + " {"
pos1 := strings.Index(Otvet, TextFind)
if pos1 >= 0 {
return Otvet
}
//найдём ProtobufTypePK
MappingPK, ok := dbmeta.GetMappings()[PrimaryKeyColumn.Type]
if ok == false {
log.Error("Неизвестный тип столбца " + PrimaryKeyColumn.Type)
return Otvet
}
ProtobufTypePK := MappingPK.ProtobufType
//добавим message
TextMessage := `
// ` + TextRequest + ` - параметры запроса на сервер
message ` + TextRequest + ` {
uint32 VersionModel= 1; //версия структуры модели
` + ProtobufTypePK + ` ` + TextFieldName + ` = 2; // id записи в БД
}
`
Otvet = Otvet + TextMessage
return Otvet
}
// AddTextMessageRequestID_ColumnType - в текст .proto добавляет message с RequestID_Int64
func AddTextMessageRequestID_ColumnType(Text string, Table1 *types.Table, Column1 *types.Column) string {
Otvet := Text
//найдём текст RequestID
PrimaryKeyColumn := create_files.FindPrimaryKeyColumn(Table1)
if PrimaryKeyColumn == nil {
return Otvet
}
//
_, FieldNamePK := create_files.FindTextProtobufRequest(Table1)
TextRequest, FieldName, _, _ := create_files.FindTextProtobufRequest_ID_Type(Table1, Column1, "_")
//найдём уже есть message
TextFind := "message " + TextRequest + " {"
pos1 := strings.Index(Otvet, TextFind)
if pos1 >= 0 {
return Otvet
}
//найдём ProtobufTypePK
MappingPK, ok := dbmeta.GetMappings()[PrimaryKeyColumn.Type]
if ok == false {
log.Error("Неизвестный тип столбца " + PrimaryKeyColumn.Type)
return Otvet
}
ProtobufTypePK := MappingPK.ProtobufType
//найдём ProtobufTypeColumn
Mapping1, ok := dbmeta.GetMappings()[Column1.Type]
if ok == false {
log.Error("Неизвестный тип столбца " + Column1.Type)
return Otvet
}
ProtobufTypeColumn := Mapping1.ProtobufType
//добавим message
TextMessage := `
// ` + TextRequest + ` - параметры запроса на сервер
message ` + TextRequest + ` {
uint32 VersionModel= 1; //версия структуры модели
` + ProtobufTypePK + ` ` + FieldNamePK + ` = 2; // id записи в БД
` + ProtobufTypeColumn + ` ` + FieldName + ` = 3; // значение поиска
}
`
Otvet = Otvet + TextMessage
return Otvet
}
// AddTextMessageRequestID - возвращает текст в.proto для таблицы
func AddTextMessageRequestID(TextProto string, Table1 *types.Table) string {
Otvet := TextProto //"\n\t//\n"
Otvet = AddTextMessageRequestID1(Otvet, Table1)
//сортировка по названию колонок
keys := make([]string, 0, len(Table1.MapColumns))
for k := range Table1.MapColumns {
keys = append(keys, k)
}
sort.Strings(keys)
//для каждой колонки добавим добавим message RequestId_Int64
for _, key1 := range keys {
Column1, ok := Table1.MapColumns[key1]
if ok == false {
log.Panic("FindTextProtoTable1_UpdateEveryColumn() Table1.MapColumns[key1] = false")
}
Otvet = AddTextMessageRequestID_ColumnType(Otvet, Table1, Column1)
}
return Otvet
}