RestResult合并进HttpResult

This commit is contained in:
Redkale
2019-09-19 21:08:36 +08:00
parent bf000b188f
commit f706209ec1
3 changed files with 18 additions and 53 deletions

View File

@@ -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) {

View File

@@ -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;
}

View File

@@ -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;
}
}