Commit 23c485dd by s_guodong

返回值的层级结构增加root

parent 090d76dc
package com.brilliance.mda.runtime.response;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.io.Serializable;
/**
* @Description
* @Author s_guodong
* @Date 2023/8/18
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
public class RespondRoot<T> implements Serializable {
private ResponseSet<T> root;
public RespondRoot(ResponseSet<T> root) {
this.root = root;
}
}
...@@ -21,18 +21,14 @@ public class ResponseSet<T> { ...@@ -21,18 +21,14 @@ public class ResponseSet<T> {
public static final String CODE_FAILURE = "BBBBBB"; public static final String CODE_FAILURE = "BBBBBB";
public static final String MSG_SUCESS = "操作成功!"; public static final String MSG_SUCESS = "操作成功!";
private String respCode; private String retcod;
private String respMsg; private String retmsg;
private Map<String, String> fieldErrors;
private Map<String, List<String>> codeSet;
private Object data; private Object data;
public ResponseSet(IContext ctx, Object t) { public ResponseSet(IContext ctx, Object t) {
this.respCode = CODE_SUCCESS; this.retcod = CODE_SUCCESS;
this.respMsg = MSG_SUCESS; this.retmsg = MSG_SUCESS;
this.data = t; this.data = t;
fieldErrors = cloneFieldErrorsFromContext(ctx);
this.codeSet = getValuesSet(ctx);
ctx.visitValues(); ctx.visitValues();
MdaDriver.setValueToVO(ctx, this.data); MdaDriver.setValueToVO(ctx, this.data);
} }
...@@ -47,42 +43,24 @@ public class ResponseSet<T> { ...@@ -47,42 +43,24 @@ public class ResponseSet<T> {
return valuesSet; return valuesSet;
} }
private Map<String, String> cloneFieldErrorsFromContext(IContext ctx) {
if (ctx == null) {
return null;
}
Map<String, String> fieldErrors = ctx.getFieldErrors();
Map<String, String> fieldErrorsClone = new LinkedHashMap<>();
fieldErrorsClone.putAll(fieldErrors);
fieldErrors.clear();
return fieldErrorsClone;
}
public ResponseSet(Object t) { public ResponseSet(Object t) {
this.respCode = CODE_SUCCESS; this.retcod = CODE_SUCCESS;
this.respMsg = MSG_SUCESS; this.retmsg = MSG_SUCESS;
if (MdaEnv.getContext() != null) { if (MdaEnv.getContext() != null) {
fieldErrors = cloneFieldErrorsFromContext(MdaEnv.getContext());
this.codeSet = getValuesSet(MdaEnv.getContext());
MdaEnv.getContext().visitValues(); MdaEnv.getContext().visitValues();
} }
this.data = t; this.data = t;
} }
public ResponseSet(String errCode, String errMsg) { public ResponseSet(String errCode, String errMsg) {
this.respCode = errCode; this.retcod = errCode;
this.respMsg = errMsg; this.retmsg = errMsg;
if (MdaEnv.getContext() != null) { if (MdaEnv.getContext() != null) {
fieldErrors = cloneFieldErrorsFromContext(MdaEnv.getContext());
this.codeSet = getValuesSet(MdaEnv.getContext());
MdaEnv.getContext().visitValues(); MdaEnv.getContext().visitValues();
} }
} }
// public ResponseSet(String errCode,String errMsg,Map<String,String> fieldErrors){
// this(errCode,errMsg);
// this.fieldErrors = fieldErrors;
// }
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; this.data = t;
...@@ -99,36 +77,20 @@ public class ResponseSet<T> { ...@@ -99,36 +77,20 @@ public class ResponseSet<T> {
this.data = data; this.data = data;
} }
public String getRespCode() { public String getRetcod() {
return respCode; return retcod;
}
public void setRespCode(String respCode) {
this.respCode = respCode;
}
public String getRespMsg() {
return respMsg;
}
public void setRespMsg(String respMsg) {
this.respMsg = respMsg;
}
public Map<String, String> getFieldErrors() {
return fieldErrors;
} }
public void setFieldErrors(Map<String, String> fieldErrors) { public void setRetcod(String retcod) {
this.fieldErrors = fieldErrors; this.retcod = retcod;
} }
public Map<String, List<String>> getCodeSet() { public String getRetmsg() {
return codeSet; return retmsg;
} }
public void setCodeSet(Map<String, List<String>> codeSet) { public void setRetmsg(String retmsg) {
this.codeSet = codeSet; this.retmsg = retmsg;
} }
static class BooleanResult { static class BooleanResult {
......
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