package com.zanxiang.game.gs.data.serve.service.impl;


import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.zanxiang.game.gs.data.serve.dao.mapper.game.order.GameServerMapper;
import com.zanxiang.game.gs.data.serve.pojo.entity.game.order.GameServer;
import com.zanxiang.game.gs.data.serve.service.IGameServerService;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 游戏区服表 服务层实现。
 *
 * @author shaosong
 * @since 1.0
 */
@Service
public class GameServerServiceImpl extends ServiceImpl<GameServerMapper, GameServer> implements IGameServerService {
    @Override
    public Map<Integer, Map<String, String>> gameServerMap(String sourceSystem, Collection<String> serverIdList) {
        return list(new QueryWrapper()
                .eq(GameServer::getSourceSystem, sourceSystem)
                .in(GameServer::getServerId, serverIdList))
                .stream()
                .collect(Collectors.groupingBy(GameServer::getSupperGameId, Collectors.toMap(GameServer::getServerId, GameServer::getServerName)));
    }
}