eladmin icon indicating copy to clipboard operation
eladmin copied to clipboard

代码生成器,字典类型查询问题

Open iswangaiguo opened this issue 5 years ago • 1 comments

版本: v2.6 环境:本地 复现步骤:

  1. 代码生成-》生成配置界面,配置了字段名称对应的关联字典,并且表单类型为下拉框类型,设置了该字段的查询方式为等于。
  2. 生成代码后,下拉框类型的搜索框显示为普通的文本框,并且只能输入字典值(int)进行搜索,如果输入标签值(string),会直接报异常,如下所示: {"message":"org.springframework.validation.BeanPropertyBindingResult: 1 errors\nField error in object 'sysUsersDetailsQueryCriteria' on field 'nation': rejected value [汉族]; codes [typeMismatch.sysUsersDetailsQueryCriteria.nation,typeMismatch.nation,typeMismatch.java.lang.Integer,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [sysUsersDetailsQueryCriteria.nation,nation]; arguments []; default message [nation]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Integer' for property 'nation'; nested exception is java.lang.NumberFormatException: For input string: "汉族"]","status":400,"timestamp":"2021-05-15 18:51:15"}
  3. 并且在修改表单的时候,字典类型的下拉框会显示值而不是标签

iswangaiguo avatar May 15 '21 11:05 iswangaiguo

字典是 String ,但是我们业务大多数是 int,返回数据的时候加上注解 @JSONField(serializeUsing = ToStringSerializer.class) 就可解决 字典类型的下拉框会显示值而不是标签 这个问题

elunez avatar May 18 '22 05:05 elunez