Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
1) Cannot connect to mysql database.
2) Lost port config when udpate password of workspace.
3) Change package name in pom.
  • Loading branch information
BrookYuGit committed Nov 5, 2021
1 parent 51fb1c9 commit 278d8c0
Show file tree
Hide file tree
Showing 22 changed files with 143 additions and 4,523 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ target
*.lock.db
*.log
.DS_Store
*.trace.db
Binary file modified server/out/artifacts/sdp_jar/sdp.mv.db
Binary file not shown.
4,444 changes: 0 additions & 4,444 deletions server/out/artifacts/sdp_jar/sdp.trace.db

This file was deleted.

2 changes: 1 addition & 1 deletion server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>cn.sdp</groupId>
<groupId>cn.mysdp</groupId>
<artifactId>sdp-root</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion server/sdp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>cn.sdp</groupId>
<groupId>cn.mysdp</groupId>
<artifactId>sdp-root</artifactId>
<version>1.0.0</version>
</parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import cn.mysdp.biz.domain.*;
import cn.mysdp.biz.dto.request.BaseNameRequest;
import cn.mysdp.biz.dto.request.SdpWorkspaceAddRequest;
import cn.mysdp.biz.dto.request.SdpWorkspaceQueryRequest;
import cn.mysdp.biz.dto.request.SdpWorkspaceUpdateRequest;
import cn.mysdp.biz.dto.response.SdpProjectQueryResponse;
import cn.mysdp.biz.dto.response.SdpTemplateQueryResponse;
Expand Down Expand Up @@ -51,7 +50,6 @@
import java.util.*;
import java.util.regex.Pattern;

import static cn.mysdp.utils.ByteWithPos.appendDestBytes;
import static org.mybatis.generator.internal.util.StringUtility.escapeStringForJava;

/**
Expand Down Expand Up @@ -83,9 +81,6 @@ public class ProcessSQLFacadeImpl extends BaseFacadeImpl implements ProcessSQLFa
@Autowired
SdpWorkspaceMapper sdpWorkspaceMapper;

@Autowired
SdpWorkspaceFacade sdpWorkspaceFacade;

@Autowired
SdpSqlMapper sdpSqlMapper;

Expand All @@ -111,6 +106,9 @@ public String decryptDbPassword(SdpWorkspaceQueryResponse record) throws Excepti
String dbHost = record.getDbHost();
String dbUsername = record.getDbUsername();
String dbPassword = record.getDbPassword();
if (StringUtils.isEmpty(dbPassword)) {
return dbPassword;
}

String data = dbPassword;

Expand Down Expand Up @@ -277,13 +275,16 @@ public Integer execute(BaseNameRequest request, Object _processInstance, Method

Map<String, SdpWorkspaceQueryResponse> sdpWorkspaceMap = new HashMap<>();
{
SdpWorkspaceQueryRequest example = new SdpWorkspaceQueryRequest();
if (jsonObject.containsKey("workspace_name")) {
example.setName(jsonObject.getString("workspace_name"));
}
List<SdpWorkspaceQueryResponse> list = sdpWorkspaceFacade.listSdpWorkspaceByExampleWithBLOBs(example);
for(SdpWorkspaceQueryResponse item: list) {
sdpWorkspaceMap.put(item.getName(), item);
SdpWorkspaceExample example = new SdpWorkspaceExample();
if (jsonObject.containsKey("workspace_name") && !StringUtils.isEmpty(jsonObject.getString("workspace_name"))) {
example.createCriteria().andNameEqualTo(jsonObject.getString("workspace_name"));
}
//这里不能调用facade的list方法,因为facade中的list已经将密码隐藏了
List<SdpWorkspaceWithBLOBs> list = sdpWorkspaceMapper.selectByExampleWithBLOBs(example);
for(SdpWorkspaceWithBLOBs item: list) {
SdpWorkspaceQueryResponse newItem = new SdpWorkspaceQueryResponse();
BeanUtils.copyProperties(item, newItem);
sdpWorkspaceMap.put(item.getName(), newItem);

if ("org.h2.Driver".equals(item.getDbClassname()) && getH2Workspace() != null) {
if (StringUtils.isEmpty(item.getDbDatabase())) {
Expand Down Expand Up @@ -456,11 +457,14 @@ public Integer execute(BaseNameRequest request, Object _processInstance, Method
ex.printStackTrace();
if (ex instanceof SQLNonTransientConnectionException) {
Throwable ex1 = ((SQLNonTransientConnectionException)ex).getCause();
if (ex1 == null) {
throw new Exception("无法连接到数据库:"+workspaceName+",数据库:"+workspace.getDbHost()+":"+workspace.getDbPort()+"@"+workspace.getDbUsername()+"("+ex.getMessage()+")");
}
if (ex1.getMessage().indexOf("Access denied for user") >= 0) {
throw new Exception("数据库无权限或密码错误:"+workspaceName+",数据库:"+workspace.getDbHost()+":"+workspace.getDbPort()+"@"+workspace.getDbUsername()+"("+ex1.getMessage()+")");
throw new Exception("数据库无权限或密码错误:"+workspaceName+",数据库:"+workspace.getDbHost()+":"+workspace.getDbPort()+"@"+workspace.getDbUsername()+"("+ex1.getMessage()+")"+","+ex.getMessage());
}

throw new Exception("无法连接到数据库:"+workspaceName+",数据库:"+workspace.getDbHost()+":"+workspace.getDbPort()+"@"+workspace.getDbUsername()+":"+workspace.getDbPassword()+"("+ex1.getMessage()+")");
throw new Exception("无法连接到数据库:"+workspaceName+",数据库:"+workspace.getDbHost()+":"+workspace.getDbPort()+"@"+workspace.getDbUsername()+"("+ex1.getMessage()+")"+","+ex.getMessage());

}
throw new Exception("无法连接到数据库:"+workspaceName+",数据库:"+workspace.getDbHost()+":"+workspace.getDbPort()+"@"+workspace.getDbUsername()+":"+workspace.getDbPassword()+"("+ex.getMessage()+")");
Expand Down
5 changes: 4 additions & 1 deletion server/sdp/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ server:
spring:
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:~/test;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1;MODE=MYSQL;DATABASE_TO_LOWER=TRUE
url: jdbc:h2:~/sdp;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1;MODE=MYSQL;DATABASE_TO_LOWER=TRUE
username: sa
password:
initialize: true
h2:
console:
enabled: true
path: /db
web-allow-others: true
trace: true

mybatis:
mapper-locations: classpath:mapper/*.xml
Expand Down
7 changes: 7 additions & 0 deletions server/sdp/src/main/resources/static/css/app.91c892b2.css

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 278d8c0

Please sign in to comment.