maptruct复制对像
现在项目中要求用mapstruct 每个接口要有自己的接收参数对象,就是controller层的入参对象,以Req结尾,比如:IndicatorReq 规定service层不能直接用IndicatorReq,要转换为IndicatorDTO service返回结果也是DTO结尾,比如IndicatorResultDTO 在controller层返回不能直接用IndicatorResultDTO,要转换为IndicatorResultResp 所有一般有四个对象:IndicatorReq -> IndicatorDTO、IndicatorResultDTO -> IndicatorResultResp 在controller层转换 1.引入mapstruct依赖 2.下载插件,idea有对应的mapstruct版本,不对应报错 3.代码: controller层 public List<SelectDimensionResp> getEachDimension (IndicatorReq indicatorReq){ //req 转DTO IndicatorDTO indicatorDTO = RegulationTransfer.INSTANCE.toSelectDimensionDTO(indicatoReq); //DTO作为参数传入service层 List