From c021ef9eb21f4b6ef3bec498150d3291725c55c4 Mon Sep 17 00:00:00 2001 From: lijiarao Date: Thu, 23 Nov 2023 11:34:36 +0800 Subject: [PATCH 1/7] =?UTF-8?q?update=20=E5=AE=A2=E6=88=B7=E7=94=9F?= =?UTF-8?q?=E4=BA=A7=E7=8E=AF=E5=A2=83=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=20application-prod.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- laws-single-startup/src/main/resources/application-prod.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/laws-single-startup/src/main/resources/application-prod.yml b/laws-single-startup/src/main/resources/application-prod.yml index 58241f7a..d8290ac1 100644 --- a/laws-single-startup/src/main/resources/application-prod.yml +++ b/laws-single-startup/src/main/resources/application-prod.yml @@ -135,9 +135,9 @@ spring: connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000;druid.stat.logSlowSql\=true datasource: master: - url: jdbc:p6spy:mysql://10.186.40.44:8921/laws_sinotrunk_grp?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&autoReconnect=true - username: law_dev - password: Lawdev!@#1234 + url: jdbc:p6spy:mysql://10.186.16.134:8921/laws_sinotrunk_grp?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&autoReconnect=true + username: law + password: Law!@123445 driver-class-name: com.p6spy.engine.spy.P6SpyDriver # url: jdbc:mysql://127.0.0.1:3306/jero-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai # username: root From f373d5148e32eb4353737ad3947cff22f278a755 Mon Sep 17 00:00:00 2001 From: lijiarao Date: Thu, 23 Nov 2023 11:34:58 +0800 Subject: [PATCH 2/7] =?UTF-8?q?update=20=E5=AE=A2=E6=88=B7=E7=94=9F?= =?UTF-8?q?=E4=BA=A7=E7=8E=AF=E5=A2=83=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=20application-prod.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-prod.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/laws-single-startup/src/main/resources/application-prod.yml b/laws-single-startup/src/main/resources/application-prod.yml index d8290ac1..cd024145 100644 --- a/laws-single-startup/src/main/resources/application-prod.yml +++ b/laws-single-startup/src/main/resources/application-prod.yml @@ -17,7 +17,6 @@ management: server: port: -1 endpoints: - #关闭actuator监控 enabled-by-default: false spring: @@ -206,7 +205,7 @@ jero: backUrl: http://localhost:3000 backUrlPhone: http://localhost:3000 #拆分图片展示地址 - splitUrl: http://laws-test.sinotruk.com/laws-sinotruk/sys/split/file/getImage?fileName= + splitUrl: http://srms.sinotruk.com/laws-sinotruk/sys/split/file/getImage?fileName= path: #文件上传根目录 设置 upload: /app/opt/upFiles @@ -287,13 +286,13 @@ jero: # 文件限制后缀黑名单 fileSuffixLimits : 0x00,%00,\\00,.jsp,.exe,.php,.asp,.aspx,.jspx,.xml,.html,.js,.sh,.bin,$DATA # 跨站白名单 - whiteUrls: localhost:3000,localhost:8080,localhost:62345,laws-test.sinotruk.com + whiteUrls: localhost:3000,localhost:8080,localhost:62345,laws.sinotruk.com # xss白名单 xssExcludedPages: /login,/updatePassword # cors白名单 notFilter: # origin地址 - originIp: http://localhost:3000,http://localhost:62345,http://laws-test.sinotruk.com + originIp: http://localhost:3000,http://localhost:62345,http://laws.sinotruk.com # 加密默认值 password: pbe: @@ -365,13 +364,13 @@ iam: hiwork: ip: http://task-test.sinotruk.com/ # 异构系统标识 - sysCode: test + sysCode: SRMS # 统一待办集成 todoUrl: taskapi/task.basedata/integrationCall/workflowIntegration # 统一消息集成 messageUrl: taskapi/task.basedata/notice/noticeCalls/send # 是否发送消息 - isSend: false + isSend: true # 汽车标准数字化平台ASMS asms: @@ -399,7 +398,4 @@ oauth: state: zhongQi # 起草部门部门名称 -draftDepartName: 流程与标准化 - -# 管理员权限roleCode,多填用英文逗号拼接 -adminRoleCode: admin \ No newline at end of file +draftDepartName: 流程与标准化 \ No newline at end of file From 62840118c8298c96d6f6c408f68e2853b807726b Mon Sep 17 00:00:00 2001 From: lijiarao Date: Fri, 1 Dec 2023 14:40:24 +0800 Subject: [PATCH 3/7] =?UTF-8?q?update=20=E4=BD=93=E7=B3=BB=E6=A0=91?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BC=96=E8=BE=91=E6=94=B9=E4=B8=BA=E5=90=8C?= =?UTF-8?q?=E4=B8=80=E5=AD=90=E9=9B=86=E4=B8=8B=E4=B8=8D=E8=83=BD=E9=87=8D?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/LawsTreeNodeServiceImpl.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/laws-modules/src/main/java/com/jero/modules/laws/standard/service/impl/LawsTreeNodeServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/standard/service/impl/LawsTreeNodeServiceImpl.java index 3a16c8f9..d9b3a92d 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/standard/service/impl/LawsTreeNodeServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/standard/service/impl/LawsTreeNodeServiceImpl.java @@ -112,12 +112,14 @@ public class LawsTreeNodeServiceImpl extends ServiceImpl query = new LambdaQueryWrapper<>(); query.eq(LawsTreeNode::getNodeName, lawsTreeNode.getNodeName()); + query.eq(LawsTreeNode::getParentId, parentId); query.eq(LawsTreeNode::getModuleCode, lawsTreeNode.getModuleCode()); query.eq(LawsTreeNode::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); List lawsTreeNodes = this.list(query); @@ -129,7 +131,6 @@ public class LawsTreeNodeServiceImpl extends ServiceImpl query = new LambdaQueryWrapper<>(); + query.eq(LawsTreeNode::getNodeName, lawsTreeNode.getNodeName()); + query.eq(LawsTreeNode::getParentId, parentId); + query.eq(LawsTreeNode::getModuleCode, lawsTreeNode.getModuleCode()); + query.eq(LawsTreeNode::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); + query.ne(LawsTreeNode::getId,lawsTreeNode.getId()); + List lawsTreeNodes = this.list(query); + if (lawsTreeNodes != null && !lawsTreeNodes.isEmpty()) { + //TODO 翻译 + throw new JeroBootException("已存在名为" + lawsTreeNode.getNodeName() + "的节点"); + } this.updateById(lawsTreeNode); return true; } else { From 7dd5ffb1bb621aa9fd40cd98e0b6d6cfe7911174 Mon Sep 17 00:00:00 2001 From: lijiarao Date: Mon, 4 Dec 2023 09:22:09 +0800 Subject: [PATCH 4/7] update application-test.yml --- .../src/main/resources/application-test.yml | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/laws-single-startup/src/main/resources/application-test.yml b/laws-single-startup/src/main/resources/application-test.yml index bf6dd3e8..e396accd 100644 --- a/laws-single-startup/src/main/resources/application-test.yml +++ b/laws-single-startup/src/main/resources/application-test.yml @@ -360,18 +360,20 @@ iam: # bimRemoteUser: bbcadmin # bimRemotePwd: P@ssw0rd bpmcAppkey: test + # 创建用户默认角色 + defaultRoleIds: 817f7f818bb3506e018bb3506ef70000 # Hiwork集成 hiwork: ip: http://task-test.sinotruk.com/ # 异构系统标识 - sysCode: test + sysCode: SRMS # 统一待办集成 todoUrl: taskapi/task.basedata/integrationCall/workflowIntegration # 统一消息集成 messageUrl: taskapi/task.basedata/notice/noticeCalls/send # 是否发送消息 - isSend: false + isSend: true # 汽车标准数字化平台ASMS asms: @@ -383,6 +385,7 @@ asms: # token过期时间(单位:小时) expire: 48 +# 单点登录配置(所有配置信息需要协调注册,现在都为假) # 单点登录配置(所有配置信息需要协调注册,现在都为假) oauth: # 客户端应用注册ID--客户申请的:SRMS @@ -391,12 +394,37 @@ oauth: clientSecret: 58a1001438de462193bec307826463c2 # 授权码验证 grantType: authorization_code - # 通过授权码获取accessToken请求地址 + # 通过授权码获取accessToken请求地址 https://iam-uat.sinotruk.com:7011 --> https://iam-uat-new.sinotruk.com accessTokenUrl: https://iam-uat.sinotruk.com:7011/idp/oauth2/getToken - # 通过accessToken获取账号信息请求地址 + # 通过accessToken获取账号信息请求地址 https://iam-uat.sinotruk.com:7011 --> https://iam-uat-new.sinotruk.com userInfoUrl: https://iam-uat.sinotruk.com:7011/idp/oauth2/getUserInfo # 防止跨站请求伪造(CSRF)标识(暂时不用) state: zhongQi # 起草部门部门名称 -draftDepartName: 流程与标准化 \ No newline at end of file +draftDepartName: 流程与标准化 +# 管理员权限roleCode,多填用英文逗号拼接 +adminRoleCode: admin + +# 文件下载加解密 +download: + enable: false + # 文件下载、预览拦截路径,多个以逗号分隔 + download_url: /sys/common/download/ + view_url: /sys/common/view/ + # 管理员角色 + admin_role_code: admin,BZGLY + # 加密参数 + encrypt: + url: http://10.2.159.90/intekey/encrypteFile + app_code: SRMS + secret_key: SRMS1234.. + # 解密参数 + decrypt: + url: http://10.2.159.90/intekey/file + app_code: SRMS + secret_key: SRMS1234.. + # 研发域 + scope_dev: 51 + # 办公域 + scope_work: 52 \ No newline at end of file From 24d2f06777d0e34fdc85a4ddb22330409a14d65b Mon Sep 17 00:00:00 2001 From: lijiarao Date: Mon, 4 Dec 2023 16:34:08 +0800 Subject: [PATCH 5/7] =?UTF-8?q?update=20ES=E7=9A=84URL=E5=A2=9E=E5=8A=A0Ba?= =?UTF-8?q?sic=20auth=E8=AE=A4=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/es/JeroElasticsearchTemplate.java | 112 +++++++++++++++--- .../src/main/resources/application-dev.yml | 2 + .../src/main/resources/application-test.yml | 6 +- 3 files changed, 104 insertions(+), 16 deletions(-) diff --git a/laws-base/laws-base-core/src/main/java/com/jero/common/es/JeroElasticsearchTemplate.java b/laws-base/laws-base-core/src/main/java/com/jero/common/es/JeroElasticsearchTemplate.java index b0f3d35c..e9932cd6 100644 --- a/laws-base/laws-base-core/src/main/java/com/jero/common/es/JeroElasticsearchTemplate.java +++ b/laws-base/laws-base-core/src/main/java/com/jero/common/es/JeroElasticsearchTemplate.java @@ -1,5 +1,6 @@ package com.jero.common.es; +import cn.hutool.http.HttpRequest; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; @@ -32,6 +33,11 @@ public class JeroElasticsearchTemplate { // ElasticSearch 最大可返回条目数 public static final int ES_MAX_SIZE = 10000; + @Value("${jero.elasticsearch.username}") + private String username; + @Value("${jero.elasticsearch.password}") + private String password; + public JeroElasticsearchTemplate(@Value("${jero.elasticsearch.cluster-nodes}") String baseUrl, @Value("${jero.elasticsearch.check-enabled}") boolean checkEnabled) { log.debug("JeroElasticsearchTemplate BaseURL:" + baseUrl); if (StringUtils.isNotEmpty(baseUrl)) { @@ -40,7 +46,11 @@ public class JeroElasticsearchTemplate { if (checkEnabled) { try { this.getElasticsearchVersion(); - RestUtil.get(this.getBaseUrl().toString()); + String basicAuth = this.getBasicAuth(); + HttpRequest.get(this.getBaseUrl().toString()) + .header("Authorization", basicAuth) + .execute() + .body(); log.info("ElasticSearch 服务连接成功"); log.info("ElasticSearch version: " + this.version); } catch (Exception e) { @@ -56,8 +66,12 @@ public class JeroElasticsearchTemplate { */ private void getElasticsearchVersion() { if (this.version == null) { - String url = this.getBaseUrl().toString(); - JSONObject result = RestUtil.get(url); + String basicAuth = this.getBasicAuth(); + String response = HttpRequest.get(this.getBaseUrl().toString()) + .header("Authorization", basicAuth) + .execute() + .body(); + JSONObject result = JSONObject.parseObject(response); if (result != null) { JSONObject v = result.getJSONObject("version"); this.version = v.getString("number"); @@ -65,6 +79,13 @@ public class JeroElasticsearchTemplate { } } + public String getBasicAuth(){ + String authString = username + ":" + password; + String encode = Base64.getEncoder().encodeToString(authString.getBytes()); + String authHeader = "Basic " + encode; + return authHeader; + } + public StringBuilder getBaseUrl(String indexName, String typeName) { typeName = typeName.trim().toLowerCase(); return this.getBaseUrl(indexName).append("/").append(typeName); @@ -79,6 +100,59 @@ public class JeroElasticsearchTemplate { return new StringBuilder("http://").append(this.baseUrl); } + /** + * cat 查询ElasticSearch系统数据,返回json + */ + public JSONArray _cat(String urlAfter) { + String url = this.getBaseUrl().append("/_cat").append(urlAfter).append("?").append(FORMAT_JSON).toString(); + String basicAuth = this.getBasicAuth(); + String response = HttpRequest.get(url) + .header("Authorization", basicAuth) + .execute() + .body(); + JSONArray jsonArray = JSONArray.parseArray(response); + return jsonArray; + } + + public JSONObject put(String url){ + String basicAuth = this.getBasicAuth(); + String response = HttpRequest.put(url) + .header("Authorization", basicAuth) + .execute() + .body(); + JSONObject jsonObject = JSONObject.parseObject(response); + return jsonObject; + } + public JSONObject put(String url, String params){ + String basicAuth = this.getBasicAuth(); + String response = HttpRequest.put(url) + .body(params) + .header("Authorization", basicAuth) + .execute() + .body(); + JSONObject jsonObject = JSONObject.parseObject(response); + return jsonObject; + } + public JSONObject post(String url, JSONObject params){ + String basicAuth = this.getBasicAuth(); + String response = HttpRequest.post(url) + .body(params.toJSONString()) + .header("Authorization", basicAuth) + .execute() + .body(); + JSONObject jsonObject = JSONObject.parseObject(response); + return jsonObject; + } + public JSONObject delete(String url){ + String basicAuth = this.getBasicAuth(); + String response = HttpRequest.delete(url) + .header("Authorization", basicAuth) + .execute() + .body(); + JSONObject jsonObject = JSONObject.parseObject(response); + return jsonObject; + } + /** * cat 查询ElasticSearch系统数据,返回json */ @@ -107,7 +181,7 @@ public class JeroElasticsearchTemplate { if (!StringUtils.isEmpty(indexName)) { urlAfter.append("/").append(indexName.trim().toLowerCase()); } - return _cat(urlAfter.toString(), JSONArray.class).getBody(); + return _cat(urlAfter.toString()); } /** @@ -139,7 +213,12 @@ public class JeroElasticsearchTemplate { public JSONObject getDataById(String indexName, String typeName, String dataId) { String url = this.getBaseUrl(indexName, typeName).append("/").append(dataId).toString(); log.info("url:" + url); - JSONObject result = RestUtil.get(url); + String basicAuth = this.getBasicAuth(); + String response = HttpRequest.get(this.getBaseUrl().toString()) + .header("Authorization", basicAuth) + .execute() + .body(); + JSONObject result = JSONObject.parseObject(response); boolean found = result.getBoolean("found"); if (found) { return result.getJSONObject("_source"); @@ -157,7 +236,7 @@ public class JeroElasticsearchTemplate { String url = this.getBaseUrl(indexName).toString(); try { - return RestUtil.put(url).getBoolean("acknowledged"); + return this.put(url).getBoolean("acknowledged"); } catch (org.springframework.web.client.HttpClientErrorException ex) { if (HttpStatus.BAD_REQUEST == ex.getStatusCode()) { log.warn("索引创建失败:" + indexName + " 已存在,无需再创建"); @@ -176,7 +255,7 @@ public class JeroElasticsearchTemplate { public boolean removeIndex(String indexName) { String url = this.getBaseUrl(indexName).toString(); try { - return RestUtil.delete(url).getBoolean("acknowledged"); + return this.delete(url).getBoolean("acknowledged"); } catch (org.springframework.web.client.HttpClientErrorException ex) { if (HttpStatus.NOT_FOUND == ex.getStatusCode()) { log.warn("索引删除失败:" + indexName + " 不存在,无需删除"); @@ -204,7 +283,13 @@ public class JeroElasticsearchTemplate { } log.info("getIndexMapping-url:" + url); try { - return RestUtil.get(url); + String basicAuth = this.getBasicAuth(); + String response = HttpRequest.get(this.getBaseUrl().toString()) + .header("Authorization", basicAuth) + .execute() + .body(); + JSONObject result = JSONObject.parseObject(response); + return result; } catch (org.springframework.web.client.HttpClientErrorException e) { String message = e.getMessage(); if (message != null && message.contains("404 Not Found")) { @@ -291,7 +376,7 @@ public class JeroElasticsearchTemplate { e.printStackTrace(); } try { - String result = RestUtil.put(url, data).getString("result"); + String result = this.put(url, data.toJSONString()).getString("result"); return "created".equals(result) || "updated".equals(result); } catch (Exception e) { log.error(e.getMessage() + "\n-- url: " + url + "\n-- data: " + data.toJSONString()); @@ -327,8 +412,7 @@ public class JeroElasticsearchTemplate { bodySB.append(data.toJSONString()).append("\n"); } log.info("+-+-+-: bodySB.toString(): " + bodySB.toString()); - HttpHeaders headers = RestUtil.getHeaderApplicationJson(); - RestUtil.request(url, HttpMethod.PUT, headers, null, bodySB, JSONObject.class); + this.put(url,bodySB.toString()); return true; } @@ -340,7 +424,7 @@ public class JeroElasticsearchTemplate { public boolean delete(String indexName, String typeName, String dataId) { String url = this.getBaseUrl(indexName, typeName).append("/").append(dataId).toString(); try { - return "deleted".equals(RestUtil.delete(url).getString("result")); + return "deleted".equals(this.delete(url).getString("result")); } catch (org.springframework.web.client.HttpClientErrorException ex) { if (HttpStatus.NOT_FOUND == ex.getStatusCode()) { return false; @@ -362,7 +446,7 @@ public class JeroElasticsearchTemplate { String url = this.getBaseUrl(indexName, typeName).append("/_search").toString(); log.info("url:" + url + " ,search: " + queryObject.toJSONString()); - JSONObject res = RestUtil.post(url, queryObject); + JSONObject res = this.post(url, queryObject); log.info("url:" + url + " ,return res: \n" + res.toJSONString()); return res; } @@ -486,7 +570,7 @@ public class JeroElasticsearchTemplate { String url = this.getBaseUrl(indexName, typeName).append("/_delete_by_query").toString(); log.info("url:" + url + " ,delete: " + queryObject.toJSONString()); - JSONObject res = RestUtil.post(url, queryObject); + JSONObject res = this.post(url, queryObject); log.info("url:" + url + " ,return res: \n" + res.toJSONString()); return res; } diff --git a/laws-single-startup/src/main/resources/application-dev.yml b/laws-single-startup/src/main/resources/application-dev.yml index e55115a9..e3be421d 100644 --- a/laws-single-startup/src/main/resources/application-dev.yml +++ b/laws-single-startup/src/main/resources/application-dev.yml @@ -259,6 +259,8 @@ jero: staticDomain: jerodev # ElasticSearch 6设置 elasticsearch: + username: grp + password: Grp2023.08 cluster-name: jero-ES cluster-nodes: 10.10.10.45:7900 check-enabled: false diff --git a/laws-single-startup/src/main/resources/application-test.yml b/laws-single-startup/src/main/resources/application-test.yml index e396accd..a63dd125 100644 --- a/laws-single-startup/src/main/resources/application-test.yml +++ b/laws-single-startup/src/main/resources/application-test.yml @@ -1,5 +1,5 @@ server: - port: 8080 + port: 8184 tomcat: max-swallow-size: -1 error: @@ -230,8 +230,10 @@ jero: staticDomain: jerodev # ElasticSearch 6设置 elasticsearch: + username: grp + password: Grp2023.08 cluster-name: jero-ES - cluster-nodes: 127.0.0.1:9200 + cluster-nodes: 10.186.43.11:9200 check-enabled: false # 表单设计器配置 desform: From 12875c245aba297a5f4261f6fe9b039d51da3cfd Mon Sep 17 00:00:00 2001 From: caihaohan Date: Wed, 6 Dec 2023 10:24:01 +0800 Subject: [PATCH 6/7] =?UTF-8?q?fix:=20=E4=BD=93=E7=B3=BB=E7=BC=96=E5=8F=B7?= =?UTF-8?q?=E7=94=9F=E6=88=90BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/jero/common/util/YouBianCodeUtil.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/laws-base/laws-base-core/src/main/java/com/jero/common/util/YouBianCodeUtil.java b/laws-base/laws-base-core/src/main/java/com/jero/common/util/YouBianCodeUtil.java index 44aeee74..dbf1dff5 100644 --- a/laws-base/laws-base-core/src/main/java/com/jero/common/util/YouBianCodeUtil.java +++ b/laws-base/laws-base-core/src/main/java/com/jero/common/util/YouBianCodeUtil.java @@ -83,7 +83,9 @@ public class YouBianCodeUtil { if (localCode != null && Objects.equals("", localCode)) { return getNextYouBianCode(localCode); } else if (localCode != null) { - parentCode = parentCode + "A" + getNextStrNum(Character.getNumericValue(localCode.charAt(localCode.length() - 1))); + String lastTwoChars = localCode.substring(localCode.length() - 2); // 获取最后两个字符 + int num = Integer.parseInt(lastTwoChars); // 将这两个字符转换为数字 + parentCode = parentCode + "A" + getNextStrNum(num); // 使用这个数字生成parentCode } else { } else { parentCode = parentCode + "A" + getNextStrNum(0); } From 15c2189f073f70867d5cac53443bebf8bff8a7c0 Mon Sep 17 00:00:00 2001 From: lijiarao Date: Wed, 6 Dec 2023 15:28:47 +0800 Subject: [PATCH 7/7] =?UTF-8?q?rollback=20=E7=99=BB=E5=BD=95=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/service/impl/LoginServiceImpl.java | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/laws-module-system/src/main/java/com/jero/modules/system/service/impl/LoginServiceImpl.java b/laws-module-system/src/main/java/com/jero/modules/system/service/impl/LoginServiceImpl.java index 6c4e2c57..5c53b2ff 100644 --- a/laws-module-system/src/main/java/com/jero/modules/system/service/impl/LoginServiceImpl.java +++ b/laws-module-system/src/main/java/com/jero/modules/system/service/impl/LoginServiceImpl.java @@ -1,6 +1,7 @@ package com.jero.modules.system.service.impl; import cn.hutool.core.util.RandomUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.asymmetric.RSA; import com.alibaba.fastjson.JSONObject; import com.aliyuncs.exceptions.ClientException; @@ -94,22 +95,22 @@ public class LoginServiceImpl implements ILoginService { String rsaPublicKey = sysLoginModel.getRsaPublicKey(); String rsaPrivateKey = redisUtil.get(rsaPublicKey) != null ? String.valueOf(redisUtil.get(rsaPublicKey)) : null; - //if(StrUtil.isEmpty(rsaPrivateKey)){ - // return Result.error(CommonConstant.SC_RSA_TIMEOUT_600, "页面过期,将刷新页面"); - //} + if(StrUtil.isEmpty(rsaPrivateKey)){ + return Result.error(CommonConstant.SC_RSA_TIMEOUT_600, "页面过期,将刷新页面"); + } - //String captcha = sysLoginModel.getCaptcha(); - //if(captcha==null){ - // return Result.error("验证码无效"); - //} - //String lowerCaseCaptcha = captcha.toLowerCase(); - //String realKey = MD5Util.MD5Encode(lowerCaseCaptcha + sysLoginModel.getCheckKey(), UTF_8); - //Object checkCode = redisUtil.get(realKey); - //// 验证码前后端比较 - //if(checkCode == null || !checkCode.toString().equals(lowerCaseCaptcha)) { - // return Result.error("验证码错误"); - //} - //redisUtil.del(realKey); + String captcha = sysLoginModel.getCaptcha(); + if(captcha==null){ + return Result.error("验证码无效"); + } + String lowerCaseCaptcha = captcha.toLowerCase(); + String realKey = MD5Util.MD5Encode(lowerCaseCaptcha + sysLoginModel.getCheckKey(), UTF_8); + Object checkCode = redisUtil.get(realKey); + // 验证码前后端比较 + if(checkCode == null || !checkCode.toString().equals(lowerCaseCaptcha)) { + return Result.error("验证码错误"); + } + redisUtil.del(realKey); try { //解密获取密码和用户名 password = CommonUtils.decryptBtRsaPriKey(password, rsaPrivateKey); @@ -138,15 +139,15 @@ public class LoginServiceImpl implements ILoginService { return Result.error("密码错误次数过多,请15分钟后重试"); } //2. 校验用户名或密码是否正确 - //String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt()); - //String syspassword = sysUser.getPassword(); - //if (!syspassword.equals(userpassword)) { - // // 重试登录次数加一 - // retryCount++; - // this.setRetryInfoToRedis(username, retryCount); - // String msg = retryCount == RETRY_LOGIN_MAX_COUNT ? "密码错误次数过多,请稍后重试":"用户名或密码错误,剩余可登录次数:"+(RETRY_LOGIN_MAX_COUNT - retryCount); - // return Result.error(msg); - //} + String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt()); + String syspassword = sysUser.getPassword(); + if (!syspassword.equals(userpassword)) { + // 重试登录次数加一 + retryCount++; + this.setRetryInfoToRedis(username, retryCount); + String msg = retryCount == RETRY_LOGIN_MAX_COUNT ? "密码错误次数过多,请稍后重试":"用户名或密码错误,剩余可登录次数:"+(RETRY_LOGIN_MAX_COUNT - retryCount); + return Result.error(msg); + } //登录成功,清除错误登录次数 redisUtil.del(RETRY_LOGIN_PREFIX + username); if (checkSysPermission(username)) {