You've already forked crud_generator
mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2025-07-14 14:44:48 +02:00
сделал ReplacePackageName()
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
package db_lawsuit_status_types
|
package crud_lawsuit_status_types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package db_lawsuit_status_types
|
package crud_lawsuit_status_types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ManyakRus/starter/config"
|
"github.com/ManyakRus/starter/config"
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package lawsuit_status_types
|
package table_lawsuit_status_types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities"
|
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/tables"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LawsuitStatusType
|
// LawsuitStatusType
|
||||||
type LawsuitStatusType struct {
|
type LawsuitStatusType struct {
|
||||||
entities.CommonStruct
|
tables.CommonStruct
|
||||||
entities.NameStruct
|
tables.NameStruct
|
||||||
Code string `json:"code" gorm:"column:code;default:0"`
|
Code string `json:"code" gorm:"column:code;default:0"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,3 +563,27 @@ func FindModelNameComment(ModelName string, Table1 *types.Table) string {
|
|||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReplacePackageName - заменяет имя пакета в шаблоне на новое
|
||||||
|
func ReplacePackageName(Text, PackageName string) string {
|
||||||
|
Otvet := Text
|
||||||
|
|
||||||
|
//
|
||||||
|
TextFind := "\tpackage "
|
||||||
|
pos1 := strings.Index(Otvet, TextFind)
|
||||||
|
if pos1 < 0 {
|
||||||
|
log.Error("not found word: package ")
|
||||||
|
return Otvet
|
||||||
|
}
|
||||||
|
|
||||||
|
s2 := Otvet[pos1:]
|
||||||
|
posEnd := strings.Index(s2, "\n")
|
||||||
|
if posEnd < 0 {
|
||||||
|
log.Error("not found word: \n")
|
||||||
|
return Otvet
|
||||||
|
}
|
||||||
|
|
||||||
|
Otvet = Otvet[:pos1] + "\t" + PackageName + Otvet[pos1+posEnd:]
|
||||||
|
|
||||||
|
return Otvet
|
||||||
|
}
|
||||||
|
@ -134,7 +134,7 @@ func FindTextImportDB1(Table1 *types.Table) string {
|
|||||||
TableName := strings.ToLower(Table1.Name)
|
TableName := strings.ToLower(Table1.Name)
|
||||||
DB_URL := config.Settings.SERVICE_REPOSITORY_URL + "/" + config.Settings.TEMPLATE_FOLDERNAME_CRUD
|
DB_URL := config.Settings.SERVICE_REPOSITORY_URL + "/" + config.Settings.TEMPLATE_FOLDERNAME_CRUD
|
||||||
TableNameWithPrefix := config.Settings.PREFIX_CRUD + TableName
|
TableNameWithPrefix := config.Settings.PREFIX_CRUD + TableName
|
||||||
Otvet := "\n\t" + TableNameWithPrefix + " \"" + DB_URL + "/" + TableNameWithPrefix + `"`
|
Otvet := "\n\t" + " \"" + DB_URL + "/" + TableNameWithPrefix + `"`
|
||||||
|
|
||||||
return Otvet
|
return Otvet
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,11 @@ func FindTextModelStruct(TextModel string, Table1 *types.Table) (string, string,
|
|||||||
ModelName = create_files.FormatName(ModelName)
|
ModelName = create_files.FormatName(ModelName)
|
||||||
Table1.NameGo = ModelName
|
Table1.NameGo = ModelName
|
||||||
|
|
||||||
|
//удалим старые импорты
|
||||||
|
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||||
|
TextModel = create_files.DeleteTemplateRepositoryImports(TextModel)
|
||||||
|
}
|
||||||
|
|
||||||
// Otvet = `// ` + ModelName + ` - ` + COMMENT_MODEL_STRUCT + TableName + `: ` + Table1.Comment + `
|
// Otvet = `// ` + ModelName + ` - ` + COMMENT_MODEL_STRUCT + TableName + `: ` + Table1.Comment + `
|
||||||
//type ` + ModelName + ` struct {
|
//type ` + ModelName + ` struct {
|
||||||
//`
|
//`
|
||||||
@ -186,6 +191,7 @@ type ` + ModelNameWithPrefix + ` struct {
|
|||||||
Table1.MapColumns[key1] = Column1
|
Table1.MapColumns[key1] = Column1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//добавим новый импорт
|
||||||
if has_Columns_CommonStruct == true || has_Columns_NameStruct == true || has_Columns_Groups == true || has_Columns_ExtLinks == true {
|
if has_Columns_CommonStruct == true || has_Columns_NameStruct == true || has_Columns_Groups == true || has_Columns_ExtLinks == true {
|
||||||
TablesURL := create_files.FindURL_Tables()
|
TablesURL := create_files.FindURL_Tables()
|
||||||
TextModel = create_files.AddImport(TextModel, TablesURL)
|
TextModel = create_files.AddImport(TextModel, TablesURL)
|
||||||
@ -203,12 +209,7 @@ func FindTextColumn(TextModel string, Table1 *types.Table, Column1 *types.Column
|
|||||||
ColumnName := Column1.Name
|
ColumnName := Column1.Name
|
||||||
ColumnNameLowerCase := strings.ToLower(ColumnName)
|
ColumnNameLowerCase := strings.ToLower(ColumnName)
|
||||||
ColumnModelName := create_files.FormatName(Column1.Name)
|
ColumnModelName := create_files.FormatName(Column1.Name)
|
||||||
//Column1.NameGo = ColumnModelName
|
|
||||||
//SQLMapping1, ok := dbmeta.GetMappings()[Column1.Type]
|
|
||||||
//if ok == false {
|
|
||||||
// log.Panic("GetMappings() ", Column1.Type, " error: not found")
|
|
||||||
//}
|
|
||||||
//Type_go := SQLMapping1.GoType
|
|
||||||
Type_go := Column1.TypeGo
|
Type_go := Column1.TypeGo
|
||||||
TextModel, Type_go = FindColumnTypeGoImport(TextModel, Table1, Column1)
|
TextModel, Type_go = FindColumnTypeGoImport(TextModel, Table1, Column1)
|
||||||
//Column1.TypeGo = Type_go
|
//Column1.TypeGo = Type_go
|
||||||
|
Reference in New Issue
Block a user