mirror of
https://github.com/wahyd4/Martian.git
synced 2026-08-09 05:16:21 +10:00
update version
This commit is contained in:
@@ -4,7 +4,6 @@ import com.mars.core.constant.MarsConstant;
|
||||
import com.mars.mvc.base.BaseInterceptor;
|
||||
import com.mars.mvc.model.MarsInterModel;
|
||||
import com.mars.mvc.util.BuildParams;
|
||||
import com.mars.mvc.util.ResultUtil;
|
||||
import com.mars.server.server.request.HttpMarsRequest;
|
||||
import com.mars.server.server.request.HttpMarsResponse;
|
||||
import com.mars.server.util.RequestUtil;
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.mars.mvc.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class ResultUtil {
|
||||
|
||||
/**
|
||||
* 成功的返回数据结构
|
||||
* @param obj bean的返回值
|
||||
* @return json
|
||||
*/
|
||||
public static JSONObject getSuccessResult(Object obj){
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("error_code","success");
|
||||
jsonObject.put("result",obj);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败的返回数据结构
|
||||
* @param obj 错误提示
|
||||
* @return json
|
||||
*/
|
||||
public static JSONObject getFailResult(Object obj){
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("error_code","fail");
|
||||
jsonObject.put("error_info",obj);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 异常的返回数据结构
|
||||
* @param e 错误提示
|
||||
* @return json
|
||||
*/
|
||||
public static JSONObject getErrorResult(Throwable e){
|
||||
if(e instanceof InvocationTargetException){
|
||||
InvocationTargetException targetException = (InvocationTargetException)e;
|
||||
return getFailResult(targetException.getTargetException().getMessage());
|
||||
}
|
||||
return getFailResult(e.getMessage());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user