dto

DTO from JSON with dynamic key

依然范特西╮ 提交于 2020-01-11 07:25:42
问题 I'm trying to figure out how to write a nice DTO for a Spring Boot app that's proxying search capabilities to another (Python) service. So I currently have an almost perfect setup going. I'm only having problems with representing the aggregations I get back from Elasticsearch as objects on the Java side. Here's the current Aggregation DTO: package com.example.dto.search; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import java.util.List; import java.util.Map;

SAP SADL和SAP Hybris DTO

血红的双手。 提交于 2020-01-11 07:24:31
When you need a simpler or more convenient format for some of the data to display in JSPs 上面是从help.hybris.com摘录出来的原话,解释为什么我们需要DTO. 简单来说,就是因为Service Layer定义的model格式和UI需要的格式不是完全一样,如果UI直接消费Service Layer的model,代码写起来非常难看,而且会产生UI layer和service layer的强耦合。 更general地说,可以把DTO看成SADL的实现方式之一,处于BO(service layer) 和UI layer之间, 作为UI(consumer layer)消费Service layer的桥梁: Hybris的DTO通常以data.java结尾,在我安装的6.5.0.0.23546这一版本里一共有445个DTO: 一个DTO例子: 在CRM Genil layer的实现里,虽然没有明文提出DTO的概念,但是从Genil layer这些方法的signature能看出这种DTO的思路其实也是蕴含在其中的:把数据从genil layer的format CRMT_PRODIL_DATA转换成UI layer的COMT_PRODUCT_MAINTAIN_UI. CL_CRM_PRODIL

VO DTO 到底是干嘛的

强颜欢笑 提交于 2020-01-07 12:54:42
1、entity 里的每一个字段,与数据库相对应, 2、vo 里的每一个字段,是和你前台 html 页面相对应, 3、dto 这是用来转换从 entity 到 vo,或者从 vo 到 entity 的中间的东西 。(DTO中拥有的字段应该是entity中或者是vo中的一个子集) 举个例子: 你的html页面上有三个字段,name,pass,age 你的数据库表里,有两个字段,name,pass , 注意没有 age。 而你的 vo 里,就应该有下面三个成员变量 ,因为对应 html 页面上三个字段 。 private string name; private string pass; private string age; 这个时候,你的 entity 里,就应该有两个成员变量 ,因为对应数据库表中的 2 个字段 。 private string name; private string pass; 到了这里,好了,业务经理让你做这样一个业务“年龄大于 20 的才能存入数据库,这个时候,你就要用到 dto 了, 1)你要先从页面上拿到 vo,然后判断 vo 中的 age 是不是大于 20。 2)如果大于 20,就把 vo 中的 name 和 pass 拿出来,放到 dto 中。 3)然后在把 dto 中的 name 和 pass 原封不动的给 entity,然后根据 entity

Automapper, mapping to a complex object

孤者浪人 提交于 2020-01-06 14:55:45
问题 I have 2 classes i'm trying to map namely 1) Entity 2) DTO I'm trying to map Entity.Foo to DTO.Child.Foo Obviously the below will not work, how do I achieve this. I need to create a new instance of Child and then attach that to the Mapper and then set the Foo property but my AutoMapper skills are not that good! Mapper.CreateMap<Entity, DTO>() .ForMember("Child.Foo", m => m.MapFrom(entity => entity.Foo)) 回答1: Mapper.CreateMap<Entity, DTO>() .ForMember(d => d.Foo, o => o.ResolveUsing(s => new

DTO returns null when called from a Rest client using spring boot

落爺英雄遲暮 提交于 2020-01-06 10:05:54
问题 This is making a spring boot project to maintain the MVC architecture and as well being RestFul. There is a project that is fully working properly using the MVC architecture, I'll like to make it work as well by being called from a Rest client. Posting from the Thymeleaf UI works fine, however, when I try to post from a Rest client all the DTO properties are null. I don't know why. How do I make the posting from the client get all the properties posted? UserDto @PasswordMatches public class

DTO returns null when called from a Rest client using spring boot

狂风中的少年 提交于 2020-01-06 10:05:12
问题 This is making a spring boot project to maintain the MVC architecture and as well being RestFul. There is a project that is fully working properly using the MVC architecture, I'll like to make it work as well by being called from a Rest client. Posting from the Thymeleaf UI works fine, however, when I try to post from a Rest client all the DTO properties are null. I don't know why. How do I make the posting from the client get all the properties posted? UserDto @PasswordMatches public class

common dto for two incoming REST json

左心房为你撑大大i 提交于 2020-01-04 05:28:50
问题 I want to create a common dto like as shown below for receiving the incoming Manager and Staff details from a REST service public class Employee { @JsonProperty("name") public String name; @JsonProperty("designation") public String designation; @JsonProperty("item") public String item; @JsonProperty("item") public List<Item> items; //setters and getters } The problem is that for for Manager the item field will be a List where as for Staff it will be a string, so I have created two field for

common dto for two incoming REST json

好久不见. 提交于 2020-01-04 05:27:09
问题 I want to create a common dto like as shown below for receiving the incoming Manager and Staff details from a REST service public class Employee { @JsonProperty("name") public String name; @JsonProperty("designation") public String designation; @JsonProperty("item") public String item; @JsonProperty("item") public List<Item> items; //setters and getters } The problem is that for for Manager the item field will be a List where as for Staff it will be a string, so I have created two field for

Is it possible to map IQueryable<CatDTO> to IQueryable<CatEf>?

情到浓时终转凉″ 提交于 2020-01-03 12:59:59
问题 This is a question for Automapper professionals. I have tried to do query mapping for several days already - and no luck. Seems like Automapper is not intended to be used the way I want to use it. But maybe I am wrong. So here is the question... I have such classes: CatDto (Name, Age, Toys (collection of ToyDto objects)) ToyDto (CatName, ToyName, Cat (parent CatDto object)) Cat (comes from Entity Framework, has properties similar to those in CatDto) Toy (comes from Entity Framework, has

Convention-based object-graph synchronization

佐手、 提交于 2020-01-02 23:01:32
问题 I'm planning my first architecture that uses DTOs. I'm now exploring how to map the modified client-side domain objects back to the DTOs that were originally retrieved from the data service. I must map back to the original object graph, instead of instantiating a new one, in order to use WCF Data Services Client Library's change tracking feature. To put it in general terms, I need a tool that maps instances and (recursively) their sub-instances (collectively called the "source graph") to