package com.zanxiang.game.module.sdk.controller;

import com.zanxiang.game.module.sdk.annotation.UnSignCheck;
import com.zanxiang.game.module.sdk.pojo.param.GameRemitLogParam;
import com.zanxiang.game.module.sdk.pojo.param.UserVisitLogParam;
import com.zanxiang.game.module.sdk.service.IGameRemitLogService;
import com.zanxiang.game.module.sdk.service.IUserVisitLogService;
import com.zanxiang.module.util.pojo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author : lingfeng
 * @time : 2023-07-17
 * @description : 消息推送接收
 */
@Api(tags = "消息推送接收接口")
@RestController
@RequestMapping(value = "/api")
public class PushController {

    @Autowired
    private IGameRemitLogService gameRemitLogService;

    @Autowired
    private IUserVisitLogService userVisitLogService;

    @UnSignCheck
    @ApiOperation(value = "游戏提现记录日志推送")
    @PostMapping("/remit/log/push")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
    public ResultVO<Boolean> addOrUpdate(@Validated @RequestBody GameRemitLogParam param) {
        return ResultVO.ok(gameRemitLogService.addOrUpdate(param));
    }

    @UnSignCheck
    @ApiOperation(value = "用户下载地址访问记录")
    @PostMapping("/visit/log/push")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
    public ResultVO<Boolean> visitLogCreate(@Validated @RequestBody UserVisitLogParam param,
                                            @RequestHeader(name = "User-Agent") String userAgent,
                                            HttpServletRequest httpServletRequest) {
        return ResultVO.ok(userVisitLogService.visitLogCreate(param.getUrl(), userAgent, httpServletRequest));
    }

}
