mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2025-01-03 01:22:21 +02:00
сделал TEMPLATES_GRPC_CLIENT_TABLES_CACHE_FILENAME
This commit is contained in:
parent
5c7d4172d2
commit
60096ccaae
@ -27,9 +27,8 @@ func (s *ServerGRPC) LawsuitStatusType_ReadFromCache(ctx context.Context, Reques
|
||||
}
|
||||
|
||||
//запрос в БД
|
||||
Model := &lawsuit_status_types.LawsuitStatusType{}
|
||||
Model.ID = Request.ID
|
||||
err = Model.ReadFromCache()
|
||||
Model := lawsuit_status_types.LawsuitStatusType{}
|
||||
Model, err = Model.ReadFromCache(Request.ID)
|
||||
if err != nil {
|
||||
return &Otvet, err
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ func (crud Crud_DB) create_update_ctx(ctx context.Context, m *lawsuit_status_typ
|
||||
}
|
||||
|
||||
//удалим из кэша
|
||||
//cache.Remove(m.ID)
|
||||
//cache.Remove(int64(m.ID))
|
||||
|
||||
//запишем NULL в пустые колонки
|
||||
MapOmit := crud_functions.MapOmit_from_MassOmit(MassOmit)
|
||||
|
@ -187,7 +187,7 @@ func (crud Crud_DB) create_update_ctx(ctx context.Context, m *lawsuit_status_typ
|
||||
}
|
||||
|
||||
//удалим из кэша
|
||||
//cache.Remove(m.ID)
|
||||
//cache.Remove(int64(m.ID))
|
||||
|
||||
//запишем NULL в пустые колонки
|
||||
MapOmit := crud_functions.MapOmit_from_MassOmit(MassOmit)
|
||||
|
@ -23,7 +23,7 @@ type ICrud_LawsuitStatusType interface {
|
||||
Delete(*LawsuitStatusType) error
|
||||
Restore(*LawsuitStatusType) error
|
||||
Find_ByExtID(*LawsuitStatusType) error
|
||||
ReadFromCache(*LawsuitStatusType) error
|
||||
ReadFromCache(ID int64) (LawsuitStatusType, error)
|
||||
}
|
||||
|
||||
// TableName - возвращает имя таблицы в БД
|
||||
@ -169,14 +169,17 @@ func (m *LawsuitStatusType) Find_ByExtID() error {
|
||||
}
|
||||
|
||||
// ReadFromCache - находит запись в кэше или в БД по ID, и заполняет в объект
|
||||
func (m *LawsuitStatusType) ReadFromCache() error {
|
||||
func (m *LawsuitStatusType) ReadFromCache(ID int64) (LawsuitStatusType, error) {
|
||||
Otvet := LawsuitStatusType{}
|
||||
var err error
|
||||
|
||||
if Crud_LawsuitStatusType == nil {
|
||||
return constants.ErrorCrudIsNotInit
|
||||
return Otvet, constants.ErrorCrudIsNotInit
|
||||
}
|
||||
|
||||
err := Crud_LawsuitStatusType.ReadFromCache(m)
|
||||
Otvet, err = Crud_LawsuitStatusType.ReadFromCache(ID)
|
||||
|
||||
return err
|
||||
return Otvet, err
|
||||
}
|
||||
|
||||
// SetCrudInterface - заполняет интерфейс crud: DB, GRPC, NRPC
|
||||
|
@ -56,7 +56,9 @@ const GRPC_CLIENT_TABLE_UPDATE_FUNC_TEST_FILENAME = "grpc_client_table_update_fu
|
||||
|
||||
const CRUD_TABLES_CACHE_FILENAME = "crud_table_cache.go_"
|
||||
const CRUD_TABLES_CACHE_TEST_FILENAME = "crud_table_cache_test.go_"
|
||||
const TEXT_CACHE_REMOVE = "cache.Remove(m.ID)"
|
||||
const TEXT_CACHE_REMOVE = "cache.Remove(int64(m.ID))"
|
||||
|
||||
const SERVER_GRPC_TABLE_CACHE_FILENAME = "server_grpc_table_cache.go_"
|
||||
const SERVER_GRPC_TABLE_CACHE_TEST_FILENAME = "server_grpc_table_cache_test.go_"
|
||||
|
||||
const TEXT_OTVET_ID_ALIAS = "Otvet.ID = ID"
|
||||
|
@ -1175,8 +1175,8 @@ func FindTextProtobufRequest_ID_Type(Table1 *types.Table, Column1 *types.Column,
|
||||
return Otvet, TextRequestFieldName, TextRequestFieldGolang
|
||||
}
|
||||
|
||||
// ConvertIdToAlias - заменяет ID на Alias
|
||||
func ConvertIdToAlias(Text string, Table1 *types.Table) string {
|
||||
// ConvertRequestIdToAlias - заменяет ID на Alias
|
||||
func ConvertRequestIdToAlias(Text string, Table1 *types.Table) string {
|
||||
Otvet := Text
|
||||
|
||||
TableName := Table1.Name
|
||||
@ -1201,6 +1201,50 @@ func ConvertIdToAlias(Text string, Table1 *types.Table) string {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// ConvertIDToAlias_OtvetID - заменяет "Otvet.ID = ID" на "Otvet.ID = alias.Name(ID)"
|
||||
func ConvertIDToAlias_OtvetID(Text string, Table1 *types.Table) string {
|
||||
Otvet := Text
|
||||
|
||||
TableName := Table1.Name
|
||||
IDName, _ := FindPrimaryKeyNameType(Table1)
|
||||
TextConvert, ok := types.MapConvertID[TableName+"."+IDName]
|
||||
if ok == false {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
if TextConvert[:6] != "alias." {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
TextFrom := constants.TEXT_OTVET_ID_ALIAS
|
||||
TextTo := TextFrom
|
||||
TextTo = strings.ReplaceAll(TextFrom, " ID", " "+TextConvert+"(ID)")
|
||||
|
||||
Otvet = strings.ReplaceAll(Otvet, TextFrom, TextTo)
|
||||
URL := FindURL_Alias()
|
||||
if URL == "" {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
Otvet = AddImport(Otvet, URL)
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// DeleteCommentFromString - удаляет комментарий из строки //
|
||||
func DeleteCommentFromString(TextFrom string) string {
|
||||
Otvet := TextFrom
|
||||
|
||||
pos1 := strings.Index(Otvet, "//")
|
||||
if pos1 < 0 {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
Otvet = Otvet[:pos1]
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// FindTextConvertGolangTypeToProtobufType - возвращает имя переменной + имя колонки, преобразованное в тип protobuf
|
||||
func FindTextConvertGolangTypeToProtobufType(Table1 *types.Table, Column1 *types.Column, VariableName string) string {
|
||||
Otvet := VariableName + Column1.NameGo
|
||||
|
@ -539,7 +539,7 @@ func CreateFilesUpdateEveryColumn(Table1 *types.Table) error {
|
||||
ModelTableURL := create_files.FindModelTableURL(TableName)
|
||||
TextCrud = create_files.AddImport(TextCrud, ModelTableURL)
|
||||
|
||||
TextCrud = create_files.ConvertIdToAlias(TextCrud, Table1)
|
||||
//TextCrud = create_files.ConvertRequestIdToAlias(TextCrud, Table1)
|
||||
}
|
||||
|
||||
//создание текста
|
||||
@ -692,7 +692,7 @@ func CreateTestFilesUpdateEveryColumn(Table1 *types.Table) error {
|
||||
ModelTableURL := create_files.FindModelTableURL(TableName)
|
||||
TextCrud = create_files.AddImport(TextCrud, ModelTableURL)
|
||||
|
||||
TextCrud = create_files.ConvertIdToAlias(TextCrud, Table1)
|
||||
TextCrud = create_files.ConvertRequestIdToAlias(TextCrud, Table1)
|
||||
}
|
||||
|
||||
//создание текста
|
||||
@ -816,7 +816,7 @@ func CreateFilesCache(Table1 *types.Table) error {
|
||||
ModelTableURL := create_files.FindModelTableURL(TableName)
|
||||
TextCache = create_files.AddImport(TextCache, ModelTableURL)
|
||||
|
||||
//TextCache = create_files.ConvertIdToAlias(TextCache, Table1)
|
||||
//TextCache = create_files.ConvertRequestIdToAlias(TextCache, Table1)
|
||||
}
|
||||
|
||||
//замена слов
|
||||
@ -825,6 +825,9 @@ func CreateFilesCache(Table1 *types.Table) error {
|
||||
TextCache = strings.ReplaceAll(TextCache, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
|
||||
TextCache = config.Settings.TEXT_MODULE_GENERATED + TextCache
|
||||
|
||||
//alias
|
||||
TextCache = create_files.ConvertIDToAlias_OtvetID(TextCache, Table1)
|
||||
|
||||
//удаление пустого импорта
|
||||
TextCache = create_files.DeleteEmptyImport(TextCache)
|
||||
|
||||
@ -877,7 +880,7 @@ func CreateFilesCacheTest(Table1 *types.Table) error {
|
||||
ModelTableURL := create_files.FindModelTableURL(TableName)
|
||||
TextCache = create_files.AddImport(TextCache, ModelTableURL)
|
||||
|
||||
//TextCache = create_files.ConvertIdToAlias(TextCache, Table1)
|
||||
//TextCache = create_files.ConvertRequestIdToAlias(TextCache, Table1)
|
||||
}
|
||||
|
||||
//замена слов
|
||||
|
@ -432,7 +432,7 @@ func CreateFilesUpdateEveryColumn(Table1 *types.Table) error {
|
||||
ModelTableURL := create_files.FindModelTableURL(TableName)
|
||||
TextGRPC_Client = create_files.AddImport(TextGRPC_Client, ModelTableURL)
|
||||
|
||||
//TextGRPC_Client = create_files.ConvertIdToAlias(TextGRPC_Client, Table1)
|
||||
//TextGRPC_Client = create_files.ConvertRequestIdToAlias(TextGRPC_Client, Table1)
|
||||
}
|
||||
|
||||
//создание текста
|
||||
@ -579,7 +579,7 @@ func CreateTestFilesUpdateEveryColumn(Table1 *types.Table) error {
|
||||
ModelTableURL := create_files.FindModelTableURL(TableName)
|
||||
TextGRPC_Client = create_files.AddImport(TextGRPC_Client, ModelTableURL)
|
||||
|
||||
//TextGRPC_Client = create_files.ConvertIdToAlias(TextGRPC_Client, Table1)
|
||||
//TextGRPC_Client = create_files.ConvertRequestIdToAlias(TextGRPC_Client, Table1)
|
||||
}
|
||||
|
||||
//создание текста
|
||||
|
@ -137,7 +137,7 @@ func CreateFiles(Table1 *types.Table) error {
|
||||
TextGRPCServer = config.Settings.TEXT_MODULE_GENERATED + TextGRPCServer
|
||||
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextGRPCServer = create_files.ConvertIdToAlias(TextGRPCServer, Table1)
|
||||
TextGRPCServer = create_files.ConvertRequestIdToAlias(TextGRPCServer, Table1)
|
||||
}
|
||||
|
||||
//удаление пустого импорта
|
||||
@ -426,7 +426,7 @@ func CreateFilesUpdateEveryColumn(Table1 *types.Table) error {
|
||||
TextGRPCServer = TextGRPCServer + TextUpdateEveryColumn
|
||||
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextGRPCServer = create_files.ConvertIdToAlias(TextGRPCServer, Table1)
|
||||
TextGRPCServer = create_files.ConvertRequestIdToAlias(TextGRPCServer, Table1)
|
||||
TextGRPCServer = create_files.CheckAndAddImportAlias(TextGRPCServer)
|
||||
TextGRPCServer = config.Settings.TEXT_MODULE_GENERATED + TextGRPCServer
|
||||
}
|
||||
@ -559,7 +559,7 @@ func CreateTestFilesUpdateEveryColumn(Table1 *types.Table) error {
|
||||
CrudStarterURL := create_files.FindCrudStarterURL()
|
||||
TextGRPCServer = create_files.AddImport(TextGRPCServer, CrudStarterURL)
|
||||
|
||||
//TextGRPCServer = create_files.ConvertIdToAlias(TextGRPCServer, Table1)
|
||||
//TextGRPCServer = create_files.ConvertRequestIdToAlias(TextGRPCServer, Table1)
|
||||
}
|
||||
|
||||
//создание текста
|
||||
@ -689,9 +689,9 @@ func CreateFilesCache(Table1 *types.Table) error {
|
||||
TextGRPCServer = strings.ReplaceAll(TextGRPCServer, config.Settings.TEXT_TEMPLATE_TABLENAME, Table1.Name)
|
||||
TextGRPCServer = config.Settings.TEXT_MODULE_GENERATED + TextGRPCServer
|
||||
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextGRPCServer = create_files.ConvertIdToAlias(TextGRPCServer, Table1)
|
||||
}
|
||||
//if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
// TextGRPCServer = create_files.ConvertRequestIdToAlias(TextGRPCServer, Table1)
|
||||
//}
|
||||
|
||||
//удаление пустого импорта
|
||||
TextGRPCServer = create_files.DeleteEmptyImport(TextGRPCServer)
|
||||
@ -751,7 +751,7 @@ func CreateFilesCacheTest(Table1 *types.Table) error {
|
||||
TextGRPCServer = config.Settings.TEXT_MODULE_GENERATED + TextGRPCServer
|
||||
|
||||
if config.Settings.USE_DEFAULT_TEMPLATE == true {
|
||||
TextGRPCServer = create_files.ConvertIdToAlias(TextGRPCServer, Table1)
|
||||
TextGRPCServer = create_files.ConvertRequestIdToAlias(TextGRPCServer, Table1)
|
||||
}
|
||||
|
||||
//удаление пустого импорта
|
||||
|
Loading…
Reference in New Issue
Block a user