You've already forked crud_generator
mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2025-07-05 14:09:20 +02:00
сделал constants_
This commit is contained in:
@ -243,3 +243,9 @@ TEMPLATES_README_MD_FILENAME="README.md_"
|
|||||||
|
|
||||||
#TEMPLATES_README_RUS_FILENAME - short filename of "readme.rus_" file
|
#TEMPLATES_README_RUS_FILENAME - short filename of "readme.rus_" file
|
||||||
TEMPLATES_README_RUS_FILENAME="readme.rus_"
|
TEMPLATES_README_RUS_FILENAME="readme.rus_"
|
||||||
|
|
||||||
|
#TEMPLATE_FOLDERNAME_CONSTANTS - folder name for service constants
|
||||||
|
TEMPLATE_FOLDERNAME_CONSTANTS="pkg/constants"
|
||||||
|
|
||||||
|
#TEMPLATES_CONSTANTS_FILENAME - short filename of "constants.go_" file
|
||||||
|
TEMPLATES_CONSTANTS_FILENAME="constants.go_"
|
@ -6,12 +6,16 @@ import (
|
|||||||
"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/crud_starter"
|
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/crud_starter"
|
||||||
"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/constants"
|
||||||
|
"github.com/ManyakRus/starter/postgres_gorm"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_server_LawsuitStatusType_ReadFromCache(t *testing.T) {
|
func Test_server_LawsuitStatusType_ReadFromCache(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
crud_starter.InitCrudTransport_DB()
|
crud_starter.InitCrudTransport_DB()
|
||||||
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
Request := grpc_proto.RequestId{}
|
Request := grpc_proto.RequestId{}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
func Test_server_LawsuitStatusType_Update(t *testing.T) {
|
func Test_server_LawsuitStatusType_Update(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
crud_starter.InitCrudTransport_DB()
|
crud_starter.InitCrudTransport_DB()
|
||||||
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
server1 := &ServerGRPC{}
|
server1 := &ServerGRPC{}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
@ -6,12 +6,17 @@ import (
|
|||||||
"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/crud_starter"
|
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/crud_starter"
|
||||||
"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/constants"
|
||||||
|
"github.com/ManyakRus/starter/postgres_gorm"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestServerGRPC_LawsuitStatusType_UpdateManyFields(t *testing.T) {
|
func TestServerGRPC_LawsuitStatusType_UpdateManyFields(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
crud_starter.InitCrudTransport_DB()
|
crud_starter.InitCrudTransport_DB()
|
||||||
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
//прочитаем из БД
|
//прочитаем из БД
|
||||||
|
@ -6,6 +6,8 @@ import (
|
|||||||
"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/crud_starter"
|
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/crud_starter"
|
||||||
"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/constants"
|
||||||
|
"github.com/ManyakRus/starter/postgres_gorm"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,6 +17,8 @@ const LawsuitStatusType_ID_Test = 0
|
|||||||
func Test_server_LawsuitStatusType_Read(t *testing.T) {
|
func Test_server_LawsuitStatusType_Read(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
crud_starter.InitCrudTransport_DB()
|
crud_starter.InitCrudTransport_DB()
|
||||||
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
Request := grpc_proto.RequestId{}
|
Request := grpc_proto.RequestId{}
|
||||||
@ -34,6 +38,8 @@ func Test_server_LawsuitStatusType_Read(t *testing.T) {
|
|||||||
func Test_server_LawsuitStatusType_Delete(t *testing.T) {
|
func Test_server_LawsuitStatusType_Delete(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
crud_starter.InitCrudTransport_DB()
|
crud_starter.InitCrudTransport_DB()
|
||||||
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
Request := grpc_proto.RequestId{}
|
Request := grpc_proto.RequestId{}
|
||||||
@ -101,6 +107,8 @@ func Test_server_LawsuitStatusType_Delete(t *testing.T) {
|
|||||||
func Test_server_LawsuitStatusType_Create(t *testing.T) {
|
func Test_server_LawsuitStatusType_Create(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
crud_starter.InitCrudTransport_DB()
|
crud_starter.InitCrudTransport_DB()
|
||||||
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
var ModelString string
|
var ModelString string
|
||||||
m := lawsuit_status_types.LawsuitStatusType{}
|
m := lawsuit_status_types.LawsuitStatusType{}
|
||||||
@ -129,6 +137,8 @@ func Test_server_LawsuitStatusType_Create(t *testing.T) {
|
|||||||
func Test_server_LawsuitStatusType_Update(t *testing.T) {
|
func Test_server_LawsuitStatusType_Update(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
crud_starter.InitCrudTransport_DB()
|
crud_starter.InitCrudTransport_DB()
|
||||||
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
Request := grpc_proto.RequestId{}
|
Request := grpc_proto.RequestId{}
|
||||||
@ -165,6 +175,8 @@ func Test_server_LawsuitStatusType_Update(t *testing.T) {
|
|||||||
func Test_server_LawsuitStatusType_Save(t *testing.T) {
|
func Test_server_LawsuitStatusType_Save(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
crud_starter.InitCrudTransport_DB()
|
crud_starter.InitCrudTransport_DB()
|
||||||
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
Request := grpc_proto.RequestId{}
|
Request := grpc_proto.RequestId{}
|
||||||
|
3
bin/templates/pkg/constants/constants.go_
Normal file
3
bin/templates/pkg/constants/constants.go_
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
package constants
|
||||||
|
|
||||||
|
const SERVICE_NAME = "sync_service"
|
@ -3,6 +3,7 @@ package crud_lawsuit_status_types
|
|||||||
import (
|
import (
|
||||||
"github.com/ManyakRus/starter/config_main"
|
"github.com/ManyakRus/starter/config_main"
|
||||||
"github.com/ManyakRus/starter/postgres_gorm"
|
"github.com/ManyakRus/starter/postgres_gorm"
|
||||||
|
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/constants"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@ -11,7 +12,7 @@ func TestReadFromCache(t *testing.T) {
|
|||||||
var err error
|
var err error
|
||||||
|
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
postgres_gorm.Connect()
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
defer postgres_gorm.CloseConnection()
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
//читаем из БД
|
//читаем из БД
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
func TestUpdate(t *testing.T) {
|
func TestUpdate(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
|
|
||||||
postgres_gorm.Connect()
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
defer postgres_gorm.CloseConnection()
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
//прочитаем из БД
|
//прочитаем из БД
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/ManyakRus/starter/config_main"
|
"github.com/ManyakRus/starter/config_main"
|
||||||
"github.com/ManyakRus/starter/postgres_gorm"
|
"github.com/ManyakRus/starter/postgres_gorm"
|
||||||
"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/constants"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ import (
|
|||||||
func TestUpdateManyFields(t *testing.T) {
|
func TestUpdateManyFields(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
|
|
||||||
postgres_gorm.Connect()
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
defer postgres_gorm.CloseConnection()
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
//прочитаем из БД
|
//прочитаем из БД
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/ManyakRus/starter/config_main"
|
"github.com/ManyakRus/starter/config_main"
|
||||||
"github.com/ManyakRus/starter/postgres_gorm"
|
"github.com/ManyakRus/starter/postgres_gorm"
|
||||||
"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/constants"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -12,7 +13,7 @@ const Postgres_ID_Test = 0
|
|||||||
func TestRead(t *testing.T) {
|
func TestRead(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
|
|
||||||
postgres_gorm.Connect()
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
defer postgres_gorm.CloseConnection()
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
crud := Crud_DB{}
|
crud := Crud_DB{}
|
||||||
@ -33,7 +34,7 @@ func TestRead(t *testing.T) {
|
|||||||
func TestSave(t *testing.T) {
|
func TestSave(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
|
|
||||||
postgres_gorm.Connect()
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
defer postgres_gorm.CloseConnection()
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
crud := Crud_DB{}
|
crud := Crud_DB{}
|
||||||
@ -59,7 +60,7 @@ func TestSave(t *testing.T) {
|
|||||||
func TestDelete(t *testing.T) {
|
func TestDelete(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
|
|
||||||
postgres_gorm.Connect()
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
defer postgres_gorm.CloseConnection()
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
crud := Crud_DB{}
|
crud := Crud_DB{}
|
||||||
@ -97,7 +98,7 @@ func TestDelete(t *testing.T) {
|
|||||||
|
|
||||||
func TestFind_ByExtID(t *testing.T) {
|
func TestFind_ByExtID(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
postgres_gorm.Connect()
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
defer postgres_gorm.CloseConnection()
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
crud := Crud_DB{}
|
crud := Crud_DB{}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/ManyakRus/starter/config_main"
|
"github.com/ManyakRus/starter/config_main"
|
||||||
"github.com/ManyakRus/starter/postgres_gorm"
|
"github.com/ManyakRus/starter/postgres_gorm"
|
||||||
"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/constants"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -12,7 +13,7 @@ const Postgres_ID_Test = 0
|
|||||||
func TestRead(t *testing.T) {
|
func TestRead(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
|
|
||||||
postgres_gorm.Connect()
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
defer postgres_gorm.CloseConnection()
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
crud := Crud_DB{}
|
crud := Crud_DB{}
|
||||||
@ -33,7 +34,7 @@ func TestRead(t *testing.T) {
|
|||||||
func TestSave(t *testing.T) {
|
func TestSave(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
|
|
||||||
postgres_gorm.Connect()
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
defer postgres_gorm.CloseConnection()
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
crud := Crud_DB{}
|
crud := Crud_DB{}
|
||||||
@ -59,7 +60,7 @@ func TestSave(t *testing.T) {
|
|||||||
func TestDelete(t *testing.T) {
|
func TestDelete(t *testing.T) {
|
||||||
config.LoadEnv()
|
config.LoadEnv()
|
||||||
|
|
||||||
postgres_gorm.Connect()
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
defer postgres_gorm.CloseConnection()
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
crud := Crud_DB{}
|
crud := Crud_DB{}
|
||||||
@ -74,7 +75,7 @@ func TestDelete(t *testing.T) {
|
|||||||
|
|
||||||
func TestFind_ByExtID(t *testing.T) {
|
func TestFind_ByExtID(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
postgres_gorm.Connect()
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
defer postgres_gorm.CloseConnection()
|
defer postgres_gorm.CloseConnection()
|
||||||
|
|
||||||
crud := Crud_DB{}
|
crud := Crud_DB{}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
func TestCrud_GRPC_Update(t *testing.T) {
|
func TestCrud_GRPC_Update(t *testing.T) {
|
||||||
config_main.LoadEnv()
|
config_main.LoadEnv()
|
||||||
|
|
||||||
grpc_client.Connect()
|
postgres_gorm.Connect_WithApplicationName(constants.SERVICE_NAME + "_test")
|
||||||
defer grpc_client.CloseConnection()
|
defer grpc_client.CloseConnection()
|
||||||
|
|
||||||
crud := Crud_GRPC{}
|
crud := Crud_GRPC{}
|
||||||
|
@ -56,6 +56,8 @@ type SettingsINI struct {
|
|||||||
TEMPLATES_GRPC_CLIENT_TABLES_CACHE_TEST_FILENAME string
|
TEMPLATES_GRPC_CLIENT_TABLES_CACHE_TEST_FILENAME string
|
||||||
TEMPLATES_README_MD_FILENAME string
|
TEMPLATES_README_MD_FILENAME string
|
||||||
TEMPLATES_README_RUS_FILENAME string
|
TEMPLATES_README_RUS_FILENAME string
|
||||||
|
TEMPLATE_FOLDERNAME_CONSTANTS string
|
||||||
|
TEMPLATES_CONSTANTS_FILENAME string
|
||||||
NEED_CREATE_MODEL_STRUCT bool
|
NEED_CREATE_MODEL_STRUCT bool
|
||||||
NEED_CREATE_MODEL_CRUD bool
|
NEED_CREATE_MODEL_CRUD bool
|
||||||
NEED_CREATE_DB bool
|
NEED_CREATE_DB bool
|
||||||
@ -502,6 +504,16 @@ func FillSettings() {
|
|||||||
s = Getenv(Name, true)
|
s = Getenv(Name, true)
|
||||||
Settings.TEMPLATES_README_RUS_FILENAME = s
|
Settings.TEMPLATES_README_RUS_FILENAME = s
|
||||||
|
|
||||||
|
//
|
||||||
|
Name = "TEMPLATE_FOLDERNAME_CONSTANTS"
|
||||||
|
s = Getenv(Name, true)
|
||||||
|
Settings.TEMPLATE_FOLDERNAME_CONSTANTS = s
|
||||||
|
|
||||||
|
//
|
||||||
|
Name = "TEMPLATES_CONSTANTS_FILENAME"
|
||||||
|
s = Getenv(Name, true)
|
||||||
|
Settings.TEMPLATES_CONSTANTS_FILENAME = s
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CurrentDirectory - возвращает текущую директорию ОС
|
// CurrentDirectory - возвращает текущую директорию ОС
|
||||||
|
59
internal/create_files/constants_file/constants_file.go
Normal file
59
internal/create_files/constants_file/constants_file.go
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package constants_file
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ManyakRus/crud_generator/internal/config"
|
||||||
|
"github.com/ManyakRus/crud_generator/internal/constants"
|
||||||
|
"github.com/ManyakRus/crud_generator/internal/create_files"
|
||||||
|
"github.com/ManyakRus/crud_generator/internal/folders"
|
||||||
|
"github.com/ManyakRus/starter/log"
|
||||||
|
"github.com/ManyakRus/starter/micro"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CreateAllFiles - создаёт все файлы в папке grpc proto
|
||||||
|
func CreateAllFiles() error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
err = CreateFileConstants()
|
||||||
|
if err != nil {
|
||||||
|
log.Error("CreateFileConstants() error: ", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateFileConstants - создаёт 1 файл в папке constants
|
||||||
|
func CreateFileConstants() error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
//чтение файлов
|
||||||
|
DirBin := micro.ProgramDir_bin()
|
||||||
|
DirTemplates := DirBin + config.Settings.TEMPLATE_FOLDERNAME + micro.SeparatorFile()
|
||||||
|
DirReady := DirBin + config.Settings.READY_FOLDERNAME + micro.SeparatorFile()
|
||||||
|
DirTemplatesConstants := DirTemplates + config.Settings.TEMPLATE_FOLDERNAME_CONSTANTS + micro.SeparatorFile()
|
||||||
|
DirReadyConstants := DirReady + config.Settings.TEMPLATE_FOLDERNAME_CONSTANTS + micro.SeparatorFile()
|
||||||
|
FilenameReadyConstants := DirReadyConstants + config.Settings.TEMPLATES_CONSTANTS_FILENAME
|
||||||
|
FilenameReadyConstants = create_files.DeleteLastUnderline(FilenameReadyConstants)
|
||||||
|
|
||||||
|
//создадим папку готовых файлов
|
||||||
|
folders.CreateFolder(DirReadyConstants)
|
||||||
|
|
||||||
|
FilenameTemplateConstants := DirTemplatesConstants + config.Settings.TEMPLATES_CONSTANTS_FILENAME
|
||||||
|
bytes, err := os.ReadFile(FilenameTemplateConstants)
|
||||||
|
if err != nil {
|
||||||
|
log.Panic("ReadFile() ", FilenameTemplateConstants, " error: ", err)
|
||||||
|
}
|
||||||
|
TextConstants := string(bytes)
|
||||||
|
|
||||||
|
//заменим название сервиса
|
||||||
|
ServiceNameTemplate := config.Settings.TEMPLATE_SERVICE_NAME
|
||||||
|
ServiceNameNew := config.Settings.SERVICE_NAME
|
||||||
|
TextConstants = strings.ReplaceAll(TextConstants, ServiceNameTemplate, ServiceNameNew)
|
||||||
|
|
||||||
|
//запись файла
|
||||||
|
err = os.WriteFile(FilenameReadyConstants, []byte(TextConstants), constants.FILE_PERMISSIONS)
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
package constants_file
|
@ -492,11 +492,20 @@ func FindNRPC_Client_URL() string {
|
|||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindDBConstantsURL - возвращает URL репозитория с пакетом db "constants"
|
// FindDBConstantsURL - возвращает URL репозитория с пакетом db "db_constants"
|
||||||
func FindDBConstantsURL() string {
|
func FindDBConstantsURL() string {
|
||||||
Otvet := ""
|
Otvet := ""
|
||||||
|
|
||||||
Otvet = config.Settings.SERVICE_REPOSITORY_URL + "/" + config.Settings.TEMPLATE_FOLDERNAME_DB + "/" + "constants"
|
Otvet = config.Settings.SERVICE_REPOSITORY_URL + "/" + config.Settings.TEMPLATE_FOLDERNAME_DB + "/" + "db_constants"
|
||||||
|
|
||||||
|
return Otvet
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindConstantsURL - возвращает URL репозитория с пакетом pkg "constants"
|
||||||
|
func FindConstantsURL() string {
|
||||||
|
Otvet := ""
|
||||||
|
|
||||||
|
Otvet = config.Settings.SERVICE_REPOSITORY_URL + "/" + config.Settings.TEMPLATE_FOLDERNAME_CONSTANTS
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
@ -223,6 +223,9 @@ func CreateFilesTest(Table1 *types.Table) error {
|
|||||||
ModelTableURL := create_files.FindModelTableURL(TableName)
|
ModelTableURL := create_files.FindModelTableURL(TableName)
|
||||||
TextDB = create_files.AddImport(TextDB, ModelTableURL)
|
TextDB = create_files.AddImport(TextDB, ModelTableURL)
|
||||||
|
|
||||||
|
ConstantsURL := create_files.FindConstantsURL()
|
||||||
|
TextDB = create_files.AddImport(TextDB, ConstantsURL)
|
||||||
|
|
||||||
//удалим лишние функции
|
//удалим лишние функции
|
||||||
TextDB = create_files.DeleteFuncTestDelete(TextDB, Table1)
|
TextDB = create_files.DeleteFuncTestDelete(TextDB, Table1)
|
||||||
TextDB = create_files.DeleteFuncTestRestore(TextDB, Table1)
|
TextDB = create_files.DeleteFuncTestRestore(TextDB, Table1)
|
||||||
@ -719,6 +722,10 @@ func CreateFilesUpdateEveryColumnTest(Table1 *types.Table) error {
|
|||||||
TextCrud = create_files.ReplacePrimaryKeyM_ID(TextCrud, Table1)
|
TextCrud = create_files.ReplacePrimaryKeyM_ID(TextCrud, Table1)
|
||||||
TextCrud = create_files.ReplacePrimaryKeyOtvetID(TextCrud, Table1)
|
TextCrud = create_files.ReplacePrimaryKeyOtvetID(TextCrud, Table1)
|
||||||
//TextCrud = create_files.ConvertRequestIdToAlias(TextCrud, Table1)
|
//TextCrud = create_files.ConvertRequestIdToAlias(TextCrud, Table1)
|
||||||
|
|
||||||
|
ConstantsURL := create_files.FindConstantsURL()
|
||||||
|
TextCrud = create_files.AddImport(TextCrud, ConstantsURL)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//создание текста
|
//создание текста
|
||||||
@ -923,6 +930,9 @@ func CreateFilesCacheTest(Table1 *types.Table) error {
|
|||||||
//TextCache = create_files.AddImport(TextCache, ModelTableURL)
|
//TextCache = create_files.AddImport(TextCache, ModelTableURL)
|
||||||
|
|
||||||
//TextCache = create_files.ConvertRequestIdToAlias(TextCache, Table1)
|
//TextCache = create_files.ConvertRequestIdToAlias(TextCache, Table1)
|
||||||
|
ConstantsURL := create_files.FindConstantsURL()
|
||||||
|
TextCache = create_files.AddImport(TextCache, ConstantsURL)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//замена слов
|
//замена слов
|
||||||
|
@ -211,6 +211,9 @@ func CreateFilesTest(Table1 *types.Table) error {
|
|||||||
CrudStarterURL := create_files.FindCrudStarterURL()
|
CrudStarterURL := create_files.FindCrudStarterURL()
|
||||||
TextGRPCServer = create_files.AddImport(TextGRPCServer, CrudStarterURL)
|
TextGRPCServer = create_files.AddImport(TextGRPCServer, CrudStarterURL)
|
||||||
|
|
||||||
|
ConstantsURL := create_files.FindConstantsURL()
|
||||||
|
TextGRPCServer = create_files.AddImport(TextGRPCServer, ConstantsURL)
|
||||||
|
|
||||||
TextGRPCServer = create_files.CheckAndAddImport(TextGRPCServer, "encoding/json")
|
TextGRPCServer = create_files.CheckAndAddImport(TextGRPCServer, "encoding/json")
|
||||||
|
|
||||||
//Postgres_ID_Test = ID Minimum
|
//Postgres_ID_Test = ID Minimum
|
||||||
@ -584,6 +587,9 @@ func CreateFilesUpdateEveryColumnTest(Table1 *types.Table) error {
|
|||||||
CrudStarterURL := create_files.FindCrudStarterURL()
|
CrudStarterURL := create_files.FindCrudStarterURL()
|
||||||
TextGRPCServer = create_files.AddImport(TextGRPCServer, CrudStarterURL)
|
TextGRPCServer = create_files.AddImport(TextGRPCServer, CrudStarterURL)
|
||||||
|
|
||||||
|
ConstantsURL := create_files.FindConstantsURL()
|
||||||
|
TextGRPCServer = create_files.AddImport(TextGRPCServer, ConstantsURL)
|
||||||
|
|
||||||
//TextGRPCServer = create_files.ConvertRequestIdToAlias(TextGRPCServer, Table1)
|
//TextGRPCServer = create_files.ConvertRequestIdToAlias(TextGRPCServer, Table1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -797,6 +803,9 @@ func CreateFilesCacheTest(Table1 *types.Table) error {
|
|||||||
CrudStarterURL := create_files.FindCrudStarterURL()
|
CrudStarterURL := create_files.FindCrudStarterURL()
|
||||||
TextGRPCServer = create_files.AddImport(TextGRPCServer, CrudStarterURL)
|
TextGRPCServer = create_files.AddImport(TextGRPCServer, CrudStarterURL)
|
||||||
|
|
||||||
|
ConstantsURL := create_files.FindConstantsURL()
|
||||||
|
TextGRPCServer = create_files.AddImport(TextGRPCServer, ConstantsURL)
|
||||||
|
|
||||||
//замена RequestId{}
|
//замена RequestId{}
|
||||||
TextGRPCServer = create_files.ReplaceTextRequestID_PrimaryKey(TextGRPCServer, Table1)
|
TextGRPCServer = create_files.ReplaceTextRequestID_PrimaryKey(TextGRPCServer, Table1)
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package logic
|
|||||||
import (
|
import (
|
||||||
"github.com/ManyakRus/crud_generator/internal/config"
|
"github.com/ManyakRus/crud_generator/internal/config"
|
||||||
"github.com/ManyakRus/crud_generator/internal/create_files/alias"
|
"github.com/ManyakRus/crud_generator/internal/create_files/alias"
|
||||||
|
"github.com/ManyakRus/crud_generator/internal/create_files/constants_file"
|
||||||
"github.com/ManyakRus/crud_generator/internal/create_files/crud_starter"
|
"github.com/ManyakRus/crud_generator/internal/create_files/crud_starter"
|
||||||
"github.com/ManyakRus/crud_generator/internal/create_files/crud_starter_tables"
|
"github.com/ManyakRus/crud_generator/internal/create_files/crud_starter_tables"
|
||||||
"github.com/ManyakRus/crud_generator/internal/create_files/crud_tables"
|
"github.com/ManyakRus/crud_generator/internal/create_files/crud_tables"
|
||||||
@ -192,5 +193,12 @@ func StartFillAll() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//constants
|
||||||
|
err = constants_file.CreateAllFiles()
|
||||||
|
if err != nil {
|
||||||
|
//log.Error("env_file.CreateAllFiles() error: ", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/ManyakRus/crud_generator/internal/config"
|
"github.com/ManyakRus/crud_generator/internal/config"
|
||||||
"github.com/ManyakRus/crud_generator/internal/create_files"
|
"github.com/ManyakRus/crud_generator/internal/create_files"
|
||||||
"github.com/ManyakRus/crud_generator/internal/mini_func"
|
|
||||||
"github.com/ManyakRus/crud_generator/internal/types"
|
"github.com/ManyakRus/crud_generator/internal/types"
|
||||||
"github.com/ManyakRus/crud_generator/pkg/dbmeta"
|
"github.com/ManyakRus/crud_generator/pkg/dbmeta"
|
||||||
"github.com/ManyakRus/starter/contextmain"
|
"github.com/ManyakRus/starter/contextmain"
|
||||||
@ -407,11 +406,16 @@ func FillIDMinimum(MapTable map[string]*types.Table) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
if TypeGo == "string" {
|
|
||||||
Table1.IDMinimum = `"` + IDMinimum.String + `"`
|
|
||||||
} else if mini_func.IsNumberType(TypeGo) == true {
|
|
||||||
Table1.IDMinimum = IDMinimum.String
|
Table1.IDMinimum = IDMinimum.String
|
||||||
}
|
//if TypeGo == "string" || TypeGo == "uuid.UUID" {
|
||||||
|
// Table1.IDMinimum = IDMinimum.String
|
||||||
|
//} else if mini_func.IsNumberType(TypeGo) == true {
|
||||||
|
// Table1.IDMinimum = IDMinimum.String
|
||||||
|
//} else if TypeGo == "time.Time" {
|
||||||
|
// Table1.IDMinimum = IDMinimum.String
|
||||||
|
//} else {
|
||||||
|
// Table1.IDMinimum = IDMinimum.String
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
Reference in New Issue
Block a user