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)
|
||||
|
||||
NEW_REPO=$(SERVICENAME)
|
||||
CD_GENERATION_PROTO=cd ./pkg/network/grpc
|
||||
CD_GENERATION_PROTO=cd ./api
|
||||
GENERATION_PROTO=generation_code.sh
|
||||
|
||||
|
||||
@ -57,3 +57,4 @@ init:
|
||||
$(CD_GENERATION_PROTO)
|
||||
$(GENERATION_PROTO)
|
||||
go mod tidy
|
||||
go mod vendor
|
@ -3,7 +3,7 @@ package server_grpc
|
||||
import (
|
||||
"errors"
|
||||
"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
|
||||
|
@ -5,12 +5,17 @@ import (
|
||||
"github.com/ManyakRus/starter/log"
|
||||
"github.com/ManyakRus/starter/stopapp"
|
||||
"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/pkg/network/grpc/grpc_proto"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
//// server is used to implement UnimplementedSyncServiceServer.
|
||||
//type server struct {
|
||||
//}
|
||||
|
||||
type SettingsINI struct {
|
||||
NATS_HOST string
|
||||
NATS_PORT string
|
||||
@ -77,6 +82,14 @@ func FillSettings() {
|
||||
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 == "" {
|
||||
log.Panic("Need fill BUS_LOCAL_HOST ! in OS Environment ")
|
||||
@ -89,6 +102,7 @@ func FillSettings() {
|
||||
|
||||
// WaitStop - ожидает отмену глобального контекста
|
||||
func WaitStop() {
|
||||
defer stopapp.GetWaitGroup_Main().Done()
|
||||
|
||||
select {
|
||||
case <-contextmain.GetContext().Done():
|
||||
@ -100,7 +114,7 @@ func WaitStop() {
|
||||
|
||||
//закрываем соединение
|
||||
CloseConnection()
|
||||
stopapp.GetWaitGroup_Main().Done()
|
||||
|
||||
}
|
||||
|
||||
// Start - необходимые процедуры для запуска сервера GRPC
|
||||
|
@ -81,7 +81,10 @@ func FillSettings() {
|
||||
Settings.TEXT_TEMPLATE_TABLENAME = os.Getenv("TEXT_TEMPLATE_TABLENAME")
|
||||
Settings.TEMPLATE_SERVICE_NAME = os.Getenv("TEMPLATE_SERVICE_NAME")
|
||||
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.PREFIX_SERVER_GRPC = os.Getenv("PREFIX_SERVER_GRPC")
|
||||
|
||||
|
@ -82,7 +82,7 @@ func DeleteFuncFromFuncName(Text, FuncName string) string {
|
||||
func DeleteFuncFromComment(Text, Comment string) string {
|
||||
Otvet := Text
|
||||
|
||||
TextFind := "\n// " + Comment
|
||||
TextFind := Comment
|
||||
pos1 := strings.Index(Otvet, TextFind)
|
||||
if pos1 < 0 {
|
||||
return Otvet
|
||||
@ -328,7 +328,8 @@ func FindTableNameURL(TableName string) string {
|
||||
func FindProtoURL() string {
|
||||
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
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ func CreateMakefile() error {
|
||||
|
||||
//заполним 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)
|
||||
|
||||
//заполним GENERATION_PROTO
|
||||
|
@ -211,7 +211,7 @@ func DeleteFunctions(Text, TableName string, MapModelCrudDeleteFunctions map[str
|
||||
|
||||
MassDelete := strings.Split(TextDelete, ",")
|
||||
for _, FunctionName1 := range MassDelete {
|
||||
Otvet = create_files.DeleteFuncFromComment(Otvet, FunctionName1)
|
||||
Otvet = create_files.DeleteFuncFromComment(Otvet, "\n// "+FunctionName1)
|
||||
Otvet = create_files.DeleteFuncFromFuncName(Otvet, FunctionName1)
|
||||
}
|
||||
|
||||
|
@ -65,14 +65,22 @@ func CreateServerGRPCStarter() error {
|
||||
TextNRPCStarter = create_files.AddImport(TextNRPCStarter, RepositoryServerGRPCURL)
|
||||
}
|
||||
|
||||
//найдём текст после конца импортов
|
||||
TextAfterImport := ""
|
||||
pos1 := strings.Index(TextNRPCStarter, "\n)")
|
||||
if pos1 >= 0 {
|
||||
TextAfterImport = TextNRPCStarter[pos1+2:]
|
||||
}
|
||||
|
||||
//заменим название сервиса
|
||||
ServiceName := config.Settings.SERVICE_NAME
|
||||
ServiceNameProto := micro.StringFromUpperCase(ServiceName)
|
||||
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)
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user