mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2025-06-05 11:57:30 +02:00
сделал ReadAll()
This commit is contained in:
parent
f4f5d67759
commit
7314abb580
@ -289,3 +289,8 @@ message ResponseEmpty {
|
|||||||
message ResponseMass {
|
message ResponseMass {
|
||||||
repeated string MassModelString = 1; //массив объект-модель в формате json
|
repeated string MassModelString = 1; //массив объект-модель в формате json
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message Request_Empty {
|
||||||
|
uint32 VersionModel = 1; //версия структуры модели
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -63,3 +63,5 @@ const SERVER_GRPC_TABLE_CACHE_TEST_FILENAME = "server_grpc_table_cache_test.go_"
|
|||||||
|
|
||||||
const TEXT_OTVET_ID_ALIAS = "Otvet.ID = AliasFromInt(ID)" //"Otvet.ID = ID"
|
const TEXT_OTVET_ID_ALIAS = "Otvet.ID = AliasFromInt(ID)" //"Otvet.ID = ID"
|
||||||
const TEXT_CACHE_SIZE_1000 = "CACHE_SIZE"
|
const TEXT_CACHE_SIZE_1000 = "CACHE_SIZE"
|
||||||
|
|
||||||
|
const TEXT_READALL = "ReadAll"
|
||||||
|
@ -147,6 +147,13 @@ func CreateFilesFindByTable1(Table1 *types.Table, TextTemplateFunction string, M
|
|||||||
Underline = "_"
|
Underline = "_"
|
||||||
Plus = "+"
|
Plus = "+"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//кроме помеченных на удаление
|
||||||
|
if create_files.Has_Column_IsDeleted_Bool(Table1) == true {
|
||||||
|
TextWhere = TextWhere + "\t" + `tx = tx.Where("is_deleted = ?", false)` + "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
Otvet = strings.ReplaceAll(Otvet, TextFind, TextWhere)
|
Otvet = strings.ReplaceAll(Otvet, TextFind, TextWhere)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithUnderline", FieldNamesWithUnderline)
|
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithUnderline", FieldNamesWithUnderline)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithPlus", FieldNamesWithComma)
|
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithPlus", FieldNamesWithComma)
|
||||||
|
@ -152,6 +152,14 @@ func CreateFilesFindMassByTable1(Table1 *types.Table, TextTemplateFunction strin
|
|||||||
Plus = "+"
|
Plus = "+"
|
||||||
Comma = ", "
|
Comma = ", "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if len(MassColumns1) == 0 {
|
||||||
|
FuncName := constants.TEXT_READALL
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, "FindMassBy_FieldNamesWithUnderline", FuncName)
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
Otvet = strings.ReplaceAll(Otvet, TextFind, TextWhere)
|
Otvet = strings.ReplaceAll(Otvet, TextFind, TextWhere)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithUnderline", FieldNamesWithUnderline)
|
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithUnderline", FieldNamesWithUnderline)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithPlus", FieldNamesWithComma)
|
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithPlus", FieldNamesWithComma)
|
||||||
@ -283,7 +291,7 @@ func CreateFilesFindMassByTestTable1(Table1 *types.Table, TextTemplateFunction s
|
|||||||
//
|
//
|
||||||
TextAssignFind := "\t" + `Otvet.FieldName = 0` + "\n"
|
TextAssignFind := "\t" + `Otvet.FieldName = 0` + "\n"
|
||||||
TextAssign := ""
|
TextAssign := ""
|
||||||
TextFieldName_TEST := ""
|
TextFieldsDefaultValue := ""
|
||||||
|
|
||||||
Underline := ""
|
Underline := ""
|
||||||
Comma := ""
|
Comma := ""
|
||||||
@ -296,15 +304,28 @@ func CreateFilesFindMassByTestTable1(Table1 *types.Table, TextTemplateFunction s
|
|||||||
TextAssign = TextAssign + "\t" + `Otvet.` + Column1.NameGo + ` = ` + DefaultValue + "\n"
|
TextAssign = TextAssign + "\t" + `Otvet.` + Column1.NameGo + ` = ` + DefaultValue + "\n"
|
||||||
FieldNamesWithUnderline = FieldNamesWithUnderline + Underline + Column1.NameGo
|
FieldNamesWithUnderline = FieldNamesWithUnderline + Underline + Column1.NameGo
|
||||||
FieldNamesWithComma = FieldNamesWithComma + Comma + Column1.NameGo
|
FieldNamesWithComma = FieldNamesWithComma + Comma + Column1.NameGo
|
||||||
TextFieldName_TEST = TextFieldName_TEST + Comma + DefaultValue
|
TextFieldsDefaultValue = TextFieldsDefaultValue + Comma + DefaultValue
|
||||||
|
|
||||||
Underline = "_"
|
Underline = "_"
|
||||||
Comma = ", "
|
Comma = ", "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if len(MassColumns1) == 0 {
|
||||||
|
FuncName := constants.TEXT_READALL
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, "FindMassBy_FieldNamesWithUnderline", FuncName)
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if TextFieldsDefaultValue == "" {
|
||||||
|
TextFieldsDefaultValue = `""`
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
Otvet = strings.ReplaceAll(Otvet, TextAssignFind, TextAssign)
|
Otvet = strings.ReplaceAll(Otvet, TextAssignFind, TextAssign)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithUnderline", FieldNamesWithUnderline)
|
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithUnderline", FieldNamesWithUnderline)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithComma", FieldNamesWithComma)
|
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithComma", FieldNamesWithComma)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "FieldNamesDefault", TextFieldName_TEST)
|
Otvet = strings.ReplaceAll(Otvet, "FieldNamesDefault", TextFieldsDefaultValue)
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
@ -152,6 +152,14 @@ func CreateFilesFindMassByTable1(Table1 *types.Table, TextTemplateFunction strin
|
|||||||
Plus = "+"
|
Plus = "+"
|
||||||
Comma = ", "
|
Comma = ", "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//функция ReadAll()
|
||||||
|
if len(MassColumns1) == 0 {
|
||||||
|
FuncName := constants.TEXT_READALL
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, "FindMassBy_FieldNamesWithUnderline", FuncName)
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
Otvet = strings.ReplaceAll(Otvet, TextFind, TextWhere)
|
Otvet = strings.ReplaceAll(Otvet, TextFind, TextWhere)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithUnderline", FieldNamesWithUnderline)
|
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithUnderline", FieldNamesWithUnderline)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithPlus", FieldNamesWithComma)
|
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithPlus", FieldNamesWithComma)
|
||||||
@ -298,6 +306,14 @@ func CreateFilesFindMassByTestTable1(Table1 *types.Table, TextTemplateFunction s
|
|||||||
Underline = "_"
|
Underline = "_"
|
||||||
Comma = ", "
|
Comma = ", "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//функция ReadAll()
|
||||||
|
if len(MassColumns1) == 0 {
|
||||||
|
FuncName := constants.TEXT_READALL
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, "FindMassBy_FieldNamesWithUnderline", FuncName)
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
Otvet = strings.ReplaceAll(Otvet, TextAssignFind, TextAssign)
|
Otvet = strings.ReplaceAll(Otvet, TextAssignFind, TextAssign)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithUnderline", FieldNamesWithUnderline)
|
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithUnderline", FieldNamesWithUnderline)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithComma", FieldNamesWithComma)
|
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithComma", FieldNamesWithComma)
|
||||||
@ -330,7 +346,15 @@ func AddInterfacesFindMassBy(TextModel string, Table1 *types.Table) string {
|
|||||||
FieldNamesWithUnderline = FieldNamesWithUnderline + Underline + Column1.NameGo
|
FieldNamesWithUnderline = FieldNamesWithUnderline + Underline + Column1.NameGo
|
||||||
Underline = "_"
|
Underline = "_"
|
||||||
}
|
}
|
||||||
TextFunc1 := "\n\tFindMassBy_" + FieldNamesWithUnderline + "(*" + Table1.NameGo + ") ([]" + Table1.NameGo + ", error)"
|
|
||||||
|
FuncName := "FindMassBy_" + FieldNamesWithUnderline
|
||||||
|
//функция ReadAll()
|
||||||
|
if len(TableColumns1.MassColumnNames) == 0 {
|
||||||
|
FuncName = constants.TEXT_READALL
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
TextFunc1 := "\n\t" + FuncName + "(*" + Table1.NameGo + ") ([]" + Table1.NameGo + ", error)"
|
||||||
TextFunc = TextFunc + TextFunc1
|
TextFunc = TextFunc + TextFunc1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -171,6 +171,14 @@ func CreateFilesFindMassByTable1(Table1 *types.Table, TextTemplateFunction strin
|
|||||||
Plus = "+"
|
Plus = "+"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//функция ReadAll()
|
||||||
|
if len(MassColumnsString) == 0 {
|
||||||
|
FuncName := constants.TEXT_READALL
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, "FindMassBy_FieldNamesWithUnderline", FuncName)
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, ".RequestName", ".Request_Empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
Otvet = strings.ReplaceAll(Otvet, "RequestName", RequestName)
|
Otvet = strings.ReplaceAll(Otvet, "RequestName", RequestName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, TextFind, TextAssign)
|
Otvet = strings.ReplaceAll(Otvet, TextFind, TextAssign)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithUnderline", FieldNamesWithUnderline)
|
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithUnderline", FieldNamesWithUnderline)
|
||||||
@ -331,6 +339,15 @@ func CreateFilesFindMassByTestTable1(Table1 *types.Table, TextTemplateFunction s
|
|||||||
Underline = "_"
|
Underline = "_"
|
||||||
Comma = ", "
|
Comma = ", "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//функция ReadAll()
|
||||||
|
if len(MassColumnsString) == 0 {
|
||||||
|
FuncName := constants.TEXT_READALL
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, "FindMassBy_FieldNamesWithUnderline", FuncName)
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, ".RequestName", ".Request_Empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
Otvet = strings.ReplaceAll(Otvet, TextAssignFind, TextAssign)
|
Otvet = strings.ReplaceAll(Otvet, TextAssignFind, TextAssign)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithUnderline", FieldNamesWithUnderline)
|
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithUnderline", FieldNamesWithUnderline)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithComma", FieldNamesWithComma)
|
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithComma", FieldNamesWithComma)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package protobuf
|
package protobuf
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/ManyakRus/crud_generator/internal/constants"
|
||||||
"github.com/ManyakRus/crud_generator/internal/create_files"
|
"github.com/ManyakRus/crud_generator/internal/create_files"
|
||||||
"github.com/ManyakRus/crud_generator/internal/types"
|
"github.com/ManyakRus/crud_generator/internal/types"
|
||||||
"strings"
|
"strings"
|
||||||
@ -53,7 +54,15 @@ func FindText_FindMassBy1(TableColumns1 types.TableColumns) string {
|
|||||||
Underline = "_"
|
Underline = "_"
|
||||||
}
|
}
|
||||||
|
|
||||||
Otvet = Otvet + TableColumns1.Table.NameGo + "_FindMassBy_" + TextFields + "(" + TextRequest + ") returns (ResponseMass) {}\n"
|
FuncName := "FindMassBy_" + TextFields
|
||||||
|
//функция ReadAll()
|
||||||
|
if len(TableColumns1.Columns) == 0 {
|
||||||
|
FuncName = constants.TEXT_READALL
|
||||||
|
TextRequest = "Request_Empty"
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Otvet = Otvet + TableColumns1.Table.NameGo + "_" + FuncName + "(" + TextRequest + ") returns (ResponseMass) {}\n"
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
@ -164,6 +164,14 @@ func CreateFilesFindMassByTable1(Table1 *types.Table, TextTemplateFunction strin
|
|||||||
Plus = "+"
|
Plus = "+"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//функция ReadAll()
|
||||||
|
if len(MassColumnsString) == 0 {
|
||||||
|
FuncName := constants.TEXT_READALL
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, "FindMassBy_FieldNamesWithUnderline", FuncName)
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, ".RequestName", ".Request_Empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
Otvet = strings.ReplaceAll(Otvet, "RequestName", RequestName)
|
Otvet = strings.ReplaceAll(Otvet, "RequestName", RequestName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, TextFind, TextAssign)
|
Otvet = strings.ReplaceAll(Otvet, TextFind, TextAssign)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithUnderline", FieldNamesWithUnderline)
|
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithUnderline", FieldNamesWithUnderline)
|
||||||
@ -326,6 +334,15 @@ func CreateFilesFindMassByTestTable1(Table1 *types.Table, TextTemplateFunction s
|
|||||||
Underline = "_"
|
Underline = "_"
|
||||||
Comma = ", "
|
Comma = ", "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//функция ReadAll()
|
||||||
|
if len(MassColumnsString) == 0 {
|
||||||
|
FuncName := constants.TEXT_READALL
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, "FindMassBy_FieldNamesWithUnderline", FuncName)
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, ".RequestName", ".Request_Empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
Otvet = strings.ReplaceAll(Otvet, TextAssignFind, TextAssign)
|
Otvet = strings.ReplaceAll(Otvet, TextAssignFind, TextAssign)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "RequestName", RequestName)
|
Otvet = strings.ReplaceAll(Otvet, "RequestName", RequestName)
|
||||||
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithUnderline", FieldNamesWithUnderline)
|
Otvet = strings.ReplaceAll(Otvet, "FieldNamesWithUnderline", FieldNamesWithUnderline)
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
отдельная функция для каждой колонки каждой таблицы.
|
отдельная функция для каждой колонки каждой таблицы.
|
||||||
- UpdateManyFields() - изменение нескольких колонок, перечисленных в массиве
|
- UpdateManyFields() - изменение нескольких колонок, перечисленных в массиве
|
||||||
- FindBy_ColumnName() - поиск записи по одной или нескольким колонкам (если заполнить файл findby_functions.json)
|
- FindBy_ColumnName() - поиск записи по одной или нескольким колонкам (если заполнить файл findby_functions.json)
|
||||||
- FindMassBy_ColumnName() - поиск несколько записей по одной или нескольким колонкам (если заполнить файл findmassby_functions.json)
|
- FindMassBy_ColumnName() - поиск несколько записей по одной или нескольким колонкам (если заполнить файл findmassby_functions.json),
|
||||||
|
если не заполнить колонки - вернёт все записи, будет функция ReadAll()
|
||||||
|
|
||||||
генерируются файлы:
|
генерируются файлы:
|
||||||
1. tables - структура struct со всеми полями из БД, и аннотациями gorm + json
|
1. tables - структура struct со всеми полями из БД, и аннотациями gorm + json
|
||||||
|
Loading…
x
Reference in New Issue
Block a user