com.obatis.config.response.ResponseResultHandleFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of obatis-web Show documentation
Show all versions of obatis-web Show documentation
obatis-web, apply web project
package com.obatis.config.response;
import com.google.common.collect.Lists;
import com.obatis.config.response.result.ResponseBodyWrapHandler;
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor;
import java.util.List;
/**
* 处理框架数据返回,进行结果封装
* @author HuangLongPu
*/
public class ResponseResultHandleFactory {
private ResponseResultHandleFactory() {}
public static void handleResponseResultInfo(RequestMappingHandlerAdapter requestMappingHandlerAdapter) {
List returnValueHandlers = requestMappingHandlerAdapter.getReturnValueHandlers();
List handlerMethodReturnValueHandlers = Lists.newArrayList(returnValueHandlers);
handlers(handlerMethodReturnValueHandlers);
requestMappingHandlerAdapter.setReturnValueHandlers(handlerMethodReturnValueHandlers);
}
private static void handlers(List handlerMethodReturnValueHandlers) {
for (HandlerMethodReturnValueHandler handlerMethodReturnValueHandler : handlerMethodReturnValueHandlers) {
if (handlerMethodReturnValueHandler instanceof RequestResponseBodyMethodProcessor) {
// 封装处理返回结果集
ResponseBodyWrapHandler responseBodyWrapHandler = new ResponseBodyWrapHandler(handlerMethodReturnValueHandler);
int index = handlerMethodReturnValueHandlers.indexOf(handlerMethodReturnValueHandler);
handlerMethodReturnValueHandlers.set(index, responseBodyWrapHandler);
break;
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy