Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(重构): 使用BeanSerializerModifier重构 #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

miaoyinjun
Copy link

  1. 不需要考虑解包器和嵌套转换问题
  2. 不需要在方法上增加转换注解
  3. 注解由目标字段换到源字段
  4. 只需关注VO内的字段

1. 不需要考虑解包器和嵌套转换问题
2. 不需要在方法上增加转换注解
3. 注解由目标字段换到源字段
4. 只需关注VO内的字段
1. 不需要考虑解包器和嵌套转换问题
2. 不需要在方法上增加转换注解
3. 注解由目标字段换到源字段
4. 只需关注VO内的字段
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@luo-zhan
Copy link
Owner

luo-zhan commented Aug 10, 2024

很棒的实现思路👍👍👍,不用考虑解包器、嵌套转换、方法申明注解,确实方便了非常多,几个问题可以探讨一下:

  1. dubbo这种一般不用json序列化场景,好像没办法处理了,AOP的方式是spring任何springbean的方法上都能用,那么这块可能在权衡之后可能要放弃支持?
  2. 注解由目标字段转换到源字段,是否有必要——标注在目标字段更好维护一些,能一眼看出哪些字段是转换而来的。另外在同一个源字段转换成多个目标字段时的这种场景,支持得也很丝滑,你的方式对于这种场景还要多一些处理。个人还是偏向原来的使用方式。
  3. 枚举的转换实现改了,可能需要支持原来的功能——Integer的情况还是蛮常见的,需要支持,可以考虑同时兼容枚举和Integer。ps.不过话说回来,Dict已经有getAll()方法能提供枚举所有code和text对应关系,客户端先接口拿一下这份数据(一般查询条件下拉框也需要),客户端自己做下渲染也是可以的
  4. 既然已经是json序列化的方式实现,这块有没有可能解析之后直接将转换结果写入目标json中,而不用反射塞值了,这样性能应该也能快不少,这里使用反射的方式有个缺陷,就是目标值在vo类中的位置必须在源值的后面(sexName必须定义在sex之后),不然转换失效

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants