lrj
6 天以前 7ba080d35812e6db7bd5aa8f88161c02653eb6c1
backend/src/main/java/com/rongyichuang/player/service/ActivityPlayerDetailService.java
@@ -1,10 +1,12 @@
package com.rongyichuang.player.service;
import com.rongyichuang.player.dto.response.*;
import com.rongyichuang.player.dto.response.RegionInfoResponse;
import com.rongyichuang.rating.dto.response.RatingItemResponse;
import com.rongyichuang.rating.entity.RatingScheme;
import com.rongyichuang.rating.repository.RatingSchemeRepository;
import com.rongyichuang.common.entity.Media;
import com.rongyichuang.common.enums.MediaTargetType;
import com.rongyichuang.common.repository.MediaRepository;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
@@ -44,14 +46,16 @@
    public ActivityPlayerDetailResponse getDetailForRating(Long activityPlayerId) {
        log.info("获取报名详情用于评分,activityPlayerId: {}", activityPlayerId);
        // 查询基本信息
        // 查询基本信息,包含区域信息
        String sql = """
            SELECT ap.id, ap.description, ap.activity_id,
            SELECT ap.id, ap.description, ap.activity_id, ap.region_id,
                   p.id as player_id, p.name as player_name, p.phone, p.description as player_desc,
                   a.name as activity_name, a.rating_scheme_id
            FROM t_avtivity_player ap
                   a.name as activity_name, a.rating_scheme_id,
                   r.id as r_id, r.name as region_name, r.full_path as region_path
            FROM t_activity_player ap
            JOIN t_player p ON p.id = ap.player_id
            JOIN t_activity a ON a.id = ap.activity_id
            LEFT JOIN t_region r ON r.id = ap.region_id
            WHERE ap.id = ?
            """;
@@ -69,18 +73,29 @@
        ActivityPlayerDetailResponse response = new ActivityPlayerDetailResponse();
        response.setId(activityPlayerId);
        response.setDescription(row[1] != null ? row[1].toString() : "");
        response.setActivityName(row[7] != null ? row[7].toString() : "");
        response.setActivityName(row[8] != null ? row[8].toString() : "");
        // 构建学员信息
        PlayerInfoResponse playerInfo = new PlayerInfoResponse();
        playerInfo.setId(row[3] != null ? Long.valueOf(row[3].toString()) : null);
        playerInfo.setName(row[4] != null ? row[4].toString() : "");
        playerInfo.setPhone(row[5] != null ? row[5].toString() : "");
        playerInfo.setDescription(row[6] != null ? row[6].toString() : "");
        playerInfo.setId(row[4] != null ? ((Number) row[4]).longValue() : null);
        playerInfo.setName(row[5] != null ? row[5].toString() : "");
        playerInfo.setPhone(row[6] != null ? row[6].toString() : "");
        playerInfo.setDescription(row[7] != null ? row[7].toString() : "");
        // 查询学员头像(target_type=5)
        // 构建区域信息
        RegionInfoResponse regionInfo = new RegionInfoResponse();
        if (row[10] != null) {
            regionInfo.setId(((Number) row[10]).longValue());
            regionInfo.setName(row[11] != null ? row[11].toString() : "");
            regionInfo.setFullPath(row[12] != null ? row[12].toString() : "");
            response.setRegionInfo(regionInfo);
            log.info("找到区域信息: {}", regionInfo.getName());
        }
        // 查询学员头像(使用枚举常量表示学员头像类型)
        if (playerInfo.getId() != null) {
            List<Media> avatarMedias = mediaRepository.findByTargetTypeAndTargetIdAndState(5, playerInfo.getId(), 1);
            List<Media> avatarMedias = mediaRepository.findByTargetTypeAndTargetIdAndState(
                MediaTargetType.STUDENT_AVATAR.getValue(), playerInfo.getId(), 1);
            if (!avatarMedias.isEmpty()) {
                Media avatar = avatarMedias.get(0);
                String avatarUrl = avatar.getPath();
@@ -90,8 +105,9 @@
        }
        response.setPlayerInfo(playerInfo);
        // 查询提交的资料(target_type=4)
        List<Media> submissionMedias = mediaRepository.findByTargetTypeAndTargetIdAndState(4, activityPlayerId, 1);
        // 查询提交的资料(使用枚举常量表示参赛报名资料类型)
        List<Media> submissionMedias = mediaRepository.findByTargetTypeAndTargetIdAndState(
            MediaTargetType.ACTIVITY_PLAYER_SUBMISSION.getValue(), activityPlayerId, 1);
        List<SubmissionMediaResponse> submissionFiles = submissionMedias.stream()
                .map(this::convertToSubmissionMedia)
                .collect(Collectors.toList());
@@ -99,7 +115,7 @@
        log.info("找到提交资料 {} 个", submissionFiles.size());
        // 查询评分模板
        Long ratingSchemeId = row[8] != null ? Long.valueOf(row[8].toString()) : null;
        Long ratingSchemeId = row[9] != null ? ((Number) row[9]).longValue() : null;
        if (ratingSchemeId != null) {
            RatingFormResponse ratingForm = buildRatingForm(ratingSchemeId);
            response.setRatingForm(ratingForm);