diff --git a/cmd/gf/internal/cmd/cmd_z_unit_gen_dao_test.go b/cmd/gf/internal/cmd/cmd_z_unit_gen_dao_test.go index 9642ad36e..5958e238e 100644 --- a/cmd/gf/internal/cmd/cmd_z_unit_gen_dao_test.go +++ b/cmd/gf/internal/cmd/cmd_z_unit_gen_dao_test.go @@ -241,7 +241,7 @@ func Test_Gen_Dao_FieldMapping(t *testing.T) { in = gendao.CGenDaoInput{ Path: path, Link: link, - Tables: "table_user", + Tables: "", TablesEx: "", Group: group, Prefix: "", diff --git a/cmd/gf/internal/cmd/gendao/gendao_structure.go b/cmd/gf/internal/cmd/gendao/gendao_structure.go index 4e457aff3..2fa4745eb 100644 --- a/cmd/gf/internal/cmd/gendao/gendao_structure.go +++ b/cmd/gf/internal/cmd/gendao/gendao_structure.go @@ -133,7 +133,7 @@ func generateStructFieldDefinition( } if in.FieldMapping != nil && len(in.FieldMapping) > 0 { - if typeMapping, ok := in.FieldMapping[fmt.Sprintf("%s.%s", in.Tables, newFiledName)]; ok { + if typeMapping, ok := in.FieldMapping[fmt.Sprintf("%s.%s", in.TableName, newFiledName)]; ok { localTypeNameStr = typeMapping.Type appendImport = typeMapping.Import } diff --git a/os/gfile/gfile_replace.go b/os/gfile/gfile_replace.go index 3cb7b689f..74fba01d6 100644 --- a/os/gfile/gfile_replace.go +++ b/os/gfile/gfile_replace.go @@ -19,7 +19,7 @@ func ReplaceFile(search, replace, path string) error { func ReplaceFileFunc(f func(path, content string) string, path string) error { data := GetContents(path) result := f(path, data) - if len(data) != len(result) && data != result { + if len(data) != len(result) || data != result { return PutContents(path, result) } return nil