controller层
@GetMapping("/page")
@Operation(summary = "获得标注属性管理分页")
public CommonResult<PageResult<MarkerPropertyViewVO>> getMarkerPropertyPage(@Valid MarkerPropertyPageReqVO pageVO) {
PageResult<MarkerPropertyDO> pageResult = markerPropertyService.getMarkerPropertyPage(pageVO);
PageResult<MarkerPropertyViewVO> result = new PageResult<>();
// 创建一个新的List来存储转换后ViewVO对象
List<MarkerPropertyViewVO> viewVOList = new ArrayList<>();
pageResult.getList().forEach(markerPropertyDO -> {
MarkerPropertyViewVO markerPropertyViewVO = MarkerPropertyConvert.INSTANCE.convertView(markerPropertyDO);
//根据自身需求自行实现(可修改) markerPropertyViewVO.setPropertyViewName(String.valueOf(markerPropertyService.getViewNameFromLabel(markerPropertyDO.getPropertyLabel())));
viewVOList.add(markerPropertyViewVO);
});
// 设置转换后的列表到PageResult中
result.setList(viewVOList);
result.setTotal(pageResult.getTotal());
return success(result);
}
MarkerPropertyBaseVO实体
@Data
public class MarkerPropertyBaseVO {
@Schema(description = "标注物id")
private Long id;
@Schema(description = "标注物名称", required = true)
@NotNull(message = "标注物名称不能为空")
private String markerObjectName;
@Schema(description = "属性名标签", required = true)
@NotNull(message = "属性名标签不能为空")
private String label;
@Schema(description = "属性名key", required = true)
@NotNull(message = "属性名key不能为空")
private String labelKey;
@Schema(description = "属性名结构", required = true)
@NotNull(message = "属性名结构不能为空")
private String propertyLabel;
@Schema(description = "属性key结构", required = true)
@NotNull(message = "属性key结构不能为空")
private String propertyKey;
}
MarkerPropertyViewVO实体
@Data
public class MarkerPropertyViewVO extends MarkerPropertyBaseVO{
@Schema(description = "属性名结构View")
private String propertyViewName;
@Schema(description = "属性key结构View")
private String propertyViewKey;
@Schema(description = "创建时间")
private LocalDateTime createTime;
}
getMarkerPropertyPage(pageVO)方法
//Service层
PageResult<MarkerPropertyDO> getMarkerPropertyPage(MarkerPropertyPageReqVO pageReqVO);
//Impl实现层
@Override
public PageResult<MarkerPropertyDO> getMarkerPropertyPage(MarkerPropertyPageReqVO pageReqVO) {
return markerPropertyMapper.selectPage(pageReqVO);
}
//Mapper层
@Mapper
public interface MarkerPropertyMapper extends BaseMapperX<MarkerPropertyDO> {
default PageResult<MarkerPropertyDO> selectPage(MarkerPropertyPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<MarkerPropertyDO>()
.likeIfPresent(MarkerPropertyDO::getMarkerObjectName, reqVO.getMarkerObjectName())
.orderByDesc(MarkerPropertyDO::getId));
}
}
MarkerPropertyConvert.INSTANCE.convertView(markerPropertyDO)方法
@Mapper
public interface MarkerPropertyConvert {
MarkerPropertyConvert INSTANCE = Mappers.getMapper(MarkerPropertyConvert.class);
MarkerPropertyViewVO convertView(MarkerPropertyDO bean);
}