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.GameTencentAppOrderDTO;
import com.zanxiang.game.back.serve.pojo.dto.GameTencentAppUserDTO;
import com.zanxiang.game.back.serve.pojo.vo.GameTencentAppOrderSplitLogVO;
import com.zanxiang.game.back.serve.pojo.vo.GameTencentAppOrderVO;
import com.zanxiang.game.back.serve.pojo.vo.GameTencentUserVO;
import com.zanxiang.game.back.serve.service.IGameTencentAppOrderService;
import com.zanxiang.game.back.serve.service.IGameTencentAppOrderSplitLogService;
import com.zanxiang.game.back.serve.service.IGameTencentAppUserService;
import com.zanxiang.module.util.pojo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * @author : lingfeng
 * @time : 2025-05-08
 * @description : 腾讯APP回传
 */
@RestController
@RequestMapping("/tencentApp")
public class TencentAppController {

    @Autowired
    private IGameTencentAppOrderService gameTencentAppOrderService;

    @Autowired
    private IGameTencentAppOrderSplitLogService gameTencentAppOrderSplitLogService;

    @Autowired
    private IGameTencentAppUserService gameTencentAppUserService;

    @PreAuthorize(permissionKey = "gameBack:tencentApp:orderLogs")
    @PostMapping("/orderLogs")
    public ResultVO<IPage<GameTencentAppOrderVO>> tencentAppOrderList(@RequestBody GameTencentAppOrderDTO dto) {
        return ResultVO.ok(gameTencentAppOrderService.gameTencentAppOrderLogList(dto));
    }

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

    @PreAuthorize(permissionKey = "gameBack:tencentApp:userLogs")
    @PostMapping("/userLogs")
    public ResultVO<IPage<GameTencentUserVO>> tencentAppUserList(@RequestBody GameTencentAppUserDTO dto) {
        return ResultVO.ok(gameTencentAppUserService.tencentUserLogList(dto));
    }
}