提交 c230ca78 编写于 作者: M MaxKey

synchronizers

上级 d4ca0408
...@@ -67,9 +67,9 @@ public class ActiveDirectoryOrganizationService extends AbstractSynchronizerSer ...@@ -67,9 +67,9 @@ public class ActiveDirectoryOrganizationService extends AbstractSynchronizerSer
attributeMap.put(objAttrs.getID().toLowerCase(), objAttrs); attributeMap.put(objAttrs.getID().toLowerCase(), objAttrs);
} }
Organizations org = buildOrganization(attributeMap,si.getName(),si.getNameInNamespace()); Organizations organization = buildOrganization(attributeMap,si.getName(),si.getNameInNamespace());
organizationsService.saveOrUpdate(organization);
_logger.info("Organizations " + org); _logger.info("Organizations " + organization);
} }
} }
......
...@@ -70,7 +70,8 @@ public class ActiveDirectoryUsersService extends AbstractSynchronizerService ...@@ -70,7 +70,8 @@ public class ActiveDirectoryUsersService extends AbstractSynchronizerService
UserInfo userInfo =buildUserInfo(attributeMap,si.getName(),si.getNameInNamespace()); UserInfo userInfo =buildUserInfo(attributeMap,si.getName(),si.getNameInNamespace());
userInfo.setPassword(userInfo.getUsername() + "Maxkey@888");
userInfoService.saveOrUpdate(userInfo);
_logger.info("userInfo " + userInfo); _logger.info("userInfo " + userInfo);
} }
} }
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
package org.maxkey.synchronizer.dingtalk; package org.maxkey.synchronizer.dingtalk;
import java.sql.Types;
import java.util.HashMap; import java.util.HashMap;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
...@@ -56,13 +55,7 @@ public class DingtalkOrganizationService extends AbstractSynchronizerService im ...@@ -56,13 +55,7 @@ public class DingtalkOrganizationService extends AbstractSynchronizerService im
deptsQueue.add(dept.getDeptId()); deptsQueue.add(dept.getDeptId());
deptMap.put(dept.getDeptId(), dept); deptMap.put(dept.getDeptId(), dept);
Organizations organization = buildOrganization(dept,deptMap.get(dept.getParentId())); Organizations organization = buildOrganization(dept,deptMap.get(dept.getParentId()));
if(organizationsService.findOne("id = ? and instid = ?", organizationsService.saveOrUpdate(organization);
new Object[] { organization.getId().toString(), organization.getInstId() },
new int[] { Types.VARCHAR, Types.VARCHAR }) == null) {
organizationsService.insert(organization);
}else {
organizationsService.update(organization);
}
_logger.info("Organizations : " + organization); _logger.info("Organizations : " + organization);
} }
} }
......
...@@ -68,14 +68,8 @@ public class DingtalkUsersService extends AbstractSynchronizerService implement ...@@ -68,14 +68,8 @@ public class DingtalkUsersService extends AbstractSynchronizerService implement
_logger.info("name : " + user.getName()+" , "+user.getLoginId()+" , "+user.getUserid()); _logger.info("name : " + user.getName()+" , "+user.getLoginId()+" , "+user.getUserid());
UserInfo userInfo = buildUserInfo(user); UserInfo userInfo = buildUserInfo(user);
_logger.info("userInfo " + userInfo); _logger.info("userInfo " + userInfo);
if(userInfoService.findOne("username = ? and instid = ?", userInfo.setPassword(userInfo.getUsername() + "Maxkey@888");
new Object[] { userInfo.getUsername(),this.getSynchronizer().getInstId() }, userInfoService.saveOrUpdate(userInfo);
new int[] { Types.VARCHAR,Types.VARCHAR}) == null) {
userInfo.setPassword(userInfo.getUsername() + "Maxkey@888");
this.userInfoService.insert(userInfo);
}else {
userInfoService.update(userInfo);
}
} }
} }
......
...@@ -67,9 +67,9 @@ public class LdapOrganizationService extends AbstractSynchronizerService implem ...@@ -67,9 +67,9 @@ public class LdapOrganizationService extends AbstractSynchronizerService implem
attributeMap.put(objAttrs.getID().toLowerCase(), objAttrs); attributeMap.put(objAttrs.getID().toLowerCase(), objAttrs);
} }
Organizations org = buildOrganization(attributeMap,si.getName(),si.getNameInNamespace()); Organizations organization = buildOrganization(attributeMap,si.getName(),si.getNameInNamespace());
organizationsService.saveOrUpdate(organization);
_logger.info("Organizations " + org); _logger.info("Organizations " + organization);
} }
} }
......
...@@ -65,6 +65,8 @@ public class LdapUsersService extends AbstractSynchronizerService implements IS ...@@ -65,6 +65,8 @@ public class LdapUsersService extends AbstractSynchronizerService implements IS
} }
UserInfo userInfo = buildUserInfo(attributeMap,si.getName(),si.getNameInNamespace()); UserInfo userInfo = buildUserInfo(attributeMap,si.getName(),si.getNameInNamespace());
userInfo.setPassword(userInfo.getUsername() + "Maxkey@888");
userInfoService.saveOrUpdate(userInfo);
_logger.info("userInfo " + userInfo); _logger.info("userInfo " + userInfo);
} }
} }
......
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
package org.maxkey.synchronizer.workweixin; package org.maxkey.synchronizer.workweixin;
import java.sql.Types;
import org.maxkey.constants.ConstsStatus; import org.maxkey.constants.ConstsStatus;
import org.maxkey.entity.Organizations; import org.maxkey.entity.Organizations;
import org.maxkey.synchronizer.AbstractSynchronizerService; import org.maxkey.synchronizer.AbstractSynchronizerService;
...@@ -48,13 +46,7 @@ public class WorkweixinOrganizationService extends AbstractSynchronizerService i ...@@ -48,13 +46,7 @@ public class WorkweixinOrganizationService extends AbstractSynchronizerService i
for(WorkWeixinDepts dept : rsp.getDepartment()) { for(WorkWeixinDepts dept : rsp.getDepartment()) {
_logger.info("dept : " + dept.getId()+" "+ dept.getName()+" "+ dept.getParentid()); _logger.info("dept : " + dept.getId()+" "+ dept.getName()+" "+ dept.getParentid());
Organizations organization = buildOrganization(dept); Organizations organization = buildOrganization(dept);
if(organizationsService.findOne("id = ? and instid = ?", organizationsService.saveOrUpdate(organization);
new Object[] { organization.getId(), organization.getInstId() },
new int[] { Types.VARCHAR, Types.VARCHAR }) == null) {
organizationsService.insert(organization);
}else {
organizationsService.update(organization);
}
} }
} catch (Exception e) { } catch (Exception e) {
......
...@@ -56,14 +56,8 @@ public class WorkweixinUsersService extends AbstractSynchronizerService implemen ...@@ -56,14 +56,8 @@ public class WorkweixinUsersService extends AbstractSynchronizerService implemen
for(WorkWeixinUsers user : usersResponse.getUserlist()) { for(WorkWeixinUsers user : usersResponse.getUserlist()) {
UserInfo userInfo = buildUserInfo(user); UserInfo userInfo = buildUserInfo(user);
_logger.info("userInfo : " + userInfo); _logger.info("userInfo : " + userInfo);
if(userInfoService.findOne("username = ? and instid = ?", userInfo.setPassword(userInfo.getUsername() + "Maxkey@888");
new Object[] { userInfo.getUsername(),this.getSynchronizer().getInstId() }, userInfoService.saveOrUpdate(userInfo);
new int[] { Types.VARCHAR,Types.VARCHAR}) == null) {
userInfo.setPassword(userInfo.getUsername() + "Maxkey@888");
this.userInfoService.insert(userInfo);
}else {
userInfoService.update(userInfo);
}
} }
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.maxkey.persistence.service; package org.maxkey.persistence.service;
import java.sql.Types;
import java.util.List; import java.util.List;
import org.apache.mybatis.jpa.persistence.JpaBaseService; import org.apache.mybatis.jpa.persistence.JpaBaseService;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
...@@ -66,6 +67,15 @@ public class OrganizationsService extends JpaBaseService<Organizations>{ ...@@ -66,6 +67,15 @@ public class OrganizationsService extends JpaBaseService<Organizations>{
return false; 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){ public List<Organizations> queryOrgs(Organizations organization){
return getMapper().queryOrgs(organization); return getMapper().queryOrgs(organization);
} }
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
package org.maxkey.persistence.service; package org.maxkey.persistence.service;
import java.sql.Types;
import org.apache.mybatis.jpa.persistence.JpaBaseService; import org.apache.mybatis.jpa.persistence.JpaBaseService;
import org.maxkey.constants.ConstsStatus; import org.maxkey.constants.ConstsStatus;
import org.maxkey.crypto.password.PasswordReciprocal; import org.maxkey.crypto.password.PasswordReciprocal;
...@@ -163,6 +165,17 @@ public class UserInfoService extends JpaBaseService<UserInfo> { ...@@ -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) { public boolean updateProtectedApps(UserInfo userinfo) {
try { try {
if(WebContext.getUserInfo() != null) { if(WebContext.getUserInfo() != null) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册