package com.spot.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spot.entity.ExTrade;
import com.spot.req.AdminTradeQueryReq;
import com.spot.resp.ApiResultVo;
import com.spot.service.ExTradeService;
import com.spot.utils.RequestUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@RestController
@RequestMapping("/v1")
public class ExTradeController {

    @Autowired
    private ExTradeService exTradeService;

    @PostMapping("/admin/trade/page")
    @ResponseBody
    public ApiResultVo<Page<ExTrade>> adminTradePage(HttpServletRequest request, @RequestBody AdminTradeQueryReq req) {
        String lang = RequestUtils.getLangFromHeader(request);
        return ApiResultVo.success(lang, exTradeService.adminPageQuery(req));
    }
}
