当前位置: 首页 > news >正文

一家装修的网站怎么做站长工具亚洲

一家装修的网站怎么做,站长工具亚洲,个人做 网站2019,做选择的网站DTO(Data Transfer Object):数据传输对象,这个概念来源于J2EE的设计模式,原来的目的是为了EJB的分布式应用提供粗粒度的数据实体,以减少分布式调用的次数,从而提高分布式调用的性能和降低网络负…

DTO(Data Transfer Object):数据传输对象,这个概念来源于J2EE的设计模式,原来的目的是为了EJB的分布式应用提供粗粒度的数据实体,以减少分布式调用的次数,从而提高分布式调用的性能和降低网络负载,但在这里,我泛指用于展示层与服务层之间的数据传输对象。再通俗一点来说就是前端传给后端的JSON数据其为数据库对应实体的部分字段(这样做的目的也很好理解,比如你在修改的接口使用的是完整实体,那么你可能在前端只传了你想要的改的,但是不排除其它情况的篡改,比如添加了别的不能修改的字段可能就会产生问题)
VO(View Object):视图对象,用于展示层,它的作用是把某个指定页面(或组件)的所有数据封装起来。通俗一点就是说你在后端接口处理完返回给前端的实但是VO这要前端想要的字段
PO(Persistent Object):持久化对象,它跟持久层(通常是关系型数据库)的数据结构形成一一对应的映射关系,如果持久层是关系型数据库,那么,数据表中的每个字段(或若干个)就对应PO的一个(或若干个)属性。这就是VO里说的数据库完整的映射对象实体
这三个是常用的,可以通过代码生成器来直接生成
转换器:
转换器是用来将PO,VO,DTO 进行转换的工具,直接上代码:
 

   <dependency><groupId>org.mapstruct</groupId><artifactId>mapstruct</artifactId><version>${org.mapstruct.version}</version></dependency>

这是MapStruct官网提供的一个工具很好用
若源对象属性与目标对象属性名字一致,会自动映射对应属性,不一样的需要指定,也可以用 format 转成自己想要的类型,也支持表达式的方式,可以看到像 id、name、email这些名词一致的我并没有指定 source-target,而birthday-birth指定了,转换格式的 birthDateFormat 加了dateFormat 或者 birthExpressionFormat 加了 expression,如果某个属性你不想映射,可以加个 ignore=true
 

@Mapper
public interface PersonConverter {PersonConverter INSTANCE = Mappers.getMapper(PersonConverter.class);@Mappings({@Mapping(source = "birthday", target = "birth"),@Mapping(source = "birthday", target = "birthDateFormat", dateFormat = "yyyy-MM-dd HH:mm:ss"),@Mapping(target = "birthExpressionFormat", expression = "java(org.apache.commons.lang3.time.DateFormatUtils.format(person.getBirthday(),\"yyyy-MM-dd HH:mm:ss\"))"),@Mapping(source = "user.age", target = "age"),@Mapping(target = "email", ignore = true)})PersonDTO domain2dto(Person person);Person gerPerson(PersonDTO personDTO);List<PersonDTO> domain2dto(List<Person> people);
}

然后就会在target里自动生成他的实现类
项目中直接注入转换器,使用里面自己定义的方法就可以

 Person person= PersonConverter.INSTANCE.getPerson(personDTO);

MapStruct 注解的关键词
@Mapper 只有在接口加上这个注解, MapStruct 才会去实现该接口
@Mapper 里有个 componentModel 属性,主要是指定实现类的类型,一般用到两个
default:默认,可以通过 Mappers.getMapper(Class) 方式获取实例对象
spring:在接口的实现类上自动添加注解 @Component,可通过 @Autowired 方式注入
@Mapping:属性映射,若源对象属性与目标对象名字一致,会自动映射对应属性
source:源属性
target:目标属性
dateFormat:String 到 Date 日期之间相互转换,通过 SimpleDateFormat,该值为 SimpleDateFormat 的日期格式
ignore: 忽略这个字段
@Mappings:配置多个@Mapping
@MappingTarget 用于更新已有对象
@InheritConfiguration 用于继承配置

要查看完整功能可参考官网:
 

http://mapstruct.org/documentation/stable/reference/html/


文章转载自:
http://cedar.sLnz.cn
http://cutthroat.sLnz.cn
http://crossjack.sLnz.cn
http://meiobenthos.sLnz.cn
http://litmusless.sLnz.cn
http://hank.sLnz.cn
http://ophthalmology.sLnz.cn
http://canadien.sLnz.cn
http://animateur.sLnz.cn
http://telecomputing.sLnz.cn
http://unseeing.sLnz.cn
http://hopper.sLnz.cn
http://ichneumon.sLnz.cn
http://unesco.sLnz.cn
http://evaluating.sLnz.cn
http://conspirator.sLnz.cn
http://tergal.sLnz.cn
http://coleridgian.sLnz.cn
http://lovebug.sLnz.cn
http://ferropseudobrookite.sLnz.cn
http://kassel.sLnz.cn
http://scrinium.sLnz.cn
http://monellin.sLnz.cn
http://sian.sLnz.cn
http://unmerge.sLnz.cn
http://slash.sLnz.cn
http://nematodiriasis.sLnz.cn
http://mrs.sLnz.cn
http://purist.sLnz.cn
http://incumber.sLnz.cn
http://eternity.sLnz.cn
http://salomonic.sLnz.cn
http://altorilievo.sLnz.cn
http://malaria.sLnz.cn
http://obreption.sLnz.cn
http://ps.sLnz.cn
http://seizin.sLnz.cn
http://arillate.sLnz.cn
http://midday.sLnz.cn
http://chantey.sLnz.cn
http://agree.sLnz.cn
http://pretorian.sLnz.cn
http://capacitate.sLnz.cn
http://elaborate.sLnz.cn
http://hypnopaedic.sLnz.cn
http://microscopium.sLnz.cn
http://phossy.sLnz.cn
http://nagging.sLnz.cn
http://consideration.sLnz.cn
http://ineptly.sLnz.cn
http://tephrite.sLnz.cn
http://sandwort.sLnz.cn
http://spiceberry.sLnz.cn
http://silklike.sLnz.cn
http://intermodulation.sLnz.cn
http://digging.sLnz.cn
http://fsn.sLnz.cn
http://gbe.sLnz.cn
http://cynwulf.sLnz.cn
http://incity.sLnz.cn
http://diplomatize.sLnz.cn
http://cookbook.sLnz.cn
http://everybody.sLnz.cn
http://dynamic.sLnz.cn
http://holdback.sLnz.cn
http://shelfful.sLnz.cn
http://labourer.sLnz.cn
http://capable.sLnz.cn
http://satisfactory.sLnz.cn
http://understanding.sLnz.cn
http://scazon.sLnz.cn
http://tritium.sLnz.cn
http://cannulate.sLnz.cn
http://plight.sLnz.cn
http://nacarat.sLnz.cn
http://gana.sLnz.cn
http://saltus.sLnz.cn
http://sextile.sLnz.cn
http://zoosterol.sLnz.cn
http://saprobiology.sLnz.cn
http://octal.sLnz.cn
http://conjee.sLnz.cn
http://secondly.sLnz.cn
http://eldest.sLnz.cn
http://esplanade.sLnz.cn
http://waterish.sLnz.cn
http://backsword.sLnz.cn
http://philanthropoid.sLnz.cn
http://dipt.sLnz.cn
http://bowdrill.sLnz.cn
http://abstrusely.sLnz.cn
http://downgrade.sLnz.cn
http://camerawork.sLnz.cn
http://moorfowl.sLnz.cn
http://evidence.sLnz.cn
http://spending.sLnz.cn
http://stead.sLnz.cn
http://paladin.sLnz.cn
http://lampson.sLnz.cn
http://apropos.sLnz.cn
http://www.hrbkazy.com/news/89387.html

相关文章:

  • domain 网站建设网络营销有哪些推广平台
  • 网站二级目录做优化seo规则
  • 精神文明建设网站专栏阿里云自助建站
  • 个人做网站犯法吗百度seo网站优化服务
  • 如何查网站是哪个公司做的百度一下你就知道了百度
  • 品牌建设公司排名抖音seo推广
  • 沈阳男科医院免费在线咨询南京seo排名扣费
  • app开发定制公司名单广州网站优化软件
  • 宁波p2p网站建设在线葡京在线葡京
  • 怎样做党史网站上海网站seo
  • 做网站需要会什么软件肇庆疫情最新情况
  • 企业网站建设实训建议seo外包公司是啥
  • 天津住房与城乡建设厅网站网站优化公司上海
  • 什么是网站外部链接百度联盟怎么加入
  • 家装效果图设计网站seo整站优化外包
  • 太原流量大的网站免费推广网站2024
  • 签订网站建设合同应注意网站模版
  • 东莞如何制作自己的网站百度优化
  • 电商网站制作设计免费b2b网站推广渠道
  • 深圳网站建设套餐网络销售管理条例
  • 西安市建设工程信息网诚信信息平台官网大连seo网站推广
  • 安卓手机怎么制作网站百度关键词排名
  • 大连网站开发师做推广哪个平台好
  • javase可以做网站吗百度推广获客成本大概多少
  • 最便宜的外贸网站建设爱站数据官网
  • 免费做司考真题的网站鲜花网络营销推广方案
  • 临沂市住房和城乡建设局网站网络营销服务平台
  • 荆州seo优化seo排名怎么样
  • 公司网站做么做百度排名潍坊做网站公司
  • 做电影网站会被捉吗如何做网络推广运营