|
|
@ -1,32 +1,15 @@ |
|
|
|
package com.gitee.sop.servercommon.bean; |
|
|
|
package com.gitee.sop.servercommon.bean; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
|
|
import org.apache.commons.lang3.time.DateUtils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.text.ParseException; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
import static com.gitee.sop.servercommon.bean.ParamNames.API_NAME; |
|
|
|
|
|
|
|
import static com.gitee.sop.servercommon.bean.ParamNames.APP_AUTH_TOKEN_NAME; |
|
|
|
|
|
|
|
import static com.gitee.sop.servercommon.bean.ParamNames.APP_KEY_NAME; |
|
|
|
|
|
|
|
import static com.gitee.sop.servercommon.bean.ParamNames.BIZ_CONTENT_NAME; |
|
|
|
|
|
|
|
import static com.gitee.sop.servercommon.bean.ParamNames.CHARSET_NAME; |
|
|
|
|
|
|
|
import static com.gitee.sop.servercommon.bean.ParamNames.FORMAT_NAME; |
|
|
|
|
|
|
|
import static com.gitee.sop.servercommon.bean.ParamNames.NOTIFY_URL_NAME; |
|
|
|
|
|
|
|
import static com.gitee.sop.servercommon.bean.ParamNames.SIGN_TYPE_NAME; |
|
|
|
|
|
|
|
import static com.gitee.sop.servercommon.bean.ParamNames.TIMESTAMP_NAME; |
|
|
|
|
|
|
|
import static com.gitee.sop.servercommon.bean.ParamNames.TIMESTAMP_PATTERN; |
|
|
|
|
|
|
|
import static com.gitee.sop.servercommon.bean.ParamNames.VERSION_NAME; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author tanghc |
|
|
|
* @author tanghc |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class OpenContextImpl implements OpenContext { |
|
|
|
public class OpenContextImpl implements OpenContext { |
|
|
|
private final JSONObject requestParams; |
|
|
|
private final Map<String, Object> requestParams; |
|
|
|
private Object bizObject; |
|
|
|
private Object bizObject; |
|
|
|
|
|
|
|
|
|
|
|
public OpenContextImpl(JSONObject requestParams) { |
|
|
|
public OpenContextImpl(Map<String, Object> requestParams) { |
|
|
|
this.requestParams = requestParams; |
|
|
|
this.requestParams = requestParams; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -34,77 +17,16 @@ public class OpenContextImpl implements OpenContext { |
|
|
|
this.bizObject = bizObject; |
|
|
|
this.bizObject = bizObject; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public String getParameter(String name) { |
|
|
|
|
|
|
|
return requestParams.getString(name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Map<String, Object> getParameterMap() { |
|
|
|
public Map<String, Object> getParameterMap() { |
|
|
|
return requestParams; |
|
|
|
return requestParams; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public String getAppId() { |
|
|
|
|
|
|
|
return requestParams.getString(APP_KEY_NAME); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Object getBizObject() { |
|
|
|
public Object getBizObject() { |
|
|
|
return bizObject; |
|
|
|
return bizObject; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public String getBizContent() { |
|
|
|
|
|
|
|
return requestParams.getString(BIZ_CONTENT_NAME); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public String getCharset() { |
|
|
|
|
|
|
|
return requestParams.getString(CHARSET_NAME); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public String getMethod() { |
|
|
|
|
|
|
|
return requestParams.getString(API_NAME); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public String getVersion() { |
|
|
|
|
|
|
|
return requestParams.getString(VERSION_NAME); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public String getFormat() { |
|
|
|
|
|
|
|
return requestParams.getString(FORMAT_NAME); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public String getSignType() { |
|
|
|
|
|
|
|
return requestParams.getString(SIGN_TYPE_NAME); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Date getTimestamp() { |
|
|
|
|
|
|
|
String timestampStr = requestParams.getString(TIMESTAMP_NAME); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
return DateUtils.parseDate(timestampStr, TIMESTAMP_PATTERN); |
|
|
|
|
|
|
|
} catch (ParseException e) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public String getAppAuthToken() { |
|
|
|
|
|
|
|
return requestParams.getString(APP_AUTH_TOKEN_NAME); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public String getNotifyUrl() { |
|
|
|
|
|
|
|
return requestParams.getString(NOTIFY_URL_NAME); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String toString() { |
|
|
|
public String toString() { |
|
|
|
return requestParams.toString(); |
|
|
|
return requestParams.toString(); |
|
|
|