|
@@ -12,7 +12,6 @@ import com.qmth.sop.common.enums.ExceptionResultEnum;
|
|
import com.qmth.sop.common.enums.ProductTypeEnum;
|
|
import com.qmth.sop.common.enums.ProductTypeEnum;
|
|
import com.qmth.sop.common.util.HttpUtil;
|
|
import com.qmth.sop.common.util.HttpUtil;
|
|
import com.qmth.sop.common.util.JacksonUtil;
|
|
import com.qmth.sop.common.util.JacksonUtil;
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -30,6 +29,8 @@ import java.util.*;
|
|
public class FxxkApiUtils {
|
|
public class FxxkApiUtils {
|
|
@Resource
|
|
@Resource
|
|
private SysConfigService sysConfigService;
|
|
private SysConfigService sysConfigService;
|
|
|
|
+ @Resource
|
|
|
|
+ private CommonUtils commonUtils;
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(FxxkApiUtils.class);
|
|
private static final Logger log = LoggerFactory.getLogger(FxxkApiUtils.class);
|
|
|
|
|
|
@@ -60,9 +61,9 @@ public class FxxkApiUtils {
|
|
String postUrl = sysConfigService.findByConfigKey(SystemConstant.FXXK_APP_AUTH_URL).getConfigValue();
|
|
String postUrl = sysConfigService.findByConfigKey(SystemConstant.FXXK_APP_AUTH_URL).getConfigValue();
|
|
try {
|
|
try {
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
- map.put("appId", validParam(fxxkAppId, null, true, "纷享销客AppID"));
|
|
|
|
- map.put("appSecret", validParam(fxxkAppSecrete, null, true, "纷享销客APPSecret"));
|
|
|
|
- map.put("permanentCode", validParam(fxxkPermanentCode, null, true, "纷享销客永久授权码"));
|
|
|
|
|
|
+ map.put("appId", commonUtils.validParam(fxxkAppId, null, true, "纷享销客AppID"));
|
|
|
|
+ map.put("appSecret", commonUtils.validParam(fxxkAppSecrete, null, true, "纷享销客APPSecret"));
|
|
|
|
+ map.put("permanentCode", commonUtils.validParam(fxxkPermanentCode, null, true, "纷享销客永久授权码"));
|
|
String requestJson = JacksonUtil.parseJson(map);
|
|
String requestJson = JacksonUtil.parseJson(map);
|
|
|
|
|
|
String result = HttpUtil.postJson(postUrl, requestJson, null, null, false);
|
|
String result = HttpUtil.postJson(postUrl, requestJson, null, null, false);
|
|
@@ -95,9 +96,9 @@ public class FxxkApiUtils {
|
|
String corpId = fxxkAppAuthInfo.getCorpId();
|
|
String corpId = fxxkAppAuthInfo.getCorpId();
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
- map.put("corpAccessToken", validParam(corpAccessToken, null, true, "企业应用访问公司合法性凭证"));
|
|
|
|
- map.put("corpId", validParam(corpId, null, true, "开放平台公司帐号"));
|
|
|
|
- map.put("mobile", validParam(mobile, null, true, "员工手机号"));
|
|
|
|
|
|
+ map.put("corpAccessToken", commonUtils.validParam(corpAccessToken, null, true, "企业应用访问公司合法性凭证"));
|
|
|
|
+ map.put("corpId", commonUtils.validParam(corpId, null, true, "开放平台公司帐号"));
|
|
|
|
+ map.put("mobile", commonUtils.validParam(mobile, null, true, "员工手机号"));
|
|
String requestJson = JacksonUtil.parseJson(map);
|
|
String requestJson = JacksonUtil.parseJson(map);
|
|
|
|
|
|
String result = HttpUtil.postJson(postUrl, requestJson, null, null, false);
|
|
String result = HttpUtil.postJson(postUrl, requestJson, null, null, false);
|
|
@@ -126,9 +127,9 @@ public class FxxkApiUtils {
|
|
String corpId = fxxkAppAuthInfo.getCorpId();
|
|
String corpId = fxxkAppAuthInfo.getCorpId();
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
- map.put("corpAccessToken", validParam(corpAccessToken, null, true, "企业应用访问公司合法性凭证"));
|
|
|
|
- map.put("corpId", validParam(corpId, null, true, "开放平台公司帐号"));
|
|
|
|
- map.put("currentOpenUserId", validParam(fxxkCurrenOpenUserId, null, true, "当前操作人OpenUserID"));
|
|
|
|
|
|
+ map.put("corpAccessToken", commonUtils.validParam(corpAccessToken, null, true, "企业应用访问公司合法性凭证"));
|
|
|
|
+ map.put("corpId", commonUtils.validParam(corpId, null, true, "开放平台公司帐号"));
|
|
|
|
+ map.put("currentOpenUserId", commonUtils.validParam(fxxkCurrenOpenUserId, null, true, "当前操作人OpenUserID"));
|
|
|
|
|
|
Map<String, Object> dataMap = new HashMap<>();
|
|
Map<String, Object> dataMap = new HashMap<>();
|
|
dataMap.put("dataObjectApiName", fxxkApiNameCrm);
|
|
dataMap.put("dataObjectApiName", fxxkApiNameCrm);
|
|
@@ -263,51 +264,4 @@ public class FxxkApiUtils {
|
|
throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|
|
throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 校验参数值并返回(字符型)
|
|
|
|
- *
|
|
|
|
- * @param value 参数值
|
|
|
|
- * @param defaultValue 默认值
|
|
|
|
- * @param require 是否必填(true:是,false:否)
|
|
|
|
- * @param name 参数名称
|
|
|
|
- */
|
|
|
|
- private String validParam(String value, String defaultValue, boolean require, String name) {
|
|
|
|
- if (require && StringUtils.isAllBlank(value, defaultValue)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception((StringUtils.isBlank(name) ? "" : name) + "值必填");
|
|
|
|
- }
|
|
|
|
- return StringUtils.isBlank(value) ? defaultValue : value;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 校验参数值并返回(Long型)
|
|
|
|
- *
|
|
|
|
- * @param value 参数值
|
|
|
|
- * @param defaultValue 默认值
|
|
|
|
- * @param require 是否必填(true:是,false:否)
|
|
|
|
- * @param name 参数名称
|
|
|
|
- */
|
|
|
|
- private Long validParam(Long value, Long defaultValue, boolean require, String name) {
|
|
|
|
- if (require && Objects.isNull(value) && Objects.isNull(defaultValue)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception((StringUtils.isBlank(name) ? "" : name) + "值必填");
|
|
|
|
- }
|
|
|
|
- return Objects.isNull(value) ? defaultValue : value;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 校验参数值并返回 (布尔型)
|
|
|
|
- *
|
|
|
|
- * @param value 参数值
|
|
|
|
- * @param defaultValue 默认值
|
|
|
|
- * @param require 是否必填
|
|
|
|
- * @param name 描述
|
|
|
|
- */
|
|
|
|
- private Boolean validParam(Boolean value, Boolean defaultValue, Boolean require, String name) {
|
|
|
|
- if (require && value == null && defaultValue == null) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception((StringUtils.isBlank(name) ? "" : name) + "值必填");
|
|
|
|
- }
|
|
|
|
- return value == null ? defaultValue : value;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|