package com.rongyichuang.player.dto; import com.rongyichuang.player.entity.ActivityPlayer; import java.math.BigDecimal; import java.time.format.DateTimeFormatter; /** * 比赛参赛者响应类 */ public class CompetitionParticipantResponse { private Long id; private String playerName; private String projectName; private String phone; private BigDecimal averageScore; private Integer ratingCount; private String applyTime; private Integer state; private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); public CompetitionParticipantResponse() {} public CompetitionParticipantResponse(ActivityPlayer activityPlayer) { this.id = activityPlayer.getId(); this.playerName = activityPlayer.getPlayer() != null ? activityPlayer.getPlayer().getName() : ""; this.projectName = activityPlayer.getProjectName(); this.phone = activityPlayer.getPlayer() != null ? activityPlayer.getPlayer().getPhone() : ""; this.averageScore = activityPlayer.getTotalScore(); this.ratingCount = 0; // 需要从评分表中统计 this.applyTime = activityPlayer.getCreateTime() != null ? activityPlayer.getCreateTime().format(FORMATTER) : null; this.state = activityPlayer.getState(); } public CompetitionParticipantResponse(ActivityPlayer activityPlayer, Integer ratingCount) { this(activityPlayer); this.ratingCount = ratingCount != null ? ratingCount : 0; } // Getters and Setters public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getPlayerName() { return playerName; } public void setPlayerName(String playerName) { this.playerName = playerName; } public String getProjectName() { return projectName; } public void setProjectName(String projectName) { this.projectName = projectName; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public BigDecimal getAverageScore() { return averageScore; } public void setAverageScore(BigDecimal averageScore) { this.averageScore = averageScore; } public Integer getRatingCount() { return ratingCount; } public void setRatingCount(Integer ratingCount) { this.ratingCount = ratingCount; } public String getApplyTime() { return applyTime; } public void setApplyTime(String applyTime) { this.applyTime = applyTime; } public Integer getState() { return state; } public void setState(Integer state) { this.state = state; } }