|
@@ -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;
|
|
|
}
|