mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2025-01-01 13:21:20 +02:00
сделал ReplacePackageName()
This commit is contained in:
parent
4ab4024d8b
commit
d4a9896403
@ -3,7 +3,7 @@ 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/db/calc_struct_version"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
|
@ -15,6 +15,7 @@ type SettingsINI struct {
|
||||
EXCLUDE_TABLES string
|
||||
TEMPLATE_FOLDERNAME string
|
||||
TEMPLATE_FOLDERNAME_MODEL string
|
||||
TEMPLATE_FOLDERNAME_DB string
|
||||
TEMPLATE_FOLDERNAME_CRUD string
|
||||
TEMPLATE_FOLDERNAME_TABLES string
|
||||
TEMPLATE_FOLDERNAME_GRPC string
|
||||
@ -148,6 +149,7 @@ func FillSettings() {
|
||||
Settings.PREFIX_TABLE = os.Getenv("PREFIX_TABLE")
|
||||
Settings.TEMPLATE_FOLDERNAME_TABLES = os.Getenv("TEMPLATE_FOLDERNAME_TABLES")
|
||||
Settings.PREFIX_MODEL = os.Getenv("PREFIX_MODEL")
|
||||
Settings.TEMPLATE_FOLDERNAME_DB = os.Getenv("TEMPLATE_FOLDERNAME_DB")
|
||||
|
||||
}
|
||||
|
||||
|
@ -261,8 +261,8 @@ func FindModelURL() string {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// FindGRPCServerlURL - возвращает URL репозитория с пакетом "server_grpc"
|
||||
func FindGRPCServerlURL() string {
|
||||
// FindGRPCServerURL - возвращает URL репозитория с пакетом "server_grpc"
|
||||
func FindGRPCServerURL() string {
|
||||
Otvet := ""
|
||||
|
||||
Otvet = config.Settings.SERVICE_REPOSITORY_URL + "/" + config.Settings.TEMPLATE_FOLDERNAME_GRPC_SERVER
|
||||
@ -342,6 +342,42 @@ func FindModelTableURL(TableName string) string {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// FindNRPCClientURL - возвращает URL репозитория с пакетом "nrpc_client"
|
||||
func FindNRPCClientURL() string {
|
||||
Otvet := ""
|
||||
|
||||
Otvet = config.Settings.SERVICE_REPOSITORY_URL + "/" + config.Settings.TEMPLATE_FOLDERNAME_NRPC_CLIENT
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// FindDBConstantsURL - возвращает URL репозитория с пакетом db "constants"
|
||||
func FindDBConstantsURL() string {
|
||||
Otvet := ""
|
||||
|
||||
Otvet = config.Settings.SERVICE_REPOSITORY_URL + "/" + config.Settings.TEMPLATE_FOLDERNAME_DB + "/" + "constants"
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// FindCrudStarterURL - возвращает URL репозитория с пакетом "crud_starter"
|
||||
func FindCrudStarterURL() string {
|
||||
Otvet := ""
|
||||
|
||||
Otvet = config.Settings.SERVICE_REPOSITORY_URL + "/" + config.Settings.TEMPLATE_FOLDERNAME_CRUD_STARTER
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// FindCalcStructVersionURL - возвращает URL репозитория с пакетом "calc_struct_version"
|
||||
func FindCalcStructVersionURL() string {
|
||||
Otvet := ""
|
||||
|
||||
Otvet = config.Settings.SERVICE_REPOSITORY_URL + "/" + config.Settings.TEMPLATE_FOLDERNAME_DB + "/" + "calc_struct_version"
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
func FindTextDefaultValue(Column1 *types.Column) string {
|
||||
var Otvet string
|
||||
|
||||
|
@ -58,15 +58,15 @@ func CreateFiles(Table1 *types.Table) error {
|
||||
|
||||
FilenameTemplateDB := DirTemplatesDB + constants.TemplateFilenameCrudGo
|
||||
TableName := strings.ToLower(Table1.Name)
|
||||
DirTable := DirReadyDB + config.Settings.PREFIX_CRUD + TableName
|
||||
FilenameReadyDB := DirTable + micro.SeparatorFile() + config.Settings.PREFIX_CRUD + TableName + ".go"
|
||||
DirReadyTable := DirReadyDB + config.Settings.PREFIX_CRUD + TableName
|
||||
FilenameReadyDB := DirReadyTable + micro.SeparatorFile() + config.Settings.PREFIX_CRUD + TableName + ".go"
|
||||
|
||||
//создадим каталог
|
||||
ok, err := micro.FileExists(DirTable)
|
||||
ok, err := micro.FileExists(DirReadyTable)
|
||||
if ok == false {
|
||||
err = os.MkdirAll(DirTable, 0777)
|
||||
err = os.MkdirAll(DirReadyTable, 0777)
|
||||
if err != nil {
|
||||
log.Panic("Mkdir() ", DirTable, " error: ", err)
|
||||
log.Panic("Mkdir() ", DirReadyTable, " error: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +77,17 @@ func CreateFiles(Table1 *types.Table) error {
|
||||
TextDB := string(bytes)
|
||||
|
||||
//заменим имя пакета на новое
|
||||
create_files.ReplacePackageName(TextDB, DirTable)
|
||||
create_files.ReplacePackageName(TextDB, DirReadyTable)
|
||||
|
||||
//заменим импорты
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextDB = create_files.DeleteTemplateRepositoryImports(TextDB)
|
||||
|
||||
TextDB = create_files.AddImport(TextDB, DirReadyTable)
|
||||
|
||||
ConstantsURL := create_files.FindGRPCConstantsURL()
|
||||
TextDB = create_files.AddImport(TextDB, ConstantsURL)
|
||||
}
|
||||
|
||||
//создание текста
|
||||
ModelName := Table1.NameGo
|
||||
@ -121,15 +131,15 @@ func CreateTestFiles(Table1 *types.Table) error {
|
||||
DirReadyDB := DirReady + config.Settings.TEMPLATE_FOLDERNAME_CRUD + micro.SeparatorFile()
|
||||
|
||||
FilenameTemplateDB := DirTemplatesDB + constants.TemplateFilenameCrudGoTest
|
||||
DirTable := DirReadyDB + config.Settings.PREFIX_CRUD + TableName
|
||||
FilenameReadyDB := DirTable + micro.SeparatorFile() + config.Settings.PREFIX_CRUD + TableName + "_test.go"
|
||||
DirReadyTable := DirReadyDB + config.Settings.PREFIX_CRUD + TableName
|
||||
FilenameReadyDB := DirReadyTable + micro.SeparatorFile() + config.Settings.PREFIX_CRUD + TableName + "_test.go"
|
||||
|
||||
//создадим каталог
|
||||
ok, err := micro.FileExists(DirTable)
|
||||
ok, err := micro.FileExists(DirReadyTable)
|
||||
if ok == false {
|
||||
err = os.Mkdir(DirTable, 0777)
|
||||
err = os.Mkdir(DirReadyTable, 0777)
|
||||
if err != nil {
|
||||
log.Panic("Mkdir() ", DirTable, " error: ", err)
|
||||
log.Panic("Mkdir() ", DirReadyTable, " error: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,7 +150,17 @@ func CreateTestFiles(Table1 *types.Table) error {
|
||||
TextDB := string(bytes)
|
||||
|
||||
//заменим имя пакета на новое
|
||||
create_files.ReplacePackageName(TextDB, DirTable)
|
||||
create_files.ReplacePackageName(TextDB, DirReadyTable)
|
||||
|
||||
//заменим импорты
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextDB = create_files.DeleteTemplateRepositoryImports(TextDB)
|
||||
|
||||
TextDB = create_files.AddImport(TextDB, DirReadyTable)
|
||||
|
||||
ConstantsURL := create_files.FindGRPCConstantsURL()
|
||||
TextDB = create_files.AddImport(TextDB, ConstantsURL)
|
||||
}
|
||||
|
||||
//создание текста
|
||||
ModelName := Table1.NameGo
|
||||
|
@ -77,6 +77,17 @@ func CreateFiles(Table1 *types.Table) error {
|
||||
//заменим имя пакета на новое
|
||||
create_files.ReplacePackageName(TextGRPCClient, DirReadyTable)
|
||||
|
||||
//заменим импорты
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextGRPCClient = create_files.DeleteTemplateRepositoryImports(TextGRPCClient)
|
||||
|
||||
ConstantsURL := create_files.FindGRPCConstantsURL()
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, ConstantsURL)
|
||||
|
||||
ProtoURL := create_files.FindProtoURL()
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, ProtoURL)
|
||||
}
|
||||
|
||||
//создание текста
|
||||
ModelName := Table1.NameGo
|
||||
TextGRPCClient = strings.ReplaceAll(TextGRPCClient, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
||||
@ -155,6 +166,14 @@ func CreateTestFiles(Table1 *types.Table) error {
|
||||
//заменим имя пакета на новое
|
||||
create_files.ReplacePackageName(TextGRPCClient, DirReadyTable)
|
||||
|
||||
//заменим импорты
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextGRPCClient = create_files.DeleteTemplateRepositoryImports(TextGRPCClient)
|
||||
|
||||
ConstantsURL := create_files.FindGRPCConstantsURL()
|
||||
TextGRPCClient = create_files.AddImport(TextGRPCClient, ConstantsURL)
|
||||
}
|
||||
|
||||
//создание текста
|
||||
ModelName := Table1.NameGo
|
||||
TextGRPCClient = strings.ReplaceAll(TextGRPCClient, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
||||
|
@ -67,6 +67,17 @@ func CreateFiles(Table1 *types.Table) error {
|
||||
//заменим имя пакета на новое
|
||||
create_files.ReplacePackageName(TextGRPCServer, DirReadyTable)
|
||||
|
||||
//заменим импорты
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextGRPCServer = create_files.DeleteTemplateRepositoryImports(TextGRPCServer)
|
||||
|
||||
ModelTableURL := create_files.FindModelTableURL(TableName)
|
||||
TextGRPCServer = create_files.AddImport(TextGRPCServer, ModelTableURL)
|
||||
|
||||
ProtoURL := create_files.FindProtoURL()
|
||||
TextGRPCServer = create_files.AddImport(TextGRPCServer, ProtoURL)
|
||||
}
|
||||
|
||||
//создание текста
|
||||
ModelName := Table1.NameGo
|
||||
TextGRPCServer = strings.ReplaceAll(TextGRPCServer, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
||||
@ -127,6 +138,20 @@ func CreateTestFiles(Table1 *types.Table) error {
|
||||
//заменим имя пакета на новое
|
||||
create_files.ReplacePackageName(TextGRPCServer, DirReadyTable)
|
||||
|
||||
//заменим импорты
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextGRPCServer = create_files.DeleteTemplateRepositoryImports(TextGRPCServer)
|
||||
|
||||
ModelTableURL := create_files.FindModelTableURL(TableName)
|
||||
TextGRPCServer = create_files.AddImport(TextGRPCServer, ModelTableURL)
|
||||
|
||||
ProtoURL := create_files.FindProtoURL()
|
||||
TextGRPCServer = create_files.AddImport(TextGRPCServer, ProtoURL)
|
||||
|
||||
CrudStarterURL := create_files.FindCrudStarterURL()
|
||||
TextGRPCServer = create_files.AddImport(TextGRPCServer, CrudStarterURL)
|
||||
}
|
||||
|
||||
//создание текста
|
||||
ModelName := Table1.NameGo
|
||||
TextGRPCServer = strings.ReplaceAll(TextGRPCServer, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
||||
|
@ -49,7 +49,7 @@ func CreateFileMain() error {
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
//GRPC
|
||||
if config.Settings.NEED_CREATE_GRPC == true {
|
||||
TextImport := create_files.FindGRPCServerlURL()
|
||||
TextImport := create_files.FindGRPCServerURL()
|
||||
TextMain = create_files.AddImport(TextMain, TextImport)
|
||||
} else {
|
||||
TextMain = strings.ReplaceAll(TextMain, "\n\tserver_grpc.Start()", "")
|
||||
|
@ -90,6 +90,14 @@ func CreateFilesModel_struct(Table1 *types.Table, DirTemplatesModel, DirReadyMod
|
||||
//заменим имя пакета на новое
|
||||
create_files.ReplacePackageName(TextModel, DirReadyModel)
|
||||
|
||||
//заменим импорты
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextModel = create_files.DeleteTemplateRepositoryImports(TextModel)
|
||||
|
||||
TableURL := create_files.FindTableNameURL(TableName)
|
||||
TextModel = create_files.AddImport(TextModel, TableURL)
|
||||
}
|
||||
|
||||
//создание текста
|
||||
//TextModel, TextModelStruct, ModelName, err := FindTextModelStruct(TextModel, Table1)
|
||||
//TextModel = ReplaceModelStruct(TextModel, TextModelStruct)
|
||||
@ -151,6 +159,14 @@ func CreateFilesModel_crud(Table1 *types.Table, DirTemplatesModel, DirReadyModel
|
||||
//заменим имя пакета на новое
|
||||
create_files.ReplacePackageName(TextModel, DirReadyModel)
|
||||
|
||||
//заменим импорты
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextModel = create_files.DeleteTemplateRepositoryImports(TextModel)
|
||||
|
||||
TableURL := create_files.FindCalcStructVersionURL()
|
||||
TextModel = create_files.AddImport(TextModel, TableURL)
|
||||
}
|
||||
|
||||
//создание текста
|
||||
TextModel = strings.ReplaceAll(TextModel, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
||||
TextModel = strings.ReplaceAll(TextModel, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
|
||||
|
@ -76,6 +76,23 @@ func CreateFiles(Table1 *types.Table) error {
|
||||
//заменим имя пакета на новое
|
||||
create_files.ReplacePackageName(TextNRPCClient, DirReadyTable)
|
||||
|
||||
//заменим импорты
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextNRPCClient = create_files.DeleteTemplateRepositoryImports(TextNRPCClient)
|
||||
|
||||
GRPCProtoURL := create_files.FindGRPCProtoURL()
|
||||
TextNRPCClient = create_files.AddImport(TextNRPCClient, GRPCProtoURL)
|
||||
|
||||
NRPCClientURL := create_files.FindNRPCClientURL()
|
||||
TextNRPCClient = create_files.AddImport(TextNRPCClient, NRPCClientURL)
|
||||
|
||||
GRPCConstantsURL := create_files.FindGRPCConstantsURL()
|
||||
TextNRPCClient = create_files.AddImport(TextNRPCClient, GRPCConstantsURL)
|
||||
|
||||
TableURL := create_files.FindModelTableURL(TableName)
|
||||
TextNRPCClient = create_files.AddImport(TextNRPCClient, TableURL)
|
||||
}
|
||||
|
||||
//создание текста
|
||||
ModelName := Table1.NameGo
|
||||
TextNRPCClient = strings.ReplaceAll(TextNRPCClient, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
||||
@ -133,6 +150,17 @@ func CreateTestFiles(Table1 *types.Table) error {
|
||||
//заменим имя пакета на новое
|
||||
create_files.ReplacePackageName(TextNRPCClient, DirReadyTable)
|
||||
|
||||
//заменим импорты
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextNRPCClient = create_files.DeleteTemplateRepositoryImports(TextNRPCClient)
|
||||
|
||||
NRPCClientURL := create_files.FindNRPCClientURL()
|
||||
TextNRPCClient = create_files.AddImport(TextNRPCClient, NRPCClientURL)
|
||||
|
||||
TableURL := create_files.FindModelTableURL(TableName)
|
||||
TextNRPCClient = create_files.AddImport(TextNRPCClient, TableURL)
|
||||
}
|
||||
|
||||
//создание текста
|
||||
ModelName := Table1.NameGo
|
||||
TextNRPCClient = strings.ReplaceAll(TextNRPCClient, config.Settings.TEXT_TEMPLATE_MODEL, ModelName)
|
||||
|
@ -53,22 +53,22 @@ func CreateServerGRPCStarter() error {
|
||||
//создадим папку ready
|
||||
folders.CreateFolder(DirReadyServerGRPC)
|
||||
|
||||
//заменим имя сервиса на новое
|
||||
ServiceNameTemplate := config.Settings.TEMPLATE_SERVICE_NAME
|
||||
ServiceName := config.Settings.SERVICE_NAME
|
||||
TextGRPCStarter = strings.ReplaceAll(TextGRPCStarter, ServiceNameTemplate, ServiceName)
|
||||
TextGRPCStarter = strings.ReplaceAll(TextGRPCStarter, micro.StringFromUpperCase(ServiceNameTemplate), micro.StringFromUpperCase(ServiceName))
|
||||
|
||||
//заменим имя сервиса на новое с CamelCase
|
||||
ServiceNameTemplate = create_files.FormatName(ServiceNameTemplate)
|
||||
ServiceName = create_files.FormatName(ServiceName)
|
||||
TextGRPCStarter = strings.ReplaceAll(TextGRPCStarter, ServiceNameTemplate, ServiceName)
|
||||
TextGRPCStarter = strings.ReplaceAll(TextGRPCStarter, micro.StringFromUpperCase(ServiceNameTemplate), micro.StringFromUpperCase(ServiceName))
|
||||
|
||||
//добавим импорты
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextGRPCStarter = create_files.DeleteTemplateRepositoryImports(TextGRPCStarter)
|
||||
|
||||
//заменим имя сервиса на новое
|
||||
ServiceNameTemplate := config.Settings.TEMPLATE_SERVICE_NAME
|
||||
ServiceName := config.Settings.SERVICE_NAME
|
||||
TextGRPCStarter = strings.ReplaceAll(TextGRPCStarter, ServiceNameTemplate, ServiceName)
|
||||
TextGRPCStarter = strings.ReplaceAll(TextGRPCStarter, micro.StringFromUpperCase(ServiceNameTemplate), micro.StringFromUpperCase(ServiceName))
|
||||
|
||||
//заменим имя сервиса на новое с CamelCase
|
||||
ServiceNameTemplate = create_files.FormatName(ServiceNameTemplate)
|
||||
ServiceName = create_files.FormatName(ServiceName)
|
||||
TextGRPCStarter = strings.ReplaceAll(TextGRPCStarter, ServiceNameTemplate, ServiceName)
|
||||
TextGRPCStarter = strings.ReplaceAll(TextGRPCStarter, micro.StringFromUpperCase(ServiceNameTemplate), micro.StringFromUpperCase(ServiceName))
|
||||
|
||||
//proto
|
||||
ProtoURL := create_files.FindGRPCProtoURL()
|
||||
TextGRPCStarter = create_files.AddImport(TextGRPCStarter, ProtoURL)
|
||||
}
|
||||
|
@ -53,26 +53,14 @@ func CreateServerGRPCStarter() error {
|
||||
folders.CreateFolder(DirReadyServerNRPC)
|
||||
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
//заменим имя сервиса на новое
|
||||
//ServiceNameTemplate := config.Settings.TEMPLATE_SERVICE_NAME
|
||||
//ServiceName := config.Settings.SERVICE_NAME
|
||||
//TextNRPCStarter = strings.ReplaceAll(TextNRPCStarter, ServiceNameTemplate, ServiceName)
|
||||
//TextNRPCStarter = strings.ReplaceAll(TextNRPCStarter, micro.StringFromUpperCase(ServiceNameTemplate), micro.StringFromUpperCase(ServiceName))
|
||||
|
||||
TextNRPCStarter = create_files.DeleteTemplateRepositoryImports(TextNRPCStarter)
|
||||
|
||||
//ProtoURL := create_files.FindProtoURL() + "/grpc_proto"
|
||||
//TextNRPCStarter = create_files.AddImport(TextNRPCStarter, ProtoURL)
|
||||
//
|
||||
//GRPCServer_URL := create_files.FindGRPCServerlURL()
|
||||
//TextNRPCStarter = create_files.AddImport(TextNRPCStarter, GRPCServer_URL)
|
||||
|
||||
//Proto URL
|
||||
RepositoryProtoURL := create_files.FindGRPCProtoURL()
|
||||
TextNRPCStarter = create_files.AddImport(TextNRPCStarter, RepositoryProtoURL)
|
||||
|
||||
//server grpc URL
|
||||
RepositoryServerGRPCURL := create_files.FindGRPCServerlURL()
|
||||
RepositoryServerGRPCURL := create_files.FindGRPCServerURL()
|
||||
TextNRPCStarter = create_files.AddImport(TextNRPCStarter, RepositoryServerGRPCURL)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user