Kaynağa Gözat

文章默认状态及app端部分接口

wenkai 2 hafta önce
ebeveyn
işleme
6af09f9400
24 değiştirilmiş dosya ile 444 ekleme ve 17 silme
  1. 20 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/ArticleController.java
  2. 41 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/app/ActivityController.java
  3. 33 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/app/AppIndexController.java
  4. 27 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/app/ProjectController.java
  5. 38 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/app/ScoreController.java
  6. 2 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/Article.java
  7. 1 1
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/GameScore.java
  8. 3 1
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/bo/ArticleBo.java
  9. 2 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/constant/GameEventConstant.java
  10. 2 1
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/vo/ArticleVo.java
  11. 3 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/vo/GameScoreVo.java
  12. 10 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/mapper/GameScoreMapper.java
  13. 21 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IArticleService.java
  14. 9 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IGameAthleteService.java
  15. 10 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IGameEventProjectService.java
  16. 9 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IGameScoreService.java
  17. 8 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IGameTeamService.java
  18. 61 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/ArticleServiceImpl.java
  19. 14 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameAthleteServiceImpl.java
  20. 15 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameEventProjectServiceImpl.java
  21. 90 6
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameScoreServiceImpl.java
  22. 14 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameTeamServiceImpl.java
  23. 3 8
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/IEnrollServiceImpl.java
  24. 8 0
      ruoyi-modules/ruoyi-game-event/src/main/resources/mapper/system/GameScoreMapper.xml

+ 20 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/ArticleController.java

@@ -2,10 +2,17 @@ package org.dromara.system.controller;
 
 import java.util.List;
 
+import jodd.bean.BeanUtil;
 import lombok.RequiredArgsConstructor;
 import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.constraints.*;
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.dromara.common.core.exception.ServiceException;
+import org.dromara.common.redis.utils.RedisUtils;
+import org.dromara.system.domain.Article;
+import org.dromara.system.domain.bo.GameEventBo;
+import org.dromara.system.domain.constant.GameEventConstant;
+import org.springframework.beans.BeanUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.validation.annotation.Validated;
 import org.dromara.common.idempotent.annotation.RepeatSubmit;
@@ -112,4 +119,17 @@ public class ArticleController extends BaseController {
     public R<Long> count() {
         return R.ok(articleService.countArticle());
     }
+
+
+    /**
+     * 修改赛事文章默认状态
+     */
+    @SaCheckPermission("system:article:edit")
+    @Log(title = "文章默认状态修改", businessType = BusinessType.UPDATE)
+    @PostMapping("/changeArticleDefault")
+    public R<Void> changeArticleDefault(@RequestBody ArticleBo bo) {
+        Boolean result= articleService.changeArticleDefault(bo);
+        return toAjax(result);
+    }
+
 }

+ 41 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/app/ActivityController.java

@@ -0,0 +1,41 @@
+package org.dromara.system.controller.app;
+
+import lombok.RequiredArgsConstructor;
+import org.dromara.system.domain.bo.ArticleBo;
+import org.dromara.system.domain.constant.GameEventConstant;
+import org.dromara.system.domain.vo.ArticleVo;
+import org.dromara.system.service.IArticleService;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 用户活动预热
+ */
+
+@Validated
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/app/activity")
+public class ActivityController {
+    private final IArticleService articleService;
+
+    /**
+     * 活动介绍
+     */
+    @GetMapping("/introduce/{eventId}")
+    public ArticleVo introduce(@PathVariable Long eventId) {
+        return articleService.queryDefaultArticleVo(eventId, GameEventConstant.ARTICLE_TYPE_INTRODUCE);
+    }
+
+
+    /**
+     * 往届风采
+     */
+    @GetMapping("/past/{eventId}")
+    public ArticleVo past(@PathVariable Long eventId) {
+        return articleService.queryDefaultArticleVo(eventId, GameEventConstant.ARTICLE_TYPE_PAST);
+    }
+}

+ 33 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/app/AppIndexController.java

@@ -0,0 +1,33 @@
+package org.dromara.system.controller.app;
+
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.dromara.common.core.domain.R;
+import org.dromara.system.domain.vo.VsNavBottomMainVo;
+import org.dromara.system.service.IVsNavBottomMainService;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@Slf4j
+@Validated
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/app/index")
+public class AppIndexController {
+
+    private final IVsNavBottomMainService vsNavBottomMainService;
+
+    /**
+     * 根据类型获取导航列表
+     */
+    @GetMapping
+    public R<List<VsNavBottomMainVo>> getNavListByType() {
+        return R.ok(vsNavBottomMainService.getNavListByType("4"));
+    }
+}

+ 27 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/app/ProjectController.java

@@ -0,0 +1,27 @@
+package org.dromara.system.controller.app;
+
+
+import lombok.RequiredArgsConstructor;
+import org.dromara.system.domain.vo.GameEventProjectVo;
+import org.dromara.system.service.IGameEventProjectService;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@Validated
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/app/project")
+public class ProjectController {
+
+    private final IGameEventProjectService gameEventProjectService;
+
+    @GetMapping("/{eventId}")
+    public List<GameEventProjectVo> getProject(@PathVariable Long eventId) {
+        return gameEventProjectService.queryListByEventId(eventId);
+    }
+}

+ 38 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/app/ScoreController.java

@@ -0,0 +1,38 @@
+package org.dromara.system.controller.app;
+
+import lombok.RequiredArgsConstructor;
+import org.dromara.system.domain.vo.GameScoreVo;
+import org.dromara.system.domain.vo.GameTeamVo;
+import org.dromara.system.service.IGameScoreService;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 获奖名单
+ */
+
+@Validated
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/app/score")
+public class ScoreController {
+
+    private final IGameScoreService gameScoreService;
+
+    /**
+     * 查看获奖名单
+     *
+     * @return 获奖名单 key:项目 list:获奖信息
+     */
+    @GetMapping("/{eventId}")
+    public Map<String, List<GameScoreVo>> getScore(@PathVariable Long eventId) {
+        return gameScoreService.getAppScore(eventId);
+    }
+
+}

+ 2 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/Article.java

@@ -47,6 +47,8 @@ public class Article extends TenantEntity {
      */
     private Long type;
 
+    private Integer isDefault;
+
     /**
      * 是否展示 0:展示 1:隐藏
      */

+ 1 - 1
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/GameScore.java

@@ -25,7 +25,7 @@ public class GameScore extends TenantEntity {
     /**
      * 主键
      */
-    @TableId(value = "score_id",type = IdType.AUTO)
+    @TableId(value = "score_id", type = IdType.AUTO)
     private Long scoreId;
 
     /**

+ 3 - 1
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/bo/ArticleBo.java

@@ -45,11 +45,13 @@ public class ArticleBo extends BaseEntity {
      */
     private String content;
 
+    private Integer isDefault;
+
     /**
      * 文章类型
      */
     @NotNull(message = "文章类型不能为空", groups = { AddGroup.class, EditGroup.class })
-    private Long type;
+    private Integer type;
 
     /**
      * 是否展示 0:展示 1:隐藏

+ 2 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/constant/GameEventConstant.java

@@ -6,4 +6,6 @@ public class GameEventConstant {
      */
     public static final String DEFAULT_EVENT = "default:gameEvent:";
     public static final String DEFAULT_EVENT_ID = "default:eventId:";
+    public static final Integer ARTICLE_TYPE_INTRODUCE = 1;
+    public static final Integer ARTICLE_TYPE_PAST = 2;
 }

+ 2 - 1
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/vo/ArticleVo.java

@@ -57,12 +57,13 @@ public class ArticleVo implements Serializable {
     @ExcelProperty(value = "内容")
     private String content;
 
+    private Integer isDefault;
     /**
      * 文章类型
      */
     @ExcelProperty(value = "文章类型", converter = ExcelDictConvert.class)
     @ExcelDictFormat(dictType = "article_type")
-    private Long type;
+    private Integer type;
 
     /**
      * 是否展示 0:展示 1:隐藏

+ 3 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/vo/GameScoreVo.java

@@ -52,12 +52,15 @@ public class GameScoreVo implements Serializable {
     @ExcelProperty(value = "运动员ID")
     private Long athleteId;
 
+    private String athleteName;
     /**
      * 队伍ID
      */
     @ExcelProperty(value = "队伍ID")
     private Long teamId;
 
+    private String teamName;
+
     /**
      * 成绩值
      */

+ 10 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/mapper/GameScoreMapper.java

@@ -4,6 +4,10 @@ import org.dromara.system.domain.GameScore;
 import org.dromara.system.domain.vo.GameScoreVo;
 import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
 
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+
 /**
  * 成绩Mapper接口
  *
@@ -12,4 +16,10 @@ import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
  */
 public interface GameScoreMapper extends BaseMapperPlus<GameScore, GameScoreVo> {
 
+    /**
+     * 获取赛事下每个项目成绩最高的前三名
+     * @param eventId
+     * @return
+     */
+    List<GameScore> listAppScoreByEventIdGroupProjectId(Long eventId);
 }

+ 21 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IArticleService.java

@@ -1,5 +1,9 @@
 package org.dromara.system.service;
 
+import jakarta.validation.constraints.NotNull;
+import org.dromara.common.core.validate.AddGroup;
+import org.dromara.common.core.validate.EditGroup;
+import org.dromara.system.domain.Article;
 import org.dromara.system.domain.vo.ArticleVo;
 import org.dromara.system.domain.bo.ArticleBo;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -71,4 +75,21 @@ public interface IArticleService {
      * @return
      */
     Long countArticle();
+
+    /**
+     * 获取默认活动介绍
+     * @param eventId
+     * @return
+     */
+    ArticleVo queryDefaultArticleVo(Long eventId, Integer articleTypeIntroduce);
+
+    /**
+     *
+     * 查询出当前赛事下该类型的默认赛事
+     * @param type
+     * @return
+     */
+    Article selectDefaultArticleByType(@NotNull(message = "文章类型不能为空", groups = { AddGroup.class, EditGroup.class }) Integer type);
+
+    Boolean changeArticleDefault(ArticleBo bo);
 }

+ 9 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IGameAthleteService.java

@@ -9,6 +9,8 @@ import org.dromara.common.mybatis.core.page.PageQuery;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Optional;
+import java.util.Set;
 
 /**
  * 参赛队员Service接口
@@ -77,4 +79,11 @@ public interface IGameAthleteService {
     Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
 
     Boolean saveOrEditBatch(List<GameAthlete> list);
+
+    /**
+     * 批量查询运动员信息
+     * @param athleteIds
+     * @return
+     */
+    List<GameAthleteVo> listByIds(Collection<Long> athleteIds);
 }

+ 10 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IGameEventProjectService.java

@@ -1,13 +1,16 @@
 package org.dromara.system.service;
 
+import org.dromara.system.domain.GameEventProject;
 import org.dromara.system.domain.vo.GameEventProjectVo;
 import org.dromara.system.domain.bo.GameEventProjectBo;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.system.service.impl.GameEventProjectServiceImpl;
 
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * 赛事项目Service接口
@@ -77,4 +80,11 @@ public interface IGameEventProjectService {
      * @return
      */
     Map<String, List<String>> mapProjectTypeAndProject(Long eventId);
+
+    /**
+     * 查询当前赛事下所有的项目
+     * @param eventId
+     * @return
+     */
+    List<GameEventProjectVo> queryListByEventId(Long eventId);
 }

+ 9 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IGameScoreService.java

@@ -4,9 +4,11 @@ import org.dromara.system.domain.vo.GameScoreVo;
 import org.dromara.system.domain.bo.GameScoreBo;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.system.domain.vo.GameTeamVo;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 成绩Service接口
@@ -65,4 +67,11 @@ public interface IGameScoreService {
      * @return 是否删除成功
      */
     Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+
+    /**
+     * 获取用户端获奖名单
+     * @param eventId
+     * @return 获奖名单 key:项目 list:获奖信息
+     */
+    Map<String, List<GameScoreVo>> getAppScore(Long eventId);
 }

+ 8 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IGameTeamService.java

@@ -8,6 +8,7 @@ import org.dromara.common.mybatis.core.page.PageQuery;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Set;
 
 /**
  * 参赛队伍Service接口
@@ -80,4 +81,11 @@ public interface IGameTeamService {
      * @return
      */
     Long countTeam();
+
+    /**
+     * 批量查询队员信息
+     * @param teamIds
+     * @return
+     */
+    List<GameTeamVo> listByIds(Collection<Long> teamIds);
 }

+ 61 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/ArticleServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -13,10 +14,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.dromara.common.redis.utils.RedisUtils;
 import org.dromara.system.domain.GameEvent;
 import org.dromara.system.domain.bo.GameEventBo;
+import org.dromara.system.domain.constant.GameEventConstant;
 import org.dromara.system.domain.vo.GameEventVo;
 import org.dromara.system.service.IGameEventService;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.dromara.system.domain.bo.ArticleBo;
 import org.dromara.system.domain.vo.ArticleVo;
@@ -182,4 +186,61 @@ public class ArticleServiceImpl implements IArticleService {
             Wrappers.lambdaQuery(Article.class)
         );
     }
+
+    /**
+     * 获取默认活动介绍
+     *
+     * @param eventId
+     * @return
+     */
+    @Override
+    public ArticleVo queryDefaultArticleVo(Long eventId, Integer articleTypeIntroduce) {
+        return baseMapper.selectVoOne(
+            Wrappers.lambdaQuery(Article.class)
+                .eq(Article::getEventId, eventId)
+                .eq(Article::getType, articleTypeIntroduce)
+        );
+    }
+
+    /**
+     *
+     * 查询出当前赛事下该类型的默认赛事
+     *
+     * @param type
+     * @return
+     */
+    @Override
+    public Article selectDefaultArticleByType(Integer type) {
+        Object cacheObject = RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID);
+        Long defualtEventId = null;
+        if (ObjectUtil.isNotNull(cacheObject)) {
+            defualtEventId = Long.valueOf(cacheObject.toString());
+        }
+        return baseMapper.selectOne(
+            Wrappers.lambdaQuery(Article.class)
+                .eq(Article::getEventId, defualtEventId)
+                .eq(Article::getType, type)
+                .eq(Article::getIsDefault, 1)
+        );
+    }
+
+    @Override
+    public Boolean changeArticleDefault(ArticleBo bo) {
+        //查询出当前赛事下的 类型中的默认文章
+        Boolean result;
+        Article article = this.selectDefaultArticleByType(bo.getType());
+        if (article == null) {
+            result = this.updateByBo(bo);
+            return result;
+        }
+        if (article.getId().equals(bo.getId()) && bo.getIsDefault().equals(0)) {
+            throw new ServiceException("必须有一个默认文章");
+        }
+        result = this.updateByBo(bo);
+        ArticleBo bo1 = new ArticleBo();
+        BeanUtils.copyProperties(article, bo1);
+        bo1.setIsDefault(0);
+        result = this.updateByBo(bo1);
+        return result;
+    }
 }

+ 14 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameAthleteServiceImpl.java

@@ -370,4 +370,18 @@ public class GameAthleteServiceImpl implements IGameAthleteService {
 
         return baseMapper.insertOrUpdateBatch(list);
     }
+
+    /**
+     * 批量查询运动员信息
+     *
+     * @param athleteIds
+     * @return
+     */
+    @Override
+    public List<GameAthleteVo> listByIds(Collection<Long> athleteIds) {
+        return baseMapper.selectVoList(
+            Wrappers.lambdaQuery(GameAthlete.class)
+                .in(GameAthlete::getAthleteId, athleteIds)
+        );
+    }
 }

+ 15 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameEventProjectServiceImpl.java

@@ -298,4 +298,19 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
 
         return result;
     }
+
+    /**
+     * 查询当前赛事下所有的项目
+     *
+     * @param eventId
+     * @return
+     */
+    @Override
+    public List<GameEventProjectVo> queryListByEventId(Long eventId) {
+        List<GameEventProjectVo> projects = baseMapper.selectVoList(
+            Wrappers.lambdaQuery(GameEventProject.class)
+                .eq(GameEventProject::getEventId, eventId)
+        );
+        return projects;
+    }
 }

+ 90 - 6
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameScoreServiceImpl.java

@@ -1,7 +1,10 @@
 package org.dromara.system.service.impl;
 
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.toolkit.reflect.GenericTypeUtils;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
+import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -10,7 +13,14 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.dromara.common.redis.utils.RedisUtils;
+import org.dromara.system.domain.GameEventProject;
 import org.dromara.system.domain.constant.GameEventConstant;
+import org.dromara.system.domain.vo.GameAthleteVo;
+import org.dromara.system.domain.vo.GameEventProjectVo;
+import org.dromara.system.domain.vo.GameTeamVo;
+import org.dromara.system.service.IGameAthleteService;
+import org.dromara.system.service.IGameEventProjectService;
+import org.dromara.system.service.IGameTeamService;
 import org.springframework.stereotype.Service;
 import org.dromara.system.domain.bo.GameScoreBo;
 import org.dromara.system.domain.vo.GameScoreVo;
@@ -18,9 +28,10 @@ import org.dromara.system.domain.GameScore;
 import org.dromara.system.mapper.GameScoreMapper;
 import org.dromara.system.service.IGameScoreService;
 
-import java.util.List;
-import java.util.Map;
-import java.util.Collection;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
  * 成绩Service业务层处理
@@ -34,6 +45,9 @@ import java.util.Collection;
 public class GameScoreServiceImpl implements IGameScoreService {
 
     private final GameScoreMapper baseMapper;
+    private final IGameTeamService gameTeamService;
+    private final IGameAthleteService gameAthleteService;
+    private final IGameEventProjectService gameEventProjectService;
 
     /**
      * 查询成绩
@@ -42,7 +56,7 @@ public class GameScoreServiceImpl implements IGameScoreService {
      * @return 成绩
      */
     @Override
-    public GameScoreVo queryById(Long scoreId){
+    public GameScoreVo queryById(Long scoreId) {
         return baseMapper.selectVoById(scoreId);
     }
 
@@ -150,7 +164,7 @@ public class GameScoreServiceImpl implements IGameScoreService {
     /**
      * 保存前的数据校验
      */
-    private void validEntityBeforeSave(GameScore entity){
+    private void validEntityBeforeSave(GameScore entity) {
         //TODO 做一些数据校验,如唯一约束
     }
 
@@ -163,9 +177,79 @@ public class GameScoreServiceImpl implements IGameScoreService {
      */
     @Override
     public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
-        if(isValid){
+        if (isValid) {
             //TODO 做一些业务上的校验,判断是否需要校验
         }
         return baseMapper.deleteByIds(ids) > 0;
     }
+
+    /**
+     * 获取用户端获奖名单
+     *
+     * @param eventId
+     * @return 获奖名单 key:项目 list:获奖信息
+     */
+    @Override
+    public Map<String, List<GameScoreVo>> getAppScore(Long eventId) {
+        // 1.查询当前赛事下的每个项目下的分数最高的前三名
+        List<GameScore> scoreList = baseMapper.listAppScoreByEventIdGroupProjectId(eventId);
+
+        // 2.将分数最高的前三名按项目分组
+        Map<Long, List<GameScore>> gorupMap = scoreList.stream()
+            .collect(Collectors.groupingBy(GameScore::getProjectId));
+
+        // 3.查询当前赛事下所有的项目 并转为map对应 方便后续直接取值
+        List<GameEventProjectVo> projects = gameEventProjectService.queryListByEventId(eventId);
+        Map<Long, String> projectMap = projects.stream()
+            .collect(Collectors.toMap(GameEventProjectVo::getProjectId, GameEventProjectVo::getProjectName));
+
+        // 4. 提取所有需要的 athleteId 和 teamId
+        Set<Long> athleteIds = scoreList.stream()
+            .map(GameScore::getAthleteId)
+            .filter(Objects::nonNull)
+            .collect(Collectors.toSet());
+
+        Set<Long> teamIds = scoreList.stream()
+            .map(GameScore::getTeamId)
+            .filter(Objects::nonNull)
+            .collect(Collectors.toSet());
+
+        //  5. 批量查询运动员和队伍信息
+        Map<Long, String> athleteNameMap;
+        if (!athleteIds.isEmpty()) {
+            List<GameAthleteVo> athletes = gameAthleteService.listByIds(athleteIds);
+            athleteNameMap = athletes.stream()
+                .collect(Collectors.toMap(GameAthleteVo::getAthleteId, GameAthleteVo::getName));
+        } else {
+            athleteNameMap = new HashMap<>();
+        }
+
+        Map<Long, String> teamNameMap;
+        if (!teamIds.isEmpty()) {
+            List<GameTeamVo> teams = gameTeamService.listByIds(teamIds);
+            teamNameMap = teams.stream()
+                .collect(Collectors.toMap(GameTeamVo::getTeamId, GameTeamVo::getTeamName));
+        } else {
+            teamNameMap = new HashMap<>();
+        }
+
+        // 6. 构建结果
+        Map<String, List<GameScoreVo>> result = new HashMap<>();
+        for (Map.Entry<Long, List<GameScore>> entry : gorupMap.entrySet()) {
+            String projectName = projectMap.get(entry.getKey());
+            List<GameScoreVo> voList = entry.getValue().stream().map(gameScore -> {
+                GameScoreVo vo = new GameScoreVo();
+                BeanUtil.copyProperties(gameScore, vo);
+                // 使用缓存 Map 获取,避免查库
+                vo.setAthleteName(athleteNameMap.get(vo.getAthleteId()));
+                vo.setTeamName(teamNameMap.get(vo.getTeamId()));
+                return vo;
+            }).collect(Collectors.toList());
+
+            result.put(projectName, voList);
+        }
+        log.error("map:{}", gorupMap);
+        return result;
+    }
+
 }

+ 14 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameTeamServiceImpl.java

@@ -267,4 +267,18 @@ public class GameTeamServiceImpl implements IGameTeamService {
     public Long countTeam() {
         return this.baseMapper.selectCount(Wrappers.lambdaQuery(GameTeam.class));
     }
+
+    /**
+     * 批量查询队员信息
+     *
+     * @param teamIds
+     * @return
+     */
+    @Override
+    public List<GameTeamVo> listByIds(Collection<Long> teamIds) {
+        return baseMapper.selectVoList(
+            Wrappers.lambdaQuery(GameTeam.class)
+                .in(GameTeam::getTeamId, teamIds)
+        );
+    }
 }

+ 3 - 8
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/IEnrollServiceImpl.java

@@ -394,7 +394,7 @@ public class IEnrollServiceImpl implements IEnrollService {
         for (Map.Entry<String, List<EnrollProjectVo>> entry : groupedByTeam.entrySet()) {
             String teamName = entry.getKey();
             List<EnrollProjectVo> athletes = entry.getValue();
-
+            //todo 判断是否存在该队伍 存在就更新 人数为原本+1 号码段无需重新分配
             GameTeamBo gameTeamBo = new GameTeamBo();
             gameTeamBo.setEventId(eventId);
             gameTeamBo.setTeamName(teamName);
@@ -418,6 +418,7 @@ public class IEnrollServiceImpl implements IEnrollService {
                 gameAthleteBo.setEventId(eventId);
                 gameAthleteBo.setTeamId(teamId);
                 gameAthleteBo.setTeamName(teamName);
+                //todo 如果存在队伍 即续分配
 
                 // 分配编号:从当前计数器获取并递增
                 int assignedNumber = currentNumber.getAndIncrement();
@@ -453,7 +454,7 @@ public class IEnrollServiceImpl implements IEnrollService {
      * @param team   当前是第几队
      * @return 号码段字符串,如 "0001-0300" 或 "00001-00300"
      */
-    public static String generateNumberRange(int member, int team) {
+    private String generateNumberRange(int member, int team) {
         // 每个队伍固定分配300个号码
         int start = 1 + (team - 1) * 300;
         int end = 300 * team;
@@ -466,10 +467,4 @@ public class IEnrollServiceImpl implements IEnrollService {
 
         return startStr + "-" + endStr;
     }
-
-    public static void main(String[] args) {
-        for (int i = 1; i <= 10; i++) {
-            System.out.println(generateNumberRange(100, i));
-        }
-    }
 }

+ 8 - 0
ruoyi-modules/ruoyi-game-event/src/main/resources/mapper/system/GameScoreMapper.xml

@@ -4,4 +4,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.dromara.system.mapper.GameScoreMapper">
 
+    <select id="listAppScoreByEventIdGroupProjectId">
+        SELECT *
+        FROM (SELECT ROW_NUMBER() OVER (PARTITION BY project_id ORDER BY score_value DESC) AS rank_score, game_score.*
+              FROM game_score
+              WHERE event_id = #{eventId}) ranked
+        WHERE rank_score &lt;= 3
+        ORDER BY ranked.project_id, ranked.score_value DESC;
+    </select>
 </mapper>