调用远程接口返回多层级对象,应该放在哪个分层领域模型下比较合理?
資深大佬 : Vimax 21
假设调用远程接口放回 school 对象,school 对象下包含 student 和 teacher 对象。
- School
- Student
- Teacher
现有系统的分层领域模型有:
- po
- bo
- dto
- vo
现有的对象都是放在分层领域模型包下,并以各自后缀大写结尾。
使用远程接口调用放回 school 对象,接收的 school 对象放在 dto 下,那 school 里面的对象 student 和 teacher 也应该放在 dto 下吗?
如果 student 和 teacher 分别定义 studentDTO 和 teacherDTO,则使用 restTemplate.getForObject 接收 student 和 teacher 则不能直接绑定上。
如果后面不加 DTO 而将对象放在 dto 包下,code review 的时候又不符合 DTO 结尾规范。
SchoolDTO school = this.restTemplate.getForObject(invokeUrl, SchoolDTO.class);
大佬有話說 (5)