RestResult合并进HttpResult
This commit is contained in:
@@ -506,11 +506,8 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
||||
} else if (result.getResult() instanceof CharSequence) {
|
||||
finish(result.getResult().toString());
|
||||
} else {
|
||||
finish(convert, result.getResult());
|
||||
finish(result.getConvert() == null ? convert : result.getConvert(), result.getResult());
|
||||
}
|
||||
} else if (obj instanceof RestResult) {
|
||||
RestResult result = (RestResult) obj;
|
||||
finish(result.getConvert() == null ? request.getJsonConvert() : result.getConvert(), type, result.getResult());
|
||||
} else {
|
||||
if (hasRender) {
|
||||
if (onlyoneHttpRender != null) {
|
||||
|
||||
@@ -8,6 +8,7 @@ package org.redkale.net.http;
|
||||
import java.io.Serializable;
|
||||
import java.net.HttpCookie;
|
||||
import java.util.*;
|
||||
import org.redkale.convert.*;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
|
||||
/**
|
||||
@@ -34,9 +35,16 @@ public class HttpResult<T> {
|
||||
|
||||
protected String message;
|
||||
|
||||
protected Convert convert;
|
||||
|
||||
public HttpResult() {
|
||||
}
|
||||
|
||||
public HttpResult(Convert convert, T result) {
|
||||
this.convert = convert;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public HttpResult(T result) {
|
||||
this.result = result;
|
||||
}
|
||||
@@ -82,6 +90,15 @@ public class HttpResult<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
@ConvertDisabled
|
||||
public Convert getConvert() {
|
||||
return convert;
|
||||
}
|
||||
|
||||
public void setConvert(Convert convert) {
|
||||
this.convert = convert;
|
||||
}
|
||||
|
||||
public Map<String, String> getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.net.http;
|
||||
|
||||
import org.redkale.convert.Convert;
|
||||
|
||||
/**
|
||||
* 当RestMapping方法需要指定Convert进行序列化时将结果和Convert对象绑定输出
|
||||
*
|
||||
* <p>
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
* @param <T> 结果对象的类型
|
||||
*/
|
||||
public class RestResult<T> {
|
||||
|
||||
protected Convert convert;
|
||||
|
||||
protected T result;
|
||||
|
||||
public RestResult() {
|
||||
}
|
||||
|
||||
public RestResult(Convert convert, T result) {
|
||||
this.convert = convert;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public Convert getConvert() {
|
||||
return convert;
|
||||
}
|
||||
|
||||
public void setConvert(Convert convert) {
|
||||
this.convert = convert;
|
||||
}
|
||||
|
||||
public T getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(T result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user