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.IGameOceanengineAppOrderLogService;
import com.zanxiang.game.back.serve.service.IGameOceanengineAppOrderSplitLogService;
import com.zanxiang.game.back.serve.service.IGameOceanengineAppUserLogService;
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;

@RestController
@RequestMapping("/oceanengineApp")
public class OceanengineAppController {
    @Autowired
    private IGameOceanengineAppUserLogService gameOceanengineAppUserLogService;
    @Autowired
    private IGameOceanengineAppOrderLogService gameOceanengineAppOrderLogService;
    @Autowired
    private IGameOceanengineAppOrderSplitLogService gameOceanengineAppOrderSplitLogService;

    @PreAuthorize(permissionKey = "gameBack:oceanengineApp:orderLogs")
    @PostMapping("/orderLogs")
    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")
    public ResultVO<IPage<GameOceanengineAppUserLogVO>> oceanengineAppUserLogList(@RequestBody GameOceanengineAppUserLogDTO dto) {
        return ResultVO.ok(gameOceanengineAppUserLogService.oceanengineAppUserLogList(dto));
    }
}
