package org.jeecg.ctop.material.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.DateUtils;
import org.jeecg.ctop.material.constants.Check;
import org.jeecg.ctop.material.entity.vo.KuaiShouOperateAccountVo;
import org.jeecg.ctop.material.entity.vo.KuaiShouOperateProjectVo;
import org.jeecg.ctop.material.mapper.MaterialStareMapper;
import org.jeecg.ctop.material.service.KuaishouOperationRecordService;
import org.jeecg.ctop.material.service.MaterialStareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 快手-账户操作记录
 */
@Slf4j
@RestController
@RequestMapping("/kuaiShouOpreate/kuaiShouOperationRecordController")
public class KuaiShouOperationRecordController {


    @Autowired
    MaterialStareService materialStareService;

    @Autowired
    private MaterialStareMapper materialStareMapper;

    @Autowired
    private KuaishouOperationRecordService kuaishouOperationRecordService;




    /**
     *
     * @description: 运营人员账户查询成功
     *
     * @param userId
     * @return: org.jeecg.common.api.vo.Result
     * @author: zianY
     */
    @GetMapping("/getAllSubordinateAccountByUserId")
    public Result<JSONObject> getAllSubordinateAccountByUserId(@RequestParam(name="userId") String userId) {
        return kuaishouOperationRecordService.getAllSubordinateAccountByUserId(userId);
    }



    /**
     *
     * @description: 消耗前10的广告组
     *
     * @param userId
     * @param advertiserId
     * @param startTime
     * @param endTime
     * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
     * @author: zianY
     */
    @GetMapping("/getKuaishouUnitChargeTopTenByAccountId")
    public Result<JSONObject> getKuaishouUnitChargeTopTenByAccountId(@RequestParam(name="userId") String userId,
                                                                    @RequestParam(name="advertiserId") long advertiserId,
                                                                     @RequestParam(name="startTime") String startTime,
                                                                     @RequestParam(name="endTime") String endTime) throws Exception{


        return kuaishouOperationRecordService.getKuaishouUnitChargeTopTenByAccountId(userId,advertiserId,startTime,endTime);
    }



    /**
     *
     * @description: 快手操作记录
     *
     * @param advertiserId
     * @param unitId
     * @param startTime
     * @param endTime
     * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
     */
    @GetMapping("/getKuaishouOperationRecordByUnit")
    public Result<JSONObject> getKuaishouOperationRecordByUnit(@RequestParam(name="advertiserId") long advertiserId,
                                                                    @RequestParam(name="unitId") long unitId,
                                                                     @RequestParam(name="startTime") String startTime,
                                                                     @RequestParam(name="endTime") String endTime) throws Exception{

        return kuaishouOperationRecordService.getKuaishouOperationRecordByUnit(advertiserId,unitId,startTime,endTime);
    }






}
