Răsfoiți Sursa

refactor(game-event): 修复新增赛事的bug

- 在 GameEventGroupController 中添加日志记录和防止重复提交的注解
- 移除 GameEventServiceImpl 中的冗余代码,简化方法实现- 删除 ruoyi-admin/pom.xml 中的 ruoyi-common-caffeine 依赖
- 在 pom.xml 中添加空行,优化配置文件格式
zhou 10 ore în urmă
părinte
comite
2d2e0008ba

+ 2 - 0
pom.xml

@@ -80,6 +80,7 @@
                 <monitor.username>ruoyi</monitor.username>
                 <monitor.password>123456</monitor.password>
             </properties>
+
         </profile>
         <profile>
             <id>test</id>
@@ -94,6 +95,7 @@
                 <!-- 默认环境 -->
                 <activeByDefault>true</activeByDefault>
             </activation>
+
         </profile>
         <profile>
             <id>prod</id>

+ 0 - 6
ruoyi-admin/pom.xml

@@ -75,12 +75,6 @@
             <artifactId>ruoyi-job</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.dromara</groupId>
-            <artifactId>ruoyi-common-caffeine</artifactId>
-            <version>5.4.1</version>
-        </dependency>
-
         <!-- 代码生成-->
         <dependency>
             <groupId>org.dromara</groupId>

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

@@ -110,6 +110,8 @@ public class GameEventGroupController extends BaseController {
      * @param groupId 分组ID
      */
     @SaCheckPermission("system:gameEventGroup:query")
+    @Log(title = "赛事生成分组结果", businessType = BusinessType.INSERT)
+    @RepeatSubmit()
     @GetMapping("/generateGroups/{groupId}")
     public R<Map<String, Object>> generateGroups(@NotNull(message = "分组ID不能为空")
                                                @PathVariable Long groupId) {

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

@@ -117,14 +117,6 @@ public class GameEventServiceImpl implements IGameEventService {
      */
     @Override
     public List<GameEventVo> queryList(GameEventBo bo) {
-        if (bo.getEventId() == null) {
-            Object cacheObject = RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID);
-            if (cacheObject instanceof Integer) {
-                bo.setEventId(((Integer) cacheObject).longValue());  // 显式转换为 Long 类型
-            } else if (cacheObject instanceof Long) {
-                bo.setEventId((Long) cacheObject);
-            }
-        }
         LambdaQueryWrapper<GameEvent> lqw = buildQueryWrapper(bo);
         return baseMapper.selectVoList(lqw);
     }
@@ -151,14 +143,6 @@ public class GameEventServiceImpl implements IGameEventService {
      */
     @Override
     public Long insertByBo(GameEventBo bo) {
-        if (bo.getEventId() == null) {
-            Object cacheObject = RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID);
-            if (cacheObject instanceof Integer) {
-                bo.setEventId(((Integer) cacheObject).longValue());  // 显式转换为 Long 类型
-            } else if (cacheObject instanceof Long) {
-                bo.setEventId((Long) cacheObject);
-            }
-        }
         GameEvent add = MapstructUtils.convert(bo, GameEvent.class);
         validEntityBeforeSave(add);
         boolean flag = baseMapper.insert(add) > 0;
@@ -176,14 +160,6 @@ public class GameEventServiceImpl implements IGameEventService {
      */
     @Override
     public Boolean updateByBo(GameEventBo bo) {
-        if (bo.getEventId() == null) {
-            Object cacheObject = RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID);
-            if (cacheObject instanceof Integer) {
-                bo.setEventId(((Integer) cacheObject).longValue());  // 显式转换为 Long 类型
-            } else if (cacheObject instanceof Long) {
-                bo.setEventId((Long) cacheObject);
-            }
-        }
         GameEvent update = MapstructUtils.convert(bo, GameEvent.class);
         validEntityBeforeSave(update);
         boolean result = baseMapper.updateById(update) > 0;
@@ -1081,19 +1057,19 @@ public class GameEventServiceImpl implements IGameEventService {
             // 没有组别,直接返回项目开始时间
             return project.getStartTime();
         }
-        
+
         // 有组别,找到最早的组别开始时间
         Date earliestGroupTime = project.getGroups().stream()
             .map(GroupProgressVo::getBeginTime)
             .filter(Objects::nonNull)
             .min(Date::compareTo)
             .orElse(null);
-        
+
         // 如果组别时间存在,与项目时间比较,返回较早的时间
         if (earliestGroupTime != null && project.getStartTime() != null) {
             return earliestGroupTime.before(project.getStartTime()) ? earliestGroupTime : project.getStartTime();
         }
-        
+
         // 如果组别时间不存在,返回项目时间
         return earliestGroupTime != null ? earliestGroupTime : project.getStartTime();
     }