一、在ec-common-core 下增加 com.yhh.common.base.ret.ApiResult
package com.yhh.common.base.ret;
import lombok.Data;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@Data
public class ApiResult implements Serializable {
public static final int SUCCESS_CODE=200;
public static final int ERROR_CODE=200;
public static final int ILLEGAL_CODE=200;
public static final String SUCCESS_MSG="操作成功";
public static final String ERROR_MSG="服务器异常";
public static final String ILLEGAL_MSG="参数非法";
private int code;
private String message;
private Map<String,Object> result = new HashMap<>();
private ApiResult(){}
/**
* 操作成功
* @return
*/
public static ApiResult success(){
ApiResult ret = new ApiResult();
ret.code = SUCCESS_CODE;
ret.message = SUCCESS_MSG;
return ret;
}
/**
* 服务器异常
* @return
*/
public static ApiResult error(){
ApiResult ret = new ApiResult();
ret.code = ERROR_CODE;
ret.message = ERROR_MSG;
return ret;
}
/**
* 参数非法
* @return
*/
public static ApiResult illegal(){
ApiResult ret = new ApiResult();
ret.code = ILLEGAL_CODE;
ret.message = ILLEGAL_MSG;
return ret;
}
public ApiResult put(String key, Object value){
this.result.put(key, value);
return this;
}
public ApiResult setMsg(String msg){
this.message = msg;
return this;
}
}
二、改写sendRegCode 方法