|
@@ -1,59 +0,0 @@
|
|
|
-//package com.gxzc.zen.common.config.request
|
|
|
-//
|
|
|
-//import com.fasterxml.jackson.databind.JsonNode
|
|
|
-//import com.fasterxml.jackson.databind.ObjectMapper
|
|
|
-//import com.gxzc.zen.common.config.request.annotation.ZenRequestTypes
|
|
|
-//import org.apache.commons.io.IOUtils
|
|
|
-//import org.springframework.core.MethodParameter
|
|
|
-//import org.springframework.web.bind.support.WebDataBinderFactory
|
|
|
-//import org.springframework.web.context.request.NativeWebRequest
|
|
|
-//import org.springframework.web.method.support.HandlerMethodArgumentResolver
|
|
|
-//import org.springframework.web.method.support.ModelAndViewContainer
|
|
|
-//import java.io.IOException
|
|
|
-//import java.nio.charset.Charset
|
|
|
-//import javax.servlet.http.HttpServletRequest
|
|
|
-//
|
|
|
-//
|
|
|
-///**
|
|
|
-// *
|
|
|
-// * @author NorthLan
|
|
|
-// * @date 2018/3/16
|
|
|
-// * @url https://noahlan.com
|
|
|
-// */
|
|
|
-//
|
|
|
-//class ZenArgumentResolver : HandlerMethodArgumentResolver {
|
|
|
-//
|
|
|
-// private val mapper = ObjectMapper()
|
|
|
-//
|
|
|
-// private val cacheNode = ThreadLocal<JsonNode>()
|
|
|
-// private val latestMethodName = ThreadLocal<String>()
|
|
|
-//
|
|
|
-// override fun supportsParameter(parameter: MethodParameter): Boolean {
|
|
|
-// if (!parameter.hasParameterAnnotation(ZenRequestTypes::class.java)) {
|
|
|
-// return false
|
|
|
-// }
|
|
|
-// val methodName = parameter.method.name
|
|
|
-// if (latestMethodName.get().isNullOrEmpty()) {
|
|
|
-// latestMethodName.set(methodName)
|
|
|
-// } else {
|
|
|
-// if (latestMethodName.get() == methodName) {
|
|
|
-// } else {
|
|
|
-// cacheNode.remove()
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return true
|
|
|
-// }
|
|
|
-//
|
|
|
-// override fun resolveArgument(parameter: MethodParameter, mavContainer: ModelAndViewContainer, webRequest: NativeWebRequest, binderFactory: WebDataBinderFactory): Any {
|
|
|
-// val rootNode = try {
|
|
|
-// cacheNode.get()
|
|
|
-// ?: mapper.readTree(webRequest.getNativeRequest(HttpServletRequest::class.java).inputStream)
|
|
|
-// } catch (e: Exception) {
|
|
|
-// null
|
|
|
-// } ?: return Any()
|
|
|
-// val annotation = parameter.getParameterAnnotation(ZenRequestTypes::class.java)
|
|
|
-// val vaa = rootNode["data"].toString()
|
|
|
-// val ret = mapper.readValue(vaa, annotation.value[0].value.java)
|
|
|
-// return ret
|
|
|
-// }
|
|
|
-//}
|