提交 dc742d1b authored 作者: wangjiahao's avatar wangjiahao

Merge remote-tracking branch 'origin/main' into main

...@@ -6,6 +6,7 @@ import io.dataease.auth.entity.TokenInfo; ...@@ -6,6 +6,7 @@ import io.dataease.auth.entity.TokenInfo;
import io.dataease.auth.service.AuthUserService; import io.dataease.auth.service.AuthUserService;
import io.dataease.auth.util.JWTUtils; import io.dataease.auth.util.JWTUtils;
import io.dataease.commons.utils.CommonBeanFactory; import io.dataease.commons.utils.CommonBeanFactory;
import io.dataease.commons.utils.ServletUtils;
import io.dataease.i18n.Translator; import io.dataease.i18n.Translator;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationException;
...@@ -111,7 +112,7 @@ public class JWTFilter extends BasicHttpAuthenticationFilter { ...@@ -111,7 +112,7 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
// JWTUtils.removeTokenExpire(token); // JWTUtils.removeTokenExpire(token);
String newToken = JWTUtils.sign(tokenInfo, password); String newToken = JWTUtils.sign(tokenInfo, password);
// 记录新token操作时间 // 记录新token操作时间
JWTUtils.addTokenExpire(newToken); // JWTUtils.addTokenExpire(newToken);
JWTToken jwtToken = new JWTToken(newToken); JWTToken jwtToken = new JWTToken(newToken);
this.getSubject(request, response).login(jwtToken); this.getSubject(request, response).login(jwtToken);
......
...@@ -84,17 +84,24 @@ public class JWTUtils { ...@@ -84,17 +84,24 @@ public class JWTUtils {
*/ */
public static boolean loginExpire(String token){ public static boolean loginExpire(String token){
if (Login_Interval==0) { if (Login_Interval==0) {
int minute = CommonBeanFactory.getBean(Environment.class).getProperty("dataease.login_timeout", Integer.class, 8*60); String property = CommonBeanFactory.getBean(Environment.class).getProperty("dataease.login_timeout");
// 默认超时时间是8h
int minute = StringUtils.isNotEmpty(property) ? Integer.parseInt(property): (8*60);
// 分钟换算成毫秒 // 分钟换算成毫秒
Login_Interval = minute * 1000 * 60; Login_Interval = minute * 1000 * 60;
} }
Long now = System.currentTimeMillis(); Long now = System.currentTimeMillis();
Long lastOperateTime = tokenLastOperateTime(token); Long lastOperateTime = tokenLastOperateTime(token);
if (ObjectUtils.isEmpty(lastOperateTime)) return true;
boolean isExpire = false; boolean isExpire = false;
if (lastOperateTime != null) { if (lastOperateTime != null) {
isExpire = now - lastOperateTime > Login_Interval; isExpire = now - lastOperateTime > Login_Interval;
} }
if (isExpire) {
// System.out.println("-----------------------");
// System.out.println("-----上次操作时间是["+lastOperateTime+"]-----");
// System.out.println("-----当前操作时间是["+now+"]-----");
// System.out.println("-----------------------");
}
return isExpire; return isExpire;
} }
...@@ -109,7 +116,7 @@ public class JWTUtils { ...@@ -109,7 +116,7 @@ public class JWTUtils {
} }
/** /**
* 生成签名,1min后过期 * 生成签名,5min后过期
* @param tokenInfo 用户信息 * @param tokenInfo 用户信息
* @param secret 用户的密码 * @param secret 用户的密码
* @return 加密的token * @return 加密的token
...@@ -158,12 +165,10 @@ public class JWTUtils { ...@@ -158,12 +165,10 @@ public class JWTUtils {
CacheManager cacheManager = CommonBeanFactory.getBean(CacheManager.class); CacheManager cacheManager = CommonBeanFactory.getBean(CacheManager.class);
Cache tokens_expire = cacheManager.getCache("tokens_expire"); Cache tokens_expire = cacheManager.getCache("tokens_expire");
Long expTime = tokens_expire.get(token, Long.class); Long expTime = tokens_expire.get(token, Long.class);
// System.out.println("get-------"+token+" :"+expTime);
return expTime; return expTime;
} }
public static void removeTokenExpire(String token){ public static void removeTokenExpire(String token){
// System.out.println("remove----"+token);
CacheManager cacheManager = CommonBeanFactory.getBean(CacheManager.class); CacheManager cacheManager = CommonBeanFactory.getBean(CacheManager.class);
Cache tokens_expire = cacheManager.getCache("tokens_expire"); Cache tokens_expire = cacheManager.getCache("tokens_expire");
tokens_expire.evict(token); tokens_expire.evict(token);
...@@ -173,7 +178,6 @@ public class JWTUtils { ...@@ -173,7 +178,6 @@ public class JWTUtils {
CacheManager cacheManager = CommonBeanFactory.getBean(CacheManager.class); CacheManager cacheManager = CommonBeanFactory.getBean(CacheManager.class);
Cache tokens_expire = cacheManager.getCache("tokens_expire"); Cache tokens_expire = cacheManager.getCache("tokens_expire");
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
// System.out.println("add-------"+token+" :"+now);
tokens_expire.put(token, now); tokens_expire.put(token, now);
} }
......
...@@ -21,6 +21,7 @@ import io.dataease.dto.dataset.DataTableInfoDTO; ...@@ -21,6 +21,7 @@ import io.dataease.dto.dataset.DataTableInfoDTO;
import io.dataease.i18n.Translator; import io.dataease.i18n.Translator;
import io.dataease.service.dataset.DataSetGroupService; import io.dataease.service.dataset.DataSetGroupService;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -118,7 +119,11 @@ public class DatasourceService { ...@@ -118,7 +119,11 @@ public class DatasourceService {
dbTableDTO.setEnableCheck(false); dbTableDTO.setEnableCheck(false);
List<DatasetGroup> parents = dataSetGroupService.getParents(datasetTable.getSceneId()); List<DatasetGroup> parents = dataSetGroupService.getParents(datasetTable.getSceneId());
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
parents.forEach(ele -> stringBuilder.append(ele.getName()).append("/")); parents.forEach(ele -> {
if (ObjectUtils.isNotEmpty(ele)) {
stringBuilder.append(ele.getName()).append("/");
}
});
stringBuilder.append(datasetTable.getName()); stringBuilder.append(datasetTable.getName());
dbTableDTO.setDatasetPath(stringBuilder.toString()); dbTableDTO.setDatasetPath(stringBuilder.toString());
break; break;
......
package io.dataease.service.dataset; package io.dataease.service.dataset;
import io.dataease.base.domain.DatasetTableTask; import io.dataease.base.domain.*;
import io.dataease.base.domain.DatasetTableTaskExample;
import io.dataease.base.domain.DatasetTableTaskLog;
import io.dataease.base.mapper.DatasetTableTaskMapper; import io.dataease.base.mapper.DatasetTableTaskMapper;
import io.dataease.commons.constants.JobStatus; import io.dataease.commons.constants.JobStatus;
import io.dataease.commons.constants.ScheduleType; import io.dataease.commons.constants.ScheduleType;
...@@ -38,7 +36,9 @@ public class DataSetTableTaskService { ...@@ -38,7 +36,9 @@ public class DataSetTableTaskService {
private DataSetTableService dataSetTableService; private DataSetTableService dataSetTableService;
@Resource @Resource
private ExtractDataService extractDataService; private ExtractDataService extractDataService;
public DatasetTableTask save(DataSetTaskRequest dataSetTaskRequest) throws Exception { public DatasetTableTask save(DataSetTaskRequest dataSetTaskRequest) throws Exception {
checkName(dataSetTaskRequest);
DatasetTableTask datasetTableTask = dataSetTaskRequest.getDatasetTableTask(); DatasetTableTask datasetTableTask = dataSetTaskRequest.getDatasetTableTask();
dataSetTableService.saveIncrementalConfig(dataSetTaskRequest.getDatasetTableIncrementalConfig()); dataSetTableService.saveIncrementalConfig(dataSetTaskRequest.getDatasetTableIncrementalConfig());
...@@ -60,10 +60,10 @@ public class DataSetTableTaskService { ...@@ -60,10 +60,10 @@ public class DataSetTableTaskService {
datasetTableTask.setId(UUID.randomUUID().toString()); datasetTableTask.setId(UUID.randomUUID().toString());
datasetTableTask.setCreateTime(System.currentTimeMillis()); datasetTableTask.setCreateTime(System.currentTimeMillis());
// SIMPLE 类型,提前占位 // SIMPLE 类型,提前占位
if(datasetTableTask.getRate().equalsIgnoreCase(ScheduleType.SIMPLE.toString())){ if (datasetTableTask.getRate().equalsIgnoreCase(ScheduleType.SIMPLE.toString())) {
if(extractDataService.updateSyncStatus(dataSetTableService.get(datasetTableTask.getTableId()))){ if (extractDataService.updateSyncStatus(dataSetTableService.get(datasetTableTask.getTableId()))) {
throw new Exception(Translator.get("i18n_sync_job_exists")); throw new Exception(Translator.get("i18n_sync_job_exists"));
}else { } else {
//write log //write log
DatasetTableTaskLog datasetTableTaskLog = new DatasetTableTaskLog(); DatasetTableTaskLog datasetTableTaskLog = new DatasetTableTaskLog();
datasetTableTaskLog.setTableId(datasetTableTask.getTableId()); datasetTableTaskLog.setTableId(datasetTableTask.getTableId());
...@@ -119,4 +119,22 @@ public class DataSetTableTaskService { ...@@ -119,4 +119,22 @@ public class DataSetTableTaskService {
datasetTableTaskExample.setOrderByClause("create_time desc,name asc"); datasetTableTaskExample.setOrderByClause("create_time desc,name asc");
return datasetTableTaskMapper.selectByExample(datasetTableTaskExample); return datasetTableTaskMapper.selectByExample(datasetTableTaskExample);
} }
private void checkName(DataSetTaskRequest dataSetTaskRequest) {
DatasetTableTaskExample datasetTableTaskExample = new DatasetTableTaskExample();
DatasetTableTaskExample.Criteria criteria = datasetTableTaskExample.createCriteria();
if (StringUtils.isNotEmpty(dataSetTaskRequest.getDatasetTableTask().getId())) {
criteria.andIdNotEqualTo(dataSetTaskRequest.getDatasetTableTask().getId());
}
if (StringUtils.isNotEmpty(dataSetTaskRequest.getDatasetTableTask().getTableId())) {
criteria.andTableIdEqualTo(dataSetTaskRequest.getDatasetTableTask().getTableId());
}
if (StringUtils.isNotEmpty(dataSetTaskRequest.getDatasetTableTask().getName())) {
criteria.andNameEqualTo(dataSetTaskRequest.getDatasetTableTask().getName());
}
List<DatasetTableTask> list = datasetTableTaskMapper.selectByExample(datasetTableTaskExample);
if (list.size() > 0) {
throw new RuntimeException(Translator.get("i18n_task_name_repeat"));
}
}
} }
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<defaultCache <defaultCache
eternal="false" eternal="false"
maxElementsInMemory="1000" maxElementsInMemory="1000"
overflowToDisk="true" overflowToDisk="false"
diskPersistent="false" diskPersistent="false"
timeToIdleSeconds="0" timeToIdleSeconds="0"
timeToLiveSeconds="600" timeToLiveSeconds="600"
...@@ -38,46 +38,46 @@ ...@@ -38,46 +38,46 @@
<cache <cache
name="users_info" name="users_info"
eternal="false" eternal="false"
maxElementsInMemory="1000" maxElementsInMemory="100"
maxElementsOnDisk="0" maxElementsOnDisk="1000"
overflowToDisk="true" overflowToDisk="true"
diskPersistent="false" diskPersistent="true"
timeToIdleSeconds="28800" timeToIdleSeconds="1800"
timeToLiveSeconds="36000" timeToLiveSeconds="3600"
memoryStoreEvictionPolicy="LRU" memoryStoreEvictionPolicy="LRU"
/> />
<cache <cache
name="users_roles_info" name="users_roles_info"
eternal="false" eternal="false"
maxElementsInMemory="1000" maxElementsInMemory="100"
maxElementsOnDisk="0" maxElementsOnDisk="1000"
overflowToDisk="true" overflowToDisk="true"
diskPersistent="false" diskPersistent="true"
timeToIdleSeconds="28800" timeToIdleSeconds="1800"
timeToLiveSeconds="36000" timeToLiveSeconds="3600"
memoryStoreEvictionPolicy="LRU" memoryStoreEvictionPolicy="LRU"
/> />
<cache <cache
name="users_permissions_info" name="users_permissions_info"
eternal="false" eternal="false"
maxElementsInMemory="1000" maxElementsInMemory="100"
maxElementsOnDisk="0" maxElementsOnDisk="1000"
overflowToDisk="true" overflowToDisk="true"
diskPersistent="false" diskPersistent="true"
timeToIdleSeconds="28800" timeToIdleSeconds="1800"
timeToLiveSeconds="36000" timeToLiveSeconds="3600"
memoryStoreEvictionPolicy="LRU" memoryStoreEvictionPolicy="LRU"
/> />
<cache <cache
name="tokens_expire" name="tokens_expire"
eternal="false" eternal="false"
maxElementsInMemory="1000" maxElementsInMemory="100"
maxElementsOnDisk="0" maxElementsOnDisk="1000"
overflowToDisk="true" overflowToDisk="true"
diskPersistent="false" diskPersistent="true"
timeToIdleSeconds="28800" timeToIdleSeconds="1800"
timeToLiveSeconds="36000" timeToLiveSeconds="3600"
memoryStoreEvictionPolicy="LRU" memoryStoreEvictionPolicy="LRU"
/> />
......
...@@ -241,8 +241,9 @@ i18n_union_field_exists=The same field can't in two dataset ...@@ -241,8 +241,9 @@ i18n_union_field_exists=The same field can't in two dataset
i18n_cron_time_error=Start time can't greater then end time i18n_cron_time_error=Start time can't greater then end time
i18n_auth_source_be_canceled=This Auth Resource Already Be Canceled i18n_auth_source_be_canceled=This Auth Resource Already Be Canceled
i18n_username_exists=ID is already exists i18n_username_exists=ID is already exists
i18n_ds_name_exists=Datasource name exists i18n_ds_name_exists=Datasource name used
i18n_sync_job_exists=There is already a synchronization task running, please try again later i18n_sync_job_exists=There is already a synchronization task running, please try again later
i18n_datasource_check_fail=Invalid,please check config i18n_datasource_check_fail=Invalid,please check config
i18n_not_find_user=Can not find user. i18n_not_find_user=Can not find user.
i18n_sql_not_empty=SQL can not be empty. i18n_sql_not_empty=SQL can not be empty.
i18n_task_name_repeat=Name is used in same data set
\ No newline at end of file
...@@ -243,8 +243,9 @@ i18n_union_field_exists=两个数据集之间关联不能出现多次相同字 ...@@ -243,8 +243,9 @@ i18n_union_field_exists=两个数据集之间关联不能出现多次相同字
i18n_cron_time_error=开始时间不能大于结束时间 i18n_cron_time_error=开始时间不能大于结束时间
i18n_auth_source_be_canceled=当前资源授权权限已经被取消 i18n_auth_source_be_canceled=当前资源授权权限已经被取消
i18n_username_exists=用户 ID 已存在 i18n_username_exists=用户 ID 已存在
i18n_ds_name_exists=数据源名称已存在 i18n_ds_name_exists=数据源名称已被使用
i18n_sync_job_exists=已经有同步任务在运行,稍后重试 i18n_sync_job_exists=已经有同步任务在运行,稍后重试
i18n_datasource_check_fail=校验失败,请检查配置信息 i18n_datasource_check_fail=校验失败,请检查配置信息
i18n_not_find_user=未找到用户 i18n_not_find_user=未找到用户
i18n_sql_not_empty=SQL 不能为空 i18n_sql_not_empty=SQL 不能为空
i18n_task_name_repeat=同一数据集下任务名称已被使用
\ No newline at end of file
...@@ -243,8 +243,9 @@ i18n_union_field_exists=兩個數據集之間關聯不能出現多次相同字 ...@@ -243,8 +243,9 @@ i18n_union_field_exists=兩個數據集之間關聯不能出現多次相同字
i18n_cron_time_error=開始時間不能大於結束時間 i18n_cron_time_error=開始時間不能大於結束時間
i18n_auth_source_be_canceled=當前資源授權權限已經被取消 i18n_auth_source_be_canceled=當前資源授權權限已經被取消
i18n_username_exists=用戶ID已存在 i18n_username_exists=用戶ID已存在
i18n_ds_name_exists=數據源名稱已存在 i18n_ds_name_exists=數據源名稱已被使用
i18n_sync_job_exists=已經有同步任務在運行,稍後重試 i18n_sync_job_exists=已經有同步任務在運行,稍後重試
i18n_datasource_check_fail=校驗失敗,請檢查配置信息 i18n_datasource_check_fail=校驗失敗,請檢查配置信息
i18n_not_find_user=未找到用戶 i18n_not_find_user=未找到用戶
i18n_sql_not_empty=SQL 不能為空 i18n_sql_not_empty=SQL 不能為空
i18n_task_name_repeat=同一數據集下任務名稱已被使用
\ No newline at end of file
...@@ -380,7 +380,9 @@ export default { ...@@ -380,7 +380,9 @@ export default {
this.calHeight() this.calHeight()
}, },
created() { created() {
this.timer = setInterval(this.listTaskLog, 5000) this.timer = setInterval(() => {
this.listTaskLog(false)
}, 5000)
}, },
beforeDestroy() { beforeDestroy() {
clearInterval(this.timer) clearInterval(this.timer)
...@@ -461,10 +463,10 @@ export default { ...@@ -461,10 +463,10 @@ export default {
post('/dataset/table/incrementalConfig', { tableId: this.table.id }).then(response => { post('/dataset/table/incrementalConfig', { tableId: this.table.id }).then(response => {
this.incrementalConfig = response.data this.incrementalConfig = response.data
this.incrementalUpdateType = 'incrementalAdd' this.incrementalUpdateType = 'incrementalAdd'
console.log(this.sql); console.log(this.sql)
if (this.incrementalConfig.incrementalAdd) { if (this.incrementalConfig.incrementalAdd) {
this.sql = this.incrementalConfig.incrementalAdd this.sql = this.incrementalConfig.incrementalAdd
}else { } else {
this.sql = '' this.sql = ''
} }
}) })
...@@ -543,8 +545,8 @@ export default { ...@@ -543,8 +545,8 @@ export default {
this.taskForm.cron = '0 0 * ? * * *' this.taskForm.cron = '0 0 * ? * * *'
} }
}, },
listTaskLog() { listTaskLog(loading = true) {
post('/dataset/taskLog/list/' + this.page.currentPage + '/' + this.page.pageSize, { tableId: this.table.id }).then(response => { post('/dataset/taskLog/list/' + this.page.currentPage + '/' + this.page.pageSize, { tableId: this.table.id }, loading).then(response => {
this.taskLogData = response.data.listObject this.taskLogData = response.data.listObject
this.page.total = response.data.itemCount this.page.total = response.data.itemCount
}) })
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论