From 73dc5c7e995009f241a8026dda211520d873b383 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Thu, 3 Jun 2021 16:23:56 +0800 Subject: [PATCH 01/38] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=9D=83=E9=99=90=E8=8F=9C=E5=8D=95=E5=85=A8=E9=83=A8?= =?UTF-8?q?=E6=89=93=E5=BC=80=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/permission.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/permission.js b/frontend/src/permission.js index 2fae911066..dda02c2b86 100644 --- a/frontend/src/permission.js +++ b/frontend/src/permission.js @@ -124,9 +124,9 @@ const hasCurrentRouter = (locations, routers, index) => { // 根据权限过滤菜单 const filterRouter = routers => { const user_permissions = store.getters.permissions - if (!user_permissions || user_permissions.length === 0) { - return routers - } + // if (!user_permissions || user_permissions.length === 0) { + // return routers + // } const tempResults = routers.filter(router => hasPermission(router, user_permissions)) // 如果是一级菜单(目录) 没有字菜单 那就移除 return tempResults.filter(item => { From 63002eefffdc6adcf014e0185d1f1b162599b6f2 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Thu, 3 Jun 2021 16:26:16 +0800 Subject: [PATCH 02/38] =?UTF-8?q?rollback:=20=E7=99=BB=E5=BD=95=E8=B6=85?= =?UTF-8?q?=E6=97=B6bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/dataease/auth/filter/JWTFilter.java | 3 +- .../java/io/dataease/auth/util/JWTUtils.java | 18 ++++---- .../src/main/resources/ehcache/ehcache.xml | 42 +++++++++---------- 3 files changed, 34 insertions(+), 29 deletions(-) diff --git a/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java b/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java index 48376db8c6..4729dcb089 100644 --- a/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java +++ b/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java @@ -6,6 +6,7 @@ import io.dataease.auth.entity.TokenInfo; import io.dataease.auth.service.AuthUserService; import io.dataease.auth.util.JWTUtils; import io.dataease.commons.utils.CommonBeanFactory; +import io.dataease.commons.utils.ServletUtils; import io.dataease.i18n.Translator; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.authc.AuthenticationException; @@ -111,7 +112,7 @@ public class JWTFilter extends BasicHttpAuthenticationFilter { // JWTUtils.removeTokenExpire(token); String newToken = JWTUtils.sign(tokenInfo, password); // 记录新token操作时间 - JWTUtils.addTokenExpire(newToken); + // JWTUtils.addTokenExpire(newToken); JWTToken jwtToken = new JWTToken(newToken); this.getSubject(request, response).login(jwtToken); diff --git a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java index 7b25d06748..4daecc0d84 100644 --- a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java +++ b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java @@ -24,7 +24,7 @@ public class JWTUtils { // token过期时间1min (过期会自动刷新续命 目的是避免一直都是同一个token ) private static final long EXPIRE_TIME = 1*60*1000; // 登录间隔时间10min 超过这个时间强制重新登录 - private static long Login_Interval; + private static long Login_Interval; @@ -84,17 +84,24 @@ public class JWTUtils { */ public static boolean loginExpire(String token){ 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; } Long now = System.currentTimeMillis(); Long lastOperateTime = tokenLastOperateTime(token); - if (ObjectUtils.isEmpty(lastOperateTime)) return true; boolean isExpire = false; if (lastOperateTime != null) { isExpire = now - lastOperateTime > Login_Interval; } + if (isExpire) { +// System.out.println("-----------------------"); +// System.out.println("-----上次操作时间是["+lastOperateTime+"]-----"); +// System.out.println("-----当前操作时间是["+now+"]-----"); +// System.out.println("-----------------------"); + } return isExpire; } @@ -109,7 +116,7 @@ public class JWTUtils { } /** - * 生成签名,1min后过期 + * 生成签名,5min后过期 * @param tokenInfo 用户信息 * @param secret 用户的密码 * @return 加密的token @@ -158,12 +165,10 @@ public class JWTUtils { CacheManager cacheManager = CommonBeanFactory.getBean(CacheManager.class); Cache tokens_expire = cacheManager.getCache("tokens_expire"); Long expTime = tokens_expire.get(token, Long.class); - // System.out.println("get-------"+token+" :"+expTime); return expTime; } public static void removeTokenExpire(String token){ - // System.out.println("remove----"+token); CacheManager cacheManager = CommonBeanFactory.getBean(CacheManager.class); Cache tokens_expire = cacheManager.getCache("tokens_expire"); tokens_expire.evict(token); @@ -173,7 +178,6 @@ public class JWTUtils { CacheManager cacheManager = CommonBeanFactory.getBean(CacheManager.class); Cache tokens_expire = cacheManager.getCache("tokens_expire"); long now = System.currentTimeMillis(); - // System.out.println("add-------"+token+" :"+now); tokens_expire.put(token, now); } diff --git a/backend/src/main/resources/ehcache/ehcache.xml b/backend/src/main/resources/ehcache/ehcache.xml index 82848300e9..ff551ec033 100644 --- a/backend/src/main/resources/ehcache/ehcache.xml +++ b/backend/src/main/resources/ehcache/ehcache.xml @@ -29,7 +29,7 @@ From 071cafcd26532e4e5e60e4a91bc24d9dd37ae840 Mon Sep 17 00:00:00 2001 From: junjie Date: Thu, 3 Jun 2021 17:02:12 +0800 Subject: [PATCH 03/38] =?UTF-8?q?feat(fix):=E8=87=AA=E5=8A=A8=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E4=B8=8D=E9=9C=80=E8=A6=81loading=EF=BC=8C=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E7=95=8C=E9=9D=A2=E6=8B=89=E4=BC=B8=E5=90=8E=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/dataset/data/UpdateInfo.vue | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/src/views/dataset/data/UpdateInfo.vue b/frontend/src/views/dataset/data/UpdateInfo.vue index 5f17e73c04..af5ca98396 100644 --- a/frontend/src/views/dataset/data/UpdateInfo.vue +++ b/frontend/src/views/dataset/data/UpdateInfo.vue @@ -380,7 +380,9 @@ export default { this.calHeight() }, created() { - this.timer = setInterval(this.listTaskLog, 5000) + this.timer = setInterval(() => { + this.listTaskLog(false) + }, 5000) }, beforeDestroy() { clearInterval(this.timer) @@ -461,10 +463,10 @@ export default { post('/dataset/table/incrementalConfig', { tableId: this.table.id }).then(response => { this.incrementalConfig = response.data this.incrementalUpdateType = 'incrementalAdd' - console.log(this.sql); + console.log(this.sql) if (this.incrementalConfig.incrementalAdd) { this.sql = this.incrementalConfig.incrementalAdd - }else { + } else { this.sql = '' } }) @@ -543,8 +545,8 @@ export default { this.taskForm.cron = '0 0 * ? * * *' } }, - listTaskLog() { - post('/dataset/taskLog/list/' + this.page.currentPage + '/' + this.page.pageSize, { tableId: this.table.id }).then(response => { + listTaskLog(loading = true) { + post('/dataset/taskLog/list/' + this.page.currentPage + '/' + this.page.pageSize, { tableId: this.table.id }, loading).then(response => { this.taskLogData = response.data.listObject this.page.total = response.data.itemCount }) From 2d6c22190f83fb05817293ec5edbb0e7f8b0d4a1 Mon Sep 17 00:00:00 2001 From: junjie Date: Thu, 3 Jun 2021 17:32:05 +0800 Subject: [PATCH 04/38] =?UTF-8?q?feat(fix):=E6=95=B0=E6=8D=AE=E6=BA=90?= =?UTF-8?q?=E3=80=81=E6=95=B0=E6=8D=AE=E9=9B=86=E3=80=81=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E5=88=86=E7=BB=84=E5=9C=BA=E6=99=AF=E7=AD=89?= =?UTF-8?q?=EF=BC=8C=E5=90=8C=E4=B8=80=E7=BA=A7=E4=B8=8B=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E5=94=AF=E4=B8=80=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=96=87=E6=A1=88=EF=BC=9B=E5=90=8C=E4=B8=80?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E4=B8=8B=E7=9B=B8=E5=90=8C=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E5=90=8C=E5=90=8D=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataset/DataSetTableTaskService.java | 30 +++++++++++++++---- .../resources/i18n/messages_en_US.properties | 5 ++-- .../resources/i18n/messages_zh_CN.properties | 5 ++-- .../resources/i18n/messages_zh_TW.properties | 5 ++-- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableTaskService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableTaskService.java index e99650b809..4a35c5d1d1 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableTaskService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableTaskService.java @@ -1,8 +1,6 @@ package io.dataease.service.dataset; -import io.dataease.base.domain.DatasetTableTask; -import io.dataease.base.domain.DatasetTableTaskExample; -import io.dataease.base.domain.DatasetTableTaskLog; +import io.dataease.base.domain.*; import io.dataease.base.mapper.DatasetTableTaskMapper; import io.dataease.commons.constants.JobStatus; import io.dataease.commons.constants.ScheduleType; @@ -38,7 +36,9 @@ public class DataSetTableTaskService { private DataSetTableService dataSetTableService; @Resource private ExtractDataService extractDataService; + public DatasetTableTask save(DataSetTaskRequest dataSetTaskRequest) throws Exception { + checkName(dataSetTaskRequest); DatasetTableTask datasetTableTask = dataSetTaskRequest.getDatasetTableTask(); dataSetTableService.saveIncrementalConfig(dataSetTaskRequest.getDatasetTableIncrementalConfig()); @@ -60,10 +60,10 @@ public class DataSetTableTaskService { datasetTableTask.setId(UUID.randomUUID().toString()); datasetTableTask.setCreateTime(System.currentTimeMillis()); // SIMPLE 类型,提前占位 - if(datasetTableTask.getRate().equalsIgnoreCase(ScheduleType.SIMPLE.toString())){ - if(extractDataService.updateSyncStatus(dataSetTableService.get(datasetTableTask.getTableId()))){ + if (datasetTableTask.getRate().equalsIgnoreCase(ScheduleType.SIMPLE.toString())) { + if (extractDataService.updateSyncStatus(dataSetTableService.get(datasetTableTask.getTableId()))) { throw new Exception(Translator.get("i18n_sync_job_exists")); - }else { + } else { //write log DatasetTableTaskLog datasetTableTaskLog = new DatasetTableTaskLog(); datasetTableTaskLog.setTableId(datasetTableTask.getTableId()); @@ -119,4 +119,22 @@ public class DataSetTableTaskService { datasetTableTaskExample.setOrderByClause("create_time desc,name asc"); 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 list = datasetTableTaskMapper.selectByExample(datasetTableTaskExample); + if (list.size() > 0) { + throw new RuntimeException(Translator.get("i18n_task_name_repeat")); + } + } } diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 0a378bdf4d..9fe4ffeaed 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -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_auth_source_be_canceled=This Auth Resource Already Be Canceled 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_datasource_check_fail=Invalid,please check config i18n_not_find_user=Can not find user. -i18n_sql_not_empty=SQL can not be empty. \ No newline at end of file +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 diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 46259d26ec..8968ee429a 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -243,8 +243,9 @@ i18n_union_field_exists=两个数据集之间关联不能出现多次相同字 i18n_cron_time_error=开始时间不能大于结束时间 i18n_auth_source_be_canceled=当前资源授权权限已经被取消 i18n_username_exists=用户 ID 已存在 -i18n_ds_name_exists=数据源名称已存在 +i18n_ds_name_exists=数据源名称已被使用 i18n_sync_job_exists=已经有同步任务在运行,稍后重试 i18n_datasource_check_fail=校验失败,请检查配置信息 i18n_not_find_user=未找到用户 -i18n_sql_not_empty=SQL 不能为空 \ No newline at end of file +i18n_sql_not_empty=SQL 不能为空 +i18n_task_name_repeat=同一数据集下任务名称已被使用 \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index fd650136bf..9b91c813dc 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -243,8 +243,9 @@ i18n_union_field_exists=兩個數據集之間關聯不能出現多次相同字 i18n_cron_time_error=開始時間不能大於結束時間 i18n_auth_source_be_canceled=當前資源授權權限已經被取消 i18n_username_exists=用戶ID已存在 -i18n_ds_name_exists=數據源名稱已存在 +i18n_ds_name_exists=數據源名稱已被使用 i18n_sync_job_exists=已經有同步任務在運行,稍後重試 i18n_datasource_check_fail=校驗失敗,請檢查配置信息 i18n_not_find_user=未找到用戶 -i18n_sql_not_empty=SQL 不能為空 \ No newline at end of file +i18n_sql_not_empty=SQL 不能為空 +i18n_task_name_repeat=同一數據集下任務名稱已被使用 \ No newline at end of file From f889d5f78f37b6531b96d20548439ab5f7590613 Mon Sep 17 00:00:00 2001 From: junjie Date: Thu, 3 Jun 2021 18:01:28 +0800 Subject: [PATCH 05/38] =?UTF-8?q?feat(fix):db=E8=A1=A8=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/dataease/datasource/service/DatasourceService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/io/dataease/datasource/service/DatasourceService.java b/backend/src/main/java/io/dataease/datasource/service/DatasourceService.java index 8a2eee16a5..7bfc4f05d7 100644 --- a/backend/src/main/java/io/dataease/datasource/service/DatasourceService.java +++ b/backend/src/main/java/io/dataease/datasource/service/DatasourceService.java @@ -21,6 +21,7 @@ import io.dataease.dto.dataset.DataTableInfoDTO; import io.dataease.i18n.Translator; import io.dataease.service.dataset.DataSetGroupService; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -118,7 +119,11 @@ public class DatasourceService { dbTableDTO.setEnableCheck(false); List parents = dataSetGroupService.getParents(datasetTable.getSceneId()); 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()); dbTableDTO.setDatasetPath(stringBuilder.toString()); break; From b69920675f99e19297e93f3a7091cda451a5dc31 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Thu, 3 Jun 2021 18:40:46 +0800 Subject: [PATCH 06/38] =?UTF-8?q?fix:=20=E4=BB=AA=E8=A1=A8=E6=9D=BF?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E6=97=A0=E6=B3=95=E9=87=8D=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/lang/tw.js | 2 +- frontend/src/lang/zh.js | 2 +- frontend/src/views/panel/list/EditPanel/index.vue | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index 1ea23167ed..0cab493eb2 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -659,7 +659,7 @@ export default { rose_radius: '園角', view_name: '視圖名稱', name_can_not_empty: '名稱不能為空', - template_can_not_empty: '请选择仪表盘', + template_can_not_empty: '请选择仪表板', custom_count: '記錄數', table_title_fontsize: '表頭字體大小', table_item_fontsize: '表格字體大小', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index c5f4d753b4..1ee7c1759d 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -659,7 +659,7 @@ export default { rose_radius: '圆角', view_name: '视图名称', name_can_not_empty: '名称不能为空', - template_can_not_empty: '请选择仪表盘', + template_can_not_empty: '请选择仪表版', custom_count: '记录数', table_title_fontsize: '表头字体大小', table_item_fontsize: '表格字体大小', diff --git a/frontend/src/views/panel/list/EditPanel/index.vue b/frontend/src/views/panel/list/EditPanel/index.vue index e4ee2f9d31..7580a47263 100644 --- a/frontend/src/views/panel/list/EditPanel/index.vue +++ b/frontend/src/views/panel/list/EditPanel/index.vue @@ -106,7 +106,7 @@ export default { this.$warning(this.$t('chart.name_can_not_empty')) return false } - if (!this.editPanel.panelInfo.panelData) { + if (!this.editPanel.panelInfo.panelData && this.editPanel.optType === 'new' && this.inputType === 'copy') { this.$warning(this.$t('chart.template_can_not_empty')) return false } From 62ca8a2dd504b4b8c0850a7aa64550c4650bc0d2 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Thu, 3 Jun 2021 18:47:36 +0800 Subject: [PATCH 07/38] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=AA?= =?UTF-8?q?=E8=A1=A8=E6=9D=BF=E5=92=8C=E6=A8=A1=E6=9D=BF=E7=9A=84=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/base/mapper/ext/ExtPanelGroupMapper.xml | 3 +++ .../io/dataease/base/mapper/ext/ExtPanelTemplateMapper.xml | 3 +++ frontend/src/views/panel/list/PanelList.vue | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/io/dataease/base/mapper/ext/ExtPanelGroupMapper.xml b/backend/src/main/java/io/dataease/base/mapper/ext/ExtPanelGroupMapper.xml index 9d35845522..a345bfc4b0 100644 --- a/backend/src/main/java/io/dataease/base/mapper/ext/ExtPanelGroupMapper.xml +++ b/backend/src/main/java/io/dataease/base/mapper/ext/ExtPanelGroupMapper.xml @@ -64,6 +64,9 @@ order by ${sort} + + order by panel_group.create_time desc + diff --git a/backend/src/main/java/io/dataease/base/mapper/ext/ExtPanelTemplateMapper.xml b/backend/src/main/java/io/dataease/base/mapper/ext/ExtPanelTemplateMapper.xml index 9782de83bd..01a45726fd 100644 --- a/backend/src/main/java/io/dataease/base/mapper/ext/ExtPanelTemplateMapper.xml +++ b/backend/src/main/java/io/dataease/base/mapper/ext/ExtPanelTemplateMapper.xml @@ -83,6 +83,9 @@ order by ${sort} + + order by panel_template.create_time desc + diff --git a/frontend/src/views/panel/list/PanelList.vue b/frontend/src/views/panel/list/PanelList.vue index 52f38538e4..c0384adab8 100644 --- a/frontend/src/views/panel/list/PanelList.vue +++ b/frontend/src/views/panel/list/PanelList.vue @@ -323,12 +323,12 @@ export default { panelType: 'self', nodeType: null, children: [], - sort: 'node_type desc,name asc' + sort: 'create_time desc,node_type desc,name asc' }, tableForm: { name: '', mode: '', - sort: 'node_type asc,create_time desc,name asc' + sort: 'create_time desc,node_type asc,create_time desc,name asc' }, groupFormRules: { name: [ From fc4bb323310a3703f63a248a934c7f04d286afee Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Thu, 3 Jun 2021 18:49:59 +0800 Subject: [PATCH 08/38] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E6=9F=A5=E8=AF=A2=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/widget/DeWidget/DeSelect.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/widget/DeWidget/DeSelect.vue b/frontend/src/components/widget/DeWidget/DeSelect.vue index b3b131cdf9..267f116da4 100644 --- a/frontend/src/components/widget/DeWidget/DeSelect.vue +++ b/frontend/src/components/widget/DeWidget/DeSelect.vue @@ -69,13 +69,17 @@ export default { changeValue(value) { this.setCondition() // this.inDraw && this.$emit('set-condition-value', { component: this.element, value: [value], operator: this.operator }) + this.showNumber = false this.$nextTick(() => { + if (!this.$refs.deSelect.$refs.tags || !this.options.attrs.multiple) { + return + } const kids = this.$refs.deSelect.$refs.tags.children[0].children let contentWidth = 0 kids.forEach(kid => { contentWidth += kid.offsetWidth }) - this.showNumber = contentWidth > (this.$refs.deSelect.$refs.tags.clientWidth * 0.7) + this.showNumber = contentWidth > (this.$refs.deSelect.$refs.tags.clientWidth * 0.9) }) }, From 2d1b646a079df1cdee5c024848228948ec0b6604 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Fri, 4 Jun 2021 09:35:35 +0800 Subject: [PATCH 09/38] =?UTF-8?q?feat:=20=E6=8F=92=E4=BB=B6=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E7=BC=BA=E5=A4=B1=E9=94=99=E8=AF=AF=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/io/dataease/plugins/config/PluginRunner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/io/dataease/plugins/config/PluginRunner.java b/backend/src/main/java/io/dataease/plugins/config/PluginRunner.java index a090a92f77..c86b82d031 100644 --- a/backend/src/main/java/io/dataease/plugins/config/PluginRunner.java +++ b/backend/src/main/java/io/dataease/plugins/config/PluginRunner.java @@ -45,7 +45,7 @@ public class PluginRunner implements ApplicationRunner { if (jarFile.exists()) { pluginService.loadJar(jarPath, plugin); }else { - LogUtil.error("插件错误"); + LogUtil.error("插件路径不存在 {} ", jarPath); } } catch (Exception e) { e.printStackTrace(); From 3b8f971796b5c75e7b13ad4de0c92da6a18b9577 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Fri, 4 Jun 2021 09:49:02 +0800 Subject: [PATCH 10/38] =?UTF-8?q?feat:=20=E6=8F=92=E4=BB=B6=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=97=A5=E5=BF=97=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/plugins/config/PluginRunner.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/io/dataease/plugins/config/PluginRunner.java b/backend/src/main/java/io/dataease/plugins/config/PluginRunner.java index c86b82d031..bb91fe21ad 100644 --- a/backend/src/main/java/io/dataease/plugins/config/PluginRunner.java +++ b/backend/src/main/java/io/dataease/plugins/config/PluginRunner.java @@ -1,11 +1,9 @@ package io.dataease.plugins.config; import io.dataease.base.domain.MyPlugin; -import io.dataease.commons.utils.DeFileUtils; import io.dataease.commons.utils.LogUtil; import io.dataease.controller.sys.base.BaseGridRequest; import io.dataease.service.sys.PluginService; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.ApplicationArguments; @@ -26,7 +24,7 @@ public class PluginRunner implements ApplicationRunner { @Override - public void run(ApplicationArguments args) throws Exception { + public void run(ApplicationArguments args) { // 执行加载插件逻辑 BaseGridRequest request = new BaseGridRequest(); List plugins = pluginService.query(request); @@ -48,14 +46,11 @@ public class PluginRunner implements ApplicationRunner { LogUtil.error("插件路径不存在 {} ", jarPath); } } catch (Exception e) { - e.printStackTrace(); + LogUtil.error(e); + //e.printStackTrace(); } }); } - private boolean isPluginJar(File file) { - String name = file.getName(); - return StringUtils.equals(DeFileUtils.getExtensionName(name), "jar"); - } } From c3e915776168685ae7131b115f4c7f852b5de7dd Mon Sep 17 00:00:00 2001 From: junjie Date: Fri, 4 Jun 2021 10:57:58 +0800 Subject: [PATCH 11/38] =?UTF-8?q?feat(fix):=E7=99=BB=E9=99=86=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/dataease/auth/server/AuthServer.java | 20 ++++++++++--------- .../dataease/controller/IndexController.java | 2 +- .../resources/i18n/messages_en_US.properties | 3 ++- .../resources/i18n/messages_zh_CN.properties | 3 ++- .../resources/i18n/messages_zh_TW.properties | 3 ++- frontend/src/lang/en.js | 4 +++- frontend/src/lang/tw.js | 4 +++- frontend/src/lang/zh.js | 4 +++- frontend/src/views/login/index.vue | 4 ++-- 9 files changed, 29 insertions(+), 18 deletions(-) diff --git a/backend/src/main/java/io/dataease/auth/server/AuthServer.java b/backend/src/main/java/io/dataease/auth/server/AuthServer.java index 0f52b94437..cfc597bb1e 100644 --- a/backend/src/main/java/io/dataease/auth/server/AuthServer.java +++ b/backend/src/main/java/io/dataease/auth/server/AuthServer.java @@ -18,12 +18,14 @@ import io.dataease.commons.utils.ServletUtils; import io.dataease.plugins.xpack.display.dto.response.SysSettingDto; import io.dataease.plugins.xpack.display.service.DisPlayXpackService;*/ +import io.dataease.i18n.Translator; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; + import java.util.HashMap; import java.util.List; import java.util.Map; @@ -41,11 +43,11 @@ public class AuthServer implements AuthApi { String password = loginDto.getPassword(); SysUserEntity user = authUserService.getUserByName(username); - if (ObjectUtils.isEmpty(user)){ - throw new RuntimeException("没有该用户!"); + if (ObjectUtils.isEmpty(user)) { + throw new RuntimeException(Translator.get("i18n_id_or_pwd_error")); } - if (user.getEnabled()==0){ - throw new RuntimeException("用户已经失效!"); + if (user.getEnabled() == 0) { + throw new RuntimeException(Translator.get("i18n_id_or_pwd_error")); } String realPwd = user.getPassword(); //私钥解密 @@ -53,10 +55,10 @@ public class AuthServer implements AuthApi { //md5加密 pwd = CodingUtil.md5(pwd); - if (!StringUtils.equals(pwd, realPwd)){ - throw new RuntimeException("密码错误!"); + if (!StringUtils.equals(pwd, realPwd)) { + throw new RuntimeException(Translator.get("i18n_id_or_pwd_error")); } - Map result = new HashMap<>(); + Map result = new HashMap<>(); TokenInfo tokenInfo = TokenInfo.builder().userId(user.getUserId()).username(username).lastLoginTime(System.currentTimeMillis()).build(); String token = JWTUtils.sign(tokenInfo, realPwd); // 记录token操作时间 @@ -68,7 +70,7 @@ public class AuthServer implements AuthApi { @Override public CurrentUserDto userInfo() { - CurrentUserDto userDto = (CurrentUserDto)SecurityUtils.getSubject().getPrincipal(); + CurrentUserDto userDto = (CurrentUserDto) SecurityUtils.getSubject().getPrincipal(); if (ObjectUtils.isEmpty(userDto)) { String token = ServletUtils.getToken(); Long userId = JWTUtils.tokenInfoByToken(token).getUserId(); @@ -84,7 +86,7 @@ public class AuthServer implements AuthApi { } @Override - public String logout(){ + public String logout() { String token = ServletUtils.getToken(); Long userId = JWTUtils.tokenInfoByToken(token).getUserId(); authUserService.clearCache(userId); diff --git a/backend/src/main/java/io/dataease/controller/IndexController.java b/backend/src/main/java/io/dataease/controller/IndexController.java index 948dc5c2df..61b37b73ff 100644 --- a/backend/src/main/java/io/dataease/controller/IndexController.java +++ b/backend/src/main/java/io/dataease/controller/IndexController.java @@ -14,7 +14,7 @@ public class IndexController { return "index.html"; } - @GetMapping(value = "/login") + @GetMapping(value = "/llogin") public String login() { return "index.html"; } diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 9fe4ffeaed..92ff232206 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -246,4 +246,5 @@ i18n_sync_job_exists=There is already a synchronization task running, please try i18n_datasource_check_fail=Invalid,please check config i18n_not_find_user=Can not find user. 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 +i18n_task_name_repeat=Name is used in same data set +i18n_id_or_pwd_error=Invalid ID or password \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 8968ee429a..f4330b8a53 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -248,4 +248,5 @@ i18n_sync_job_exists=已经有同步任务在运行,稍后重试 i18n_datasource_check_fail=校验失败,请检查配置信息 i18n_not_find_user=未找到用户 i18n_sql_not_empty=SQL 不能为空 -i18n_task_name_repeat=同一数据集下任务名称已被使用 \ No newline at end of file +i18n_task_name_repeat=同一数据集下任务名称已被使用 +i18n_id_or_pwd_error=无效的ID或密码 \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 9b91c813dc..5537823911 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -248,4 +248,5 @@ i18n_sync_job_exists=已經有同步任務在運行,稍後重試 i18n_datasource_check_fail=校驗失敗,請檢查配置信息 i18n_not_find_user=未找到用戶 i18n_sql_not_empty=SQL 不能為空 -i18n_task_name_repeat=同一數據集下任務名稱已被使用 \ No newline at end of file +i18n_task_name_repeat=同一數據集下任務名稱已被使用 +i18n_id_or_pwd_error=無效的ID或密碼 \ No newline at end of file diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index be2fd0c6f7..504e2d5a4b 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -283,7 +283,9 @@ export default { }, datasource: 'Datasource', char_can_not_more_50: 'Can not more 50 char', - share_success: 'Share Success' + share_success: 'Share Success', + input_id: 'Please input ID', + input_pwd: 'Please input password' }, documentation: { documentation: 'Documentation', diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index 0cab493eb2..44faae5d4f 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -283,7 +283,9 @@ export default { }, datasource: '數據源', char_can_not_more_50: '不能超過50字符', - share_success: '分享成功' + share_success: '分享成功', + input_id: '請輸入ID', + input_pwd: '請輸入密碼' }, documentation: { documentation: '文檔', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index 1ee7c1759d..6324580114 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -283,7 +283,9 @@ export default { }, datasource: '数据源', char_can_not_more_50: '不能超过50字符', - share_success: '分享成功' + share_success: '分享成功', + input_id: '请输入ID', + input_pwd: '请输入密码' }, documentation: { documentation: '文档', diff --git a/frontend/src/views/login/index.vue b/frontend/src/views/login/index.vue index 02a47191ce..43f2b171b5 100644 --- a/frontend/src/views/login/index.vue +++ b/frontend/src/views/login/index.vue @@ -84,8 +84,8 @@ export default { password: '' }, loginRules: { - username: [{ required: true, trigger: 'blur', validator: validateUsername }], - password: [{ required: true, trigger: 'blur', validator: validatePassword }] + username: [{ required: true, trigger: 'blur', message: this.$t('commons.input_id') }], + password: [{ required: true, trigger: 'blur', message: this.$t('commons.input_pwd') }] }, loading: false, passwordType: 'password', From 152c621054dd347e23f928a43aa968db3f984b70 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Fri, 4 Jun 2021 11:03:42 +0800 Subject: [PATCH 12/38] =?UTF-8?q?fix:=20=20=E3=80=90ID1003561=E3=80=91?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=9C=89=E6=95=88=E6=97=B6=E9=97=B4=E4=BC=BC?= =?UTF-8?q?=E4=B9=8E=E4=B8=8D=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/auth/api/AuthApi.java | 3 -- .../io/dataease/auth/config/F2CRealm.java | 1 - .../io/dataease/auth/entity/TokenInfo.java | 2 - .../io/dataease/auth/filter/JWTFilter.java | 19 +------ .../io/dataease/auth/server/AuthServer.java | 22 +------- .../java/io/dataease/auth/util/JWTUtils.java | 50 ++++--------------- .../src/main/resources/ehcache/ehcache.xml | 11 ---- 7 files changed, 11 insertions(+), 97 deletions(-) diff --git a/backend/src/main/java/io/dataease/auth/api/AuthApi.java b/backend/src/main/java/io/dataease/auth/api/AuthApi.java index e4872b8485..313845a1ee 100644 --- a/backend/src/main/java/io/dataease/auth/api/AuthApi.java +++ b/backend/src/main/java/io/dataease/auth/api/AuthApi.java @@ -31,7 +31,4 @@ public interface AuthApi { @PostMapping("/validateName") Boolean validateName(Map nameDto); - - @GetMapping("/test") - String test(); } diff --git a/backend/src/main/java/io/dataease/auth/config/F2CRealm.java b/backend/src/main/java/io/dataease/auth/config/F2CRealm.java index 719f6db9d9..c91dbe1ff3 100644 --- a/backend/src/main/java/io/dataease/auth/config/F2CRealm.java +++ b/backend/src/main/java/io/dataease/auth/config/F2CRealm.java @@ -19,7 +19,6 @@ import org.apache.shiro.subject.PrincipalCollection; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; - import java.util.List; import java.util.Set; import java.util.stream.Collectors; diff --git a/backend/src/main/java/io/dataease/auth/entity/TokenInfo.java b/backend/src/main/java/io/dataease/auth/entity/TokenInfo.java index 83d4dc0e96..ade63a71ce 100644 --- a/backend/src/main/java/io/dataease/auth/entity/TokenInfo.java +++ b/backend/src/main/java/io/dataease/auth/entity/TokenInfo.java @@ -13,8 +13,6 @@ public class TokenInfo implements Serializable { private Long userId; - private Long lastLoginTime; - public String format(){ return username + "," +userId; } diff --git a/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java b/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java index 4729dcb089..462e2f27f0 100644 --- a/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java +++ b/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java @@ -6,7 +6,6 @@ import io.dataease.auth.entity.TokenInfo; import io.dataease.auth.service.AuthUserService; import io.dataease.auth.util.JWTUtils; import io.dataease.commons.utils.CommonBeanFactory; -import io.dataease.commons.utils.ServletUtils; import io.dataease.i18n.Translator; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.authc.AuthenticationException; @@ -29,9 +28,6 @@ public class JWTFilter extends BasicHttpAuthenticationFilter { public final static String expireMessage = "Login token is expire."; - /*@Autowired - private AuthUserService authUserService;*/ - /** * 判断用户是否想要登入。 @@ -53,22 +49,15 @@ public class JWTFilter extends BasicHttpAuthenticationFilter { String authorization = httpServletRequest.getHeader("Authorization"); // 当没有出现登录超时 且需要刷新token 则执行刷新token if (JWTUtils.loginExpire(authorization)){ - throw new AuthenticationException(expireMessage); + throw new AuthenticationException(expireMessage); } if (JWTUtils.needRefresh(authorization)){ - String oldAuthorization = authorization; authorization = refreshToken(request, response); - JWTUtils.removeTokenExpire(oldAuthorization); } - // 删除老的操作时间 - JWTUtils.removeTokenExpire(authorization); - // 设置新的操作时间 - JWTUtils.addTokenExpire(authorization); JWTToken token = new JWTToken(authorization); Subject subject = getSubject(request, response); // 提交给realm进行登入,如果错误他会抛出异常并被捕获 subject.login(token); - return true; } @@ -108,14 +97,8 @@ public class JWTFilter extends BasicHttpAuthenticationFilter { } String password = user.getPassword(); - // 删除老token操作时间 - // JWTUtils.removeTokenExpire(token); String newToken = JWTUtils.sign(tokenInfo, password); - // 记录新token操作时间 - // JWTUtils.addTokenExpire(newToken); - JWTToken jwtToken = new JWTToken(newToken); - this.getSubject(request, response).login(jwtToken); // 设置响应的Header头新Token HttpServletResponse httpServletResponse = (HttpServletResponse) response; httpServletResponse.addHeader("Access-Control-Expose-Headers", "RefreshAuthorization"); diff --git a/backend/src/main/java/io/dataease/auth/server/AuthServer.java b/backend/src/main/java/io/dataease/auth/server/AuthServer.java index cfc597bb1e..4be4f80693 100644 --- a/backend/src/main/java/io/dataease/auth/server/AuthServer.java +++ b/backend/src/main/java/io/dataease/auth/server/AuthServer.java @@ -14,10 +14,6 @@ import io.dataease.commons.utils.BeanUtils; import io.dataease.commons.utils.CodingUtil; import io.dataease.commons.utils.ServletUtils; -/*import io.dataease.plugins.config.SpringContextUtil; - -import io.dataease.plugins.xpack.display.dto.response.SysSettingDto; -import io.dataease.plugins.xpack.display.service.DisPlayXpackService;*/ import io.dataease.i18n.Translator; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -59,10 +55,9 @@ public class AuthServer implements AuthApi { throw new RuntimeException(Translator.get("i18n_id_or_pwd_error")); } Map result = new HashMap<>(); - TokenInfo tokenInfo = TokenInfo.builder().userId(user.getUserId()).username(username).lastLoginTime(System.currentTimeMillis()).build(); + TokenInfo tokenInfo = TokenInfo.builder().userId(user.getUserId()).username(username).build(); String token = JWTUtils.sign(tokenInfo, realPwd); // 记录token操作时间 - JWTUtils.addTokenExpire(token); result.put("token", token); ServletUtils.setToken(token); return result; @@ -107,20 +102,5 @@ public class AuthServer implements AuthApi { return null; } - @Override - public String test() { - SysUserEntity userById = authUserService.getUserById(4L); - String nickName = userById.getNickName(); -// System.out.println(nickName); - /* Map beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType(DisPlayXpackService.class); - for (Map.Entry entry : beansOfType.entrySet()) { - Object key = entry.getKey(); - DisPlayXpackService value = (DisPlayXpackService)entry.getValue(); - List sysSettingDtos = value.systemSettings(); - String name = entry.getValue().getClass().getName(); - System.out.println("key: "+ key + ", value: "+ name); - }*/ - return "apple"; - } } diff --git a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java index 4daecc0d84..8b3b7e4c92 100644 --- a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java +++ b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java @@ -11,8 +11,7 @@ import io.dataease.commons.utils.CommonBeanFactory; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.authc.AuthenticationException; -import org.springframework.cache.Cache; -import org.springframework.cache.CacheManager; + import org.springframework.core.env.Environment; import java.util.Date; @@ -38,17 +37,10 @@ public class JWTUtils { public static boolean verify(String token, TokenInfo tokenInfo, String secret) { Algorithm algorithm = Algorithm.HMAC256(secret); JWTVerifier verifier = JWT.require(algorithm) - .withClaim("lastLoginTime", tokenInfo.getLastLoginTime()) .withClaim("username", tokenInfo.getUsername()) .withClaim("userId", tokenInfo.getUserId()) .build(); verifier.verify(token); - if (loginExpire(token)){ - // 登录超时 - throw new AuthenticationException(JWTFilter.expireMessage); - // 前端拦截 登录超时状态 直接logout - //return false; - } return true; } @@ -60,11 +52,10 @@ public class JWTUtils { DecodedJWT jwt = JWT.decode(token); String username = jwt.getClaim("username").asString(); Long userId = jwt.getClaim("userId").asLong(); - Long lastLoginTime = jwt.getClaim("lastLoginTime").asLong(); - if (StringUtils.isEmpty(username) || ObjectUtils.isEmpty(userId) || ObjectUtils.isEmpty(lastLoginTime)){ + if (StringUtils.isEmpty(username) || ObjectUtils.isEmpty(userId) ){ throw new RuntimeException("token格式错误!"); } - TokenInfo tokenInfo = TokenInfo.builder().username(username).userId(userId).lastLoginTime(lastLoginTime).build(); + TokenInfo tokenInfo = TokenInfo.builder().username(username).userId(userId).build(); return tokenInfo; } @@ -84,24 +75,17 @@ public class JWTUtils { */ public static boolean loginExpire(String token){ if (Login_Interval==0) { - String property = CommonBeanFactory.getBean(Environment.class).getProperty("dataease.login_timeout"); // 默认超时时间是8h - int minute = StringUtils.isNotEmpty(property) ? Integer.parseInt(property): (8*60); + int minute = CommonBeanFactory.getBean(Environment.class).getProperty("dataease.login_timeout", Integer.class, 8*60); // 分钟换算成毫秒 Login_Interval = minute * 1000 * 60; } - Long now = System.currentTimeMillis(); Long lastOperateTime = tokenLastOperateTime(token); - boolean isExpire = false; + boolean isExpire = true; if (lastOperateTime != null) { + Long now = System.currentTimeMillis(); isExpire = now - lastOperateTime > Login_Interval; } - if (isExpire) { -// System.out.println("-----------------------"); -// System.out.println("-----上次操作时间是["+lastOperateTime+"]-----"); -// System.out.println("-----当前操作时间是["+now+"]-----"); -// System.out.println("-----------------------"); - } return isExpire; } @@ -127,10 +111,8 @@ public class JWTUtils { Algorithm algorithm = Algorithm.HMAC256(secret); // 附带username信息 return JWT.create() - .withClaim("lastLoginTime", tokenInfo.getLastLoginTime()) .withClaim("username", tokenInfo.getUsername()) .withClaim("userId", tokenInfo.getUserId()) - .withClaim("exp", date) .withExpiresAt(date) .sign(algorithm); } catch (Exception e) { @@ -162,23 +144,9 @@ public class JWTUtils { * @return */ public static Long tokenLastOperateTime(String token){ - CacheManager cacheManager = CommonBeanFactory.getBean(CacheManager.class); - Cache tokens_expire = cacheManager.getCache("tokens_expire"); - Long expTime = tokens_expire.get(token, Long.class); - return expTime; - } - - public static void removeTokenExpire(String token){ - CacheManager cacheManager = CommonBeanFactory.getBean(CacheManager.class); - Cache tokens_expire = cacheManager.getCache("tokens_expire"); - tokens_expire.evict(token); - } - - public static void addTokenExpire(String token){ - CacheManager cacheManager = CommonBeanFactory.getBean(CacheManager.class); - Cache tokens_expire = cacheManager.getCache("tokens_expire"); - long now = System.currentTimeMillis(); - tokens_expire.put(token, now); + DecodedJWT jwt = JWT.decode(token); + Date expiresAt = jwt.getExpiresAt(); + return expiresAt.getTime(); } } diff --git a/backend/src/main/resources/ehcache/ehcache.xml b/backend/src/main/resources/ehcache/ehcache.xml index ff551ec033..9491e0fa0d 100644 --- a/backend/src/main/resources/ehcache/ehcache.xml +++ b/backend/src/main/resources/ehcache/ehcache.xml @@ -69,16 +69,5 @@ memoryStoreEvictionPolicy="LRU" /> - \ No newline at end of file From f011ca7a6804eb33926d2b6eb1320f0c4fca252d Mon Sep 17 00:00:00 2001 From: junjie Date: Fri, 4 Jun 2021 11:08:50 +0800 Subject: [PATCH 13/38] =?UTF-8?q?feat(fix):=E7=99=BB=E9=99=86=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/io/dataease/controller/IndexController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/io/dataease/controller/IndexController.java b/backend/src/main/java/io/dataease/controller/IndexController.java index 61b37b73ff..948dc5c2df 100644 --- a/backend/src/main/java/io/dataease/controller/IndexController.java +++ b/backend/src/main/java/io/dataease/controller/IndexController.java @@ -14,7 +14,7 @@ public class IndexController { return "index.html"; } - @GetMapping(value = "/llogin") + @GetMapping(value = "/login") public String login() { return "index.html"; } From a51ec3e2eb39a15ded9eeb8cb17c431133426b60 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Fri, 4 Jun 2021 11:11:21 +0800 Subject: [PATCH 14/38] =?UTF-8?q?fix:=20=E5=8E=BB=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/login/index.vue | 44 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/frontend/src/views/login/index.vue b/frontend/src/views/login/index.vue index 43f2b171b5..b2ebe6e7c0 100644 --- a/frontend/src/views/login/index.vue +++ b/frontend/src/views/login/index.vue @@ -49,35 +49,35 @@