pull/3/head
tanghc 4 years ago
parent faa9310759
commit 994960da31
  1. 14
      sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/OpenContext.java
  2. 13
      sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/OpenContextImpl.java

@ -1,6 +1,7 @@
package com.gitee.sop.servercommon.bean;
import java.util.Date;
import java.util.Map;
/**
* 获取开放平台请求参数
@ -9,6 +10,19 @@ import java.util.Date;
*/
public interface OpenContext {
/**
* 获取某个参数值
* @param name 参数名称
* @return 没有返回null
*/
String getParameter(String name);
/**
* 返回所有的请求参数
* @return 返回所有的请求参数
*/
Map<String, Object> getParameterMap();
/**
* 返回appid
*

@ -5,6 +5,7 @@ import org.apache.commons.lang3.time.DateUtils;
import java.text.ParseException;
import java.util.Date;
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;
@ -22,7 +23,7 @@ import static com.gitee.sop.servercommon.bean.ParamNames.VERSION_NAME;
* @author tanghc
*/
public class OpenContextImpl implements OpenContext {
private JSONObject requestParams;
private final JSONObject requestParams;
private Object bizObject;
public OpenContextImpl(JSONObject requestParams) {
@ -33,6 +34,16 @@ public class OpenContextImpl implements OpenContext {
this.bizObject = bizObject;
}
@Override
public String getParameter(String name) {
return requestParams.getString(name);
}
@Override
public Map<String, Object> getParameterMap() {
return requestParams;
}
@Override
public String getAppId() {
return requestParams.getString(APP_KEY_NAME);

Loading…
Cancel
Save