|
@@ -7,6 +7,7 @@ import com.liangjiang11.wx.cp.service.QiyeUsersService;
|
|
|
import com.liangjiang11.wx.cp.utils.FiltersData;
|
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
import me.chanjar.weixin.cp.api.WxCpDepartmentService;
|
|
|
+import me.chanjar.weixin.cp.api.WxCpExternalContactService;
|
|
|
import me.chanjar.weixin.cp.api.WxCpService;
|
|
|
import me.chanjar.weixin.cp.api.WxCpUserService;
|
|
|
import me.chanjar.weixin.cp.bean.WxCpDepart;
|
|
@@ -97,22 +98,38 @@ public class QiyeUsersServiceImpl implements QiyeUsersService {
|
|
|
|
|
|
@Override
|
|
|
public void syncUser(String corpid, WxCpService wxCpService) throws WxErrorException {
|
|
|
+ WxCpExternalContactService externalContactService = wxCpService.getExternalContactService();
|
|
|
WxCpUserService userService = wxCpService.getUserService();
|
|
|
- List<WxCpUser> wxCpUserList = userService.listByDepartment(1L, true, null);
|
|
|
|
|
|
- for (WxCpUser wxCpUser : wxCpUserList) {
|
|
|
- String userid = wxCpUser.getUserId();
|
|
|
+
|
|
|
+ List<String> useridList = externalContactService.listFollowUser();
|
|
|
+ for (String userid : useridList) {
|
|
|
QueryWrapper<Users> wrapper = new QueryWrapper<>();
|
|
|
wrapper.eq("corpid", corpid);
|
|
|
wrapper.eq("userid", userid);
|
|
|
Integer count = usersMapper.selectCount(wrapper);
|
|
|
|
|
|
- Users users = new Users(wxCpUser, corpid);
|
|
|
if(count==0){
|
|
|
+ WxCpUser wxCpUser = userService.getById(userid);
|
|
|
+ Users users = new Users(wxCpUser, corpid);
|
|
|
usersMapper.insert(users);
|
|
|
- }else{
|
|
|
- usersMapper.update(users, wrapper);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// List<WxCpUser> wxCpUserList = userService.listByDepartment(1L, true, null);
|
|
|
+// for (WxCpUser wxCpUser : wxCpUserList) {
|
|
|
+// String userid = wxCpUser.getUserId();
|
|
|
+// QueryWrapper<Users> wrapper = new QueryWrapper<>();
|
|
|
+// wrapper.eq("corpid", corpid);
|
|
|
+// wrapper.eq("userid", userid);
|
|
|
+// Integer count = usersMapper.selectCount(wrapper);
|
|
|
+//
|
|
|
+// Users users = new Users(wxCpUser, corpid);
|
|
|
+// if(count==0){
|
|
|
+// usersMapper.insert(users);
|
|
|
+// }else{
|
|
|
+// usersMapper.update(users, wrapper);
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
}
|