All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dc.invoke.pojo.ApiLogSetupMethod Maven / Gradle / Ivy

There is a newer version: 0.5.4
Show newest version
package com.github.dc.invoke.pojo;

import com.github.dc.invoke.aop.handler.IApiLogDataHandler;
import com.github.dc.invoke.util.ApiLogSetupHelper;
import org.apache.commons.lang3.ObjectUtils;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

/**
 * 

* 接口日志设置方法 *

* * @author wangpeiyuan * @date 2022/6/8 10:16 */ public abstract class ApiLogSetupMethod { protected static final ThreadLocal> LOCAL_SETUP = new ThreadLocal<>(); public static final String FIELD_CONTEXT = "context"; public static final String FIELD_BUSINESS_KEY = "businessKey"; public static final String FIELD_HANDLER = "handler"; public static final String FIELD_ENCODING = "encoding"; public static final String FIELD_REQUEST_ENCODING = "requestEncoding"; public static final String FIELD_BODY_MAX_LENGTH = "bodyMaxLength"; public static final String FIELD_FILE_UPLOAD = "fileUpload"; public static final String FIELD_FILE_DOWNLOAD = "fileDownload"; public static void set(String apiCode, String apiDesc, Class handler) { set(null, apiCode, apiDesc, null, StandardCharsets.UTF_8, null, handler, null); } public static void set(Object businessKey, String apiCode, String apiDesc, Class handler) { set(businessKey, apiCode, apiDesc, null, StandardCharsets.UTF_8, null, handler, null); } public static void set(Object businessKey, String apiCode, String apiDesc, Class handler, Map context) { set(businessKey, apiCode, apiDesc, null, StandardCharsets.UTF_8, null, handler, context); } public static void set(Object businessKey, String apiCode, String apiDesc, Integer bodyMaxLength, Class handler, Map context) { set(businessKey, apiCode, apiDesc, bodyMaxLength, StandardCharsets.UTF_8, null, handler, context); } public static void set(Object businessKey, String apiCode, String apiDesc, Charset responseBodyEncoding, Class handler, Map context) { set(businessKey, apiCode, apiDesc, null, StandardCharsets.UTF_8, responseBodyEncoding, handler, context); } public static void set(Object businessKey, String apiCode, String apiDesc, Integer bodyMaxLength, Charset responseBodyEncoding, Class handler, Map context) { set(businessKey, apiCode, apiDesc, bodyMaxLength, StandardCharsets.UTF_8, responseBodyEncoding, handler, context); } public static void set(Object businessKey, String apiCode, String apiDesc, Integer bodyMaxLength, Charset requestBodyEncoding, Charset responseBodyEncoding, Class handler, Map context) { Map apiInfo = new HashMap<>(3); apiInfo.put(FIELD_BUSINESS_KEY, businessKey); apiInfo.put(ApiLogData.FIELD_API_CODE, apiCode); apiInfo.put(ApiLogData.FIELD_API_DESC, apiDesc); apiInfo.put(FIELD_BODY_MAX_LENGTH, bodyMaxLength); apiInfo.put(FIELD_REQUEST_ENCODING, requestBodyEncoding); apiInfo.put(FIELD_ENCODING, responseBodyEncoding); apiInfo.put(FIELD_HANDLER, handler); apiInfo.put(FIELD_CONTEXT, context); LOCAL_SETUP.set(apiInfo); } public static void set(Map data) { LOCAL_SETUP.set(data); } public static void append(Map data) { LOCAL_SETUP.get().putAll(data); } public static Map get() { return LOCAL_SETUP.get(); } public static void clear() { LOCAL_SETUP.remove(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy