package com.zanxiang.game.back.serve.controller.api;

import com.zanxiang.game.back.serve.pojo.dto.GameTencentAppCallbackDTO;
import com.zanxiang.game.back.serve.service.IGameTencentAppCallbackService;
import com.zanxiang.game.back.serve.service.IGameTencentMiniGameCallbackService;
import com.zanxiang.module.util.pojo.ResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 腾讯监测链接
 */
@Slf4j
@RestController
@RequestMapping("/api/tencentCallback")
public class TencentCallbackApi {

    @Autowired
    private IGameTencentAppCallbackService gameTencentAppCallbackService;

    @Autowired
    private IGameTencentMiniGameCallbackService gameTencentMiniGameCallbackService;

    // https://api.zanxiangwl.com/gameBack/api/tencentCallback/callback
    // ?clickId=__CLICK_ID__&clickTime=__CLICK_TIME__&adgroupId=__ADGROUP_ID__&dynamicCreativeId=__DYNAMIC_CREATIVE_ID__
    // &marketingAssetId=__MARKETING_ASSET_ID__&materialPackageId=__MATERIAL_PACKAGE_ID__&adPlatformType=__AD_PLATFORM_TYPE__
    // &accountId=__ACCOUNT_ID__&agencyId=__AGENCY_ID__&clickSkuId=__CLICK_SKU_ID__&deviceOsType=__DEVICE_OS_TYPE__
    // &processTime=__PROCESS_TIME__&requestId=__REQUEST_ID__&impressionId=__IMPRESSION_ID__&muid=__MUID__
    // &hashAndroidId=__HASH_ANDROID_ID__&ip=__IP__&userAgent=__USER_AGENT__&callback=__CALLBACK__
    // &encryptedPositionId=__ENCRYPTED_POSITION_ID__&ipv6=__IPV6__&hashOaid=__HASH_OAID__&&caid=__QAID_CAA__&ipMd5=__IP_MD5__&ipv6Md5=__IPV6_MD5__
    @GetMapping("/app/callback")
    public ResultVO<Boolean> appCallback(GameTencentAppCallbackDTO dto) {
        return ResultVO.ok(gameTencentAppCallbackService.callback(dto));
    }

    // https://api.zanxiangwl.com/gameBack/api/tencentCallback/miniGame/callback
    // ?clickId=__CLICK_ID__&clickTime=__CLICK_TIME__&adgroupId=__ADGROUP_ID__&dynamicCreativeId=__DYNAMIC_CREATIVE_ID__
    // &marketingAssetId=__MARKETING_ASSET_ID__&materialPackageId=__MATERIAL_PACKAGE_ID__&adPlatformType=__AD_PLATFORM_TYPE__
    // &accountId=__ACCOUNT_ID__&agencyId=__AGENCY_ID__&clickSkuId=__CLICK_SKU_ID__&deviceOsType=__DEVICE_OS_TYPE__
    // &processTime=__PROCESS_TIME__&requestId=__REQUEST_ID__&impressionId=__IMPRESSION_ID__&ip=__IP__&userAgent=__USER_AGENT__
    // &callback=__CALLBACK__&encryptedPositionId=__ENCRYPTED_POSITION_ID__&ipv6=__IPV6__&ipMd5=__IP_MD5__&ipv6Md5=__IPV6_MD5__
    @GetMapping("/miniGame/callback")
    public ResultVO<Boolean> miniGameCallback(@RequestParam Map<String, Object> paramMap) {
        return ResultVO.ok(gameTencentMiniGameCallbackService.callback(paramMap));
    }
}
