Commit 370a656e by s_guodong

规范返回值

parent 44771830
...@@ -178,9 +178,11 @@ public abstract class AbstractCommonResource<V extends BaseVO> { ...@@ -178,9 +178,11 @@ public abstract class AbstractCommonResource<V extends BaseVO> {
String[] ruleArr = new String[]{rule}; String[] ruleArr = new String[]{rule};
ResponseSet responseSet = getCommonService().executeRule(baseVO, ruleArr); ResponseSet responseSet = getCommonService().executeRule(baseVO, ruleArr);
Object data = responseSet.getData(); Object data = responseSet.getData();
ReflectUtil.setValue2RespondVo(t, respondVoClass, data, baseVO.getClass()); if (data != null) {
setTotal(t, baseVO); ReflectUtil.setValue2RespondVo(t, respondVoClass, data, baseVO.getClass());
responseSet.setData(t); setTotal(t, baseVO);
responseSet.setData(t);
}
return responseSet; return responseSet;
} }
...@@ -203,9 +205,11 @@ public abstract class AbstractCommonResource<V extends BaseVO> { ...@@ -203,9 +205,11 @@ public abstract class AbstractCommonResource<V extends BaseVO> {
String[] ruleArr = new String[]{rule}; String[] ruleArr = new String[]{rule};
ResponseSet responseSet = getCommonService().executeCheck(baseVO, ruleArr); ResponseSet responseSet = getCommonService().executeCheck(baseVO, ruleArr);
Object data = responseSet.getData(); Object data = responseSet.getData();
ReflectUtil.setValue2RespondVo(t, respondVoClass, data, baseVO.getClass()); if (data != null) {
setTotal(t, baseVO); ReflectUtil.setValue2RespondVo(t, respondVoClass, data, baseVO.getClass());
responseSet.setData(t); setTotal(t, baseVO);
responseSet.setData(t);
}
return responseSet; return responseSet;
} }
...@@ -290,7 +294,8 @@ public abstract class AbstractCommonResource<V extends BaseVO> { ...@@ -290,7 +294,8 @@ public abstract class AbstractCommonResource<V extends BaseVO> {
*/ */
private void setTotal(Object t, BaseVO baseVO) { private void setTotal(Object t, BaseVO baseVO) {
Long total = baseVO.getTotal(); Long total = baseVO.getTotal();
if (total != null) {
if (total != null && baseVO.getPageNum() != 0) {
Class<?> superclass = t.getClass().getSuperclass(); Class<?> superclass = t.getClass().getSuperclass();
Field totalField = null; Field totalField = null;
try { try {
......
...@@ -53,8 +53,13 @@ public class ResponseSet<T> { ...@@ -53,8 +53,13 @@ public class ResponseSet<T> {
} }
public ResponseSet(String errCode, String errMsg) { public ResponseSet(String errCode, String errMsg) {
this.retcod = errCode; if (CODE_SUCCESS.equals(errCode)) {
this.retmsg = errMsg; this.retcod = CODE_SUCCESS;
this.retmsg = CODE_SUCCESS;
} else {
this.retcod = CODE_FAILURE;
this.retmsg = CODE_FAILURE;
}
if (MdaEnv.getContext() != null) { if (MdaEnv.getContext() != null) {
MdaEnv.getContext().visitValues(); MdaEnv.getContext().visitValues();
} }
...@@ -62,9 +67,11 @@ public class ResponseSet<T> { ...@@ -62,9 +67,11 @@ public class ResponseSet<T> {
public ResponseSet(String errCode, String errMsg, T t) { public ResponseSet(String errCode, String errMsg, T t) {
this(errCode, errMsg); this(errCode, errMsg);
this.data = t; if (CODE_SUCCESS.equals(errCode)) {
this.data = t;
}
if (t != null && MdaEnv.getContext() != null) { if (t != null && MdaEnv.getContext() != null) {
MdaDriver.setValueToVO(MdaEnv.getContext(), this.data); MdaDriver.setValueToVO(MdaEnv.getContext(), t);
} }
} }
...@@ -102,7 +109,7 @@ public class ResponseSet<T> { ...@@ -102,7 +109,7 @@ public class ResponseSet<T> {
public static ResponseSet fail(String message) { public static ResponseSet fail(String message) {
ResponseSet responseSet = new ResponseSet(CODE_FAILURE, message); ResponseSet responseSet = new ResponseSet(CODE_FAILURE, CODE_FAILURE);
return responseSet; return responseSet;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment