1
0
mirror of https://github.com/ManyakRus/crud_generator.git synced 2024-12-22 00:36:41 +02:00
crud_generator/internal/logic/logic.go

182 lines
4.8 KiB
Go
Raw Normal View History

2023-09-28 16:45:44 +02:00
package logic
import (
2023-11-15 12:58:31 +02:00
"github.com/ManyakRus/crud_generator/internal/config"
2023-10-26 16:03:50 +02:00
"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/db_crud_tables"
2023-11-16 14:08:10 +02:00
"github.com/ManyakRus/crud_generator/internal/create_files/db_tables"
"github.com/ManyakRus/crud_generator/internal/create_files/env_file"
2023-11-15 16:59:21 +02:00
"github.com/ManyakRus/crud_generator/internal/create_files/generation_code_sh"
2023-11-17 13:57:47 +02:00
"github.com/ManyakRus/crud_generator/internal/create_files/grpc_client"
2023-11-16 11:59:02 +02:00
"github.com/ManyakRus/crud_generator/internal/create_files/grpc_client_tables"
2023-12-01 15:00:11 +02:00
"github.com/ManyakRus/crud_generator/internal/create_files/grpc_server_tables"
2023-11-15 10:43:15 +02:00
"github.com/ManyakRus/crud_generator/internal/create_files/main_file"
2023-11-15 16:59:21 +02:00
"github.com/ManyakRus/crud_generator/internal/create_files/makefile"
2023-10-24 17:03:04 +02:00
"github.com/ManyakRus/crud_generator/internal/create_files/model"
"github.com/ManyakRus/crud_generator/internal/create_files/nrpc_client"
2023-11-17 15:48:58 +02:00
"github.com/ManyakRus/crud_generator/internal/create_files/nrpc_client_tables"
"github.com/ManyakRus/crud_generator/internal/create_files/protobuf"
"github.com/ManyakRus/crud_generator/internal/create_files/server_grpc_func"
2023-11-15 10:43:15 +02:00
"github.com/ManyakRus/crud_generator/internal/create_files/server_grpc_starter"
2023-11-15 12:58:31 +02:00
"github.com/ManyakRus/crud_generator/internal/create_files/server_nrpc_starter"
"github.com/ManyakRus/crud_generator/internal/folders"
2023-09-28 16:45:44 +02:00
"github.com/ManyakRus/crud_generator/internal/postgres"
"github.com/ManyakRus/starter/log"
2023-11-15 12:58:31 +02:00
"github.com/ManyakRus/starter/micro"
2023-09-28 16:45:44 +02:00
)
//var MassTable []types.Table
2023-10-24 17:03:04 +02:00
func StartFillAll() error {
var err error
2023-09-28 16:45:44 +02:00
//заполним MapAll
MapAll, err := postgres.FillMapTable()
if err != nil {
log.Error("FillMapTable() error: ", err)
2023-10-24 17:03:04 +02:00
return err
2023-09-28 16:45:44 +02:00
}
2023-10-24 17:03:04 +02:00
if len(MapAll) == 0 {
2023-11-29 14:56:40 +02:00
log.Error("FillMapTable()error: len(MapAll) == 0")
2023-10-24 17:03:04 +02:00
return err
2023-09-28 16:45:44 +02:00
}
2023-11-15 12:58:31 +02:00
//копируем все файлы
dir := micro.ProgramDir_bin()
err = folders.CopyAllFiles_Exclude_(dir+config.Settings.TEMPLATE_FOLDERNAME, dir+config.Settings.READY_FOLDERNAME)
if err != nil {
2023-11-29 14:56:40 +02:00
//log.Error("folders.CopyAllFiles_Exclude_() error: ", err)
2023-11-15 12:58:31 +02:00
return err
}
2023-11-08 16:37:35 +02:00
2023-10-25 15:22:30 +02:00
//модель
2023-10-26 10:33:12 +02:00
err = model.CreateAllFiles(MapAll)
2023-10-25 15:22:30 +02:00
if err != nil {
2023-11-29 14:56:40 +02:00
//log.Error("model.CreateAllFiles() error: ", err)
2023-10-25 15:22:30 +02:00
return err
}
//db crud
err = db_crud_tables.CreateAllFiles(MapAll)
2023-10-26 10:33:12 +02:00
if err != nil {
2023-11-29 14:56:40 +02:00
//log.Error("db_crud_tables.CreateAllFiles() error: ", err)
2023-10-26 10:33:12 +02:00
return err
}
//grpc_server
2023-12-01 15:00:11 +02:00
err = grpc_server_tables.CreateAllFiles(MapAll)
2023-10-26 10:33:12 +02:00
if err != nil {
2023-11-29 14:56:40 +02:00
//log.Error("grpc_server.CreateAllFiles() error: ", err)
2023-10-26 10:33:12 +02:00
return err
}
2023-11-17 13:57:47 +02:00
//grpc_client tables
2023-11-16 11:59:02 +02:00
err = grpc_client_tables.CreateAllFiles(MapAll)
2023-10-25 15:22:30 +02:00
if err != nil {
2023-11-29 14:56:40 +02:00
//log.Error("grpc_client_tables.CreateAllFiles() error: ", err)
2023-10-25 15:22:30 +02:00
return err
}
2023-09-28 16:45:44 +02:00
2023-11-17 13:57:47 +02:00
//grpc_client
err = grpc_client.CreateAllFiles()
if err != nil {
2023-11-29 14:56:40 +02:00
//log.Error("grpc_client.CreateAllFiles() error: ", err)
2023-11-17 13:57:47 +02:00
return err
}
//nrpc_client
err = nrpc_client.CreateAllFiles()
if err != nil {
2023-11-29 14:56:40 +02:00
//log.Error("nrpc_client.CreateAllFiles() error: ", err)
return err
}
2023-10-26 13:18:38 +02:00
//grpc_client
2023-11-17 15:48:58 +02:00
err = nrpc_client_tables.CreateAllFiles(MapAll)
2023-10-26 13:18:38 +02:00
if err != nil {
2023-11-29 14:56:40 +02:00
//log.Error("nrpc_client_tables.CreateAllFiles() error: ", err)
2023-10-26 13:18:38 +02:00
return err
}
//grpc_proto
err = protobuf.CreateAllFiles(MapAll)
2023-10-26 13:18:38 +02:00
if err != nil {
2023-11-29 14:56:40 +02:00
//log.Error("protobuf.CreateAllFiles() error: ", err)
2023-10-26 13:18:38 +02:00
return err
}
2023-10-26 16:03:50 +02:00
//crud_starter
err = crud_starter.CreateAllFiles(MapAll)
if err != nil {
2023-11-29 14:56:40 +02:00
//log.Error("crud_starter.CreateAllFiles() error: ", err)
2023-10-26 16:03:50 +02:00
return err
}
2023-11-15 10:43:15 +02:00
//main file
err = main_file.CreateAllFiles()
if err != nil {
2023-11-29 14:56:40 +02:00
//log.Error("main_file.CreateAllFiles() error: ", err)
2023-11-15 10:43:15 +02:00
return err
}
//server_grpc_starter
err = server_grpc_starter.CreateAllFiles()
if err != nil {
2023-11-29 14:56:40 +02:00
//log.Error("server_grpc_starter.CreateAllFiles() error: ", err)
2023-11-15 10:43:15 +02:00
return err
}
2023-11-15 12:58:31 +02:00
//server_nrpc_starter
err = server_nrpc_starter.CreateAllFiles()
if err != nil {
2023-11-29 14:56:40 +02:00
//log.Error("server_nrpc_starter.CreateAllFiles() error: ", err)
2023-11-15 12:58:31 +02:00
return err
}
//server_grpc_func
err = server_grpc_func.CreateAllFiles()
if err != nil {
2023-11-29 14:56:40 +02:00
//log.Error("server_grpc_func.CreateAllFiles() error: ", err)
return err
}
2023-11-15 16:59:21 +02:00
//makefile
err = makefile.CreateAllFiles()
if err != nil {
2023-11-29 14:56:40 +02:00
//log.Error("makefile.CreateAllFiles() error: ", err)
2023-11-15 16:59:21 +02:00
return err
}
//generation_code.sh
err = generation_code_sh.CreateAllFiles()
if err != nil {
2023-11-29 14:56:40 +02:00
//log.Error("generation_code_sh.CreateAllFiles() error: ", err)
2023-11-15 16:59:21 +02:00
return err
}
2023-11-16 14:08:10 +02:00
//tables
err = db_tables.CreateAllFiles(MapAll)
if err != nil {
2023-11-29 14:56:40 +02:00
//log.Error("db_tables.CreateAllFiles() error: ", err)
2023-11-16 14:08:10 +02:00
return err
}
//tables
err = crud_starter_tables.CreateAllFiles(MapAll)
if err != nil {
//log.Error("db_tables.CreateAllFiles() error: ", err)
return err
}
//env
err = env_file.CreateAllFiles()
if err != nil {
2023-11-29 14:56:40 +02:00
//log.Error("env_file.CreateAllFiles() error: ", err)
return err
}
2023-10-24 17:03:04 +02:00
return err
2023-09-28 16:45:44 +02:00
}