package com.red.circle.other.app.command.game.roompk;


import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.other.app.dto.clientobject.game.GameRoomPkH5DataCO;
import com.red.circle.other.app.dto.clientobject.game.GameRoomPkRankingCO;
import com.red.circle.other.infra.database.cache.service.other.GameRoomPkCacheService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 房间PK - 榜单数据.
 *
 * @author pengshigang on 2021/9/25
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class GameRoomPkRankingCmdExe {

  private final GameRoomPkCacheService gameRoomPkCacheService;

  public GameRoomPkH5DataCO execute(AppExtCommand cmd) {

    return new GameRoomPkH5DataCO()
        .setThisWeek(
            gameRoomPkCacheService.getRoomPkThisWeek(
                SysOriginPlatformEnum.valueOf(cmd.getReqSysOrigin().getOrigin()),
                GameRoomPkRankingCO.class))
        .setLastWeek(
            gameRoomPkCacheService.getRoomPkLastWeek(
                SysOriginPlatformEnum.valueOf(cmd.getReqSysOrigin().getOrigin()),
                GameRoomPkRankingCO.class));
  }


}
