|
|
@ -280,18 +280,21 @@ public class ClientService implements IClientService { |
|
|
|
@Override |
|
|
|
public GameMessageCountOut clientAddTimes(String userId,String recordId) { |
|
|
|
GameMessageCountOut gameMessageCountOut = new GameMessageCountOut(); |
|
|
|
|
|
|
|
log.info("userId:{}", userId); |
|
|
|
if(ObjectUtil.isNotNull(userId)){ |
|
|
|
GameUserJoinExample gameUserJoinExample = new GameUserJoinExample(); |
|
|
|
gameUserJoinExample.createCriteria().andUserIdEqualTo(Long.valueOf(userId)).andRecordIdEqualTo(Long.valueOf(recordId)); |
|
|
|
List<GameUserJoin> userJoinList = gameUserJoinDao.selectByExample(gameUserJoinExample); |
|
|
|
log.info("游戏对象:{}", userJoinList); |
|
|
|
if(CollectionUtil.isNotEmpty(userJoinList)){ |
|
|
|
GameUserJoin userJoin = userJoinList.get(0); |
|
|
|
userJoin.setTimes(userJoin.getTimes() + 1); |
|
|
|
userJoin.setScore(userJoin.getScore() + 100); |
|
|
|
log.info("更新分数:{}", userJoin); |
|
|
|
gameUserJoinDao.updateByPrimaryKeySelective(userJoin); |
|
|
|
//更新redis
|
|
|
|
ClientDto.RedisUser user = ClientDto.RedisUser.getInstance(userJoin); |
|
|
|
log.info("游戏id:{}, 对象:{}, 分数:{}", recordId, user,userJoin.getScore()); |
|
|
|
redisUtil.zsSet(GameConstant.generateGameKey(Long.parseLong(recordId)), JSON.toJSONString(user), userJoin.getScore(), GameConstant.REDIS_TIME); |
|
|
|
gameMessageCountOut = new GameMessageCountOut(userJoin.getTimes(),userJoin.getScore()); |
|
|
|
} |
|
|
|