delete maxkey-synchronizer-reorgdept & settings.gradle文件优化

This commit is contained in:
MaxKey
2024-06-24 20:57:09 +08:00
parent 2df897913b
commit f3ccc7c831
8 changed files with 99 additions and 136 deletions

View File

@@ -22,9 +22,11 @@ import org.dromara.maxkey.configuration.ApplicationConfig;
import org.dromara.maxkey.listener.DynamicGroupsListenerAdapter;
import org.dromara.maxkey.listener.ListenerAdapter;
import org.dromara.maxkey.listener.ListenerParameter;
import org.dromara.maxkey.listener.ReorgDeptListenerAdapter;
import org.dromara.maxkey.listener.SessionListenerAdapter;
import org.dromara.maxkey.persistence.service.ConnectorsService;
import org.dromara.maxkey.persistence.service.GroupsService;
import org.dromara.maxkey.persistence.service.OrganizationsService;
import org.dromara.maxkey.provision.thread.ProvisioningRunner;
import org.dromara.maxkey.provision.thread.ProvisioningRunnerThread;
import org.quartz.Scheduler;
@@ -55,6 +57,20 @@ public class MaxKeyMgtListenerConfig {
return "sessionListenerAdapter";
}
@Bean
public String reorgDeptListenerAdapter(
Scheduler scheduler,
OrganizationsService organizationsService) throws SchedulerException {
ListenerAdapter.addListener(
scheduler,
ReorgDeptListenerAdapter.class,
"0 0/30 * * * ?",//30 minutes
new ListenerParameter().add("organizationsService",organizationsService).build()
);
logger.debug("ReorgDept ListenerAdapter inited .");
return "reorgDeptListenerAdapter";
}
@Bean
public String dynamicGroupsListenerAdapter(
Scheduler scheduler,

View File

@@ -0,0 +1,59 @@
/*
* Copyright [2024] [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.listener;
import java.io.Serializable;
import org.dromara.maxkey.persistence.service.OrganizationsService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ReorgDeptListenerAdapter extends ListenerAdapter implements Job , Serializable {
static final Logger _logger = LoggerFactory.getLogger(ReorgDeptListenerAdapter.class);
private static final long serialVersionUID = 4782358765969474833L;
transient OrganizationsService organizationsService;
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
if(jobStatus == JOBSTATUS.RUNNING) {return;}
init(context);
_logger.debug("running ... " );
jobStatus = JOBSTATUS.RUNNING;
try {
organizationsService.reorgNamePath(null);
_logger.debug("finished " );
jobStatus = JOBSTATUS.FINISHED;
}catch(Exception e) {
jobStatus = JOBSTATUS.ERROR;
_logger.error("Exception " ,e);
}
}
@Override
protected void init(JobExecutionContext context){
super.init(context);
if(organizationsService == null) {
organizationsService = getParameter("organizationsService",OrganizationsService.class);
}
}
}

View File

@@ -48,7 +48,7 @@ public class SessionListenerAdapter extends ListenerAdapter implements Job , S
for (HistoryLogin login : sessionManager.querySessions()) {
Session session = sessionManager.get(login.getSessionId());
if(session == null) {
logger.debug("user {} session {} Login at {} and TimeOut at {} ." ,
logger.debug("TimeOut user {} session {} Login at {} and at {} ." ,
login.getUsername(),
login.getId(),
login.getLoginTime(),