package com.gic.haoban.manage.service.util;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.enterprise.service.CustomSettingApiService;

@Component
public class QwFriendLimitCountUtil {

    private static CustomSettingApiService customSettingApiService;
    
    @Autowired
    public void setCustomSettingApiService(CustomSettingApiService customSettingApiService) {
        QwFriendLimitCountUtil.customSettingApiService = customSettingApiService;
    }

    // 是否认证
    public static int getLimit(boolean regFlag) {
        String tableName = "tab_gic_map";
        JSONObject searchParamMap = new JSONObject();
        int defaultCount = 200;
        String key = "hm_add_limit_count_1";
        if (regFlag) {
            key = "hm_add_limit_count_2";
            defaultCount = 500;
        }
        searchParamMap.put("key", key);
        ServiceResponse<Map<String, Object>> resp = customSettingApiService.getDetail(tableName,
                searchParamMap.toJSONString());
        if (resp.isSuccess() && null != resp.getResult()) {
            int count = Integer.valueOf(resp.getResult().get("value").toString());
            return count;
        }
        return defaultCount;
    }

}
