package cn.com.ctop.bytedance.controller;

import cn.com.ctop.bytedance.service.IBytedanceReportService;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/ctop/report")
public class BytedanceReportController {
    @Autowired
    private IBytedanceReportService bytedanceReportService;

    /**
     * 昨日总花费
     *
     * @return
     */
    @RequestMapping(value = "/accountReport")
    public Result<JSONObject> getAccountReport() {
        Result<JSONObject> result = new Result<>();

        try {
            JSONObject json = bytedanceReportService.getAccountReport("e9ca23d68d884d4ebb19d07889727dae");
            result.setResult(json);
            result.setSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            result.setSuccess(false);
        }

        return result;
    }


    @PostMapping("/kuaiShou/accountReport")
    public Result<JSONObject> getKuaiShouAccountReport(@RequestBody JSONObject requestJson) {
        Result<JSONObject> result = new Result<>();
        try {
            JSONObject json = bytedanceReportService.getKuaiShouAccountReport(requestJson);
            result.setResult(json);
            result.setSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            result.setSuccess(false);
        }

        return result;

    }


    @PostMapping("/kuaiShou/accountDetailReport")
    public Result<List<JSONObject>> getKuaiShouAccountDetailReport(@RequestBody JSONObject requestJson) {

        Result<List<JSONObject>> result = new Result<>();
        try {
            List<JSONObject> kuaiShouAccounDetailtReport = bytedanceReportService.getKuaiShouAccounDetailtReport(requestJson);
            result.setResult(kuaiShouAccounDetailtReport);
            result.setSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            result.setSuccess(false);
        }

        return result;

    }


    @PostMapping("/kuaiShou/getReportList")
    public Result<List<JSONObject>> getReportList(@RequestBody JSONObject requestJson) {

        Result<List<JSONObject>> result = new Result<>();
        try {
            List<JSONObject> kuaiShouAccounDetailtReport = bytedanceReportService.getReportList(requestJson);
            result.setResult(kuaiShouAccounDetailtReport);
            result.setSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            result.setSuccess(false);

        }
        return result;

    }


}
