mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2024-11-21 05:05:52 +02:00
сделал CreateFiles_FindModelBy()
This commit is contained in:
parent
5427c82e7d
commit
9e5826a6b2
@ -100,6 +100,10 @@ func CreateFileProto(MapAll map[string]*types.Table) error {
|
||||
TextProto, TextProtoNew1 = FindText_ReadAll(TextProto, Table1)
|
||||
TextProtoNew = TextProtoNew + TextProtoNew1
|
||||
|
||||
//добавим текст FindModelBy
|
||||
TextProto, TextProtoNew1 = FindText_FindModelBy(TextProto, Table1)
|
||||
TextProtoNew = TextProtoNew + TextProtoNew1
|
||||
|
||||
//
|
||||
if config.Settings.NEED_CREATE_CACHE_API == true {
|
||||
TextProtoNew = TextProtoNew + FindText_ProtoTable1_Cache(TextProto, Table1)
|
||||
@ -368,6 +372,41 @@ message ` + TextRequest + ` {
|
||||
` + ProtoType + ` ` + ProtoName + ` = ` + strconv.Itoa(i+2) + `; //значение поиска`
|
||||
}
|
||||
|
||||
TextMessage = TextMessage + `
|
||||
}`
|
||||
Otvet = TextMessage
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// AddTextMessageRequestModel_Column - в текст .proto добавляет message из присланных колонок
|
||||
func AddTextMessageRequestModel_Column(Text string, Column1 *types.Column) string {
|
||||
Otvet := Text
|
||||
|
||||
ProtoName := create_files.Convert_GolangTypeNameToProtobufFieldName(Column1.TypeGo)
|
||||
TextRequest := "Request_Model_" + ProtoName
|
||||
|
||||
//найдём уже есть message
|
||||
TextFind := "message " + TextRequest + " {"
|
||||
pos1 := strings.Index(Otvet, TextFind)
|
||||
if pos1 >= 0 {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
TextMessage := `
|
||||
// ` + TextRequest + ` - параметры запроса на сервер
|
||||
message ` + TextRequest + ` {
|
||||
uint32 VersionModel = 1; //версия структуры модели
|
||||
string ModelString = 2; //объект-модель в формате json
|
||||
`
|
||||
|
||||
//
|
||||
//for i, Column1 := range Columns {
|
||||
ProtoType := create_files.Convert_GolangTypeNameToProtobufTypeName(Column1.TypeGo)
|
||||
//ProtoName := create_files.Find_RequestFieldName(Table1, Column1)
|
||||
TextMessage = TextMessage + "\t" + ProtoType + ` ` + ProtoName + ` = 3; //значение поиска`
|
||||
//}
|
||||
|
||||
TextMessage = TextMessage + `
|
||||
}`
|
||||
Otvet = Otvet + "\n" + TextMessage
|
||||
|
60
internal/create_files/protobuf/protobuf_findmodelby.go
Normal file
60
internal/create_files/protobuf/protobuf_findmodelby.go
Normal file
@ -0,0 +1,60 @@
|
||||
package protobuf
|
||||
|
||||
import (
|
||||
"github.com/ManyakRus/crud_generator/internal/create_files"
|
||||
"github.com/ManyakRus/crud_generator/internal/types"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// FindText_FindModelBy - возвращает TextProto и текст FindModelBy
|
||||
func FindText_FindModelBy(TextProto string, Table1 *types.Table) (string, string) {
|
||||
Otvet := TextProto
|
||||
|
||||
Otvet2 := ""
|
||||
for _, TableColumns1 := range types.MassFindModelBy {
|
||||
if TableColumns1.Table != Table1 {
|
||||
continue
|
||||
}
|
||||
|
||||
Text1 := FindText_FindModelBy1(TableColumns1.Table, TableColumns1.Column)
|
||||
|
||||
//проверим такой текст функции уже есть
|
||||
pos1 := strings.Index(TextProto, Text1)
|
||||
if pos1 >= 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
//добавим message
|
||||
TextMess := AddTextMessageRequestModel_Column(TextProto, TableColumns1.Column)
|
||||
|
||||
//проверим такой текст message уже есть
|
||||
pos1 = strings.Index(TextProto, TextMess)
|
||||
if pos1 < 0 {
|
||||
Otvet = TextMess
|
||||
}
|
||||
|
||||
//
|
||||
Otvet2 = Otvet2 + Text1
|
||||
}
|
||||
|
||||
return Otvet, Otvet2
|
||||
}
|
||||
|
||||
// FindText_FindModelBy1 - находит текст FindModelBy
|
||||
func FindText_FindModelBy1(Table1 *types.Table, Column1 *types.Column) string {
|
||||
Otvet := "\n\trpc "
|
||||
|
||||
TextFields := ""
|
||||
TextRequest := "Request_Model_"
|
||||
Underline := ""
|
||||
//for _, Column1 := range TableColumns1.Columns {
|
||||
TextFields = TextFields + Underline + Column1.NameGo_translit
|
||||
TextRequest1 := create_files.Convert_GolangTypeNameToProtobufFieldName(Column1.TypeGo)
|
||||
TextRequest = TextRequest + Underline + TextRequest1
|
||||
Underline = "_"
|
||||
//}
|
||||
|
||||
Otvet = Otvet + Table1.NameGo_translit + "_FindModelBy_" + TextFields + "(" + TextRequest + ") returns (Response) {}\n"
|
||||
|
||||
return Otvet
|
||||
}
|
Loading…
Reference in New Issue
Block a user