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

import com.zanxiang.game.back.serve.pojo.dto.GameOceanengineAppCallbackDTO;
import com.zanxiang.game.back.serve.pojo.dto.GameOceanengineCallbackDTO;
import com.zanxiang.game.back.serve.service.IGameOceanengineAppCallbackService;
import com.zanxiang.game.back.serve.service.IGameOceanengineAppCallbackXgltService;
import com.zanxiang.game.back.serve.service.IGameOceanengineCallbackService;
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/oceanengineCallback")
public class OceanengineCallbackApi {

    @Autowired
    private IGameOceanengineCallbackService gameOceanengineCallbackService;

    @Autowired
    private IGameOceanengineAppCallbackService gameOceanengineAppCallbackService;

    @Autowired
    private IGameOceanengineAppCallbackXgltService gameOceanengineAppCallbackXgltService;

    // https://api.zanxiangwl.com/gameBack/api/oceanengineCallback/app/xglt/callBack?ts=__TS__&os=__OS__&ua=__UA__
    // &demandId=__DEMAND_ID__&ip=__IP__&ipv6=__IPV6__&model=__MODEL__&itemId=__ITEM_ID__&mid3=__MID3__
    // &callbackParam=__CALLBACK_PARAM__&imeiMd5=__IMEI_MD5__&idfaMd5=__IDFA_MD5__&oaidMd5=__OAID_MD5__
    // &androidIdMd5=__ANDROIDID_MD5__&caidMd5=__CAID_MD5__
    @GetMapping("/app/xglt/callBack")
    public ResultVO<Boolean> appXgltCallback(@RequestParam Map<String, Object> paramMap) {
        return ResultVO.ok(gameOceanengineAppCallbackXgltService.callback(paramMap));
    }

    // https://api.zanxiangwl.com/gameBack/api/oceanengineCallback/app/callBack?promotionId=__PROMOTION_ID__
    // &projectId=__PROJECT_ID__&mid1=__MID1__&mid2=__MID2__&mid3=__MID3__&mid4=__MID4__&mid5=__MID5__&mid6=__MID6__
    // &aid=__AID__&cid=__CID__&campaignId=__CAMPAIGN_ID__&ctype=__CTYPE__&advertiserId=__ADVERTISER_ID__
    // &csite=__CSITE__&convertId=__CONVERT_ID__&requestId=__REQUEST_ID__&trackId=__TRACK_ID__&sl=__SL__
    // &idfa=__IDFA__&idfaMd5=__IDFA_MD5__&androidid=__ANDROIDID__&oaid=__OAID__&oaidMd5=__OAID_MD5__&os=__OS__
    // &mac=__MAC__&mac1=MAC1&ipv4=__IPV4__&ip=__IP__&ua=__UA__&geo=__GEO__&ts=__TS__&callbackParam=__CALLBACK_PARAM__
    // &callbackUrl=__CALLBACK_URL__&model=__MODEL__&unionSite=__UNION_SITE__&caid=__CAID__&productid=__PRODUCTID__&outerid=__OUTERID__
    @GetMapping("/app/callBack")
    public ResultVO<Boolean> appCallback(GameOceanengineAppCallbackDTO dto) {
        return ResultVO.ok(gameOceanengineAppCallbackService.callback(dto));
    }

    @GetMapping("/miniGame/callback")
    public ResultVO<Boolean> callback(GameOceanengineCallbackDTO dto) {
        return ResultVO.ok(gameOceanengineCallbackService.callback(dto));
    }
}
