mirror of https://github.com/jeecgboot/jeecg-boot
企业微信官方通讯录同步接口调整 #4058
parent
9f6c89a983
commit
14c69fa533
|
@ -72,15 +72,17 @@ public class ThirdAppController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/sync/wechatEnterprise/user/toLocal")
|
@GetMapping("/sync/wechatEnterprise/user/toLocal")
|
||||||
public Result syncWechatEnterpriseUserToLocal(@RequestParam(value = "ids", required = false) String ids) {
|
public Result syncWechatEnterpriseUserToLocal(@RequestParam(value = "ids", required = false) String ids) {
|
||||||
if (thirdAppConfig.isWechatEnterpriseEnabled()) {
|
return Result.error("由于企业微信接口调整,同步到本地功能已失效");
|
||||||
SyncInfoVo syncInfo = wechatEnterpriseService.syncThirdAppUserToLocal();
|
|
||||||
if (syncInfo.getFailInfo().size() == 0) {
|
// if (thirdAppConfig.isWechatEnterpriseEnabled()) {
|
||||||
return Result.OK("同步成功", syncInfo);
|
// SyncInfoVo syncInfo = wechatEnterpriseService.syncThirdAppUserToLocal();
|
||||||
} else {
|
// if (syncInfo.getFailInfo().size() == 0) {
|
||||||
return Result.error("同步失败", syncInfo);
|
// return Result.OK("同步成功", syncInfo);
|
||||||
}
|
// } else {
|
||||||
}
|
// return Result.error("同步失败", syncInfo);
|
||||||
return Result.error("企业微信同步功能已禁用");
|
// }
|
||||||
|
// }
|
||||||
|
// return Result.error("企业微信同步功能已禁用");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.jeecg.common.util.PasswordUtil;
|
||||||
import org.jeecg.common.util.RestUtil;
|
import org.jeecg.common.util.RestUtil;
|
||||||
import org.jeecg.common.util.SpringContextUtils;
|
import org.jeecg.common.util.SpringContextUtils;
|
||||||
import org.jeecg.common.util.oConvertUtils;
|
import org.jeecg.common.util.oConvertUtils;
|
||||||
|
import org.jeecg.config.JeecgBaseConfig;
|
||||||
import org.jeecg.config.thirdapp.ThirdAppConfig;
|
import org.jeecg.config.thirdapp.ThirdAppConfig;
|
||||||
import org.jeecg.modules.system.entity.*;
|
import org.jeecg.modules.system.entity.*;
|
||||||
import org.jeecg.modules.system.mapper.SysAnnouncementSendMapper;
|
import org.jeecg.modules.system.mapper.SysAnnouncementSendMapper;
|
||||||
|
@ -51,6 +52,8 @@ public class ThirdAppWechatEnterpriseServiceImpl implements IThirdAppService {
|
||||||
@Autowired
|
@Autowired
|
||||||
ThirdAppConfig thirdAppConfig;
|
ThirdAppConfig thirdAppConfig;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
JeecgBaseConfig jeecgBaseConfig;
|
||||||
|
@Autowired
|
||||||
private ISysDepartService sysDepartService;
|
private ISysDepartService sysDepartService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysUserMapper userMapper;
|
private SysUserMapper userMapper;
|
||||||
|
@ -302,7 +305,10 @@ public class ThirdAppWechatEnterpriseServiceImpl implements IThirdAppService {
|
||||||
return syncInfo;
|
return syncInfo;
|
||||||
}
|
}
|
||||||
// 获取企业微信所有的用户
|
// 获取企业微信所有的用户
|
||||||
List<User> qwUsers = JwUserAPI.getDetailUsersByDepartid("1", null, null, accessToken);
|
// List<User> qwUsers = JwUserAPI.getDetailUsersByDepartid("1", null, null, accessToken);
|
||||||
|
// 获取企业微信所有的用户(只能获取userid)
|
||||||
|
List<User> qwUsers = JwUserAPI.getUserIdList(accessToken);
|
||||||
|
|
||||||
if (qwUsers == null) {
|
if (qwUsers == null) {
|
||||||
syncInfo.addFailInfo("企业微信用户列表查询失败!");
|
syncInfo.addFailInfo("企业微信用户列表查询失败!");
|
||||||
return syncInfo;
|
return syncInfo;
|
||||||
|
@ -336,15 +342,16 @@ public class ThirdAppWechatEnterpriseServiceImpl implements IThirdAppService {
|
||||||
for (User qwUserTemp : qwUsers) {
|
for (User qwUserTemp : qwUsers) {
|
||||||
if (sysThirdAccount == null || oConvertUtils.isEmpty(sysThirdAccount.getThirdUserId()) || !sysThirdAccount.getThirdUserId().equals(qwUserTemp.getUserid())) {
|
if (sysThirdAccount == null || oConvertUtils.isEmpty(sysThirdAccount.getThirdUserId()) || !sysThirdAccount.getThirdUserId().equals(qwUserTemp.getUserid())) {
|
||||||
// sys_third_account 表匹配失败,尝试用手机号匹配
|
// sys_third_account 表匹配失败,尝试用手机号匹配
|
||||||
String phone = sysUser.getPhone();
|
// 新版企业微信调整了API,现在只能通过userid来判断是否同步过了
|
||||||
if (!(oConvertUtils.isEmpty(phone) || phone.equals(qwUserTemp.getMobile()))) {
|
// String phone = sysUser.getPhone();
|
||||||
|
// if (!(oConvertUtils.isEmpty(phone) || phone.equals(qwUserTemp.getMobile()))) {
|
||||||
// 手机号匹配失败,再尝试用username匹配
|
// 手机号匹配失败,再尝试用username匹配
|
||||||
String username = sysUser.getUsername();
|
String username = sysUser.getUsername();
|
||||||
if (!(oConvertUtils.isEmpty(username) || username.equals(qwUserTemp.getUserid()))) {
|
if (!(oConvertUtils.isEmpty(username) || username.equals(qwUserTemp.getUserid()))) {
|
||||||
// username 匹配失败,直接跳到下一次循环继续
|
// username 匹配失败,直接跳到下一次循环继续
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
// 循环到此说明用户匹配成功,进行更新操作
|
// 循环到此说明用户匹配成功,进行更新操作
|
||||||
qwUser = this.sysUserToQwUser(sysUser, qwUserTemp);
|
qwUser = this.sysUserToQwUser(sysUser, qwUserTemp);
|
||||||
|
@ -834,7 +841,18 @@ public class ThirdAppWechatEnterpriseServiceImpl implements IThirdAppService {
|
||||||
TextCardEntity entity = new TextCardEntity();
|
TextCardEntity entity = new TextCardEntity();
|
||||||
entity.setTitle(announcement.getTitile());
|
entity.setTitle(announcement.getTitile());
|
||||||
entity.setDescription(oConvertUtils.getString(announcement.getMsgAbstract(),"空"));
|
entity.setDescription(oConvertUtils.getString(announcement.getMsgAbstract(),"空"));
|
||||||
entity.setUrl(RestUtil.getBaseUrl() + "/sys/annountCement/show/" + announcement.getId());
|
String baseUrl = null;
|
||||||
|
|
||||||
|
//优先通过请求获取basepath,获取不到读取 jeecg.domainUrl.pc
|
||||||
|
try {
|
||||||
|
baseUrl = RestUtil.getBaseUrl();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn(e.getMessage());
|
||||||
|
baseUrl = jeecgBaseConfig.getDomainUrl().getPc();
|
||||||
|
//e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.setUrl(baseUrl + "/sys/annountCement/show/" + announcement.getId());
|
||||||
textCard.setTextcard(entity);
|
textCard.setTextcard(entity);
|
||||||
return JwMessageAPI.sendTextCardMessage(textCard, accessToken);
|
return JwMessageAPI.sendTextCardMessage(textCard, accessToken);
|
||||||
}
|
}
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -297,7 +297,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jeecgframework</groupId>
|
<groupId>org.jeecgframework</groupId>
|
||||||
<artifactId>jeewx-api</artifactId>
|
<artifactId>jeewx-api</artifactId>
|
||||||
<version>1.4.9</version>
|
<version>1.5.0</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<artifactId>commons-beanutils</artifactId>
|
<artifactId>commons-beanutils</artifactId>
|
||||||
|
|
Loading…
Reference in New Issue