Преглед изворни кода

feat(game-event): 添加默认赛事缓存支持

- 在 GameEventConstant 中添加 DEFAULT_EVENT 和 DEFAULT_EVENT_ID 常量
- 在 GameEventServiceImpl 中实现默认赛事和赛事 ID 的缓存逻辑
- 修改相关服务方法,以支持从缓存中获取默认赛事 ID
- 优化 GameEventController 中的 getDefaultEvent 方法
zhou пре 2 недеља
родитељ
комит
a4757c8c96
16 измењених фајлова са 139 додато и 30 уклоњено
  1. 0 1
      pom.xml
  2. 7 2
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/GameEventController.java
  3. 0 5
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/GameEventConfigType.java
  4. 0 5
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/bo/GameEventConfigTypeBo.java
  5. 2 1
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/constant/GameEventConstant.java
  6. 0 5
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/vo/GameEventConfigTypeVo.java
  7. 14 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameAthleteServiceImpl.java
  8. 14 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameEventConfigServiceImpl.java
  9. 14 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameEventGroupServiceImpl.java
  10. 14 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameEventMenuServiceImpl.java
  11. 14 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameEventProjectServiceImpl.java
  12. 18 11
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameEventServiceImpl.java
  13. 14 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameRefereeServiceImpl.java
  14. 14 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameScoreServiceImpl.java
  15. 14 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameTeamServiceImpl.java
  16. BIN
      ruoyi-modules/ruoyi-game-event/src/main/resources/template/报名表模板.xlsx

+ 0 - 1
pom.xml

@@ -416,7 +416,6 @@
                         <arg>-parameters</arg>
                     </compilerArgs>
                     <excludes>
-                        <exclude>ruoyi-game-event/**</exclude>
                         <exclude>ruoyi-common-tenant/**</exclude>
                         <exclude>ruoyi-common-mybatis/**</exclude>
                     </excludes>

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

@@ -7,6 +7,8 @@ import lombok.RequiredArgsConstructor;
 import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.constraints.*;
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.dromara.common.redis.utils.RedisUtils;
+import org.dromara.system.domain.constant.GameEventConstant;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.validation.annotation.Validated;
 import org.dromara.common.idempotent.annotation.RepeatSubmit;
@@ -118,7 +120,9 @@ public class GameEventController extends BaseController {
      */
     @GetMapping("/default")
     public R<GameEventVo> getDefaultEvent() {
-        return R.ok(gameEventService.getDefaultEvent());
+        GameEventVo defaultEvent = gameEventService.getDefaultEvent();
+//        RedisUtils.setCacheObject(GameEventConstant.DEFAULT_EVENT, defaultEvent);
+        return R.ok(defaultEvent);
     }
 
     /**
@@ -128,7 +132,8 @@ public class GameEventController extends BaseController {
     @Log(title = "赛事默认状态修改", businessType = BusinessType.UPDATE)
     @PutMapping("/changeEventDefault")
     public R<Void> changeEventDefault(@RequestBody GameEventBo bo) {
-        return toAjax(gameEventService.updateEventDefault(bo));
+        int result = gameEventService.updateEventDefault(bo);
+        return toAjax(result);
     }
 
     /**

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

@@ -27,11 +27,6 @@ public class GameEventConfigType extends TenantEntity {
     @TableId(value = "type_id",type = IdType.AUTO)
     private Long typeId;
 
-    /**
-     * 赛事ID
-     */
-    private Long eventId;
-
     /**
      * 类型编码
      */

+ 0 - 5
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/bo/GameEventConfigTypeBo.java

@@ -25,11 +25,6 @@ public class GameEventConfigTypeBo extends BaseEntity {
      */
     private Long typeId;
 
-    /**
-     * 赛事ID
-     */
-    private Long eventId;
-
     /**
      * 类型编码
      */

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

@@ -4,5 +4,6 @@ public class GameEventConstant {
     /**
      * 默认赛事缓存键
      */
-    public static final String DEFAULT_EVENT_KEY = "default_game_event";
+    public static final String DEFAULT_EVENT = "default:gameEvent:";
+    public static final String DEFAULT_EVENT_ID = "default:eventId:";
 }

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

@@ -33,11 +33,6 @@ public class GameEventConfigTypeVo implements Serializable {
      */
     private Long typeId;
 
-    /**
-     * 赛事ID
-     */
-    private String eventId;
-
     /**
      * 类型编码
      */

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

@@ -12,10 +12,12 @@ 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.*;
 import org.dromara.system.domain.bo.GameEventBo;
 import org.dromara.system.domain.bo.GameEventGroupBo;
 import org.dromara.system.domain.bo.GameTeamBo;
+import org.dromara.system.domain.constant.GameEventConstant;
 import org.dromara.system.domain.vo.*;
 import org.dromara.system.mapper.GameEventProjectMapper;
 import org.dromara.system.mapper.GameScoreMapper;
@@ -149,6 +151,9 @@ public class GameAthleteServiceImpl implements IGameAthleteService {
      */
     @Override
     public TableDataInfo<GameAthleteVo> queryPageList(GameAthleteBo bo, PageQuery pageQuery) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         LambdaQueryWrapper<GameAthlete> lqw = buildQueryWrapper(bo);
         Page<GameAthleteVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
         result.getRecords().stream()
@@ -186,6 +191,9 @@ public class GameAthleteServiceImpl implements IGameAthleteService {
      */
     @Override
     public List<GameAthleteVo> queryList(GameAthleteBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         LambdaQueryWrapper<GameAthlete> lqw = buildQueryWrapper(bo);
         return baseMapper.selectVoList(lqw);
     }
@@ -245,6 +253,9 @@ public class GameAthleteServiceImpl implements IGameAthleteService {
      */
     @Override
     public Boolean insertByBo(GameAthleteBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         GameAthlete add = MapstructUtils.convert(bo, GameAthlete.class);
         validEntityBeforeSave(add);
         boolean flag = baseMapper.insert(add) > 0;
@@ -262,6 +273,9 @@ public class GameAthleteServiceImpl implements IGameAthleteService {
      */
     @Override
     public Boolean updateByBo(GameAthleteBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         GameAthlete update = MapstructUtils.convert(bo, GameAthlete.class);
         validEntityBeforeSave(update);
         return baseMapper.updateById(update) > 0;

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

@@ -3,6 +3,7 @@ package org.dromara.system.service.impl;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.redis.utils.RedisUtils;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -11,6 +12,7 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.dromara.system.domain.bo.GameEventConfigBo;
+import org.dromara.system.domain.constant.GameEventConstant;
 import org.dromara.system.domain.vo.GameEventConfigVo;
 import org.dromara.system.domain.GameEventConfig;
 import org.dromara.system.mapper.GameEventConfigMapper;
@@ -53,6 +55,9 @@ public class GameEventConfigServiceImpl implements IGameEventConfigService {
      */
     @Override
     public TableDataInfo<GameEventConfigVo> queryPageList(GameEventConfigBo bo, PageQuery pageQuery) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         LambdaQueryWrapper<GameEventConfig> lqw = buildQueryWrapper(bo);
         Page<GameEventConfigVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
         return TableDataInfo.build(result);
@@ -66,6 +71,9 @@ public class GameEventConfigServiceImpl implements IGameEventConfigService {
      */
     @Override
     public List<GameEventConfigVo> queryList(GameEventConfigBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         LambdaQueryWrapper<GameEventConfig> lqw = buildQueryWrapper(bo);
         return baseMapper.selectVoList(lqw);
     }
@@ -90,6 +98,9 @@ public class GameEventConfigServiceImpl implements IGameEventConfigService {
      */
     @Override
     public Boolean insertByBo(GameEventConfigBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         GameEventConfig add = MapstructUtils.convert(bo, GameEventConfig.class);
         validEntityBeforeSave(add);
         boolean flag = baseMapper.insert(add) > 0;
@@ -107,6 +118,9 @@ public class GameEventConfigServiceImpl implements IGameEventConfigService {
      */
     @Override
     public Boolean updateByBo(GameEventConfigBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         GameEventConfig update = MapstructUtils.convert(bo, GameEventConfig.class);
         validEntityBeforeSave(update);
         return baseMapper.updateById(update) > 0;

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

@@ -3,6 +3,7 @@ package org.dromara.system.service.impl;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.redis.utils.RedisUtils;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -13,6 +14,7 @@ import org.dromara.system.domain.vo.GameEventProjectVo;
 import org.dromara.system.service.IGameEventProjectService;
 import org.springframework.stereotype.Service;
 import org.dromara.system.domain.bo.GameEventGroupBo;
+import org.dromara.system.domain.constant.GameEventConstant;
 import org.dromara.system.domain.vo.GameEventGroupVo;
 import org.dromara.system.domain.GameEventGroup;
 import org.dromara.system.mapper.GameEventGroupMapper;
@@ -59,6 +61,9 @@ public class GameEventGroupServiceImpl implements IGameEventGroupService {
      */
     @Override
     public TableDataInfo<GameEventGroupVo> queryPageList(GameEventGroupBo bo, PageQuery pageQuery) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         LambdaQueryWrapper<GameEventGroup> lqw = buildQueryWrapper(bo);
         Page<GameEventGroupVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
         result.getRecords().stream()
@@ -90,6 +95,9 @@ public class GameEventGroupServiceImpl implements IGameEventGroupService {
      */
     @Override
     public List<GameEventGroupVo> queryList(GameEventGroupBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         LambdaQueryWrapper<GameEventGroup> lqw = buildQueryWrapper(bo);
         return baseMapper.selectVoList(lqw);
     }
@@ -116,6 +124,9 @@ public class GameEventGroupServiceImpl implements IGameEventGroupService {
      */
     @Override
     public Boolean insertByBo(GameEventGroupBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         GameEventGroup add = MapstructUtils.convert(bo, GameEventGroup.class);
         validEntityBeforeSave(add);
         boolean flag = baseMapper.insert(add) > 0;
@@ -133,6 +144,9 @@ public class GameEventGroupServiceImpl implements IGameEventGroupService {
      */
     @Override
     public Boolean updateByBo(GameEventGroupBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         GameEventGroup update = MapstructUtils.convert(bo, GameEventGroup.class);
         validEntityBeforeSave(update);
         return baseMapper.updateById(update) > 0;

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

@@ -9,6 +9,8 @@ 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.constant.GameEventConstant;
 import org.springframework.stereotype.Service;
 import org.dromara.system.domain.bo.GameEventMenuBo;
 import org.dromara.system.domain.vo.GameEventMenuVo;
@@ -53,6 +55,9 @@ public class GameEventMenuServiceImpl implements IGameEventMenuService {
      */
     @Override
     public TableDataInfo<GameEventMenuVo> queryPageList(GameEventMenuBo bo, PageQuery pageQuery) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         LambdaQueryWrapper<GameEventMenu> lqw = buildQueryWrapper(bo);
         Page<GameEventMenuVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
         return TableDataInfo.build(result);
@@ -66,6 +71,9 @@ public class GameEventMenuServiceImpl implements IGameEventMenuService {
      */
     @Override
     public List<GameEventMenuVo> queryList(GameEventMenuBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         LambdaQueryWrapper<GameEventMenu> lqw = buildQueryWrapper(bo);
         return baseMapper.selectVoList(lqw);
     }
@@ -87,6 +95,9 @@ public class GameEventMenuServiceImpl implements IGameEventMenuService {
      */
     @Override
     public Boolean insertByBo(GameEventMenuBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         GameEventMenu add = MapstructUtils.convert(bo, GameEventMenu.class);
         validEntityBeforeSave(add);
         boolean flag = baseMapper.insert(add) > 0;
@@ -104,6 +115,9 @@ public class GameEventMenuServiceImpl implements IGameEventMenuService {
      */
     @Override
     public Boolean updateByBo(GameEventMenuBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         GameEventMenu update = MapstructUtils.convert(bo, GameEventMenu.class);
         validEntityBeforeSave(update);
         return baseMapper.updateById(update) > 0;

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

@@ -11,9 +11,11 @@ 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.GameAthlete;
 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.mapper.GameEventMapper;
 import org.dromara.system.service.IGameEventService;
@@ -64,6 +66,9 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
      */
     @Override
     public TableDataInfo<GameEventProjectVo> queryPageList(GameEventProjectBo bo, PageQuery pageQuery) {
+        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()
@@ -88,6 +93,9 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
      */
     @Override
     public List<GameEventProjectVo> queryList(GameEventProjectBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         LambdaQueryWrapper<GameEventProject> lqw = buildQueryWrapper(bo);
         return baseMapper.selectVoList(lqw);
     }
@@ -131,6 +139,9 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
      */
     @Override
     public Boolean insertByBo(GameEventProjectBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         GameEventProject add = MapstructUtils.convert(bo, GameEventProject.class);
         validEntityBeforeSave(add);
         boolean flag = baseMapper.insert(add) > 0;
@@ -148,6 +159,9 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
      */
     @Override
     public Boolean updateByBo(GameEventProjectBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         GameEventProject update = MapstructUtils.convert(bo, GameEventProject.class);
         validEntityBeforeSave(update);
         return baseMapper.updateById(update) > 0;

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

@@ -73,6 +73,9 @@ public class GameEventServiceImpl implements IGameEventService {
      */
     @Override
     public List<GameEventVo> queryList(GameEventBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         LambdaQueryWrapper<GameEvent> lqw = buildQueryWrapper(bo);
         return baseMapper.selectVoList(lqw);
     }
@@ -99,6 +102,9 @@ public class GameEventServiceImpl implements IGameEventService {
      */
     @Override
     public Long insertByBo(GameEventBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         GameEvent add = MapstructUtils.convert(bo, GameEvent.class);
         validEntityBeforeSave(add);
         boolean flag = baseMapper.insert(add) > 0;
@@ -116,12 +122,15 @@ public class GameEventServiceImpl implements IGameEventService {
      */
     @Override
     public Boolean updateByBo(GameEventBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         GameEvent update = MapstructUtils.convert(bo, GameEvent.class);
         validEntityBeforeSave(update);
         boolean result = baseMapper.updateById(update) > 0;
         // 如果修改的是默认赛事,更新缓存
         if ("0".equals(bo.getIsDefault())) {
-            RedisUtils.setCacheObject(GameEventConstant.DEFAULT_EVENT_KEY, JsonUtils.toJsonString(update));
+            RedisUtils.setCacheObject(GameEventConstant.DEFAULT_EVENT, JsonUtils.toJsonString(update));
         }
         return result;
     }
@@ -155,7 +164,7 @@ public class GameEventServiceImpl implements IGameEventService {
 
         // 如果删除了默认赛事,清除缓存
         if (defaultEvent != null) {
-            RedisUtils.deleteObject(GameEventConstant.DEFAULT_EVENT_KEY);
+            RedisUtils.deleteObject(GameEventConstant.DEFAULT_EVENT);
         }
         return baseMapper.deleteByIds(ids) > 0;
     }
@@ -185,15 +194,11 @@ public class GameEventServiceImpl implements IGameEventService {
         lqw.eq(GameEvent::getIsDefault, "0");
         GameEvent defaultEvent = baseMapper.selectOne(lqw);
         if (defaultEvent != null) {
-            RedisUtils.setCacheObject(GameEventConstant.DEFAULT_EVENT_KEY, JsonUtils.toJsonString(defaultEvent));
+            RedisUtils.setCacheObject(GameEventConstant.DEFAULT_EVENT, JsonUtils.toJsonString(defaultEvent));
+            RedisUtils.setCacheObject(GameEventConstant.DEFAULT_EVENT_ID, defaultEvent.getEventId());
         }
     }
 
-    @PostConstruct
-    public void initCache(){
-        init();
-    }
-
     /**
      * 获取默认赛事信息
      *
@@ -201,7 +206,7 @@ public class GameEventServiceImpl implements IGameEventService {
      */
     @Override
     public GameEventVo getDefaultEvent() {
-        String defaultEventJson = RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_KEY);
+        String defaultEventJson = RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT);
         if (StringUtils.isNotEmpty(defaultEventJson)) {
             return JsonUtils.parseObject(defaultEventJson, GameEventVo.class);
         }
@@ -213,7 +218,8 @@ public class GameEventServiceImpl implements IGameEventService {
 
         if (defaultEvent != null) {
             // 放入缓存
-            RedisUtils.setCacheObject(GameEventConstant.DEFAULT_EVENT_KEY, JsonUtils.toJsonString(defaultEvent));
+            RedisUtils.setCacheObject(GameEventConstant.DEFAULT_EVENT, JsonUtils.toJsonString(defaultEvent));
+            RedisUtils.setCacheObject(GameEventConstant.DEFAULT_EVENT_ID, defaultEvent.getEventId());
             return baseMapper.selectVoById(defaultEvent.getEventId());
         }
 
@@ -239,7 +245,8 @@ public class GameEventServiceImpl implements IGameEventService {
         if (row > 0) {
             // 更新缓存中的默认赛事信息
             GameEvent updatedEvent = baseMapper.selectById(event.getEventId());
-            RedisUtils.setCacheObject(GameEventConstant.DEFAULT_EVENT_KEY, JsonUtils.toJsonString(updatedEvent));
+            RedisUtils.setCacheObject(GameEventConstant.DEFAULT_EVENT, JsonUtils.toJsonString(updatedEvent));
+            RedisUtils.setCacheObject(GameEventConstant.DEFAULT_EVENT_ID, updatedEvent.getEventId());
         }
         return row;
     }

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

@@ -9,6 +9,8 @@ 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.constant.GameEventConstant;
 import org.springframework.stereotype.Service;
 import org.dromara.system.domain.bo.GameRefereeBo;
 import org.dromara.system.domain.vo.GameRefereeVo;
@@ -53,6 +55,9 @@ public class GameRefereeServiceImpl implements IGameRefereeService {
      */
     @Override
     public TableDataInfo<GameRefereeVo> queryPageList(GameRefereeBo bo, PageQuery pageQuery) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         LambdaQueryWrapper<GameReferee> lqw = buildQueryWrapper(bo);
         Page<GameRefereeVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
         return TableDataInfo.build(result);
@@ -66,6 +71,9 @@ public class GameRefereeServiceImpl implements IGameRefereeService {
      */
     @Override
     public List<GameRefereeVo> queryList(GameRefereeBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         LambdaQueryWrapper<GameReferee> lqw = buildQueryWrapper(bo);
         return baseMapper.selectVoList(lqw);
     }
@@ -88,6 +96,9 @@ public class GameRefereeServiceImpl implements IGameRefereeService {
      */
     @Override
     public Boolean insertByBo(GameRefereeBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         GameReferee add = MapstructUtils.convert(bo, GameReferee.class);
         validEntityBeforeSave(add);
         boolean flag = baseMapper.insert(add) > 0;
@@ -105,6 +116,9 @@ public class GameRefereeServiceImpl implements IGameRefereeService {
      */
     @Override
     public Boolean updateByBo(GameRefereeBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         GameReferee update = MapstructUtils.convert(bo, GameReferee.class);
         validEntityBeforeSave(update);
         return baseMapper.updateById(update) > 0;

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

@@ -9,6 +9,8 @@ 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.constant.GameEventConstant;
 import org.springframework.stereotype.Service;
 import org.dromara.system.domain.bo.GameScoreBo;
 import org.dromara.system.domain.vo.GameScoreVo;
@@ -53,6 +55,9 @@ public class GameScoreServiceImpl implements IGameScoreService {
      */
     @Override
     public TableDataInfo<GameScoreVo> queryPageList(GameScoreBo bo, PageQuery pageQuery) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         LambdaQueryWrapper<GameScore> lqw = buildQueryWrapper(bo);
         Page<GameScoreVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
         return TableDataInfo.build(result);
@@ -66,6 +71,9 @@ public class GameScoreServiceImpl implements IGameScoreService {
      */
     @Override
     public List<GameScoreVo> queryList(GameScoreBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         LambdaQueryWrapper<GameScore> lqw = buildQueryWrapper(bo);
         return baseMapper.selectVoList(lqw);
     }
@@ -91,6 +99,9 @@ public class GameScoreServiceImpl implements IGameScoreService {
      */
     @Override
     public Boolean insertByBo(GameScoreBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         GameScore add = MapstructUtils.convert(bo, GameScore.class);
         validEntityBeforeSave(add);
         boolean flag = baseMapper.insert(add) > 0;
@@ -108,6 +119,9 @@ public class GameScoreServiceImpl implements IGameScoreService {
      */
     @Override
     public Boolean updateByBo(GameScoreBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         GameScore update = MapstructUtils.convert(bo, GameScore.class);
         validEntityBeforeSave(update);
         return baseMapper.updateById(update) > 0;

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

@@ -11,8 +11,10 @@ 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.GameAthlete;
 import org.dromara.system.domain.GameEvent;
+import org.dromara.system.domain.constant.GameEventConstant;
 import org.dromara.system.domain.vo.GameEventProjectVo;
 import org.dromara.system.mapper.GameAthleteMapper;
 import org.dromara.system.mapper.GameEventMapper;
@@ -64,6 +66,9 @@ public class GameTeamServiceImpl implements IGameTeamService {
      */
     @Override
     public TableDataInfo<GameTeamVo> queryPageList(GameTeamBo bo, PageQuery pageQuery) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         LambdaQueryWrapper<GameTeam> lqw = buildQueryWrapper(bo);
         Page<GameTeamVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
         // 查询领队和队员列表
@@ -122,6 +127,9 @@ public class GameTeamServiceImpl implements IGameTeamService {
      */
     @Override
     public List<GameTeamVo> queryList(GameTeamBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         LambdaQueryWrapper<GameTeam> lqw = buildQueryWrapper(bo);
         return baseMapper.selectVoList(lqw);
     }
@@ -170,6 +178,9 @@ public class GameTeamServiceImpl implements IGameTeamService {
      */
     @Override
     public Boolean insertByBo(GameTeamBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         GameTeam add = MapstructUtils.convert(bo, GameTeam.class);
         validEntityBeforeSave(add);
         boolean flag = baseMapper.insert(add) > 0;
@@ -187,6 +198,9 @@ public class GameTeamServiceImpl implements IGameTeamService {
      */
     @Override
     public Boolean updateByBo(GameTeamBo bo) {
+        if (bo.getEventId() == null){
+            bo.setEventId(RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID));
+        }
         GameTeam update = MapstructUtils.convert(bo, GameTeam.class);
         validEntityBeforeSave(update);
         return baseMapper.updateById(update) > 0;

BIN
ruoyi-modules/ruoyi-game-event/src/main/resources/template/报名表模板.xlsx