You've already forked crud_generator
mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2025-06-19 01:07:36 +02:00
сделал StringIdentifier()
This commit is contained in:
@ -30,13 +30,6 @@ func (crud Crud_DB) ReadFromCache(ID int64) (lawsuit_status_types.LawsuitStatusT
|
|||||||
var Otvet lawsuit_status_types.LawsuitStatusType
|
var Otvet lawsuit_status_types.LawsuitStatusType
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// поищем сначала в кэше
|
|
||||||
Otvet, ok := cache.Get(ID)
|
|
||||||
if ok {
|
|
||||||
return Otvet, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// поищем в БД
|
|
||||||
ctxMain := contextmain.GetContext()
|
ctxMain := contextmain.GetContext()
|
||||||
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
|
ctx, ctxCancelFunc := context.WithTimeout(ctxMain, time.Second*time.Duration(db_constants.TIMEOUT_DB_SECONDS))
|
||||||
defer ctxCancelFunc()
|
defer ctxCancelFunc()
|
||||||
@ -53,11 +46,18 @@ func ReadFromCache_ctx(ctx context.Context, db *gorm.DB, ID int64) (lawsuit_stat
|
|||||||
var Otvet lawsuit_status_types.LawsuitStatusType
|
var Otvet lawsuit_status_types.LawsuitStatusType
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
// поищем сначала в кэше
|
||||||
|
Identifier := (ID)
|
||||||
|
Otvet, ok := cache.Get(Identifier)
|
||||||
|
if ok {
|
||||||
|
return Otvet, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// поищем в БД
|
||||||
Otvet.ID = AliasFromInt(ID)
|
Otvet.ID = AliasFromInt(ID)
|
||||||
err = Read_ctx(ctx, db, &Otvet)
|
err = Read_ctx(ctx, db, &Otvet)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
cache.Add(ID, Otvet)
|
cache.Add(Identifier, Otvet)
|
||||||
}
|
}
|
||||||
|
|
||||||
return Otvet, err
|
return Otvet, err
|
||||||
|
@ -173,6 +173,19 @@ func FindPrimaryKeyColumn(Table1 *types.Table) (Column1 *types.Column) {
|
|||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FindPrimaryKeyColumns - возвращает несколько Column для колонки PrimaryKey
|
||||||
|
func FindPrimaryKeyColumns(Table1 *types.Table) []*types.Column {
|
||||||
|
Otvet := make([]*types.Column, 0)
|
||||||
|
|
||||||
|
for _, Column1 := range Table1.MapColumns {
|
||||||
|
if Column1.IsPrimaryKey == true {
|
||||||
|
Otvet = append(Otvet, Column1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Otvet
|
||||||
|
}
|
||||||
|
|
||||||
//// FindPrimaryKeyNameTypeGo - возвращает наименование и тип golang колонки PrimaryKey
|
//// FindPrimaryKeyNameTypeGo - возвращает наименование и тип golang колонки PrimaryKey
|
||||||
//func FindPrimaryKeyNameTypeGo(Table1 *types.Table) (string, string) {
|
//func FindPrimaryKeyNameTypeGo(Table1 *types.Table) (string, string) {
|
||||||
// Otvet := ""
|
// Otvet := ""
|
||||||
@ -191,6 +204,20 @@ func FindPrimaryKeyColumn(Table1 *types.Table) (Column1 *types.Column) {
|
|||||||
func ReplacePrimaryKeyOtvetID(Text string, Table1 *types.Table) string {
|
func ReplacePrimaryKeyOtvetID(Text string, Table1 *types.Table) string {
|
||||||
Otvet := Text
|
Otvet := Text
|
||||||
|
|
||||||
|
PrimaryKeyCount := Table1.PrimaryKeyColumnsCount
|
||||||
|
if PrimaryKeyCount == 1 {
|
||||||
|
Otvet = ReplacePrimaryKeyOtvetID1(Otvet, Table1)
|
||||||
|
} else {
|
||||||
|
Otvet = ReplacePrimaryKeyOtvetID_Many(Otvet, Table1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return Otvet
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReplacePrimaryKeyOtvetID1 - заменяет "Otvet.ID" на название колонки PrimaryKey
|
||||||
|
func ReplacePrimaryKeyOtvetID1(Text string, Table1 *types.Table) string {
|
||||||
|
Otvet := Text
|
||||||
|
|
||||||
ColumnNamePK, ColumnTypeGoPK := FindPrimaryKeyNameTypeGo(Table1)
|
ColumnNamePK, ColumnTypeGoPK := FindPrimaryKeyNameTypeGo(Table1)
|
||||||
|
|
||||||
//заменим ID-Alias на ID
|
//заменим ID-Alias на ID
|
||||||
@ -237,6 +264,66 @@ func ReplacePrimaryKeyOtvetID(Text string, Table1 *types.Table) string {
|
|||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReplacePrimaryKeyOtvetID_Many - заменяет "Otvet.ID" на название колонки PrimaryKey
|
||||||
|
func ReplacePrimaryKeyOtvetID_Many(Text string, Table1 *types.Table) string {
|
||||||
|
Otvet := Text
|
||||||
|
|
||||||
|
TextOtvetIDID := ""
|
||||||
|
for _, Column1 := range Table1.MapColumns {
|
||||||
|
if Column1.IsPrimaryKey == false {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
TextOtvetIDID = TextOtvetIDID + "\tOtvet." + Column1.NameGo + " = " + Column1.NameGo + "\n"
|
||||||
|
}
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, "\tOtvet.ID = AliasFromInt(ID)", TextOtvetIDID)
|
||||||
|
|
||||||
|
//TextNames, TextNamesTypes, TextProtoNames := FindTextIDMany(Table1)
|
||||||
|
|
||||||
|
////заменим ID-Alias на ID
|
||||||
|
//TableName := Table1.Name
|
||||||
|
//IDName, _ := FindPrimaryKeyNameType(Table1)
|
||||||
|
//Alias, ok := types.MapConvertID[TableName+"."+IDName]
|
||||||
|
//OtvetColumnName := "Otvet." + ColumnNamePK
|
||||||
|
//if ok == true {
|
||||||
|
// OtvetColumnName = Alias + "(" + OtvetColumnName + ")"
|
||||||
|
//}
|
||||||
|
|
||||||
|
////заменим int64(Otvet.ID) на Otvet.ID
|
||||||
|
//if mini_func.IsNumberType(ColumnTypeGoPK) == true {
|
||||||
|
// Otvet = strings.ReplaceAll(Otvet, "int64(Otvet.ID)", OtvetColumnName)
|
||||||
|
//} else if ColumnTypeGoPK == "string" {
|
||||||
|
// Otvet = strings.ReplaceAll(Otvet, "int64(Otvet.ID) == 0", OtvetColumnName+" == \"\"")
|
||||||
|
// Otvet = strings.ReplaceAll(Otvet, "int64(Otvet.ID) != 0", OtvetColumnName+" != \"\"")
|
||||||
|
// Otvet = strings.ReplaceAll(Otvet, "int64(Otvet.ID)", OtvetColumnName)
|
||||||
|
//} else if ColumnTypeGoPK == "uuid.UUID" || ColumnTypeGoPK == "uuid.NullUUID" {
|
||||||
|
// Otvet = strings.ReplaceAll(Otvet, "int64(Otvet.ID) == 0", OtvetColumnName+" == uuid.Nil")
|
||||||
|
// Otvet = strings.ReplaceAll(Otvet, "int64(Otvet.ID) != 0", OtvetColumnName+" != uuid.Nil")
|
||||||
|
// Otvet = strings.ReplaceAll(Otvet, "int64(Otvet.ID)", OtvetColumnName)
|
||||||
|
//} else if ColumnTypeGoPK == "time.Time" {
|
||||||
|
// Otvet = strings.ReplaceAll(Otvet, "int64(Otvet.ID) == 0", OtvetColumnName+".IsZero() == true")
|
||||||
|
// Otvet = strings.ReplaceAll(Otvet, "int64(Otvet.ID) != 0", OtvetColumnName+".IsZero() == false")
|
||||||
|
// Otvet = strings.ReplaceAll(Otvet, "int64(Otvet.ID)", OtvetColumnName)
|
||||||
|
//}
|
||||||
|
////Otvet = strings.ReplaceAll(Otvet, "Otvet.ID = ", OtvetColumnName+" = ")
|
||||||
|
////Otvet = strings.ReplaceAll(Otvet, "Otvet.ID != ", OtvetColumnName+" != ")
|
||||||
|
////Otvet = strings.ReplaceAll(Otvet, " Otvet.ID)", " "+OtvetColumnName+")")
|
||||||
|
//Otvet = strings.ReplaceAll(Otvet, " Otvet.ID)", " Otvet."+ColumnNamePK+")")
|
||||||
|
//
|
||||||
|
////Alias преобразуем в int64, и наоборот
|
||||||
|
//if Alias != "" {
|
||||||
|
// Otvet = strings.ReplaceAll(Otvet, "IntFromAlias(Otvet.ID)", ColumnTypeGoPK+"(Otvet."+ColumnNamePK+")")
|
||||||
|
// Otvet = strings.ReplaceAll(Otvet, "AliasFromInt(Otvet.ID)", OtvetColumnName)
|
||||||
|
// Otvet = strings.ReplaceAll(Otvet, "AliasFromInt(ID)", Alias+"("+ColumnNamePK+")")
|
||||||
|
//} else {
|
||||||
|
// Otvet = strings.ReplaceAll(Otvet, "IntFromAlias(Otvet.ID)", "Otvet."+ColumnNamePK+"")
|
||||||
|
// Otvet = strings.ReplaceAll(Otvet, "AliasFromInt(Otvet.ID)", OtvetColumnName)
|
||||||
|
// Otvet = strings.ReplaceAll(Otvet, "AliasFromInt(ID)", "ID")
|
||||||
|
//}
|
||||||
|
|
||||||
|
return Otvet
|
||||||
|
}
|
||||||
|
|
||||||
// ReplacePrimaryKeyM_ID - заменяет "m.ID" на название колонки PrimaryKey
|
// ReplacePrimaryKeyM_ID - заменяет "m.ID" на название колонки PrimaryKey
|
||||||
func ReplacePrimaryKeyM_ID(Text string, Table1 *types.Table) string {
|
func ReplacePrimaryKeyM_ID(Text string, Table1 *types.Table) string {
|
||||||
Otvet := Text
|
Otvet := Text
|
||||||
@ -719,23 +806,28 @@ func CheckAndAddImport(Text, URL string) string {
|
|||||||
func AddImportTime(Text string) string {
|
func AddImportTime(Text string) string {
|
||||||
Otvet := Text
|
Otvet := Text
|
||||||
|
|
||||||
//если уже есть импорт
|
|
||||||
RepositoryURL := `time`
|
RepositoryURL := `time`
|
||||||
Otvet = AddImport(Text, RepositoryURL)
|
Otvet = AddImport(Text, RepositoryURL)
|
||||||
//pos1 := strings.Index(Otvet, RepositoryURL)
|
|
||||||
//if pos1 >= 0 {
|
return Otvet
|
||||||
// return Otvet
|
}
|
||||||
//}
|
|
||||||
//
|
// CheckAndAddImportStrconv - добавляет пакет в секцию Import, если его там нет
|
||||||
////
|
func CheckAndAddImportStrconv(Text string) string {
|
||||||
//TextImport := "import ("
|
Otvet := Text
|
||||||
//pos1 = strings.Index(Otvet, TextImport)
|
|
||||||
//if pos1 < 0 {
|
RepositoryURL := `strconv`
|
||||||
// log.Error("not found word: ", TextImport)
|
Otvet = AddImport(Text, RepositoryURL)
|
||||||
// return Text
|
|
||||||
//}
|
return Otvet
|
||||||
//
|
}
|
||||||
//Otvet = Otvet[:pos1+len(TextImport)] + "\n\t" + RepositoryURL + Otvet[pos1+len(TextImport):]
|
|
||||||
|
// CheckAndAddImportFmt - добавляет пакет fmt в секцию Import, если его там нет
|
||||||
|
func CheckAndAddImportFmt(Text string) string {
|
||||||
|
Otvet := Text
|
||||||
|
|
||||||
|
RepositoryURL := `fmt`
|
||||||
|
Otvet = AddImport(Text, RepositoryURL)
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
@ -1957,10 +2049,23 @@ func ReplaceTextRequestID_PrimaryKey1(Text string, Table1 *types.Table, TextRequ
|
|||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReplaceIDtoID - заменяет int64(ID) на ID
|
|
||||||
func ReplaceIDtoID(Text string, Table1 *types.Table) string {
|
func ReplaceIDtoID(Text string, Table1 *types.Table) string {
|
||||||
Otvet := Text
|
Otvet := Text
|
||||||
|
|
||||||
|
PrimaryKeyCount := Table1.PrimaryKeyColumnsCount
|
||||||
|
if PrimaryKeyCount == 1 {
|
||||||
|
Otvet = ReplaceIDtoID1(Otvet, Table1)
|
||||||
|
} else {
|
||||||
|
Otvet = ReplaceIDtoID_Many(Otvet, Table1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return Otvet
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReplaceIDtoID1 - заменяет int64(ID) на ID
|
||||||
|
func ReplaceIDtoID1(Text string, Table1 *types.Table) string {
|
||||||
|
Otvet := Text
|
||||||
|
|
||||||
PrimaryKeyColumn := FindPrimaryKeyColumn(Table1)
|
PrimaryKeyColumn := FindPrimaryKeyColumn(Table1)
|
||||||
OtvetColumnName := FindTextConvertGolangTypeToProtobufType(Table1, PrimaryKeyColumn, "")
|
OtvetColumnName := FindTextConvertGolangTypeToProtobufType(Table1, PrimaryKeyColumn, "")
|
||||||
if OtvetColumnName == "" {
|
if OtvetColumnName == "" {
|
||||||
@ -1974,6 +2079,45 @@ func ReplaceIDtoID(Text string, Table1 *types.Table) string {
|
|||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FindTextIDMany - находит все PrimaryKey строкой
|
||||||
|
func FindTextIDMany(Table1 *types.Table) (TextNames, TextNamesTypes, TextProtoNames string) {
|
||||||
|
//TextProtoNames := ""
|
||||||
|
//TextNamesTypes := ""
|
||||||
|
//TextNames := ""
|
||||||
|
|
||||||
|
Comma := ""
|
||||||
|
MassPrimaryKey := FindPrimaryKeyColumns(Table1)
|
||||||
|
for _, PrimaryKey1 := range MassPrimaryKey {
|
||||||
|
OtvetColumnName := FindTextConvertGolangTypeToProtobufType(Table1, PrimaryKey1, "")
|
||||||
|
if OtvetColumnName == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
TextProtoNames = TextProtoNames + Comma + OtvetColumnName
|
||||||
|
TextNamesTypes = TextNamesTypes + Comma + PrimaryKey1.NameGo + " " + PrimaryKey1.TypeGo
|
||||||
|
TextNames = TextNames + Comma + PrimaryKey1.NameGo
|
||||||
|
|
||||||
|
Comma = ", "
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReplaceIDtoID_Many - заменяет int64(ID) на ID, и остальные PrimaryKey
|
||||||
|
func ReplaceIDtoID_Many(Text string, Table1 *types.Table) string {
|
||||||
|
Otvet := Text
|
||||||
|
|
||||||
|
TextNames, TextNamesTypes, TextProtoNames := FindTextIDMany(Table1)
|
||||||
|
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, "int64(ID)", TextProtoNames)
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, "(ID int64", "("+TextNamesTypes)
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, "(ID)", "("+TextNames+")")
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, ", ID)", ", "+TextNames+")")
|
||||||
|
Otvet = strings.ReplaceAll(Otvet, ", ID int64)", ", "+TextNamesTypes+")")
|
||||||
|
|
||||||
|
return Otvet
|
||||||
|
}
|
||||||
|
|
||||||
// ReplaceOtvetIDEqual1 - заменяет Otvet.ID = -1
|
// ReplaceOtvetIDEqual1 - заменяет Otvet.ID = -1
|
||||||
func ReplaceOtvetIDEqual1(Text string, Table1 *types.Table) string {
|
func ReplaceOtvetIDEqual1(Text string, Table1 *types.Table) string {
|
||||||
Otvet := Text
|
Otvet := Text
|
||||||
@ -2040,3 +2184,31 @@ func ReplaceConnect_WithApplicationName(Text string) string {
|
|||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FindTextConvertToString - возвращает имя переменной + имя колонки, преобразованное в тип string
|
||||||
|
func FindTextConvertToString(Column1 *types.Column, VariableName string) string {
|
||||||
|
Otvet := ""
|
||||||
|
|
||||||
|
if Column1 == nil {
|
||||||
|
return Otvet
|
||||||
|
}
|
||||||
|
Otvet = VariableName + "." + Column1.NameGo
|
||||||
|
switch Column1.TypeGo {
|
||||||
|
case "time.Time":
|
||||||
|
Otvet = VariableName + ".String()"
|
||||||
|
case "int64":
|
||||||
|
Otvet = "strconv.Itoa(int(" + VariableName + "))"
|
||||||
|
case "int32":
|
||||||
|
Otvet = "strconv.Itoa(int(" + VariableName + "))"
|
||||||
|
case "bool":
|
||||||
|
Otvet = "strconv.FormatBool(" + VariableName + ")"
|
||||||
|
case "float32":
|
||||||
|
Otvet = "fmt.Sprintf(%f," + VariableName + ")"
|
||||||
|
case "float64":
|
||||||
|
Otvet = "fmt.Sprintf(%f," + VariableName + ")"
|
||||||
|
case "uuid.UUID":
|
||||||
|
Otvet = VariableName + ".String()"
|
||||||
|
}
|
||||||
|
|
||||||
|
return Otvet
|
||||||
|
}
|
||||||
|
@ -26,6 +26,13 @@ func CreateAllFiles(MapAll map[string]*types.Table) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//проверка что таблица нормальная
|
||||||
|
err2 := create_files.IsGoodTableNamePrefix(Table1)
|
||||||
|
if err2 != nil {
|
||||||
|
log.Warn(err2)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
//файлы crud
|
//файлы crud
|
||||||
if config.Settings.NEED_CREATE_DB == true {
|
if config.Settings.NEED_CREATE_DB == true {
|
||||||
err = CreateFiles(Table1)
|
err = CreateFiles(Table1)
|
||||||
@ -879,9 +886,20 @@ func CreateFilesCache(Table1 *types.Table) error {
|
|||||||
TextCache = create_files.FillVariable(TextCache, constants.TEXT_CACHE_SIZE_1000, sCACHE_ELEMENTS_COUNT)
|
TextCache = create_files.FillVariable(TextCache, constants.TEXT_CACHE_SIZE_1000, sCACHE_ELEMENTS_COUNT)
|
||||||
|
|
||||||
//тип ID кэша
|
//тип ID кэша
|
||||||
|
if Table1.PrimaryKeyColumnsCount == 1 {
|
||||||
_, ColumnTypeGo := create_files.FindPrimaryKeyNameTypeGo(Table1)
|
_, ColumnTypeGo := create_files.FindPrimaryKeyNameTypeGo(Table1)
|
||||||
TextCache = strings.ReplaceAll(TextCache, "LRU[int64", "LRU["+ColumnTypeGo)
|
TextCache = strings.ReplaceAll(TextCache, "LRU[int64", "LRU["+ColumnTypeGo)
|
||||||
TextCache = strings.ReplaceAll(TextCache, "ID int64", "ID "+ColumnTypeGo)
|
TextCache = strings.ReplaceAll(TextCache, "ID int64", "ID "+ColumnTypeGo)
|
||||||
|
} else {
|
||||||
|
TextCache = strings.ReplaceAll(TextCache, "LRU[int64", "LRU[string")
|
||||||
|
TextCache = create_files.ReplacePrimaryKeyOtvetID_Many(TextCache, Table1)
|
||||||
|
TextIDMany := "(ID)"
|
||||||
|
TextIDMany = create_files.ReplaceIDtoID_Many(TextIDMany, Table1)
|
||||||
|
TextCache = strings.ReplaceAll(TextCache, "(ID)", "("+Table1.Name+".StringIdentifier"+TextIDMany+")")
|
||||||
|
TextCache = create_files.ReplaceIDtoID_Many(TextCache, Table1)
|
||||||
|
//TextCache = strings.ReplaceAll(TextCache, "(ID,", "("+Table1.Name+".StringIdentifier"+TextIDMany+",")
|
||||||
|
//TextCache = strings.ReplaceAll(TextCache, "ID int64", "ID "+ColumnTypeGo)
|
||||||
|
}
|
||||||
|
|
||||||
//uuid
|
//uuid
|
||||||
TextCache = create_files.CheckAndAddImportUUID_FromText(TextCache)
|
TextCache = create_files.CheckAndAddImportUUID_FromText(TextCache)
|
||||||
|
@ -194,9 +194,18 @@ func CreateFilesModel_crud(Table1 *types.Table, DirTemplatesModel, DirReadyModel
|
|||||||
}
|
}
|
||||||
TextModel = create_files.ReplaceIDtoID(TextModel, Table1)
|
TextModel = create_files.ReplaceIDtoID(TextModel, Table1)
|
||||||
|
|
||||||
|
//
|
||||||
|
TextModel = AddFunctionStringIdentifier(TextModel, Table1)
|
||||||
|
|
||||||
//добавим импорт uuid
|
//добавим импорт uuid
|
||||||
TextModel = create_files.CheckAndAddImportUUID_FromText(TextModel)
|
TextModel = create_files.CheckAndAddImportUUID_FromText(TextModel)
|
||||||
|
|
||||||
|
//добавим импорт strconv
|
||||||
|
TextModel = create_files.CheckAndAddImportStrconv(TextModel)
|
||||||
|
|
||||||
|
//добавим импорт fmt
|
||||||
|
TextModel = create_files.CheckAndAddImportFmt(TextModel)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -712,3 +721,36 @@ func DeleteFromInterfaceUpdateManyFields(TextModel string, Table1 *types.Table)
|
|||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddFunctionStringIdentifier - добавляет функцию StringIdentifier(), для таблиц где много PrimaryKey
|
||||||
|
func AddFunctionStringIdentifier(TextModel string, Table1 *types.Table) string {
|
||||||
|
Otvet := TextModel
|
||||||
|
|
||||||
|
if Table1.PrimaryKeyColumnsCount == 1 {
|
||||||
|
return Otvet
|
||||||
|
}
|
||||||
|
|
||||||
|
_, TextNamesTypes, _ := create_files.FindTextIDMany(Table1)
|
||||||
|
|
||||||
|
Text := `
|
||||||
|
// StringIdentifier - возвращает строковое представление PrimaryKey
|
||||||
|
func StringIdentifier(` + TextNamesTypes + `) string {
|
||||||
|
Otvet := ""
|
||||||
|
`
|
||||||
|
|
||||||
|
for _, Column1 := range Table1.MapColumns {
|
||||||
|
if Column1.IsPrimaryKey == false {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
TextConvert := create_files.FindTextConvertToString(Column1, Column1.NameGo)
|
||||||
|
Text = Text + "\tOtvet = Otvet + " + `"_" + ` + TextConvert + "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
Text = Text + `
|
||||||
|
return Otvet
|
||||||
|
}`
|
||||||
|
|
||||||
|
Otvet = Otvet + Text
|
||||||
|
|
||||||
|
return Otvet
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user