package com.zanxiang.game.module.sdk.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zanxiang.game.module.mybatis.entity.Game;
import com.zanxiang.game.module.mybatis.mapper.GameMapper;
import com.zanxiang.game.module.sdk.pojo.param.UserData;
import com.zanxiang.game.module.sdk.service.IGameService;
import com.zanxiang.module.util.JsonUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.Map;

/**
 * @author : lingfeng
 * @time : 2022-07-13
 * @description : game管理
 */
@Slf4j
@Service
public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements IGameService {

    @Override
    public Map<String, Object> getAdSdkConfig(UserData userData) {
        Game game = super.getById(userData.getGameId());
        if (Strings.isBlank(game.getAdSdkConfig())) {
            return Collections.singletonMap("adSdk", 0);
        }
        return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
    }
}
