dto

浅析VO、DTO、DO、PO的概念、区别和用处

早过忘川 提交于 2019-11-28 19:53:59
由于不同的项目和开发人员有不同的命名习惯,这里我首先对上述的概念进行一个简单描述,名字只是个标识,我们重点关注其概念: 概念: VO ( View Object ): 视图对象,用于展示层,它的作用是把某个指定页面(或组件)的所有数据封装起来。 DTO ( Data Transfer Object ): 数据传输对象,这个概念来源于 J2EE 的设计模式,原来的目的是为了 EJB 的分布式应用提供粗粒度的数据实体,以减少分布式调用的次数,从而提高分布式调用的性能和降低网络负载,但在这里,我泛指用于展示层与服务层之间的数据传输对象。 DO ( Domain Object ): 领域对象,就是从现实世界中抽象出来的有形或无形的业务实体。 PO ( Persistent Object ): 持久化对象,它跟持久层(通常是关系型数据库)的数据结构形成一一对应的映射关系,如果持久层是关系型数据库,那么,数据表中的每个字段(或若干个)就对应 PO 的一个(或若干个)属性。 模型: 下面以一个时序图建立简单模型来描述上述对象在三层架构应用中的位置 l 用户发出请求(可能是填写表单),表单的数据在展示层被匹配为 VO 。 l 展示层把 VO 转换为服务层对应方法所要求的 DTO ,传送给服务层。 l 服务层首先根据 DTO 的数据构造(或重建)一个 DO ,调用 DO 的业务方法完成具体业务。 l

留言板功能记录

懵懂的女人 提交于 2019-11-28 19:52:10
基于已经建立好的do、dto、html、js、以及api接口。 1、如何将页面添加到功能模块中: sys_menu中的status字段修改为A。 PS:你要确认自己的web.config指向的数据库位置是你想要的那个数据库 2、[FromBody]和[FromUrl]的区别: FromBody:使用FromBody将强制从FormData中读取数据 FromUri强制从url中读取FileRequest 对象,当访问时将自动转换将Uri中的参数作为对象属性忽略form传递的数据 3、 来源: https://blog.csdn.net/w_run/article/details/100113362

Mapping Validation Attributes From Domain Entity to DTO

三世轮回 提交于 2019-11-28 17:01:13
I have a standard Domain Layer entity: public class Product { public int Id { get; set; } public string Name { get; set; } public decimal Price { get; set;} } which has some kind of validation attributes applied: public class Product { public int Id { get; set; } [NotEmpty, NotShorterThan10Characters, NotLongerThan100Characters] public string Name { get; set; } [NotLessThan0] public decimal Price { get; set;} } As you can see, I have made up these attributes completely. Which validation framework (NHibernate Validator, DataAnnotations, ValidationApplicationBlock, Castle Validator, etc) in use

Domain vs DTO vs ViewModel - How and When to use them?

允我心安 提交于 2019-11-28 16:19:07
问题 In a Multi-layer project with Domain layer (DL)/Business (Service) Layer (BL)/Presentation Layer (PL), what is the best approach to deliver Entities to the Presentation Layer? DO => Domain Object; DTO = Domain Transfer Object; VM => View Model; V => View; Option 1: DL => DO => BL => DTO => PL => VM => V This option seems to be the Best Practice but also seems heavy to mantain. Option 2: DL => DO => BL => DTO => PL => V This option seems not very good practice but as DTO are almost identical

Should I map a DTO to/from a domain entity on both client and server sides?

谁都会走 提交于 2019-11-28 15:41:00
问题 I've got a rich domain model, where most classes have some behaviour and some properties that are either calculated or expose the properties of member objects (which is to say that the values of these properties are never persisted). My client speaks to the server only via WCF. As such, for each domain entity, I have a corresponding DTO -- a simple representation that contains only data -- as well as a mapper class that implements DtoMapper<DTO,Entity> and can convert an entity to its DTO

实体类(VO,DO,DTO,PO)的划分《转载---》

左心房为你撑大大i 提交于 2019-11-28 14:45:11
转载自: https://blog.csdn.net/u010722643/article/details/61201899 经常会接触到 VO, DO, DTO的概念,本文从领域建模中的实体划分和项目中的实际应用情况两个角度,对这几个概念进行简析。 得出的主要结论是:在项目应用中, VO对应于页面上需要显示的数据(表单), DO对应于 数据库 中存储的数据(数据表), DTO对应于除二者之外需要进行传递的数据。 一、实体类 百度百科中对于实体类的定义如下: 实体类的主要职责是存储和管理系统内部的信息,它也可以有行为,甚至很复杂的行为,但这些行为必须与它所代表的实体对象密切相关。 根据以上定义,我们可以了解到,实体类有两方面内容,存储数据和执行数据本身相关的操作。这两方面内容对应到实现上,最简单的实体类是 POJO类,含有属性及属性对应的 set和 get方法,实体类常见的方法还有用于输出自身数据的 toString方法。 二、领域模型中的实体类 领域模型中的实体类分为四种类型: VO、 DTO、 DO、 PO,各种实体类用于不同业务层次间的交互,并会在层次内实现实体类之间的转化。 业务分层为:视图层( VIEW+ACTION),服务层( SERVICE),持久层( DAO) 相应各层间实体的传递如下图: 项目中我们并没有严格遵循这种传递关系

DTO or Domain Model Object in the View Layer?

a 夏天 提交于 2019-11-28 13:54:59
问题 I know this is probably an age-old question, but what is the better practice? Using a domain model object throughout all layers of your application, and even binding values directly to them on the JSP (I'm using JSF). Or convert a domain model object into a DTO in the DAO or Service layer and send a lightweight DTO to the presentation layer. I have been told it makes no sense to use DTOs because changes to the database will result in changes to all your DTOs whereas using Model Objects

Query result in JSON format (key value pair) on using @Query annotation in Spring Boot, Hibernate

爷,独闯天下 提交于 2019-11-28 12:56:40
My Controller @GetMapping(value="/getAllDetails") public List<PriceListEntity> getAllDetails() { return MyRepository.getAllDetails(); } My Repository @Repository public interface MyRepository extends CrudRepository<TestNativeQ, String> { @Query( value="SELECT qplt.name price_list_name, qplab.status_code, qplab.start_date, (SELECT charge_definition_code FROM oalfsaas_repl.QP_CHARGE_DEFINITIONS_B WHERE charge_definition_id=qplab.charge_definition_id ) chargedefinitioncode " + "FROM PriceListEntity qplab, PriceListLineEntity qplt " + " WHERE qplab.price_list_id =qplt.price_list_id ", nativeQuery

SpringBoot中在除Controller层 使用Validation的方式

三世轮回 提交于 2019-11-28 12:41:56
说明:Validation 在Controller层使用Validation应该都使用过了,以下方式可以使用 Validation 在Service层完成对dto的属性校验,避免写一堆的 if else 来处理这些逻辑,提高开发效率,代码如下: 1:DTO实体类代 @Data public class AddUserParamsDto implements Serializable { private Integer id; @NotEmpty(message = "用户名不能为空") private String username; @Length(min = 6, message = "密码长度不能小于6") private String password; @Max(value = 120, message = "年龄必须在18-120之间") @Min(value = 18, message = "年龄必须在18-120之间") private Integer age; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date birthday; private String description; } 2:可以将ValidatorFactory的创建放入配置类里,后期如果使用 Validation

Copying NHibernate POCO to DTO without triggering lazy load or eager load

岁酱吖の 提交于 2019-11-28 08:48:23
问题 I need to create DTOs from NHibernate POCO objects. The problem is that the POCO objects contain dynamic proxies , which should not be copied to the DTO. I eager load all the collections and references I need to transfer in advance, I don't want NHibernate to start loading referenced collections which I did not load in advance. Several similar questions on SO received answers which either: Suggest Session.GetSessionImplementation().PersistenceContext.Unproxy(); Suggest turning off Lazy