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

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zanxiang.erp.security.annotation.PreAuthorize;
import com.zanxiang.game.back.serve.pojo.dto.GameOceanengineAppOrderLogDTO;
import com.zanxiang.game.back.serve.pojo.dto.GameOceanengineAppUserLogDTO;
import com.zanxiang.game.back.serve.pojo.vo.GameOceanengineAppOrderLogVO;
import com.zanxiang.game.back.serve.pojo.vo.GameOceanengineAppOrderSplitLogVO;
import com.zanxiang.game.back.serve.pojo.vo.GameOceanengineAppUserLogVO;
import com.zanxiang.game.back.serve.service.*;
import com.zanxiang.module.util.pojo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Collections;
import java.util.List;

@RestController
@RequestMapping("/oceanengineApp")
@Api("头条APP回传策略")
public class OceanengineAppController {
    @Autowired
    private IGameOceanengineAppUserLogService gameOceanengineAppUserLogService;
    @Autowired
    private IGameOceanengineAppOrderLogService gameOceanengineAppOrderLogService;
    @Autowired
    private IGameOceanengineAppOrderSplitLogService gameOceanengineAppOrderSplitLogService;

    @PreAuthorize(permissionKey = "gameBack:oceanengineApp:orderLogs")
    @PostMapping("/orderLogs")
    @ApiOperation(value = "头条订单回传日志列表")
    public ResultVO<IPage<GameOceanengineAppOrderLogVO>> oceanengineAppOrderLogList(@RequestBody GameOceanengineAppOrderLogDTO dto) {
        return ResultVO.ok(gameOceanengineAppOrderLogService.oceanengineAppOrderLogList(dto));
    }

    @PreAuthorize(permissionKey = "gameBack:oceanengineApp:orderLogs")
    @GetMapping("/orderSplitList/{orderId}")
    public ResultVO<List<GameOceanengineAppOrderSplitLogVO>> orderSplitList(@PathVariable("orderId") String orderId) {
        return ResultVO.ok(gameOceanengineAppOrderSplitLogService.listByOrderNo(Collections.singletonList(orderId)));
    }

    @PreAuthorize(permissionKey = "gameBack:oceanengineApp:userLogs")
    @PostMapping("/userLogs")
    @ApiOperation(value = "头条用户回传日志列表")
    public ResultVO<IPage<GameOceanengineAppUserLogVO>> oceanengineAppUserLogList(@RequestBody GameOceanengineAppUserLogDTO dto) {
        return ResultVO.ok(gameOceanengineAppUserLogService.oceanengineAppUserLogList(dto));
    }
}
