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

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

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

/**
 * @Author guojx
 * @Date 2024/5/21 14:12
 */
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class WechatWorkLostDetailQO implements Serializable {
    /**
     * yyyy-MM-dd
     */
    private String startDate;

    /**
     * yyyy-MM-dd
     */
    private String endDate;

    /**
     * 用户模糊
     */
    private String vagueQueryUser;

    /**
     * 导购名称/code
     */
    private String vagueQueryClerk;

    /**
     * 是/否
     * 是否已解除双向好友
     */
    private String isDelete;

    /**
     * 导购删除好友/好友删除导购
     * 删除类型
     */
    private String deleteType;


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

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

    private Integer pageNum;

    private Integer pageSize;


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

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

    public Integer getDataApiOrderField() {
        Map<String, Integer> map = new HashMap<>(8);
        map.put("remainDays", 9);
        return map.get(orderByFields) == null ? 1 : map.get(orderByFields);
    }

    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);
        if (StringUtils.isNotBlank(vagueQueryClerk)) {
            jsonObject.put("vagueQueryClerk", vagueQueryClerk);
        }
        if (StringUtils.isNotBlank(vagueQueryUser)) {
            jsonObject.put("vagueQueryUser", vagueQueryUser);
        }
        if (StringUtils.isNotBlank(isDelete)) {
            jsonObject.put("isDelete", isDelete);
        }
        if (StringUtils.isNotBlank(deleteType)) {
            jsonObject.put("deleteType", deleteType);
        }
    }
}
