|
@ -1,5 +1,7 @@ |
|
|
package com.epmet.wxapi.service.impl; |
|
|
package com.epmet.wxapi.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.utils.HttpClientManager; |
|
|
import com.epmet.commons.tools.utils.HttpClientManager; |
|
@ -36,6 +38,7 @@ import java.util.Map; |
|
|
public class WxMaCodeServiceImpl implements WxMaCodeService { |
|
|
public class WxMaCodeServiceImpl implements WxMaCodeService { |
|
|
private static final String ERR_CODE = "errcode"; |
|
|
private static final String ERR_CODE = "errcode"; |
|
|
private static final String ERR_MSG = "errmsg"; |
|
|
private static final String ERR_MSG = "errmsg"; |
|
|
|
|
|
private static final String SETTING_LIST = "setting_list"; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private WxMaDomainDTO wxMaDomainDTO; |
|
|
private WxMaDomainDTO wxMaDomainDTO; |
|
@ -150,6 +153,50 @@ public class WxMaCodeServiceImpl implements WxMaCodeService { |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public WxResult<String> getPrivacySetting(String accessToken) { |
|
|
|
|
|
WxResult<String> result = new WxResult<>(); |
|
|
|
|
|
String url = WxMaCodeConstant.SET_PRIVACY_SETTING_URL + "?" + "access_token=" + accessToken; |
|
|
|
|
|
Result<String> submitResult = HttpClientManager.getInstance().sendPostByJSON(url, "{}"); |
|
|
|
|
|
log.info("getPrivacySetting result:{}", JSON.toJSONString(submitResult)); |
|
|
|
|
|
if (!submitResult.success()) { |
|
|
|
|
|
result.setErrorCode(submitResult.getCode()); |
|
|
|
|
|
result.setErrorMsg(submitResult.getMsg()); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(submitResult.getData()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONArray jsonArray = jsonObject.getJSONArray(SETTING_LIST); |
|
|
|
|
|
if (jsonArray.size() == 9){ |
|
|
|
|
|
result.setErrorCode(9999); |
|
|
|
|
|
result.setErrorMsg("用户隐私权限未设置或设置不完整"); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
result.setErrorCode(jsonObject.getInteger(ERR_CODE)); |
|
|
|
|
|
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE))); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public WxResult setPrivacySetting(String accessToken) { |
|
|
|
|
|
//todo 目前设置9个隐私权限
|
|
|
|
|
|
String param = "{\"owner_setting\":{\"contact_email\":\"eshitong@elink-cn.com\",\"contact_phone\":\"\",\"contact_qq\":\"\",\"contact_weixin\":\"\",\"ext_file_media_id\":\"\",\"notice_method\":\"通知\",\"store_expire_timestamp\":\"\"},\"setting_list\":[{\"privacy_key\":\"UserInfo\",\"privacy_text\":\"用户个人中心显示用户头像及昵称等\"},{\"privacy_key\":\"Location\",\"privacy_text\":\"发表话题等功能时获取位置信息\"},{\"privacy_key\":\"Record\",\"privacy_text\":\"录音发话题等\"},{\"privacy_key\":\"Album\",\"privacy_text\":\"上传照片发话题等\"},{\"privacy_key\":\"AlbumWriteOnly\",\"privacy_text\":\"下载党建声音图片或项目附近等\"},{\"privacy_key\":\"Camera\",\"privacy_text\":\"通过相机拍照发话题反应问题等\"},{\"privacy_key\":\"PhoneNumber\",\"privacy_text\":\"通过手机号为用户开通账号,更新用户基础信息\"},{\"privacy_key\":\"MessageFile\",\"privacy_text\":\"发表话题等可以选择文件上传\"},{\"privacy_key\":\"ChooseLocation\",\"privacy_text\":\"用户巡查上报\"}],\"privacy_ver\":2}\n"; |
|
|
|
|
|
WxResult<String> result = new WxResult<>(); |
|
|
|
|
|
String url = WxMaCodeConstant.SET_PRIVACY_SETTING_URL + "?" + "access_token=" + accessToken; |
|
|
|
|
|
Result<String> submitResult = HttpClientManager.getInstance().sendPostByJSON(url, param); |
|
|
|
|
|
log.info("setPrivacySetting param:{}, result:{}", param, JSON.toJSONString(submitResult)); |
|
|
|
|
|
if (!submitResult.success()) { |
|
|
|
|
|
result.setErrorCode(submitResult.getCode()); |
|
|
|
|
|
result.setErrorMsg(submitResult.getMsg()); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(submitResult.getData()); |
|
|
|
|
|
result.setErrorCode(jsonObject.getInteger(ERR_CODE)); |
|
|
|
|
|
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE))); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public WxResult speedUpAudit(String accessToken, WxMaSpeedUpAuditReq request) { |
|
|
public WxResult speedUpAudit(String accessToken, WxMaSpeedUpAuditReq request) { |
|
|
WxResult result = new WxResult(); |
|
|
WxResult result = new WxResult(); |
|
|