mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2025-01-03 01:22:21 +02:00
сделал api
This commit is contained in:
parent
634d316da3
commit
48302a229a
@ -5,8 +5,7 @@ FILEMAIN=./cmd/$(SERVICENAME)/main.go
|
|||||||
FILEAPP=./bin/$(SERVICENAME)
|
FILEAPP=./bin/$(SERVICENAME)
|
||||||
|
|
||||||
NEW_REPO=$(SERVICENAME)
|
NEW_REPO=$(SERVICENAME)
|
||||||
CD_GENERATION_PROTO=cd ./api
|
GENERATION_PROTO=cd ./api && ./generation_code.sh
|
||||||
GENERATION_PROTO=generation_code.sh
|
|
||||||
|
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@ -54,7 +53,6 @@ conn:
|
|||||||
init:
|
init:
|
||||||
clear
|
clear
|
||||||
go mod init gitlab.aescorp.ru/dsp_dev/claim/sync_service
|
go mod init gitlab.aescorp.ru/dsp_dev/claim/sync_service
|
||||||
$(CD_GENERATION_PROTO)
|
|
||||||
$(GENERATION_PROTO)
|
$(GENERATION_PROTO)
|
||||||
go mod tidy
|
go mod tidy
|
||||||
go mod vendor
|
go mod vendor
|
@ -91,7 +91,13 @@ func CreateENV() error {
|
|||||||
Value = postgres_gorm.Settings.DB_PASSWORD
|
Value = postgres_gorm.Settings.DB_PASSWORD
|
||||||
TextMakefile = ReplaceVariable(TextMakefile, VariableName, Value)
|
TextMakefile = ReplaceVariable(TextMakefile, VariableName, Value)
|
||||||
|
|
||||||
//запись файла
|
//запись файла в корень проекта
|
||||||
|
err = os.WriteFile(FilenameReadyENV, []byte(TextMakefile), constants.FILE_PERMISSIONS)
|
||||||
|
|
||||||
|
//запись файла в bin
|
||||||
|
Dir := DirReady + "bin" + micro.SeparatorFile()
|
||||||
|
folders.CreateFolder(Dir)
|
||||||
|
FilenameReadyENV = Dir + constants.ENV_FILENAME
|
||||||
err = os.WriteFile(FilenameReadyENV, []byte(TextMakefile), constants.FILE_PERMISSIONS)
|
err = os.WriteFile(FilenameReadyENV, []byte(TextMakefile), constants.FILE_PERMISSIONS)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
@ -57,14 +57,14 @@ func CreateMakefile() error {
|
|||||||
Value := config.Settings.SERVICE_REPOSITORY_URL
|
Value := config.Settings.SERVICE_REPOSITORY_URL
|
||||||
TextMakefile = ReplaceVariable(TextMakefile, VariableName, Value)
|
TextMakefile = ReplaceVariable(TextMakefile, VariableName, Value)
|
||||||
|
|
||||||
//заполним GENERATION_PROTO
|
////заполним GENERATION_PROTO
|
||||||
VariableName = "CD_GENERATION_PROTO"
|
//VariableName = "CD_GENERATION_PROTO"
|
||||||
Value = "cd ./" + config.Settings.TEMPLATE_FOLDERNAME_GRPC_PROTO + " && \\"
|
//Value = "cd ./" + config.Settings.TEMPLATE_FOLDERNAME_GRPC_PROTO + " && \\"
|
||||||
TextMakefile = ReplaceVariable(TextMakefile, VariableName, Value)
|
//TextMakefile = ReplaceVariable(TextMakefile, VariableName, Value)
|
||||||
|
|
||||||
//заполним GENERATION_PROTO
|
//заполним GENERATION_PROTO
|
||||||
VariableName = "GENERATION_PROTO"
|
VariableName = "GENERATION_PROTO"
|
||||||
Value = "./" + constants.GENERATION_PROTO_FILENAME
|
Value = "cd ./" + config.Settings.TEMPLATE_FOLDERNAME_GRPC_PROTO + " && " + "./" + constants.GENERATION_PROTO_FILENAME
|
||||||
TextMakefile = ReplaceVariable(TextMakefile, VariableName, Value)
|
TextMakefile = ReplaceVariable(TextMakefile, VariableName, Value)
|
||||||
|
|
||||||
//запись файла
|
//запись файла
|
||||||
|
@ -53,18 +53,6 @@ func CreateServerGRPCStarter() error {
|
|||||||
//заменим имя пакета на новое
|
//заменим имя пакета на новое
|
||||||
create_files.ReplacePackageName(TextGRPCStarter, DirReadyServerGRPC)
|
create_files.ReplacePackageName(TextGRPCStarter, 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 {
|
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||||
TextGRPCStarter = create_files.DeleteTemplateRepositoryImports(TextGRPCStarter)
|
TextGRPCStarter = create_files.DeleteTemplateRepositoryImports(TextGRPCStarter)
|
||||||
@ -73,6 +61,26 @@ func CreateServerGRPCStarter() error {
|
|||||||
TextGRPCStarter = create_files.AddImport(TextGRPCStarter, ProtoURL)
|
TextGRPCStarter = create_files.AddImport(TextGRPCStarter, ProtoURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//найдём текст после конца импортов
|
||||||
|
TextAfterImport := ""
|
||||||
|
pos1 := strings.Index(TextGRPCStarter, "\n)")
|
||||||
|
if pos1 >= 0 {
|
||||||
|
TextAfterImport = TextGRPCStarter[pos1+2:]
|
||||||
|
}
|
||||||
|
|
||||||
|
//заменим имя сервиса на новое
|
||||||
|
ServiceNameTemplate := config.Settings.TEMPLATE_SERVICE_NAME
|
||||||
|
ServiceName := config.Settings.SERVICE_NAME
|
||||||
|
TextAfterImport = strings.ReplaceAll(TextAfterImport, ServiceNameTemplate, ServiceName)
|
||||||
|
TextAfterImport = strings.ReplaceAll(TextAfterImport, micro.StringFromUpperCase(ServiceNameTemplate), micro.StringFromUpperCase(ServiceName))
|
||||||
|
|
||||||
|
//заменим имя сервиса на новое с CamelCase
|
||||||
|
ServiceNameTemplate = create_files.FormatName(ServiceNameTemplate)
|
||||||
|
ServiceName = create_files.FormatName(ServiceName)
|
||||||
|
TextAfterImport = strings.ReplaceAll(TextAfterImport, ServiceNameTemplate, ServiceName)
|
||||||
|
TextAfterImport = strings.ReplaceAll(TextAfterImport, micro.StringFromUpperCase(ServiceNameTemplate), micro.StringFromUpperCase(ServiceName))
|
||||||
|
TextGRPCStarter = TextGRPCStarter[:pos1+2] + TextAfterImport
|
||||||
|
|
||||||
//удаление пустого импорта
|
//удаление пустого импорта
|
||||||
TextGRPCStarter = create_files.DeleteEmptyImport(TextGRPCStarter)
|
TextGRPCStarter = create_files.DeleteEmptyImport(TextGRPCStarter)
|
||||||
|
|
||||||
|
@ -234,6 +234,10 @@ func DeleteFolder(FilenameFull string) error {
|
|||||||
func CopyAllFiles_Exclude_(src, dest string) error {
|
func CopyAllFiles_Exclude_(src, dest string) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
//создадим папку готовых файлов
|
||||||
|
CreateFolder(dest)
|
||||||
|
|
||||||
|
//скопируем все файлы
|
||||||
opt := copy_files.Options{
|
opt := copy_files.Options{
|
||||||
Skip: CopyFilesFilterGo,
|
Skip: CopyFilesFilterGo,
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ func StartFillAll() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(MapAll) == 0 {
|
if len(MapAll) == 0 {
|
||||||
|
log.Error("FillMapTable()error: len(MapAll) == 0")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,108 +46,126 @@ func StartFillAll() error {
|
|||||||
dir := micro.ProgramDir_bin()
|
dir := micro.ProgramDir_bin()
|
||||||
err = folders.CopyAllFiles_Exclude_(dir+config.Settings.TEMPLATE_FOLDERNAME, dir+config.Settings.READY_FOLDERNAME)
|
err = folders.CopyAllFiles_Exclude_(dir+config.Settings.TEMPLATE_FOLDERNAME, dir+config.Settings.READY_FOLDERNAME)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Error("folders.CopyAllFiles_Exclude_() error: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//модель
|
//модель
|
||||||
err = model.CreateAllFiles(MapAll)
|
err = model.CreateAllFiles(MapAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Error("model.CreateAllFiles() error: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//db crud
|
//db crud
|
||||||
err = db_crud_tables.CreateAllFiles(MapAll)
|
err = db_crud_tables.CreateAllFiles(MapAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Error("db_crud_tables.CreateAllFiles() error: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//grpc_server
|
//grpc_server
|
||||||
err = grpc_server.CreateAllFiles(MapAll)
|
err = grpc_server.CreateAllFiles(MapAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Error("grpc_server.CreateAllFiles() error: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//grpc_client tables
|
//grpc_client tables
|
||||||
err = grpc_client_tables.CreateAllFiles(MapAll)
|
err = grpc_client_tables.CreateAllFiles(MapAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Error("grpc_client_tables.CreateAllFiles() error: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//grpc_client
|
//grpc_client
|
||||||
err = grpc_client.CreateAllFiles()
|
err = grpc_client.CreateAllFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Error("grpc_client.CreateAllFiles() error: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//nrpc_client
|
//nrpc_client
|
||||||
err = nrpc_client.CreateAllFiles()
|
err = nrpc_client.CreateAllFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Error("nrpc_client.CreateAllFiles() error: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//grpc_client
|
//grpc_client
|
||||||
err = nrpc_client_tables.CreateAllFiles(MapAll)
|
err = nrpc_client_tables.CreateAllFiles(MapAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Error("nrpc_client_tables.CreateAllFiles() error: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//grpc_proto
|
//grpc_proto
|
||||||
err = protobuf.CreateAllFiles(MapAll)
|
err = protobuf.CreateAllFiles(MapAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Error("protobuf.CreateAllFiles() error: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//crud_starter
|
//crud_starter
|
||||||
err = crud_starter.CreateAllFiles(MapAll)
|
err = crud_starter.CreateAllFiles(MapAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Error("crud_starter.CreateAllFiles() error: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//main file
|
//main file
|
||||||
err = main_file.CreateAllFiles()
|
err = main_file.CreateAllFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Error("main_file.CreateAllFiles() error: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//server_grpc_starter
|
//server_grpc_starter
|
||||||
err = server_grpc_starter.CreateAllFiles()
|
err = server_grpc_starter.CreateAllFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Error("server_grpc_starter.CreateAllFiles() error: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//server_nrpc_starter
|
//server_nrpc_starter
|
||||||
err = server_nrpc_starter.CreateAllFiles()
|
err = server_nrpc_starter.CreateAllFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Error("server_nrpc_starter.CreateAllFiles() error: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//server_grpc_func
|
//server_grpc_func
|
||||||
err = server_grpc_func.CreateAllFiles()
|
err = server_grpc_func.CreateAllFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Error("server_grpc_func.CreateAllFiles() error: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//makefile
|
//makefile
|
||||||
err = makefile.CreateAllFiles()
|
err = makefile.CreateAllFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Error("makefile.CreateAllFiles() error: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//generation_code.sh
|
//generation_code.sh
|
||||||
err = generation_code_sh.CreateAllFiles()
|
err = generation_code_sh.CreateAllFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Error("generation_code_sh.CreateAllFiles() error: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//tables
|
//tables
|
||||||
err = db_tables.CreateAllFiles(MapAll)
|
err = db_tables.CreateAllFiles(MapAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Error("db_tables.CreateAllFiles() error: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//env
|
//env
|
||||||
err = env_file.CreateAllFiles()
|
err = env_file.CreateAllFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Error("env_file.CreateAllFiles() error: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user