mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2024-12-22 00:36:41 +02:00
сделал api
This commit is contained in:
parent
067419e4a6
commit
62cf2a573e
@ -5,7 +5,7 @@ FILEMAIN=./cmd/$(SERVICENAME)/main.go
|
|||||||
FILEAPP=./bin/$(SERVICENAME)
|
FILEAPP=./bin/$(SERVICENAME)
|
||||||
|
|
||||||
NEW_REPO=$(SERVICENAME)
|
NEW_REPO=$(SERVICENAME)
|
||||||
CD_GENERATION_PROTO=cd ./pkg/network/grpc
|
CD_GENERATION_PROTO=cd ./api
|
||||||
GENERATION_PROTO=generation_code.sh
|
GENERATION_PROTO=generation_code.sh
|
||||||
|
|
||||||
|
|
||||||
@ -57,3 +57,4 @@ init:
|
|||||||
$(CD_GENERATION_PROTO)
|
$(CD_GENERATION_PROTO)
|
||||||
$(GENERATION_PROTO)
|
$(GENERATION_PROTO)
|
||||||
go mod tidy
|
go mod tidy
|
||||||
|
go mod vendor
|
@ -3,7 +3,7 @@ package server_grpc
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/ManyakRus/starter/micro"
|
"github.com/ManyakRus/starter/micro"
|
||||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_client/constants"
|
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrorModelVersion
|
// ErrorModelVersion
|
||||||
|
@ -5,12 +5,17 @@ import (
|
|||||||
"github.com/ManyakRus/starter/log"
|
"github.com/ManyakRus/starter/log"
|
||||||
"github.com/ManyakRus/starter/stopapp"
|
"github.com/ManyakRus/starter/stopapp"
|
||||||
"github.com/nats-io/nats.go"
|
"github.com/nats-io/nats.go"
|
||||||
|
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/api/grpc_proto"
|
||||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/internal/app/grpc/server_grpc"
|
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/internal/app/grpc/server_grpc"
|
||||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/grpc_proto"
|
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//// server is used to implement UnimplementedSyncServiceServer.
|
||||||
|
//type server struct {
|
||||||
|
//}
|
||||||
|
|
||||||
type SettingsINI struct {
|
type SettingsINI struct {
|
||||||
NATS_HOST string
|
NATS_HOST string
|
||||||
NATS_PORT string
|
NATS_PORT string
|
||||||
@ -77,6 +82,14 @@ func FillSettings() {
|
|||||||
Settings.NATS_PORT = os.Getenv("BUS_LOCAL_PORT")
|
Settings.NATS_PORT = os.Getenv("BUS_LOCAL_PORT")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//удалим лишний :порт
|
||||||
|
if Settings.NATS_PORT != "" {
|
||||||
|
pos1 := strings.Index(Settings.NATS_HOST, ":")
|
||||||
|
if pos1 > 0 {
|
||||||
|
Settings.NATS_HOST = Settings.NATS_HOST[0:pos1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//проверка
|
//проверка
|
||||||
if Settings.NATS_HOST == "" {
|
if Settings.NATS_HOST == "" {
|
||||||
log.Panic("Need fill BUS_LOCAL_HOST ! in OS Environment ")
|
log.Panic("Need fill BUS_LOCAL_HOST ! in OS Environment ")
|
||||||
@ -89,6 +102,7 @@ func FillSettings() {
|
|||||||
|
|
||||||
// WaitStop - ожидает отмену глобального контекста
|
// WaitStop - ожидает отмену глобального контекста
|
||||||
func WaitStop() {
|
func WaitStop() {
|
||||||
|
defer stopapp.GetWaitGroup_Main().Done()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-contextmain.GetContext().Done():
|
case <-contextmain.GetContext().Done():
|
||||||
@ -100,7 +114,7 @@ func WaitStop() {
|
|||||||
|
|
||||||
//закрываем соединение
|
//закрываем соединение
|
||||||
CloseConnection()
|
CloseConnection()
|
||||||
stopapp.GetWaitGroup_Main().Done()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start - необходимые процедуры для запуска сервера GRPC
|
// Start - необходимые процедуры для запуска сервера GRPC
|
||||||
|
@ -81,7 +81,10 @@ func FillSettings() {
|
|||||||
Settings.TEXT_TEMPLATE_TABLENAME = os.Getenv("TEXT_TEMPLATE_TABLENAME")
|
Settings.TEXT_TEMPLATE_TABLENAME = os.Getenv("TEXT_TEMPLATE_TABLENAME")
|
||||||
Settings.TEMPLATE_SERVICE_NAME = os.Getenv("TEMPLATE_SERVICE_NAME")
|
Settings.TEMPLATE_SERVICE_NAME = os.Getenv("TEMPLATE_SERVICE_NAME")
|
||||||
Settings.TEMPLATE_FOLDERNAME_CRUD_STARTER = os.Getenv("TEMPLATE_FOLDERNAME_CRUD_STARTER")
|
Settings.TEMPLATE_FOLDERNAME_CRUD_STARTER = os.Getenv("TEMPLATE_FOLDERNAME_CRUD_STARTER")
|
||||||
Settings.SERVICE_REPOSITORY_URL = os.Getenv("SERVICE_REPOSITORY_URL")
|
|
||||||
|
SERVICE_REPOSITORY_URL := strings.ToLower(os.Getenv("SERVICE_REPOSITORY_URL"))
|
||||||
|
Settings.SERVICE_REPOSITORY_URL = SERVICE_REPOSITORY_URL
|
||||||
|
|
||||||
Settings.TEMPLATE_FOLDERNAME_ALIAS = os.Getenv("TEMPLATE_FOLDERNAME_ALIAS")
|
Settings.TEMPLATE_FOLDERNAME_ALIAS = os.Getenv("TEMPLATE_FOLDERNAME_ALIAS")
|
||||||
Settings.PREFIX_SERVER_GRPC = os.Getenv("PREFIX_SERVER_GRPC")
|
Settings.PREFIX_SERVER_GRPC = os.Getenv("PREFIX_SERVER_GRPC")
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ func DeleteFuncFromFuncName(Text, FuncName string) string {
|
|||||||
func DeleteFuncFromComment(Text, Comment string) string {
|
func DeleteFuncFromComment(Text, Comment string) string {
|
||||||
Otvet := Text
|
Otvet := Text
|
||||||
|
|
||||||
TextFind := "\n// " + Comment
|
TextFind := Comment
|
||||||
pos1 := strings.Index(Otvet, TextFind)
|
pos1 := strings.Index(Otvet, TextFind)
|
||||||
if pos1 < 0 {
|
if pos1 < 0 {
|
||||||
return Otvet
|
return Otvet
|
||||||
@ -328,7 +328,8 @@ func FindTableNameURL(TableName string) string {
|
|||||||
func FindProtoURL() string {
|
func FindProtoURL() string {
|
||||||
Otvet := ""
|
Otvet := ""
|
||||||
|
|
||||||
Otvet = config.Settings.SERVICE_REPOSITORY_URL + "/" + config.Settings.TEMPLATE_FOLDERNAME_GRPC_PROTO + "/" + "grpc_proto"
|
TEMPLATE_FOLDERNAME_GRPC_PROTO := strings.ToLower(config.Settings.TEMPLATE_FOLDERNAME_GRPC_PROTO)
|
||||||
|
Otvet = config.Settings.SERVICE_REPOSITORY_URL + "/" + TEMPLATE_FOLDERNAME_GRPC_PROTO + "/" + "grpc_proto"
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ func CreateMakefile() error {
|
|||||||
|
|
||||||
//заполним GENERATION_PROTO
|
//заполним GENERATION_PROTO
|
||||||
VariableName = "CD_GENERATION_PROTO"
|
VariableName = "CD_GENERATION_PROTO"
|
||||||
Value = "cd ./" + config.Settings.TEMPLATE_FOLDERNAME_GRPC + " && \\"
|
Value = "cd ./" + config.Settings.TEMPLATE_FOLDERNAME_GRPC_PROTO + " && \\"
|
||||||
TextMakefile = ReplaceVariable(TextMakefile, VariableName, Value)
|
TextMakefile = ReplaceVariable(TextMakefile, VariableName, Value)
|
||||||
|
|
||||||
//заполним GENERATION_PROTO
|
//заполним GENERATION_PROTO
|
||||||
|
@ -211,7 +211,7 @@ func DeleteFunctions(Text, TableName string, MapModelCrudDeleteFunctions map[str
|
|||||||
|
|
||||||
MassDelete := strings.Split(TextDelete, ",")
|
MassDelete := strings.Split(TextDelete, ",")
|
||||||
for _, FunctionName1 := range MassDelete {
|
for _, FunctionName1 := range MassDelete {
|
||||||
Otvet = create_files.DeleteFuncFromComment(Otvet, FunctionName1)
|
Otvet = create_files.DeleteFuncFromComment(Otvet, "\n// "+FunctionName1)
|
||||||
Otvet = create_files.DeleteFuncFromFuncName(Otvet, FunctionName1)
|
Otvet = create_files.DeleteFuncFromFuncName(Otvet, FunctionName1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,14 +65,22 @@ func CreateServerGRPCStarter() error {
|
|||||||
TextNRPCStarter = create_files.AddImport(TextNRPCStarter, RepositoryServerGRPCURL)
|
TextNRPCStarter = create_files.AddImport(TextNRPCStarter, RepositoryServerGRPCURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//найдём текст после конца импортов
|
||||||
|
TextAfterImport := ""
|
||||||
|
pos1 := strings.Index(TextNRPCStarter, "\n)")
|
||||||
|
if pos1 >= 0 {
|
||||||
|
TextAfterImport = TextNRPCStarter[pos1+2:]
|
||||||
|
}
|
||||||
|
|
||||||
//заменим название сервиса
|
//заменим название сервиса
|
||||||
ServiceName := config.Settings.SERVICE_NAME
|
ServiceName := config.Settings.SERVICE_NAME
|
||||||
ServiceNameProto := micro.StringFromUpperCase(ServiceName)
|
ServiceNameProto := micro.StringFromUpperCase(ServiceName)
|
||||||
TEMPLATE_SERVICE_NAME := config.Settings.TEMPLATE_SERVICE_NAME
|
TEMPLATE_SERVICE_NAME := config.Settings.TEMPLATE_SERVICE_NAME
|
||||||
TextNRPCStarter = strings.ReplaceAll(TextNRPCStarter, TEMPLATE_SERVICE_NAME, ServiceNameProto)
|
TextAfterImport = strings.ReplaceAll(TextAfterImport, TEMPLATE_SERVICE_NAME, ServiceNameProto)
|
||||||
//заменим ещё раз с большой буквы
|
//заменим ещё раз с большой буквы
|
||||||
TEMPLATE_SERVICE_NAME = micro.StringFromUpperCase(TEMPLATE_SERVICE_NAME)
|
TEMPLATE_SERVICE_NAME = micro.StringFromUpperCase(TEMPLATE_SERVICE_NAME)
|
||||||
TextNRPCStarter = strings.ReplaceAll(TextNRPCStarter, TEMPLATE_SERVICE_NAME, ServiceNameProto)
|
TextAfterImport = strings.ReplaceAll(TextAfterImport, TEMPLATE_SERVICE_NAME, ServiceNameProto)
|
||||||
|
TextNRPCStarter = TextNRPCStarter[:pos1+2] + TextAfterImport
|
||||||
|
|
||||||
//удаление пустого импорта
|
//удаление пустого импорта
|
||||||
TextNRPCStarter = create_files.DeleteEmptyImport(TextNRPCStarter)
|
TextNRPCStarter = create_files.DeleteEmptyImport(TextNRPCStarter)
|
||||||
|
Loading…
Reference in New Issue
Block a user