1
0
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:
Nikitin Aleksandr 2024-10-16 17:54:47 +03:00
parent f9e681a82c
commit 0e898bb18e
4 changed files with 15 additions and 9 deletions

View File

@ -1,4 +1,4 @@
// FieldNamesWithUnderline - находит модель в БД по FieldNamesWithPlus
// FindBy_FieldNamesWithUnderline - находит модель в БД по FieldNamesWithPlus
func (crud Crud_GRPC) FindBy_FieldNamesWithUnderline(m *lawsuit_status_types.LawsuitStatusType) error {
var err error
@ -24,6 +24,7 @@ func (crud Crud_GRPC) FindBy_FieldNamesWithUnderline(m *lawsuit_status_types.Law
Response, err = grpc_client_func.Client.LawsuitStatusType_FindBy_FieldNamesWithUnderline(ctx, Request)
}
if err != nil {
err = fmt.Errorf("LawsuitStatusType_FindBy_FieldNamesWithUnderline() error: %w", err)
if grpc_client_func.IsErrorModelVersion(err) == true {
log.Panic("table: ", TableName, " error: ", err)
}
@ -34,6 +35,7 @@ func (crud Crud_GRPC) FindBy_FieldNamesWithUnderline(m *lawsuit_status_types.Law
sModel := Response.ModelString
err = json.Unmarshal([]byte(sModel), m)
if err != nil {
err = fmt.Errorf("Unmarshal() error: %w", err)
return err
}

View File

@ -1,4 +1,4 @@
// FieldNamesWithUnderline - находит массив записей в БД по FieldNamesWithPlus
// FindMassBy_FieldNamesWithUnderline - находит массив записей в БД по FieldNamesWithPlus
func (crud Crud_GRPC) FindMassBy_FieldNamesWithUnderline(m *lawsuit_status_types.LawsuitStatusType) ([]lawsuit_status_types.LawsuitStatusType, error) {
Otvet := make([]lawsuit_status_types.LawsuitStatusType, 0)
var err error
@ -25,6 +25,7 @@ func (crud Crud_GRPC) FindMassBy_FieldNamesWithUnderline(m *lawsuit_status_types
Response, err = grpc_client_func.Client.LawsuitStatusType_FindMassBy_FieldNamesWithUnderline(ctx, Request)
}
if err != nil {
err = fmt.Errorf("LawsuitStatusType_FindMassBy_FieldNamesWithUnderline() error: %w", err)
if grpc_client_func.IsErrorModelVersion(err) == true {
log.Panic("table: ", TableName, " error: ", err)
}
@ -36,6 +37,7 @@ func (crud Crud_GRPC) FindMassBy_FieldNamesWithUnderline(m *lawsuit_status_types
for _, v := range Response.MassModelString {
err = json.Unmarshal([]byte(v), &m1)
if err != nil {
err = fmt.Errorf("Unmarshal() error: %w", err)
return Otvet, err
}
Otvet = append(Otvet, m1)

View File

@ -1,5 +1,5 @@
// FieldNamesWithUnderline - находит модель в БД по FieldNamesWithPlus
func (crud Crud_GRPC) FindBy_FieldNamesWithUnderline(m *lawsuit_status_types.LawsuitStatusType) error {
// FindModelBy_FieldNamesWithUnderline - находит модель в БД по FieldNamesWithPlus
func (crud Crud_GRPC) FindModelBy_FieldNamesWithUnderline(m *lawsuit_status_types.LawsuitStatusType) (foreign_package.ForeignModel, error) {
var err error
// подключение
@ -19,11 +19,12 @@ func (crud Crud_GRPC) FindBy_FieldNamesWithUnderline(m *lawsuit_status_types.Law
// запрос
var Response *grpc_proto.Response
if grpc_nrpc.NeedNRPC == true {
Response, err = nrpc_client.Client.LawsuitStatusType_FindBy_FieldNamesWithUnderline(Request)
Response, err = nrpc_client.Client.LawsuitStatusType_FindModelBy_FieldNamesWithUnderline(Request)
} else {
Response, err = grpc_client_func.Client.LawsuitStatusType_FindBy_FieldNamesWithUnderline(ctx, Request)
Response, err = grpc_client_func.Client.LawsuitStatusType_FindModelBy_FieldNamesWithUnderline(ctx, Request)
}
if err != nil {
err = fmt.Errorf("LawsuitStatusType_FindModelBy_FieldNamesWithUnderline() error: %w", err)
if grpc_client_func.IsErrorModelVersion(err) == true {
log.Panic("table: ", TableName, " error: ", err)
}
@ -34,6 +35,7 @@ func (crud Crud_GRPC) FindBy_FieldNamesWithUnderline(m *lawsuit_status_types.Law
sModel := Response.ModelString
err = json.Unmarshal([]byte(sModel), m)
if err != nil {
err = fmt.Errorf("Unmarshal() error: %w", err)
return err
}

View File

@ -1,4 +1,4 @@
func TestFindBy_FieldNamesWithUnderline(t *testing.T) {
func TestFindModelBy_FieldNamesWithUnderline(t *testing.T) {
config_main.LoadEnv()
grpc_client.Connect()
@ -7,10 +7,10 @@ func TestFindBy_FieldNamesWithUnderline(t *testing.T) {
crud := grpc_lawsuit_status_types.Crud_GRPC{}
Otvet := lawsuit_status_types.LawsuitStatusType{}
Otvet.FieldName = 0
err := crud.FindBy_FieldNamesWithUnderline(&Otvet)
_, err := crud.FindModelBy_FieldNamesWithUnderline(&Otvet)
if err != nil && crud_func.IsRecordNotFound(err) == false {
t.Error("TestFindBy_FieldNamesWithUnderline() error: ", err)
t.Error("TestFindModelBy_FieldNamesWithUnderline() error: ", err)
}
}