mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-14 20:50:14 +08:00
v 3.2.0
This commit is contained in:
@@ -120,6 +120,7 @@ public class ActiveDirectoryOrganizationService extends AbstractSynchronizerSer
|
||||
org.setStreet(LdapUtils.getAttributeStringValue(OrganizationalUnit.STREET,attributeMap));
|
||||
org.setPostalCode(LdapUtils.getAttributeStringValue(OrganizationalUnit.POSTALCODE,attributeMap));
|
||||
org.setDescription(LdapUtils.getAttributeStringValue(OrganizationalUnit.DESCRIPTION,attributeMap));
|
||||
org.setInstId(this.synchronizer.getInstId());
|
||||
orgsNamePathMap.put(org.getNamePath(), org);
|
||||
_logger.info("org " + org);
|
||||
organizationsService.insert(org);
|
||||
|
||||
@@ -151,6 +151,7 @@ public class ActiveDirectoryUsersService extends AbstractSynchronizerService
|
||||
userInfo.setUserType("EMPLOYEE");
|
||||
userInfo.setTimeZone("Asia/Shanghai");
|
||||
userInfo.setStatus(1);
|
||||
userInfo.setInstId(this.synchronizer.getInstId());
|
||||
UserInfo quser=new UserInfo();
|
||||
quser.setUsername(userInfo.getUsername());
|
||||
UserInfo loadedUser=userInfoService.load(quser);
|
||||
|
||||
@@ -18,12 +18,10 @@
|
||||
package org.maxkey.synchronizer.dingding;
|
||||
|
||||
import org.maxkey.entity.Organizations;
|
||||
import org.maxkey.entity.Synchronizers;
|
||||
import org.maxkey.persistence.service.OrganizationsService;
|
||||
import org.maxkey.synchronizer.AbstractSynchronizerService;
|
||||
import org.maxkey.synchronizer.ISynchronizerService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.dingtalk.api.DefaultDingTalkClient;
|
||||
import com.dingtalk.api.DingTalkClient;
|
||||
@@ -33,14 +31,11 @@ import com.dingtalk.api.response.OapiV2DepartmentListsubResponse.DeptBaseRespons
|
||||
import com.taobao.api.ApiException;
|
||||
|
||||
@Service
|
||||
public class DingdingOrganizationService implements ISynchronizerService{
|
||||
public class DingdingOrganizationService extends AbstractSynchronizerService implements ISynchronizerService{
|
||||
final static Logger _logger = LoggerFactory.getLogger(DingdingOrganizationService.class);
|
||||
|
||||
OapiV2DepartmentListsubResponse rspDepts;
|
||||
|
||||
@Autowired
|
||||
OrganizationsService organizationsService;
|
||||
|
||||
String access_token;
|
||||
|
||||
public void sync() {
|
||||
@@ -78,6 +73,7 @@ public class DingdingOrganizationService implements ISynchronizerService{
|
||||
org.setId(dept.getDeptId()+"");
|
||||
org.setName(dept.getName());
|
||||
org.setParentId(dept.getParentId()+"");
|
||||
org.setInstId(this.synchronizer.getInstId());
|
||||
return org;
|
||||
}
|
||||
|
||||
@@ -94,19 +90,6 @@ public class DingdingOrganizationService implements ISynchronizerService{
|
||||
public OapiV2DepartmentListsubResponse getRspDepts() {
|
||||
return rspDepts;
|
||||
}
|
||||
|
||||
public OrganizationsService getOrganizationsService() {
|
||||
return organizationsService;
|
||||
}
|
||||
|
||||
public void setOrganizationsService(OrganizationsService organizationsService) {
|
||||
this.organizationsService = organizationsService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSynchronizer(Synchronizers Synchronizer) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -48,12 +48,13 @@ public class DingdingSynchronizerService implements ISynchronizerService{
|
||||
_logger.info("Sync ...");
|
||||
dingdingAccessTokenService.setAppkey(synchronizer.getPrincipal());
|
||||
dingdingAccessTokenService.setAppsecret(synchronizer.getCredentials());
|
||||
|
||||
String access_token=dingdingAccessTokenService.requestToken();
|
||||
|
||||
dingdingOrganizationService.setSynchronizer(synchronizer);
|
||||
dingdingOrganizationService.setAccess_token(access_token);
|
||||
dingdingOrganizationService.sync();
|
||||
|
||||
dingdingUsersService.setSynchronizer(synchronizer);
|
||||
dingdingUsersService.setAccess_token(access_token);
|
||||
dingdingUsersService.sync();
|
||||
}
|
||||
|
||||
@@ -19,9 +19,8 @@ package org.maxkey.synchronizer.dingding;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.maxkey.entity.Synchronizers;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.persistence.service.UserInfoService;
|
||||
import org.maxkey.synchronizer.AbstractSynchronizerService;
|
||||
import org.maxkey.synchronizer.ISynchronizerService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -36,14 +35,11 @@ import com.dingtalk.api.response.OapiV2DepartmentListsubResponse.DeptBaseRespons
|
||||
import com.dingtalk.api.response.OapiV2UserListResponse.ListUserResponse;
|
||||
|
||||
@Service
|
||||
public class DingdingUsersService implements ISynchronizerService{
|
||||
public class DingdingUsersService extends AbstractSynchronizerService implements ISynchronizerService{
|
||||
final static Logger _logger = LoggerFactory.getLogger(DingdingUsersService.class);
|
||||
|
||||
@Autowired
|
||||
DingdingOrganizationService organizationService;
|
||||
|
||||
@Autowired
|
||||
UserInfoService userInfoService;
|
||||
DingdingOrganizationService dingdingOrganizationService;
|
||||
|
||||
String access_token;
|
||||
|
||||
@@ -51,7 +47,7 @@ public class DingdingUsersService implements ISynchronizerService{
|
||||
_logger.info("Sync Users...");
|
||||
try {
|
||||
|
||||
OapiV2DepartmentListsubResponse rspDepts = organizationService.getRspDepts();
|
||||
OapiV2DepartmentListsubResponse rspDepts = dingdingOrganizationService.getRspDepts();
|
||||
for(DeptBaseResponse dept : rspDepts.getResult()) {
|
||||
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/list");
|
||||
OapiV2UserListRequest req = new OapiV2UserListRequest();
|
||||
@@ -101,35 +97,19 @@ public class DingdingUsersService implements ISynchronizerService{
|
||||
userInfo.setWorkPhoneNumber(user.getTelephone());//鍏徃鐢佃瘽
|
||||
userInfo.setWorkOfficeName(user.getWorkPlace());//鍔炲叕瀹<E58F95>
|
||||
userInfo.setDescription(user.getRemark());//澶囨敞
|
||||
|
||||
userInfo.setInstId(this.synchronizer.getInstId());
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
public void setOrganizationService(DingdingOrganizationService organizationService) {
|
||||
this.organizationService = organizationService;
|
||||
}
|
||||
|
||||
|
||||
public void setAccess_token(String access_token) {
|
||||
this.access_token = access_token;
|
||||
}
|
||||
|
||||
public UserInfoService getUserInfoService() {
|
||||
return userInfoService;
|
||||
}
|
||||
|
||||
public void setUserInfoService(UserInfoService userInfoService) {
|
||||
this.userInfoService = userInfoService;
|
||||
}
|
||||
|
||||
public DingdingOrganizationService getOrganizationService() {
|
||||
return organizationService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSynchronizer(Synchronizers Synchronizer) {
|
||||
|
||||
public void setDingdingOrganizationService(DingdingOrganizationService dingdingOrganizationService) {
|
||||
this.dingdingOrganizationService = dingdingOrganizationService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ public class LdapOrganizationService extends AbstractSynchronizerService implem
|
||||
org.setPhone(LdapUtils.getAttributeStringValue(OrganizationalUnit.TELEPHONENUMBER,attributeMap));
|
||||
org.setFax(LdapUtils.getAttributeStringValue(OrganizationalUnit.FACSIMILETELEPHONENUMBER,attributeMap));
|
||||
org.setDescription(LdapUtils.getAttributeStringValue(OrganizationalUnit.DESCRIPTION,attributeMap));
|
||||
org.setInstId(this.synchronizer.getInstId());
|
||||
orgsNamePathMap.put(org.getNamePath(), org);
|
||||
_logger.info("org " + org);
|
||||
organizationsService.insert(org);
|
||||
|
||||
@@ -49,6 +49,7 @@ public class LdapSynchronizerService implements ISynchronizerService{
|
||||
synchronizer.getCredentials(),
|
||||
synchronizer.getBasedn());
|
||||
ldapUtils.openConnection();
|
||||
|
||||
ldapOrganizationService.setSynchronizer(synchronizer);
|
||||
ldapUsersService.setSynchronizer(synchronizer);
|
||||
|
||||
@@ -58,6 +59,7 @@ public class LdapSynchronizerService implements ISynchronizerService{
|
||||
|
||||
ldapOrganizationService.sync();
|
||||
ldapUsersService.sync();
|
||||
|
||||
ldapUtils.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -138,6 +138,7 @@ public class LdapUsersService extends AbstractSynchronizerService implements IS
|
||||
userInfo.setUserType("EMPLOYEE");
|
||||
userInfo.setTimeZone("Asia/Shanghai");
|
||||
userInfo.setStatus(1);
|
||||
userInfo.setInstId(this.synchronizer.getInstId());
|
||||
UserInfo quser=new UserInfo();
|
||||
quser.setUsername(userInfo.getUsername());
|
||||
UserInfo loadedUser=userInfoService.load(quser);
|
||||
|
||||
@@ -40,6 +40,7 @@ public class ReorgDeptSynchronizerService implements ISynchronizerService {
|
||||
|
||||
public void sync() throws Exception {
|
||||
_logger.info("Sync ...");
|
||||
reorgDeptService.setSynchronizer(synchronizer);
|
||||
reorgDeptService.sync();
|
||||
|
||||
}
|
||||
|
||||
@@ -22,22 +22,16 @@ import java.util.List;
|
||||
|
||||
import org.maxkey.constants.ConstantsStatus;
|
||||
import org.maxkey.entity.Organizations;
|
||||
import org.maxkey.entity.Synchronizers;
|
||||
import org.maxkey.persistence.service.OrganizationsService;
|
||||
import org.maxkey.synchronizer.AbstractSynchronizerService;
|
||||
import org.maxkey.synchronizer.ISynchronizerService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ReorgDeptService implements ISynchronizerService{
|
||||
public class ReorgDeptService extends AbstractSynchronizerService implements ISynchronizerService{
|
||||
final static Logger _logger = LoggerFactory.getLogger(ReorgDeptService.class);
|
||||
|
||||
@Autowired
|
||||
OrganizationsService organizationsService;
|
||||
|
||||
|
||||
|
||||
String rootParentOrgId = "-1";
|
||||
|
||||
public void sync() {
|
||||
@@ -46,7 +40,9 @@ public class ReorgDeptService implements ISynchronizerService{
|
||||
try {
|
||||
long responseCount =0;
|
||||
HashMap<String,Organizations>orgCastMap =new HashMap<String,Organizations>();
|
||||
List<Organizations> listOrg = organizationsService.findAll();
|
||||
Organizations queryOrganization =new Organizations();
|
||||
queryOrganization.setInstId(this.synchronizer.getInstId());
|
||||
List<Organizations> listOrg = organizationsService.query(queryOrganization);
|
||||
|
||||
buildNamePath(orgCastMap,listOrg);
|
||||
|
||||
@@ -104,18 +100,4 @@ public class ReorgDeptService implements ISynchronizerService{
|
||||
}while(listOrg.size()>listOrg.size());
|
||||
}
|
||||
|
||||
public OrganizationsService getOrganizationsService() {
|
||||
return organizationsService;
|
||||
}
|
||||
|
||||
public void setOrganizationsService(OrganizationsService organizationsService) {
|
||||
this.organizationsService = organizationsService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSynchronizer(Synchronizers synchronizer) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
package org.maxkey.synchronizer.workweixin;
|
||||
|
||||
import org.maxkey.entity.Organizations;
|
||||
import org.maxkey.entity.Synchronizers;
|
||||
import org.maxkey.persistence.service.OrganizationsService;
|
||||
import org.maxkey.synchronizer.AbstractSynchronizerService;
|
||||
import org.maxkey.synchronizer.ISynchronizerService;
|
||||
import org.maxkey.synchronizer.workweixin.entity.WorkWeixinDepts;
|
||||
import org.maxkey.synchronizer.workweixin.entity.WorkWeixinDeptsResponse;
|
||||
@@ -27,16 +26,12 @@ import org.maxkey.util.JsonUtils;
|
||||
import org.maxkey.web.HttpRequestAdapter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class WorkweixinOrganizationService implements ISynchronizerService{
|
||||
public class WorkweixinOrganizationService extends AbstractSynchronizerService implements ISynchronizerService{
|
||||
final static Logger _logger = LoggerFactory.getLogger(WorkweixinOrganizationService.class);
|
||||
|
||||
@Autowired
|
||||
OrganizationsService organizationsService;
|
||||
|
||||
WorkWeixinDeptsResponse deptsResponse;
|
||||
|
||||
String access_token;
|
||||
@@ -77,6 +72,7 @@ public class WorkweixinOrganizationService implements ISynchronizerService{
|
||||
org.setName(dept.getName());
|
||||
org.setParentId(dept.getParentid()+"");
|
||||
org.setSortIndex(dept.getOrder());
|
||||
org.setInstId(this.synchronizer.getInstId());
|
||||
return org;
|
||||
}
|
||||
|
||||
@@ -96,18 +92,4 @@ public class WorkweixinOrganizationService implements ISynchronizerService{
|
||||
this.deptsResponse = deptsResponse;
|
||||
}
|
||||
|
||||
public OrganizationsService getOrganizationsService() {
|
||||
return organizationsService;
|
||||
}
|
||||
|
||||
public void setOrganizationsService(OrganizationsService organizationsService) {
|
||||
this.organizationsService = organizationsService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSynchronizer(Synchronizers synchronizer) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,9 +48,11 @@ public class WorkweixinSynchronizerService implements ISynchronizerService{
|
||||
workweixinAccessTokenService.setCorpsecret(synchronizer.getCredentials());
|
||||
String access_token=workweixinAccessTokenService.requestToken();
|
||||
|
||||
workweixinOrganizationService.setSynchronizer(synchronizer);
|
||||
workweixinOrganizationService.setAccess_token(access_token);
|
||||
workweixinOrganizationService.sync();
|
||||
|
||||
workweixinUsersService.setSynchronizer(synchronizer);
|
||||
workweixinUsersService.setAccess_token(access_token);
|
||||
workweixinUsersService.sync();
|
||||
}
|
||||
|
||||
@@ -17,9 +17,8 @@
|
||||
|
||||
package org.maxkey.synchronizer.workweixin;
|
||||
|
||||
import org.maxkey.entity.Synchronizers;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.persistence.service.UserInfoService;
|
||||
import org.maxkey.synchronizer.AbstractSynchronizerService;
|
||||
import org.maxkey.synchronizer.ISynchronizerService;
|
||||
import org.maxkey.synchronizer.workweixin.entity.WorkWeixinDepts;
|
||||
import org.maxkey.synchronizer.workweixin.entity.WorkWeixinUsers;
|
||||
@@ -32,14 +31,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class WorkweixinUsersService implements ISynchronizerService{
|
||||
public class WorkweixinUsersService extends AbstractSynchronizerService implements ISynchronizerService{
|
||||
final static Logger _logger = LoggerFactory.getLogger(WorkweixinUsersService.class);
|
||||
|
||||
@Autowired
|
||||
WorkweixinOrganizationService organizationService;
|
||||
|
||||
@Autowired
|
||||
UserInfoService userInfoService;
|
||||
WorkweixinOrganizationService workweixinOrganizationService;
|
||||
|
||||
String access_token;
|
||||
|
||||
@@ -49,7 +45,7 @@ public class WorkweixinUsersService implements ISynchronizerService{
|
||||
_logger.info("Sync Users...");
|
||||
try {
|
||||
|
||||
for (WorkWeixinDepts dept : organizationService.getDeptsResponse().getDepartment()) {
|
||||
for (WorkWeixinDepts dept : workweixinOrganizationService.getDeptsResponse().getDepartment()) {
|
||||
HttpRequestAdapter request =new HttpRequestAdapter();
|
||||
String responseBody = request.get(String.format(USERS_URL, access_token,dept.getId()));
|
||||
WorkWeixinUsersResponse usersResponse =JsonUtils.gson2Object(responseBody, WorkWeixinUsersResponse.class);
|
||||
@@ -88,35 +84,17 @@ public class WorkweixinUsersService implements ISynchronizerService{
|
||||
|
||||
//激活状态: 1=已激活,2=已禁用,4=未激活,5=退出企业。
|
||||
userInfo.setStatus(user.getStatus());
|
||||
|
||||
userInfo.setInstId(this.synchronizer.getInstId());
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
public void setOrganizationService(WorkweixinOrganizationService organizationService) {
|
||||
this.organizationService = organizationService;
|
||||
}
|
||||
|
||||
public void setAccess_token(String access_token) {
|
||||
this.access_token = access_token;
|
||||
}
|
||||
|
||||
public UserInfoService getUserInfoService() {
|
||||
return userInfoService;
|
||||
public void setWorkweixinOrganizationService(WorkweixinOrganizationService workweixinOrganizationService) {
|
||||
this.workweixinOrganizationService = workweixinOrganizationService;
|
||||
}
|
||||
|
||||
public void setUserInfoService(UserInfoService userInfoService) {
|
||||
this.userInfoService = userInfoService;
|
||||
}
|
||||
|
||||
public WorkweixinOrganizationService getOrganizationService() {
|
||||
return organizationService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSynchronizer(Synchronizers Synchronizer) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user