95 lines
2.3 KiB
Java
95 lines
2.3 KiB
Java
package com.example.caseData.dto.statsCaseClinical;
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import com.example.caseData.model.StatsCaseClinicalModel;
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
import lombok.Data;
|
|
import java.time.LocalDateTime;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
|
|
@Data
|
|
public class StatsCaseClinicalDto {
|
|
/**
|
|
* 主键id
|
|
*/
|
|
@JsonProperty("stats_id")
|
|
private String statsId;
|
|
|
|
/**
|
|
* 总阅读量-文章
|
|
*/
|
|
@JsonProperty("article_read_num")
|
|
private Integer articleReadNum;
|
|
|
|
/**
|
|
* 总收藏量-文章
|
|
*/
|
|
@JsonProperty("article_collect_num")
|
|
private Integer articleCollectNum;
|
|
|
|
/**
|
|
* 总阅读量-视频
|
|
*/
|
|
@JsonProperty("video_read_num")
|
|
private Integer videoReadNum;
|
|
|
|
/**
|
|
* 总收藏量-视频
|
|
*/
|
|
@JsonProperty("video_collect_num")
|
|
private Integer videoCollectNum;
|
|
|
|
/**
|
|
* 创建时间
|
|
*/
|
|
@JsonProperty("created_at")
|
|
private LocalDateTime createdAt;
|
|
|
|
/**
|
|
* 修改时间
|
|
*/
|
|
@JsonProperty("updated_at")
|
|
private LocalDateTime updatedAt;
|
|
|
|
/**
|
|
* 列表
|
|
*/
|
|
public static List<StatsCaseClinicalDto> GetListDto(List<StatsCaseClinicalModel> models) {
|
|
if (models == null || models.isEmpty()) {
|
|
return Collections.emptyList();
|
|
}
|
|
|
|
return models.stream()
|
|
.map(model -> {
|
|
StatsCaseClinicalDto dto = BeanUtil.copyProperties(model, StatsCaseClinicalDto.class);
|
|
|
|
// 示例:手动处理字段类型不一致
|
|
if (model.getStatsId() != null) {
|
|
dto.setStatsId(String.valueOf(model.getStatsId())); // Long -> String
|
|
}
|
|
|
|
return dto;
|
|
})
|
|
.collect(Collectors.toList());
|
|
}
|
|
|
|
/**
|
|
* 详情
|
|
*/
|
|
public static StatsCaseClinicalDto GetDto(StatsCaseClinicalModel model) {
|
|
if (model == null) {
|
|
return null;
|
|
}
|
|
|
|
StatsCaseClinicalDto dto = BeanUtil.copyProperties(model, StatsCaseClinicalDto.class);
|
|
|
|
// 示例:手动处理字段类型不一致
|
|
if (model.getStatsId() != null) {
|
|
dto.setStatsId(String.valueOf(model.getStatsId())); // Long -> String
|
|
}
|
|
|
|
return dto;
|
|
}
|
|
} |