mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-06 17:08:29 +08:00
synchronizers
This commit is contained in:
parent
d4ca040849
commit
c230ca7877
@ -67,9 +67,9 @@ public class ActiveDirectoryOrganizationService extends AbstractSynchronizerSer
|
||||
attributeMap.put(objAttrs.getID().toLowerCase(), objAttrs);
|
||||
}
|
||||
|
||||
Organizations org = buildOrganization(attributeMap,si.getName(),si.getNameInNamespace());
|
||||
|
||||
_logger.info("Organizations " + org);
|
||||
Organizations organization = buildOrganization(attributeMap,si.getName(),si.getNameInNamespace());
|
||||
organizationsService.saveOrUpdate(organization);
|
||||
_logger.info("Organizations " + organization);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -70,7 +70,8 @@ public class ActiveDirectoryUsersService extends AbstractSynchronizerService
|
||||
|
||||
UserInfo userInfo =buildUserInfo(attributeMap,si.getName(),si.getNameInNamespace());
|
||||
|
||||
|
||||
userInfo.setPassword(userInfo.getUsername() + "Maxkey@888");
|
||||
userInfoService.saveOrUpdate(userInfo);
|
||||
_logger.info("userInfo " + userInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
|
||||
package org.maxkey.synchronizer.dingtalk;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.HashMap;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
@ -56,13 +55,7 @@ public class DingtalkOrganizationService extends AbstractSynchronizerService im
|
||||
deptsQueue.add(dept.getDeptId());
|
||||
deptMap.put(dept.getDeptId(), dept);
|
||||
Organizations organization = buildOrganization(dept,deptMap.get(dept.getParentId()));
|
||||
if(organizationsService.findOne("id = ? and instid = ?",
|
||||
new Object[] { organization.getId().toString(), organization.getInstId() },
|
||||
new int[] { Types.VARCHAR, Types.VARCHAR }) == null) {
|
||||
organizationsService.insert(organization);
|
||||
}else {
|
||||
organizationsService.update(organization);
|
||||
}
|
||||
organizationsService.saveOrUpdate(organization);
|
||||
_logger.info("Organizations : " + organization);
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,14 +68,8 @@ public class DingtalkUsersService extends AbstractSynchronizerService implement
|
||||
_logger.info("name : " + user.getName()+" , "+user.getLoginId()+" , "+user.getUserid());
|
||||
UserInfo userInfo = buildUserInfo(user);
|
||||
_logger.info("userInfo " + userInfo);
|
||||
if(userInfoService.findOne("username = ? and instid = ?",
|
||||
new Object[] { userInfo.getUsername(),this.getSynchronizer().getInstId() },
|
||||
new int[] { Types.VARCHAR,Types.VARCHAR}) == null) {
|
||||
userInfo.setPassword(userInfo.getUsername() + "Maxkey@888");
|
||||
this.userInfoService.insert(userInfo);
|
||||
}else {
|
||||
userInfoService.update(userInfo);
|
||||
}
|
||||
userInfo.setPassword(userInfo.getUsername() + "Maxkey@888");
|
||||
userInfoService.saveOrUpdate(userInfo);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,9 +67,9 @@ public class LdapOrganizationService extends AbstractSynchronizerService implem
|
||||
attributeMap.put(objAttrs.getID().toLowerCase(), objAttrs);
|
||||
}
|
||||
|
||||
Organizations org = buildOrganization(attributeMap,si.getName(),si.getNameInNamespace());
|
||||
|
||||
_logger.info("Organizations " + org);
|
||||
Organizations organization = buildOrganization(attributeMap,si.getName(),si.getNameInNamespace());
|
||||
organizationsService.saveOrUpdate(organization);
|
||||
_logger.info("Organizations " + organization);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -65,6 +65,8 @@ public class LdapUsersService extends AbstractSynchronizerService implements IS
|
||||
}
|
||||
|
||||
UserInfo userInfo = buildUserInfo(attributeMap,si.getName(),si.getNameInNamespace());
|
||||
userInfo.setPassword(userInfo.getUsername() + "Maxkey@888");
|
||||
userInfoService.saveOrUpdate(userInfo);
|
||||
_logger.info("userInfo " + userInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,8 +17,6 @@
|
||||
|
||||
package org.maxkey.synchronizer.workweixin;
|
||||
|
||||
import java.sql.Types;
|
||||
|
||||
import org.maxkey.constants.ConstsStatus;
|
||||
import org.maxkey.entity.Organizations;
|
||||
import org.maxkey.synchronizer.AbstractSynchronizerService;
|
||||
@ -48,13 +46,7 @@ public class WorkweixinOrganizationService extends AbstractSynchronizerService i
|
||||
for(WorkWeixinDepts dept : rsp.getDepartment()) {
|
||||
_logger.info("dept : " + dept.getId()+" "+ dept.getName()+" "+ dept.getParentid());
|
||||
Organizations organization = buildOrganization(dept);
|
||||
if(organizationsService.findOne("id = ? and instid = ?",
|
||||
new Object[] { organization.getId(), organization.getInstId() },
|
||||
new int[] { Types.VARCHAR, Types.VARCHAR }) == null) {
|
||||
organizationsService.insert(organization);
|
||||
}else {
|
||||
organizationsService.update(organization);
|
||||
}
|
||||
organizationsService.saveOrUpdate(organization);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
@ -56,14 +56,8 @@ public class WorkweixinUsersService extends AbstractSynchronizerService implemen
|
||||
for(WorkWeixinUsers user : usersResponse.getUserlist()) {
|
||||
UserInfo userInfo = buildUserInfo(user);
|
||||
_logger.info("userInfo : " + userInfo);
|
||||
if(userInfoService.findOne("username = ? and instid = ?",
|
||||
new Object[] { userInfo.getUsername(),this.getSynchronizer().getInstId() },
|
||||
new int[] { Types.VARCHAR,Types.VARCHAR}) == null) {
|
||||
userInfo.setPassword(userInfo.getUsername() + "Maxkey@888");
|
||||
this.userInfoService.insert(userInfo);
|
||||
}else {
|
||||
userInfoService.update(userInfo);
|
||||
}
|
||||
userInfo.setPassword(userInfo.getUsername() + "Maxkey@888");
|
||||
userInfoService.saveOrUpdate(userInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
|
||||
package org.maxkey.persistence.service;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.List;
|
||||
import org.apache.mybatis.jpa.persistence.JpaBaseService;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
@ -66,6 +67,15 @@ public class OrganizationsService extends JpaBaseService<Organizations>{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void saveOrUpdate(Organizations organization) {
|
||||
if(findOne(" id = ? and instid = ?",
|
||||
new Object[] { organization.getId().toString(), organization.getInstId() },
|
||||
new int[] { Types.VARCHAR, Types.VARCHAR }) == null) {
|
||||
insert(organization);
|
||||
}else {
|
||||
update(organization);
|
||||
}
|
||||
}
|
||||
public List<Organizations> queryOrgs(Organizations organization){
|
||||
return getMapper().queryOrgs(organization);
|
||||
}
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
package org.maxkey.persistence.service;
|
||||
|
||||
|
||||
import java.sql.Types;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.JpaBaseService;
|
||||
import org.maxkey.constants.ConstsStatus;
|
||||
import org.maxkey.crypto.password.PasswordReciprocal;
|
||||
@ -163,6 +165,17 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
|
||||
}
|
||||
|
||||
|
||||
public void saveOrUpdate(UserInfo userInfo) {
|
||||
if(findOne(" username = ? and instid = ?",
|
||||
new Object[] { userInfo.getUsername(),userInfo.getInstId() },
|
||||
new int[] { Types.VARCHAR,Types.VARCHAR}) == null) {
|
||||
insert(userInfo);
|
||||
}else {
|
||||
userInfo.setPassword(null);
|
||||
update(userInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean updateProtectedApps(UserInfo userinfo) {
|
||||
try {
|
||||
if(WebContext.getUserInfo() != null) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user