2023-09-28 16:45:44 +02:00
|
|
|
package logic
|
|
|
|
|
|
|
|
import (
|
2023-10-25 15:22:30 +02:00
|
|
|
"github.com/ManyakRus/crud_generator/internal/create_files/db"
|
2023-10-26 10:33:12 +02:00
|
|
|
"github.com/ManyakRus/crud_generator/internal/create_files/grpc_client"
|
|
|
|
"github.com/ManyakRus/crud_generator/internal/create_files/grpc_server"
|
2023-10-24 17:03:04 +02:00
|
|
|
"github.com/ManyakRus/crud_generator/internal/create_files/model"
|
2023-09-28 16:45:44 +02:00
|
|
|
"github.com/ManyakRus/crud_generator/internal/postgres"
|
|
|
|
"github.com/ManyakRus/starter/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
//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 {
|
|
|
|
return err
|
2023-09-28 16:45:44 +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 {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
//db crud
|
2023-10-26 10:33:12 +02:00
|
|
|
err = db.CreateAllFiles(MapAll)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
//grpc_server
|
|
|
|
err = grpc_server.CreateAllFiles(MapAll)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
//grpc_client
|
|
|
|
err = grpc_client.CreateAllFiles(MapAll)
|
2023-10-25 15:22:30 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2023-09-28 16:45:44 +02:00
|
|
|
|
2023-10-24 17:03:04 +02:00
|
|
|
return err
|
2023-09-28 16:45:44 +02:00
|
|
|
}
|
|
|
|
|
2023-09-28 17:08:00 +02:00
|
|
|
//// MassFromMapColumns - возвращает Slice из Map
|
|
|
|
//func MassFromMapColumns(MapColumns map[string]types.Column) []types.Column {
|
|
|
|
// Otvet := make([]types.Column, 0)
|
|
|
|
//
|
|
|
|
// for _, v := range MapColumns {
|
|
|
|
// Otvet = append(Otvet, v)
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// sort.Slice(Otvet[:], func(i, j int) bool {
|
|
|
|
// return Otvet[i].OrderNumber < Otvet[j].OrderNumber
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// return Otvet
|
|
|
|
//}
|