wenkai 2 weken geleden
bovenliggende
commit
418407fdc0

+ 4 - 0
ruoyi-modules/ruoyi-game-event/pom.xml

@@ -103,6 +103,10 @@
             <groupId>org.dromara</groupId>
             <artifactId>ruoyi-common-core</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.dromara</groupId>
+            <artifactId>ruoyi-system</artifactId>
+        </dependency>
 
     </dependencies>
 

+ 1 - 11
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/GameAthleteController.java

@@ -83,7 +83,7 @@ public class GameAthleteController extends BaseController {
         ExcelResult<GameAthleteVo> excelResult = null;
         try {
             // 从redis中获取默认参赛赛事
-            Long defaultEventId = Long.valueOf(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID_KEY).toString());
+            Long defaultEventId = Long.valueOf(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID).toString());
             excelResult = ExcelUtil.importExcel(file.getInputStream(), GameAthleteVo.class, true);
             List<GameAthlete> list = MapstructUtils.convert(excelResult.getList(), GameAthlete.class);
             Long finalDefaultEventId = defaultEventId;
@@ -166,14 +166,4 @@ public class GameAthleteController extends BaseController {
                           @PathVariable Long[] athleteIds) {
         return toAjax(gameAthleteService.deleteWithValidByIds(List.of(athleteIds), true));
     }
-
-
-    public static void main(String[] args) {
-        List<String> strings = List.of("1", "2", "3");
-        String str = JSONUtil.toJsonStr(strings);
-        System.out.println(str);
-        String s="["1","2","3"]"
-        List<String> list = JSONUtil.toList(str, String.class);
-        System.out.println(list);
-    }
 }

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

@@ -7,6 +7,7 @@ import org.dromara.common.mybatis.core.page.PageQuery;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 赛事项目Service接口
@@ -69,4 +70,6 @@ public interface IGameEventProjectService {
     List<GameEventProjectVo> listProjectsByEventIdAndProjectIndex(Long eventId, String[] projectIds);
 
     Long countEventProject();
+
+    Map<String, List<String>> mapProjectTypeAndProject();
 }

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

@@ -17,8 +17,10 @@ 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.domain.vo.SysDictDataVo;
 import org.dromara.system.mapper.GameEventMapper;
 import org.dromara.system.service.IGameEventService;
+import org.dromara.system.service.ISysDictTypeService;
 import org.springframework.stereotype.Service;
 import org.dromara.system.domain.bo.GameEventProjectBo;
 import org.dromara.system.domain.vo.GameEventProjectVo;
@@ -26,10 +28,7 @@ import org.dromara.system.domain.GameEventProject;
 import org.dromara.system.mapper.GameEventProjectMapper;
 import org.dromara.system.service.IGameEventProjectService;
 
-import java.util.List;
-import java.util.Map;
-import java.util.Collection;
-import java.util.Optional;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -45,6 +44,7 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
 
     private final GameEventProjectMapper baseMapper;
     private final GameEventMapper gameEventMapper;
+    private final ISysDictTypeService sysDictTypeService;
 
     /**
      * 查询赛事项目
@@ -66,7 +66,7 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
      */
     @Override
     public TableDataInfo<GameEventProjectVo> queryPageList(GameEventProjectBo bo, PageQuery pageQuery) {
-        if (bo.getEventId() == null){
+        if (bo.getEventId() == null) {
             bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
         }
         LambdaQueryWrapper<GameEventProject> lqw = buildQueryWrapper(bo);
@@ -93,7 +93,7 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
      */
     @Override
     public List<GameEventProjectVo> queryList(GameEventProjectBo bo) {
-        if (bo.getEventId() == null){
+        if (bo.getEventId() == null) {
             bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
         }
         LambdaQueryWrapper<GameEventProject> lqw = buildQueryWrapper(bo);
@@ -107,18 +107,18 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
         lqw.eq(bo.getEventId() != null, GameEventProject::getEventId, bo.getEventId());
         // 通过名称模糊查询
         Optional.ofNullable(bo.getEventName())
-            .ifPresent(eventName->{
+            .ifPresent(eventName -> {
                 List<GameEvent> gameEvents = gameEventMapper.selectList(
                     Wrappers.lambdaQuery(GameEvent.class)
                         .like(GameEvent::getEventName, bo.getEventName())
                         .select(GameEvent::getEventId)
                 );
-                if(CollectionUtils.isNotEmpty(gameEvents)){
+                if (CollectionUtils.isNotEmpty(gameEvents)) {
                     List<Long> ids = gameEvents.stream()
                         .map(GameEvent::getEventId)
                         .collect(Collectors.toList());
                     lqw.in(GameEventProject::getEventId, ids);
-                }else{
+                } else {
                     lqw.apply("1=0");
                 }
             });
@@ -139,7 +139,7 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
      */
     @Override
     public Boolean insertByBo(GameEventProjectBo bo) {
-        if (bo.getEventId() == null){
+        if (bo.getEventId() == null) {
             bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
         }
         GameEventProject add = MapstructUtils.convert(bo, GameEventProject.class);
@@ -159,7 +159,7 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
      */
     @Override
     public Boolean updateByBo(GameEventProjectBo bo) {
-        if (bo.getEventId() == null){
+        if (bo.getEventId() == null) {
             bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
         }
         GameEventProject update = MapstructUtils.convert(bo, GameEventProject.class);
@@ -204,4 +204,32 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
             Wrappers.lambdaQuery(GameEventProject.class)
         );
     }
+
+    @Override
+    public Map<String, List<String>> mapProjectTypeAndProject() {
+        Long defaultEventId = RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID);
+        List<GameEventProject> list = baseMapper.selectList(
+            Wrappers.lambdaQuery(GameEventProject.class)
+                .eq(GameEventProject::getEventId, defaultEventId)
+                .select(GameEventProject::getProjectType, GameEventProject::getProjectName)
+        );
+
+        // 从字典中获取项目类型映射:projectType (dictValue) -> dictLabel
+        List<SysDictDataVo> projectTypeDictList = sysDictTypeService.selectDictDataByType("game_project_type");
+        Map<String, String> dictMap = projectTypeDictList.stream()
+            .collect(Collectors.toMap(SysDictDataVo::getDictValue, SysDictDataVo::getDictLabel));
+
+        // 按照项目类型(中文 label)分组,每个类型对应一个项目名称列表
+        Map<String, List<String>> result = new HashMap<>();
+        for (GameEventProject project : list) {
+            String projectType = project.getProjectType();
+            String projectName = project.getProjectName();
+            String label = dictMap.getOrDefault(projectType, projectType); // 使用中文标签作为 key
+
+            // 将项目名添加到对应类型的列表中
+            result.computeIfAbsent(label, k -> new ArrayList<>()).add(projectName);
+        }
+
+        return result;
+    }
 }