diff --git a/maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/OrganizationsService.java b/maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/OrganizationsService.java index 62b4b8bd..1a08fd28 100644 --- a/maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/OrganizationsService.java +++ b/maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/OrganizationsService.java @@ -57,6 +57,7 @@ public class OrganizationsService extends JpaService{ return (OrganizationsMapper)super.getMapper(); } + @Override public boolean insert(Organizations organization) { if(super.insert(organization)){ provisionService.send( @@ -66,6 +67,7 @@ public class OrganizationsService extends JpaService{ return false; } + @Override public boolean update(Organizations organization) { if(super.update(organization)){ provisionService.send( @@ -77,7 +79,7 @@ public class OrganizationsService extends JpaService{ public void saveOrUpdate(Organizations organization) { Organizations loadOrg =findOne(" id = ? and instid = ?", - new Object[] { organization.getId().toString(), organization.getInstId() }, + new Object[] { organization.getId(), organization.getInstId() }, new int[] { Types.VARCHAR, Types.VARCHAR }); if( loadOrg == null) { insert(organization); @@ -90,6 +92,7 @@ public class OrganizationsService extends JpaService{ return getMapper().queryOrgs(organization); } + @Override public boolean delete(Organizations organization) { if(super.delete(organization)){ provisionService.send( @@ -137,14 +140,13 @@ public class OrganizationsService extends JpaService{ } public static boolean isRootOrg(Organizations rootOrg){ - if(rootOrg.getParentId() == null + return ( + rootOrg.getParentId() == null || rootOrg.getParentId().equalsIgnoreCase("-1") || rootOrg.getParentId().equalsIgnoreCase("0") || rootOrg.getParentId().equalsIgnoreCase(rootOrg.getId()) - || rootOrg.getParentId().equalsIgnoreCase(rootOrg.getInstId())) { - return true; - } - return false; + || rootOrg.getParentId().equalsIgnoreCase(rootOrg.getInstId()) + ); } void reorg(HashMap orgMap, List orgList,Organizations rootOrg) { diff --git a/maxkey-synchronizers/maxkey-synchronizer-reorgdept/src/main/java/org/dromara/maxkey/synchronizer/reorg/ReorgDeptSynchronizerService.java b/maxkey-synchronizers/maxkey-synchronizer-reorgdept/src/main/java/org/dromara/maxkey/synchronizer/reorg/ReorgDeptSynchronizerService.java index 4c3ad734..f6510912 100644 --- a/maxkey-synchronizers/maxkey-synchronizer-reorgdept/src/main/java/org/dromara/maxkey/synchronizer/reorg/ReorgDeptSynchronizerService.java +++ b/maxkey-synchronizers/maxkey-synchronizer-reorgdept/src/main/java/org/dromara/maxkey/synchronizer/reorg/ReorgDeptSynchronizerService.java @@ -19,7 +19,7 @@ package org.dromara.maxkey.synchronizer.reorg; import org.dromara.maxkey.entity.Synchronizers; import org.dromara.maxkey.synchronizer.ISynchronizerService; -import org.dromara.maxkey.synchronizer.workweixin.service.ReorgDeptService; +import org.dromara.maxkey.synchronizer.reorg.service.ReorgDeptService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -27,7 +27,7 @@ import org.springframework.stereotype.Service; @Service public class ReorgDeptSynchronizerService implements ISynchronizerService { - final static Logger _logger = LoggerFactory.getLogger(ReorgDeptSynchronizerService.class); + static final Logger _logger = LoggerFactory.getLogger(ReorgDeptSynchronizerService.class); Synchronizers synchronizer; @Autowired diff --git a/maxkey-synchronizers/maxkey-synchronizer-reorgdept/src/main/java/org/dromara/maxkey/synchronizer/reorg/service/ReorgDeptService.java b/maxkey-synchronizers/maxkey-synchronizer-reorgdept/src/main/java/org/dromara/maxkey/synchronizer/reorg/service/ReorgDeptService.java new file mode 100644 index 00000000..d7325b30 --- /dev/null +++ b/maxkey-synchronizers/maxkey-synchronizer-reorgdept/src/main/java/org/dromara/maxkey/synchronizer/reorg/service/ReorgDeptService.java @@ -0,0 +1,36 @@ +/* + * Copyright [2021] [MaxKey of copyright http://www.maxkey.top] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.dromara.maxkey.synchronizer.reorg.service; + +import org.dromara.maxkey.synchronizer.AbstractSynchronizerService; +import org.dromara.maxkey.synchronizer.ISynchronizerService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +@Service +public class ReorgDeptService extends AbstractSynchronizerService implements ISynchronizerService{ + static final Logger _logger = LoggerFactory.getLogger(ReorgDeptService.class); + + public void sync() { + _logger.info("Sync Organizations ..."); + organizationsService.reorgNamePath(this.synchronizer.getInstId()); + + } + +} diff --git a/maxkey-synchronizers/maxkey-synchronizer-reorgdept/src/main/java/org/dromara/maxkey/synchronizer/workweixin/service/ReorgDeptService.java b/maxkey-synchronizers/maxkey-synchronizer-reorgdept/src/main/java/org/dromara/maxkey/synchronizer/workweixin/service/ReorgDeptService.java deleted file mode 100644 index a72f63ca..00000000 --- a/maxkey-synchronizers/maxkey-synchronizer-reorgdept/src/main/java/org/dromara/maxkey/synchronizer/workweixin/service/ReorgDeptService.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright [2021] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.dromara.maxkey.synchronizer.workweixin.service; - -import java.util.HashMap; -import java.util.List; - -import org.dromara.maxkey.constants.ConstsStatus; -import org.dromara.maxkey.entity.Organizations; -import org.dromara.maxkey.synchronizer.AbstractSynchronizerService; -import org.dromara.maxkey.synchronizer.ISynchronizerService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -@Service -public class ReorgDeptService extends AbstractSynchronizerService implements ISynchronizerService{ - final static Logger _logger = LoggerFactory.getLogger(ReorgDeptService.class); - - String rootParentOrgId = "-1"; - - public void sync() { - _logger.info("Sync Organizations ..."); - - try { - long responseCount =0; - HashMaporgCastMap =new HashMap(); - Organizations queryOrganization =new Organizations(); - queryOrganization.setInstId(this.synchronizer.getInstId()); - List listOrg = organizationsService.query(queryOrganization); - - buildNamePath(orgCastMap,listOrg); - - for(Organizations org :listOrg) { - _logger.info("Dept "+(++responseCount)+" : " + org); - org.setStatus(ConstsStatus.ACTIVE); - organizationsService.update(org); - } - - - } catch (Exception e) { - e.printStackTrace(); - } - - } - - - - /** - * Reorganization name path & code path - * @param orgCastMap - * @param listOrgCast - */ - public void buildNamePath(HashMaporgMap, - List listOrg) { - Organizations tempOrg = null; - //root org - for(int i=0;ilistOrg.size()); - } - -}