package org.jeecg.ctop.material.controller;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.ctop.material.constants.Check;
import org.jeecg.ctop.material.mapper.MaterialStareMapper;
import org.jeecg.ctop.material.service.MaterialStareService;
import org.jeecg.ctop.material.service.impl.MaterialStareServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 快手-运营数据盯盘-经理&个人-end-master
 */
@Slf4j
@RestController
@RequestMapping("/kuaiShouOpreate/kuaiShouMaterialStareController")
public class KuaiShouMaterialStareController {


    @Autowired
    MaterialStareService materialStareService;


    /**
     *
     * @description:数据总览-快手
     *
     * @param mediaType 媒体类型 1-头条 2-快手
     * @param type 查询类型 1-汇总 2-运营个人
     * @param startTime
     * @param endTime
     * @param userId
     * @author: zianY
     * @time: 2022/2/15
     */
    @GetMapping("/kuaiShousumData")
    public Result<JSONObject> kuaiShousumData(@RequestParam(name="mediaType",defaultValue = "2") String mediaType,
                                              @RequestParam(name="type") String type,
                                              @RequestParam(name="startTime") String startTime,
                                              @RequestParam(name="endTime") String endTime,
                                              @RequestParam(name="userId") String userId) {
        return materialStareService.kuaiShousumData(mediaType, type, startTime, endTime, userId);
    }


    /**
     *
     * @description: 快手-运营组数据
     *
     * @param mediaType 媒体类型 1-头条 2-快手
     * @param startTime
     * @param endTime
     * @param userId
     * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
     * @author: zianY
     * @time: 2022/2/15
     */
    @GetMapping("/kuaiShouOperateDateTotal")
    public Result<JSONObject> kuaiShouOperateDateTotal(@RequestParam(name="mediaType") String mediaType,
                                              @RequestParam(name="startTime") String startTime,
                                              @RequestParam(name="endTime") String endTime,
                                              @RequestParam(name="userId") String userId) {

        return materialStareService.kuaiShouOperateDateTotal(mediaType, startTime, endTime, userId);
    }


    /**
     *
     * @description: 运营数据详情
     *
     * @param pageNum
     * @param pageSize
     * @param startTime
     * @param endTime
     * @param userId
     * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
     * @author: zianY
     * @time: 2022/2/16
     */
    @GetMapping("/getKuaiShouOperateInfo")
    public Result<JSONObject> getKuaiShouOperateInfo(@RequestParam(name="pageNum",defaultValue = "1") Integer pageNum,
                                                       @RequestParam(name="pageSize",defaultValue = "5") int pageSize,
                                              @RequestParam(name="startTime") String startTime,
                                              @RequestParam(name="endTime") String endTime,
                                              @RequestParam(name="userId") String userId) {
        return materialStareService.getKuaiShouOperateInfo(pageNum, pageSize,startTime, endTime, userId);
    }

    @GetMapping("/exportKuaiShouOperateInfo")
    public Result<JSONObject> exportKuaiShouOperateInfo(@RequestParam(name="startTime") String startTime,
                                              @RequestParam(name="endTime") String endTime,
                                              @RequestParam(name="userId") String userId,
                                                        HttpServletResponse response) {
        return materialStareService.exportKuaiShouOperateInfo(startTime, endTime, userId,response);
    }


    /**
     *
     * @description:运营数据-项目列表
     *
     * @param pageNum
     * @param pageSize
     * @param startTime
     * @param endTime
     * @param userId
     * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
     * @author: zianY
     * @time: 2022/2/17
     */
    @GetMapping("/getKuaiShouOperateProjectInfo")
    public Result<JSONObject> getKuaiShouOperateProjectInfo(@RequestParam(name="pageNum",defaultValue = "1") Integer pageNum,
                                                     @RequestParam(name="pageSize",defaultValue = "10") int pageSize,
                                                     @RequestParam(name="startTime") String startTime,
                                                     @RequestParam(name="endTime") String endTime,
                                                     @RequestParam(name="userId") String userId) {

        return materialStareService.getKuaiShouOperateProjectInfo(pageNum, pageSize,startTime, endTime, userId);
    }



    /**
     *
     * @description:运营数据-账户列表
     *
     * @param pageNum
     * @param pageSize
     * @param startTime
     * @param endTime
     * @param projectId
     * @param userId
     * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
     * @author: zianY
     * @time: 2022/2/18
     */
    @GetMapping("/getKuaiShouOperateAccountInfo")
    public Result<JSONObject> getKuaiShouOperateAccountInfo(@RequestParam(name="pageNum",defaultValue = "1") Integer pageNum,
                                                     @RequestParam(name="pageSize",defaultValue = "1000") int pageSize,
                                                     @RequestParam(name="startTime") String startTime,
                                                     @RequestParam(name="endTime") String endTime,
                                                     @RequestParam(name="projectId",required = false) String projectId,
                                                     @RequestParam(name="userId") String userId) {


        return materialStareService.getKuaiShouOperateAccountInfo(pageNum, pageSize,startTime, endTime,projectId, userId);
    }


    /**
     *
     * @description: 查询账户余额 以及 账户状态 和 消耗
     *
     * @param accountId
     * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
     * @author: zianY
     * @time: 2022/2/21 14:39
     */
    @GetMapping("/getKuaiShouAccountInfo")
    public Result<JSONObject> getKuaiShouAccountInfo(@RequestParam(name="accountId") long accountId) {
        return materialStareService.getKuaiShouAccountInfo(accountId);
    }


    /**
     *
     * @description: 账户 折线图 查询时间为当天查询时报；查询时间为多天 查询日报
     *
     * @param accountId
     * @param startTime
     * @param endTime
     * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
     * @author: zianY
     * @time: 2022/2/21
     */
    @GetMapping("/getKuaiShouAccountInfoBrokenLine")
    public Result<JSONObject> getKuaiShouAccountInfoBrokenLine(@RequestParam(name="accountId") long accountId,
                                                     @RequestParam(name="startTime") String startTime,
                                                     @RequestParam(name="endTime") String endTime,
                                                     @RequestParam(name="type") String type) {
        return materialStareService.getKuaiShouAccountInfoBrokenLine(accountId,startTime,endTime,type);
    }



    /**
     *
     * @description: 快手 账户 素材上新-有效-爆款
     *
     * @param accountId
     * @param searchType searchType：查询类型  0-全部 1-上新 2-有效 3-爆款
     * @param startTime
     * @param endTime
     * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
     * @author: zianY
     * @time: 2022/2/21
     */
    @GetMapping("/getKuaiShouAccountMaterialNewAndEffectAndFaddish")
    public Result<JSONObject> getKuaiShouAccountMaterialNewAndEffectAndFaddish(@RequestParam(name="accountId") long accountId,
                                                                               @RequestParam(name="searchType") String searchType,
                                                                               @RequestParam(name="startTime") String startTime,
                                                                               @RequestParam(name="endTime") String endTime,
                                                                               @RequestParam(name="pageNum",defaultValue = "1") Integer pageNum,
                                                                               @RequestParam(name="pageSize",defaultValue = "10") Integer pageSize) {
        return materialStareService.getKuaiShouAccountMaterialNewAndEffectAndFaddish(accountId,searchType,startTime,endTime,pageNum,pageSize);
    }



    /**
     *
     * @description: 查询账户饼图数据信息 分版位；年龄；性别
     *
     * @param accountId
     * @param startTime
     * @param endTime
     * @param type 查询类型 额。。。 查询选中的指标 --、 给前端组装数据格式  I didn't want to write
     * @return: org.jeecg.common.api.vo.Result
     * @author: zianY
     * @time: 2022/2/22
     */
    @GetMapping("/getKuaiShouAccountPieChar")
    public Result getKuaiShouAccountPieChar(@RequestParam(name="accountId") long accountId,
                                            @RequestParam(name="startTime") String startTime,
                                            @RequestParam(name="endTime") String endTime,
                                            @RequestParam(name="type") String type) {
        return materialStareService.getKuaiShouAccountPieChar(accountId,startTime,endTime,type);
    }





    /**
     *
     * @description:数据总览-快手-运营个人
     *
     * @param mediaType 媒体类型 1-头条 2-快手
     * @param startTime
     * @param endTime
     * @param userId
     * @author: zianY
     * @time: 2022/2/15
     */
    @GetMapping("/kuaiShousumDataPersonal")
    public Result<JSONObject> kuaiShousumDataPersonal(@RequestParam(name="mediaType",defaultValue = "2") String mediaType,
                                              @RequestParam(name="startTime") String startTime,
                                              @RequestParam(name="endTime") String endTime,
                                              @RequestParam(name="userId") String userId) {
        return materialStareService.kuaiShousumDataPersonal(mediaType, startTime, endTime, userId);
    }


    /**
     *
     * @description: 运营个人数据
     *
     * @param mediaType 媒体类型 1-头条 2-快手
     * @param startTime
     * @param endTime
     * @param userId
     * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
     * @author: zianY
     * @time: 2022/3/3
     */
    @GetMapping("/kuaiShouOperateDateTotalPersonal")
    public Result<JSONObject> kuaiShouOperateDateTotalPersonal(@RequestParam(name="mediaType") String mediaType,
                                                       @RequestParam(name="startTime") String startTime,
                                                       @RequestParam(name="endTime") String endTime,
                                                       @RequestParam(name="userId") String userId) {

        return materialStareService.kuaiShouOperateDateTotalPersonal(mediaType, startTime, endTime, userId);
    }


    @GetMapping("/realTime/getUnitDateInfo")
    public Result<JSONObject> kuaiShouOperateDateTotalPersonal(@RequestParam(name="accountId") long accountId,
                                                               @RequestParam(name="pageNum") Integer pageNum,
                                                               @RequestParam(name="pageSize") Integer pageSize) {

        return materialStareService.kuaiShouRealTimeUnitDateInfo(accountId, pageNum, pageSize);
    }




    /**
     * 获取用户下级的项目以及账户信息
     *
     * @param requestJson
     * @return
     */
    @GetMapping(value = "/participateListByMediaIdAllSubordinate")
    public Result<List<JSONObject>> participateListByMediaIdAllSubordinate(@RequestParam(name="userId") String userId,
                                                                           @RequestParam(name="type") String type) {
        JSONObject requestJson = new JSONObject();
        requestJson.put("userId",userId);
        requestJson.put("type",type);
        return materialStareService.participateListByMediaIdAllSubordinate(requestJson);
    }









    //获取当前用户所属公司的所有下级
    @GetMapping("/getCompanyAllSubordinateByUserId")
    public Result getCompanyAllSubordinateByUserId(@RequestParam(name="userId") String userId) {
       return materialStareService.getCompanyAllSubordinateByUserId(userId);
    }














}
