package com.gic.haoban.manage.web.qo.chat;

import com.alibaba.fastjson.JSONObject;
import com.gic.haoban.manage.web.qo.wechatwork.StoreGroupCommonQO;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @author shangfeng
 * @date 2024-06-20 13:57:57
 */
public class GroupChatStoreGroupReq extends StoreGroupCommonQO implements Serializable {
    private static final long serialVersionUID = -174199242296091966L;

    /**
     * 开始日期, 非日类型的时候。根据数据组api文档
     */
    private String startDate;

    /**
     * 结束日期, 非日类型的时候。根据数据组api文档
     */
    private String endDate;

    /**
     * 排序类型 1 正序  2 倒序
     */
    private Integer orderByType;

    /**
     * 排序字段名称
     */
    private String orderByFields;

    /**
     * 当前页*
     */
    private Integer pageNum;

    /**
     * 每页条数*
     */
    private Integer pageSize;


    /**
     * 下载导出参数：数据脱敏 1:脱敏 2:完整
     */
    private Integer dataType = 1;

    /**
     * 下载导出参数：为了兼容前端传参
     */
    private String requestProject;

    /**
     * 排序*
     * 1新增群数2活跃群数3群总人数4新增群人数5活跃群人数6新退群人数7群会话总条数8群总数
     * @return
     */
    public Integer getDataApiOrderField() {
        Map<String, Integer> map = new HashMap<>(8);
        map.put("newGroupNum", 1);
        map.put("actGroupNum", 2);
        map.put("groupCustNum", 3);
        map.put("newGroupCustNum", 4);
        map.put("actGroupCustNum", 5);
        map.put("newExitGroupCustNum", 6);
        map.put("groupSessionsNum", 7);
        map.put("groupNum", 8);
        return map.get(orderByFields) == null ? 1 : map.get(orderByFields);
    }

    /**
     * 处理请求参数
     * * *
     * @param jsonObject
     */
    public void dealWithParam(JSONObject jsonObject) {
        if (jsonObject == null) {
            jsonObject = new JSONObject();
        }
        if (StringUtils.isNotBlank(startDate)) {
            jsonObject.put("startDate", startDate);
        }
        if (StringUtils.isNotBlank(endDate)) {
            jsonObject.put("endDate", endDate);
        }
        if (orderByType != null) {
            jsonObject.put("orderByType", orderByType);
        }
        if (orderByFields != null) {
            jsonObject.put("orderByFields", getDataApiOrderField());
        }
        jsonObject.put("pageNum", pageNum);
        jsonObject.put("pageSize", pageSize);
    }

    public String getStartDate() {
        return startDate;
    }

    public void setStartDate(String startDate) {
        this.startDate = startDate;
    }

    public String getEndDate() {
        return endDate;
    }

    public void setEndDate(String endDate) {
        this.endDate = endDate;
    }

    public Integer getOrderByType() {
        return orderByType;
    }

    public void setOrderByType(Integer orderByType) {
        this.orderByType = orderByType;
    }

    public String getOrderByFields() {
        return orderByFields;
    }

    public void setOrderByFields(String orderByFields) {
        this.orderByFields = orderByFields;
    }

    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getDataType() {
        return dataType;
    }

    public void setDataType(Integer dataType) {
        this.dataType = dataType;
    }

    public String getRequestProject() {
        return requestProject;
    }

    public void setRequestProject(String requestProject) {
        this.requestProject = requestProject;
    }
}
