Selaa lähdekoodia

裁判显示修改

wenkai 2 viikkoa sitten
vanhempi
sitoutus
3b6922512d

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

@@ -52,7 +52,7 @@ public class GameEventProject extends TenantEntity {
     /**
      * 裁判员ID
      */
-    private Long refereeId;
+    private String refereeId;
 
     /**
      * 比赛场地

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

@@ -11,6 +11,7 @@ import lombok.EqualsAndHashCode;
 import jakarta.validation.constraints.*;
 
 import java.util.Date;
+import java.util.List;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
 
@@ -63,7 +64,12 @@ public class GameEventProjectBo extends BaseEntity {
      * 裁判员ID
      */
 //    @NotNull(message = "裁判员ID不能为空", groups = { AddGroup.class, EditGroup.class })
-    private Long refereeId;
+    private String refereeId;
+
+    /**
+     * 裁判id集合
+     */
+    private List<String> refereeIds;
 
     /**
      * 比赛场地

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

@@ -13,7 +13,7 @@ import lombok.Data;
 import java.io.Serial;
 import java.io.Serializable;
 import java.util.Date;
-
+import java.util.List;
 
 
 /**
@@ -67,8 +67,11 @@ public class GameEventProjectVo implements Serializable {
     /**
      * 裁判员ID
      */
-    @ExcelProperty(value = "裁判员ID")
-    private Long refereeId;
+    // @ExcelProperty(value = "裁判员ID")
+    private String refereeId;
+
+    // @ExcelProperty(value = "裁判员ID")
+    private List<String> refereeIds;
 
     /**
      * 比赛场地

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

@@ -71,5 +71,4 @@ public interface IGameEventProjectService {
 
     Long countEventProject();
 
-    Map<String, List<String>> mapProjectTypeAndProject();
 }

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

@@ -1,6 +1,8 @@
 package org.dromara.system.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
@@ -17,10 +19,8 @@ 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;
@@ -28,7 +28,10 @@ import org.dromara.system.domain.GameEventProject;
 import org.dromara.system.mapper.GameEventProjectMapper;
 import org.dromara.system.service.IGameEventProjectService;
 
-import java.util.*;
+import java.util.List;
+import java.util.Map;
+import java.util.Collection;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 /**
@@ -44,7 +47,6 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
 
     private final GameEventProjectMapper baseMapper;
     private final GameEventMapper gameEventMapper;
-    private final ISysDictTypeService sysDictTypeService;
 
     /**
      * 查询赛事项目
@@ -54,7 +56,9 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
      */
     @Override
     public GameEventProjectVo queryById(Long projectId) {
-        return baseMapper.selectVoById(projectId);
+        GameEventProjectVo vo = baseMapper.selectVoById(projectId);
+        vo.setRefereeIds(JSONUtil.toList(vo.getRefereeId(), String.class));
+        return vo;
     }
 
     /**
@@ -66,22 +70,31 @@ 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);
         Page<GameEventProjectVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
-        result.getRecords().stream()
-            .map(vo -> {
-                Optional.ofNullable(vo.getEventId())
-                    .filter(ObjectUtil::isNotEmpty)
-                    .ifPresent(projectValue -> {
-                        GameEvent gameEvent = gameEventMapper.selectById(vo.getEventId());
+
+        // 使用 forEach 直接修改原对象
+        result.getRecords().forEach(vo -> {
+            Optional.ofNullable(vo.getEventId())
+                .filter(ObjectUtil::isNotEmpty)
+                .ifPresent(eventId -> {
+                    GameEvent gameEvent = gameEventMapper.selectById(eventId);
+                    if (gameEvent != null) {
                         vo.setEventName(gameEvent.getEventName());
-                    });
-                return vo;
-            })
-            .collect(Collectors.toList());  // 收集结果
+                    }
+                });
+
+            Optional.ofNullable(vo.getRefereeId())
+                .filter(ObjectUtil::isNotEmpty)
+                .ifPresent(refereeIdStr -> {
+                    List<String> refereeList = JSONUtil.toList(refereeIdStr.toString(), String.class);
+                    vo.setRefereeIds(refereeList);
+                });
+        });
+
         return TableDataInfo.build(result);
     }
 
@@ -93,7 +106,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 +120,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,11 +152,14 @@ 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);
         validEntityBeforeSave(add);
+        if (StrUtil.isNotEmpty(bo.getRefereeId())) {
+            add.setRefereeId(JSONUtil.toJsonStr(bo.getRefereeIds()));
+        }
         boolean flag = baseMapper.insert(add) > 0;
         if (flag) {
             bo.setProjectId(add.getProjectId());
@@ -159,7 +175,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,32 +220,4 @@ 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;
-    }
 }