1
0
mirror of https://github.com/ManyakRus/crud_generator.git synced 2025-02-03 09:57:21 +02:00

сделал find_by_functions.json

This commit is contained in:
Nikitin Aleksandr 2024-09-05 13:40:08 +03:00
parent e72cfee99f
commit d14e8877a5
6 changed files with 41 additions and 18 deletions

View File

@ -12,7 +12,7 @@ func TestReadFromCache(t *testing.T) {
grpc_client.Connect()
defer grpc_client.CloseConnection()
crud := Crud_GRPC{}
crud := grpc_lawsuit_status_types.Crud_GRPC{}
Otvet := lawsuit_status_types.LawsuitStatusType{}
Otvet, err := crud.ReadFromCache(Postgres_ID_Test)

View File

@ -3,6 +3,7 @@ package grpc_lawsuit_status_types
import (
"github.com/ManyakRus/starter/config_main"
"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/grpc_lawsuit_status_types"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/lawsuit_status_types"
"testing"
)
@ -12,7 +13,7 @@ const Postgres_ID_Test = 0
func TestGetVersionModel(t *testing.T) {
crud := Crud_GRPC{}
crud := grpc_lawsuit_status_types.Crud_GRPC{}
Otvet := crud.GetVersionModel()
if Otvet == 0 {
t.Error("TestGetVersionModel() error: Otvet =0")
@ -24,7 +25,7 @@ func TestRead(t *testing.T) {
grpc_client.Connect()
defer grpc_client.CloseConnection()
crud := Crud_GRPC{}
crud := grpc_lawsuit_status_types.Crud_GRPC{}
Otvet := lawsuit_status_types.LawsuitStatusType{}
Otvet.ID = Postgres_ID_Test
err := crud.Read(&Otvet)
@ -46,7 +47,7 @@ func TestCreate(t *testing.T) {
Otvet := lawsuit_status_types.LawsuitStatusType{}
Otvet.ID = -1
crud := Crud_GRPC{}
crud := grpc_lawsuit_status_types.Crud_GRPC{}
err := crud.Create(&Otvet)
if err == nil {
@ -63,7 +64,7 @@ func TestUpdate(t *testing.T) {
Otvet := lawsuit_status_types.LawsuitStatusType{}
Otvet.ID = 0
crud := Crud_GRPC{}
crud := grpc_lawsuit_status_types.Crud_GRPC{}
err := crud.Update(&Otvet)
if err == nil {
@ -80,7 +81,7 @@ func TestSave(t *testing.T) {
grpc_client.Connect()
defer grpc_client.CloseConnection()
crud := Crud_GRPC{}
crud := grpc_lawsuit_status_types.Crud_GRPC{}
Otvet := lawsuit_status_types.LawsuitStatusType{}
Otvet.ID = Postgres_ID_Test
err := crud.Read(&Otvet)
@ -105,7 +106,7 @@ func TestDelete(t *testing.T) {
grpc_client.Connect()
defer grpc_client.CloseConnection()
crud := Crud_GRPC{}
crud := grpc_lawsuit_status_types.Crud_GRPC{}
Otvet := lawsuit_status_types.LawsuitStatusType{}
Otvet.ID = Postgres_ID_Test
err := crud.Read(&Otvet)
@ -153,7 +154,7 @@ func TestFindByExtID(t *testing.T) {
grpc_client.Connect()
defer grpc_client.CloseConnection()
crud := Crud_GRPC{}
crud := grpc_lawsuit_status_types.Crud_GRPC{}
Otvet1 := lawsuit_status_types.LawsuitStatusType{}
Otvet1.ID = Postgres_ID_Test
err := crud.Read(&Otvet1)

View File

@ -4,7 +4,7 @@ func TestCrud_GRPC_Update(t *testing.T) {
grpc_client.Connect()
defer grpc_client.CloseConnection()
crud := Crud_GRPC{}
crud := grpc_lawsuit_status_types.Crud_GRPC{}
//прочитаем из БД
m := lawsuit_status_types.LawsuitStatusType{}

View File

@ -13,7 +13,7 @@ func TestCrud_GRPC_UpdateManyFields(t *testing.T) {
defer grpc_client.CloseConnection()
//прочитаем из БД
crud := Crud_GRPC{}
crud := grpc_lawsuit_status_types.Crud_GRPC{}
Otvet := lawsuit_status_types.LawsuitStatusType{}
Otvet.ID = Postgres_ID_Test
err := crud.Read(&Otvet)

View File

@ -253,6 +253,12 @@ func CreateFilesTest(Table1 *types.Table) error {
ModelTableName := create_files.FindModelTableURL(TableName)
TextGRPCClient = create_files.AddImport(TextGRPCClient, ModelTableName)
GRPClientTableURL := create_files.FindGRPCClientTableURL(Table1.Name)
TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPClientTableURL)
//GRPClientFuncURL := create_files.Find_GRPCClient_func_URL()
//TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPClientFuncURL)
//Postgres_ID_Test = ID Minimum
TextGRPCClient = create_files.Replace_Postgres_ID_Test(TextGRPCClient, Table1)
@ -650,6 +656,12 @@ func CreateFilesUpdateEveryColumnTest(Table1 *types.Table) error {
//TextGRPC_Client = create_files.ConvertRequestIdToAlias(TextGRPC_Client, Table1)
GRPClientTableURL := create_files.FindGRPCClientTableURL(Table1.Name)
TextGRPC_Client = create_files.AddImport(TextGRPC_Client, GRPClientTableURL)
//GRPClientFuncURL := create_files.Find_GRPCClient_func_URL()
//TextGRPC_Client = create_files.AddImport(TextGRPC_Client, GRPClientFuncURL)
TextGRPC_Client = create_files.Replace_Postgres_ID_Test(TextGRPC_Client, Table1)
TextGRPC_Client = create_files.ReplacePrimaryKeyOtvetID(TextGRPC_Client, Table1)
@ -903,6 +915,12 @@ func CreateFiles_GRPC_Client_Cache_Test(Table1 *types.Table) error {
//RepositoryGRPCConstantsURL := create_files.FindGRPCConstantsURL()
//TextGRPCClient = create_files.AddImport(TextGRPCClient, RepositoryGRPCConstantsURL)
GRPClientTableURL := create_files.FindGRPCClientTableURL(Table1.Name)
TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPClientTableURL)
//GRPClientFuncURL := create_files.Find_GRPCClient_func_URL()
//TextGRPCClient = create_files.AddImport(TextGRPCClient, GRPClientFuncURL)
// замена ID на PrimaryKey
TextGRPCClient = create_files.ReplacePrimaryKeyOtvetID(TextGRPCClient, Table1)

View File

@ -248,6 +248,9 @@ func CreateFilesTest(Table1 *types.Table) error {
ConstantsURL := create_files.FindConstantsURL()
TextGRPCServer = create_files.AddImport(TextGRPCServer, ConstantsURL)
GRPClientTableURL := create_files.FindGRPCClientTableURL(Table1.Name)
TextGRPCServer = create_files.AddImport(TextGRPCServer, GRPClientTableURL)
TextGRPCServer = create_files.CheckAndAddImport(TextGRPCServer, "encoding/json")
//замена "postgres_gorm.Connect_WithApplicationName("
@ -485,10 +488,10 @@ func CreateFilesUpdateEveryColumn(Table1 *types.Table) error {
//создание текста
TextUpdateEveryColumn := FindTextUpdateEveryColumn(TextGRPCServerUpdateFunc, Table1)
// пустой файл не нужен
if TextUpdateEveryColumn == "" {
return err
}
//// пустой файл не нужен
//if TextUpdateEveryColumn == "" {
// return err
//}
TextGRPCServer = TextGRPCServer + TextUpdateEveryColumn
@ -674,10 +677,11 @@ func CreateFilesUpdateEveryColumnTest(Table1 *types.Table) error {
TextGRPCServer = strings.ReplaceAll(TextGRPCServer, config.Settings.TEXT_TEMPLATE_MODEL, Table1.NameGo)
TextGRPCServer = strings.ReplaceAll(TextGRPCServer, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
// пустой файл не нужен
if TextUpdateEveryColumn == "" {
return err
}
//// пустой файл не нужен
//if TextUpdateEveryColumn == "" {
// return err
//}
TextGRPCServer = TextGRPCServer + TextUpdateEveryColumn
TextGRPCServer = config.Settings.TEXT_MODULE_GENERATED + TextGRPCServer