Commit 932e1b9e by 徐高华

自建接口调整

parent 37c541be
...@@ -40,6 +40,7 @@ import com.gic.haoban.manage.service.service.MaterialService; ...@@ -40,6 +40,7 @@ import com.gic.haoban.manage.service.service.MaterialService;
import com.gic.haoban.manage.service.service.MiniprogramSettingService; import com.gic.haoban.manage.service.service.MiniprogramSettingService;
import com.gic.haoban.manage.service.service.WxEnterpriseService; import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.util.CommonUtil; import com.gic.haoban.manage.service.util.CommonUtil;
import com.gic.haoban.manage.service.util.QwUtils;
import com.gic.wechat.api.enums.QywxMediaTypeEnum; import com.gic.wechat.api.enums.QywxMediaTypeEnum;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService; import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
...@@ -145,7 +146,7 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -145,7 +146,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
if (type == 3) { if (type == 3) {
String imgUrl = materialDTO.getImgUrl(); String imgUrl = materialDTO.getImgUrl();
logger.info("【上传图片】imgUrl={}", imgUrl); logger.info("【上传图片】imgUrl={}", imgUrl);
JSONResponse response = qywxSuiteApiService.uploadImage(qwDTO.getThirdCorpid() , config.getWxSuiteid(), CommonUtil.getFileByte(imgUrl)); JSONResponse response = qywxSuiteApiService.uploadImage(qwDTO.getThirdCorpid() , QwUtils.getSecret(qwDTO, config.getWxSuiteid()), CommonUtil.getFileByte(imgUrl) , qwDTO.isSelf());
logger.info("【上传图片返回】response={}", JSON.toJSONString(response)); logger.info("【上传图片返回】response={}", JSON.toJSONString(response));
String wxImgUrl = response.getResult() == null ? "" : response.getResult().toString(); String wxImgUrl = response.getResult() == null ? "" : response.getResult().toString();
materialDTO.setWxImgUrl(wxImgUrl); materialDTO.setWxImgUrl(wxImgUrl);
...@@ -215,7 +216,7 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -215,7 +216,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
String imgUrl = materialDTO.getImgUrl(); String imgUrl = materialDTO.getImgUrl();
String oldImgUrl = materialDTO.getImgUrl(); String oldImgUrl = materialDTO.getImgUrl();
if (!imgUrl.equals(oldImgUrl)) { if (!imgUrl.equals(oldImgUrl)) {
JSONResponse response = qywxSuiteApiService.uploadImage(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(imgUrl)); JSONResponse response = qywxSuiteApiService.uploadImage(qwDTO.getThirdCorpid(), QwUtils.getSecret(qwDTO, config.getWxSuiteid()), CommonUtil.getFileByte(imgUrl) ,qwDTO.isSelf());
String wxImgUrl = response.getResult() == null ? "" : response.getResult().toString(); String wxImgUrl = response.getResult() == null ? "" : response.getResult().toString();
materialDTO.setWxImgUrl(wxImgUrl); materialDTO.setWxImgUrl(wxImgUrl);
} }
......
...@@ -98,6 +98,7 @@ import com.gic.haoban.manage.service.service.chat.GroupChatService; ...@@ -98,6 +98,7 @@ import com.gic.haoban.manage.service.service.chat.GroupChatService;
import com.gic.haoban.manage.service.service.hm.HmLinkService; import com.gic.haoban.manage.service.service.hm.HmLinkService;
import com.gic.haoban.manage.service.service.hm.WxUserAddLogService; import com.gic.haoban.manage.service.service.hm.WxUserAddLogService;
import com.gic.haoban.manage.service.util.EmojiFilterUtil; import com.gic.haoban.manage.service.util.EmojiFilterUtil;
import com.gic.haoban.manage.service.util.QwUtils;
import com.gic.member.api.dto.MemberDTO; import com.gic.member.api.dto.MemberDTO;
import com.gic.member.api.dto.MemberSimpleDetailDTO; import com.gic.member.api.dto.MemberSimpleDetailDTO;
import com.gic.member.api.dto.MemberSourceDetailDTO; import com.gic.member.api.dto.MemberSourceDetailDTO;
...@@ -1144,7 +1145,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA ...@@ -1144,7 +1145,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
if (qwDTO == null) { if (qwDTO == null) {
return null; return null;
} }
return qywxSuiteApiService.resultExternalMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(), wxMessageId); return qywxSuiteApiService.resultExternalMessage(qwDTO.getThirdCorpid(), QwUtils.getSecret(qwDTO, config.getWxSuiteid()), wxMessageId , qwDTO.isSelf());
} }
@Override @Override
......
...@@ -20,6 +20,7 @@ import com.gic.haoban.manage.service.pojo.QywxSyncTagFormatPojo; ...@@ -20,6 +20,7 @@ import com.gic.haoban.manage.service.pojo.QywxSyncTagFormatPojo;
import com.gic.haoban.manage.service.service.ExternalClerkRelatedService; import com.gic.haoban.manage.service.service.ExternalClerkRelatedService;
import com.gic.haoban.manage.service.service.QywxTagService; import com.gic.haoban.manage.service.service.QywxTagService;
import com.gic.haoban.manage.service.service.WxEnterpriseService; import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.util.QwUtils;
import com.gic.member.api.dto.MemberTagDTO; import com.gic.member.api.dto.MemberTagDTO;
import com.gic.member.api.service.MemberTagService; import com.gic.member.api.service.MemberTagService;
import com.gic.member.tag.api.dto.MemberTagItemDTO; import com.gic.member.tag.api.dto.MemberTagItemDTO;
...@@ -93,7 +94,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService { ...@@ -93,7 +94,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
logger.info("企业标签所在企业不存在"); logger.info("企业标签所在企业不存在");
return; return;
} }
QywxGetCorpTagListDTO corpTagListResp = qywxSuiteApiService.getCorpTagList(qwDTO.getThirdCorpid(), config.getWxSuiteid(), null, -1); QywxGetCorpTagListDTO corpTagListResp = qywxSuiteApiService.getCorpTagList(qwDTO.getThirdCorpid(), QwUtils.getSecret(qwDTO, config.getWxSuiteid()), null, -1 , qwDTO.isSelf());
if (corpTagListResp.getErrcode() != 0) { if (corpTagListResp.getErrcode() != 0) {
logger.info("企业微信标签有问题:{}", wxEnterpriseId); logger.info("企业微信标签有问题:{}", wxEnterpriseId);
return; return;
...@@ -110,7 +111,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService { ...@@ -110,7 +111,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
ServiceResponse ret = new ServiceResponse(); ServiceResponse ret = new ServiceResponse();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ; WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
//调用企业微信接口保存 //调用企业微信接口保存
QywxGetCorpTagListDTO resp = this.saveQywxTag(qwDTO.getThirdCorpid(), infoDTO, items); QywxGetCorpTagListDTO resp = this.saveQywxTag(qwDTO.getThirdCorpid(), infoDTO, items,qwDTO);
if (resp.getErrcode() != 0 && CollectionUtils.isEmpty(resp.getTagGroup())) { if (resp.getErrcode() != 0 && CollectionUtils.isEmpty(resp.getTagGroup())) {
logger.info("同步失败:{}", JSONObject.toJSONString(resp)); logger.info("同步失败:{}", JSONObject.toJSONString(resp));
ret.setCode(resp.getErrcode()); ret.setCode(resp.getErrcode());
...@@ -187,7 +188,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService { ...@@ -187,7 +188,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
* @param items * @param items
* @return * @return
*/ */
private QywxGetCorpTagListDTO saveQywxTag(String corpid, QywxTagInfoDTO infoDTO, List<QywxTagItemDTO> items) { private QywxGetCorpTagListDTO saveQywxTag(String corpid, QywxTagInfoDTO infoDTO, List<QywxTagItemDTO> items , WxEnterpriseQwDTO qwDTO) {
QywxTagGroupDTO qywxTagGroupDTO = new QywxTagGroupDTO(); QywxTagGroupDTO qywxTagGroupDTO = new QywxTagGroupDTO();
qywxTagGroupDTO.setGroupName("GIC" + infoDTO.getQywxGroupName()); qywxTagGroupDTO.setGroupName("GIC" + infoDTO.getQywxGroupName());
qywxTagGroupDTO.setOrder(infoDTO.getOrder()); qywxTagGroupDTO.setOrder(infoDTO.getOrder());
...@@ -200,8 +201,11 @@ public class QywxTagApiServiceImpl implements QywxTagApiService { ...@@ -200,8 +201,11 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
return qywxTagDTO; return qywxTagDTO;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
qywxTagGroupDTO.setTag(tagItems); qywxTagGroupDTO.setTag(tagItems);
String secret = config.getWxSuiteid() ;
return qywxSuiteApiService.saveCorpTag(corpid, config.getWxSuiteid(), qywxTagGroupDTO); if(qwDTO.isSelf()) {
secret = qwDTO.getSelfSecret() ;
}
return qywxSuiteApiService.saveCorpTag(corpid, secret, qywxTagGroupDTO , qwDTO.isSelf());
} }
@Override @Override
...@@ -217,7 +221,11 @@ public class QywxTagApiServiceImpl implements QywxTagApiService { ...@@ -217,7 +221,11 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
qywxTagService.closeSync(wxEnterpriseId, memberTagId); qywxTagService.closeSync(wxEnterpriseId, memberTagId);
List<String> delIds = new ArrayList<>(); List<String> delIds = new ArrayList<>();
delIds.add(tabQywxTag.getQywxGroupKey()); delIds.add(tabQywxTag.getQywxGroupKey());
QywxResponseDTO responseDTO = qywxSuiteApiService.delCorpTag(qwDTO.getThirdCorpid(), config.getWxSuiteid(), delIds, 0); String secret = config.getWxSuiteid() ;
if(qwDTO.isSelf()) {
secret = qwDTO.getSelfSecret() ;
}
QywxResponseDTO responseDTO = qywxSuiteApiService.delCorpTag(qwDTO.getThirdCorpid(), secret, delIds, 0,qwDTO.isSelf());
logger.info("关闭同步:{}", JSONObject.toJSONString(responseDTO)); logger.info("关闭同步:{}", JSONObject.toJSONString(responseDTO));
if (responseDTO.getErrcode() != 0) { if (responseDTO.getErrcode() != 0) {
resp.setMessage(responseDTO.getErrmsg()); resp.setMessage(responseDTO.getErrmsg());
...@@ -241,7 +249,11 @@ public class QywxTagApiServiceImpl implements QywxTagApiService { ...@@ -241,7 +249,11 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
List<String> delIds = new ArrayList<>(); List<String> delIds = new ArrayList<>();
delIds.add(qywxTagItem.getQywxTagKey()); delIds.add(qywxTagItem.getQywxTagKey());
QywxResponseDTO responseDTO = qywxSuiteApiService.delCorpTag(qwDTO.getThirdCorpid(), config.getWxSuiteid(), delIds, 1); String secret = config.getWxSuiteid() ;
if(qwDTO.isSelf()) {
secret = qwDTO.getSelfSecret() ;
}
QywxResponseDTO responseDTO = qywxSuiteApiService.delCorpTag(qwDTO.getThirdCorpid(), secret, delIds, 1,qwDTO.isSelf());
logger.info("删除标签项:{}", JSONObject.toJSONString(responseDTO)); logger.info("删除标签项:{}", JSONObject.toJSONString(responseDTO));
if (responseDTO.getErrcode() != 0) { if (responseDTO.getErrcode() != 0) {
resp.setMessage(responseDTO.getErrmsg()); resp.setMessage(responseDTO.getErrmsg());
...@@ -285,7 +297,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService { ...@@ -285,7 +297,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
logger.info("新增标签组无需操作:{}", callbackDTO.getTagId()); logger.info("新增标签组无需操作:{}", callbackDTO.getTagId());
List<String> ids = new ArrayList<>(); List<String> ids = new ArrayList<>();
ids.add(callbackDTO.getTagId()); ids.add(callbackDTO.getTagId());
QywxGetCorpTagListDTO tagDetail = qywxSuiteApiService.getCorpTagList(qwDTO.getThirdCorpid(), config.getWxSuiteid(), ids, QywxTagRelationTypeEnum.TAG_GROUP.getType()); QywxGetCorpTagListDTO tagDetail = qywxSuiteApiService.getCorpTagList(qwDTO.getThirdCorpid(), QwUtils.getSecret(qwDTO, config.getWxSuiteid()), ids, QywxTagRelationTypeEnum.TAG_GROUP.getType() , qwDTO.isSelf());
if (tagDetail.getErrcode() != 0) { if (tagDetail.getErrcode() != 0) {
logger.info("没有关联,无需操作:{}", JSONObject.toJSONString(tagDetail)); logger.info("没有关联,无需操作:{}", JSONObject.toJSONString(tagDetail));
return; return;
...@@ -298,7 +310,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService { ...@@ -298,7 +310,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
//查找对应的标签组 如果标签组关联了 //查找对应的标签组 如果标签组关联了
List<String> ids = new ArrayList<>(); List<String> ids = new ArrayList<>();
ids.add(callbackDTO.getTagId()); ids.add(callbackDTO.getTagId());
QywxGetCorpTagListDTO tagDetail = qywxSuiteApiService.getCorpTagList(qwDTO.getThirdCorpid(), config.getWxSuiteid(), ids, QywxTagRelationTypeEnum.TAG_ITEM.getType()); QywxGetCorpTagListDTO tagDetail = qywxSuiteApiService.getCorpTagList(qwDTO.getThirdCorpid(), QwUtils.getSecret(qwDTO, config.getWxSuiteid()), ids, QywxTagRelationTypeEnum.TAG_ITEM.getType() , qwDTO.isSelf());
if (tagDetail.getErrcode() != 0) { if (tagDetail.getErrcode() != 0) {
logger.info("查询失败,无需操作:{}", JSONObject.toJSONString(tagDetail)); logger.info("查询失败,无需操作:{}", JSONObject.toJSONString(tagDetail));
return; return;
...@@ -405,7 +417,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService { ...@@ -405,7 +417,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
qywxTagDTO.setId(callbackDTO.getTagId()); qywxTagDTO.setId(callbackDTO.getTagId());
qywxTagDTO.setName(qywxGroupKey.getQywxGroupName()); qywxTagDTO.setName(qywxGroupKey.getQywxGroupName());
qywxTagDTO.setOrder(qywxGroupKey.getOrder()); qywxTagDTO.setOrder(qywxGroupKey.getOrder());
qywxSuiteApiService.editCorpTagNameOrOrder(qwDTO.getThirdCorpid(), config.getWxSuiteid(), qywxTagDTO); qywxSuiteApiService.editCorpTagNameOrOrder(qwDTO.getThirdCorpid(), QwUtils.getSecret(qwDTO, config.getWxSuiteid()), qywxTagDTO , qwDTO.isSelf());
//标签项 //标签项
} else if (Objects.equals(relationTypeEnum.getTagType(), QywxTagRelationTypeEnum.TAG_ITEM.getTagType())) { } else if (Objects.equals(relationTypeEnum.getTagType(), QywxTagRelationTypeEnum.TAG_ITEM.getTagType())) {
...@@ -425,7 +437,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService { ...@@ -425,7 +437,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
qywxTagDTO.setId(callbackDTO.getTagId()); qywxTagDTO.setId(callbackDTO.getTagId());
qywxTagDTO.setName(qywxTagItem.getQywxTagName()); qywxTagDTO.setName(qywxTagItem.getQywxTagName());
qywxTagDTO.setOrder(qywxTagItem.getOrder()); qywxTagDTO.setOrder(qywxTagItem.getOrder());
qywxSuiteApiService.editCorpTagNameOrOrder(qwDTO.getThirdCorpid(), config.getWxSuiteid(), qywxTagDTO); qywxSuiteApiService.editCorpTagNameOrOrder(qwDTO.getThirdCorpid(), QwUtils.getSecret(qwDTO, config.getWxSuiteid()), qywxTagDTO,qwDTO.isSelf());
} }
} }
...@@ -754,7 +766,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService { ...@@ -754,7 +766,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
qywxTagDTO.setId(renameQywxKey); qywxTagDTO.setId(renameQywxKey);
qywxTagDTO.setName(name); qywxTagDTO.setName(name);
qywxTagDTO.setOrder(order); qywxTagDTO.setOrder(order);
QywxResponseDTO responseDTO = qywxSuiteApiService.editCorpTagNameOrOrder(qwDTO.getThirdCorpid(), config.getWxSuiteid(), qywxTagDTO); QywxResponseDTO responseDTO = qywxSuiteApiService.editCorpTagNameOrOrder(qwDTO.getThirdCorpid(), QwUtils.getSecret(qwDTO, config.getWxSuiteid()), qywxTagDTO , qwDTO.isSelf());
logger.info("同步名称:{}", JSONObject.toJSONString(responseDTO)); logger.info("同步名称:{}", JSONObject.toJSONString(responseDTO));
if (responseDTO.getErrcode() != 0) { if (responseDTO.getErrcode() != 0) {
resp.setMessage(responseDTO.getErrmsg()); resp.setMessage(responseDTO.getErrmsg());
...@@ -837,7 +849,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService { ...@@ -837,7 +849,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(relation.getWxEnterpriseId()) ; WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(relation.getWxEnterpriseId()) ;
List<String> ids = new ArrayList<>(); List<String> ids = new ArrayList<>();
ids.add(tabQywxTag.getQywxGroupKey()); ids.add(tabQywxTag.getQywxGroupKey());
QywxGetCorpTagListDTO tagDetail = qywxSuiteApiService.getCorpTagList(qwDTO.getThirdCorpid(), config.getWxSuiteid(), ids, QywxTagRelationTypeEnum.TAG_GROUP.getType()); QywxGetCorpTagListDTO tagDetail = qywxSuiteApiService.getCorpTagList(qwDTO.getThirdCorpid(), QwUtils.getSecret(qwDTO, config.getWxSuiteid()), ids, QywxTagRelationTypeEnum.TAG_GROUP.getType() , qwDTO.isSelf());
if (tagDetail.getErrcode() != 0) { if (tagDetail.getErrcode() != 0) {
logger.info("查询失败,无需操作:{}", JSONObject.toJSONString(tagDetail)); logger.info("查询失败,无需操作:{}", JSONObject.toJSONString(tagDetail));
ret.put("描述", "查询失败:" + tagDetail.getErrmsg()); ret.put("描述", "查询失败:" + tagDetail.getErrmsg());
...@@ -951,5 +963,4 @@ public class QywxTagApiServiceImpl implements QywxTagApiService { ...@@ -951,5 +963,4 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
RedisUtil.setCache(key, currentTimes + 1, 2L, TimeUnit.HOURS); RedisUtil.setCache(key, currentTimes + 1, 2L, TimeUnit.HOURS);
} }
} }
} }
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