Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-tool
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tool
amos-tool
Commits
1eb12ffd
Commit
1eb12ffd
authored
Jul 25, 2023
by
陈祥烨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修订
parent
d2a7edfc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
41 deletions
+1
-41
DataBaseLinkResource.java
...eejoin/amos/api/tool/controller/DataBaseLinkResource.java
+1
-3
DataBaseLinkService.java
...ejoin/amos/api/tool/face/service/DataBaseLinkService.java
+0
-38
No files found.
src/main/java/com/yeejoin/amos/api/tool/controller/DataBaseLinkResource.java
View file @
1eb12ffd
package
com
.
yeejoin
.
amos
.
api
.
tool
.
controller
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.api.tool.face.model.ApiInfoModel
;
import
com.yeejoin.amos.api.tool.face.model.DataBaseLinkModel
;
import
com.yeejoin.amos.api.tool.face.service.DataBaseLinkService
;
import
io.swagger.annotations.Api
;
...
...
@@ -13,7 +12,6 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -65,7 +63,7 @@ public class DataBaseLinkResource {
public
ResponseModel
<
Page
<
DataBaseLinkModel
>>
queryForPage
(
@RequestParam
(
value
=
"current"
)
int
current
,
@RequestParam
(
value
=
"size"
)
int
size
)
{
Page
<
DataBaseLinkModel
>
page
=
new
Page
<
DataBaseLinkModel
>();
Page
<
DataBaseLinkModel
>
page
=
new
Page
<>();
page
.
setCurrent
(
current
);
page
.
setSize
(
size
);
return
ResponseHelper
.
buildResponse
(
dataBaseLinkService
.
queryForDataBasePage
(
page
));
...
...
src/main/java/com/yeejoin/amos/api/tool/face/service/DataBaseLinkService.java
View file @
1eb12ffd
...
...
@@ -6,14 +6,10 @@ import com.yeejoin.amos.api.tool.face.model.DataBaseLinkModel;
import
com.yeejoin.amos.api.tool.face.orm.dao.DataBaseLinkMapper
;
import
com.yeejoin.amos.api.tool.face.orm.entity.DataBaseLink
;
import
com.yeejoin.amos.api.tool.utils.AESUtils
;
import
org.apache.commons.beanutils.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
java.sql.*
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
/**
...
...
@@ -22,13 +18,8 @@ import java.util.List;
* @author r
*/
@Service
public
class
DataBaseLinkService
extends
BaseService
<
DataBaseLinkModel
,
DataBaseLink
,
DataBaseLinkMapper
>
{
@Autowired
private
DataBaseLinkMapper
dataBaseLinkMapper
;
@Autowired
private
DataBaseLinkService
dataBaseLinkService
;
/**
* 分页查询
*/
...
...
@@ -58,33 +49,6 @@ public class DataBaseLinkService extends BaseService<DataBaseLinkModel, DataBase
}
/**
* 初始化数据库连接表
*/
public
List
<
DataBaseLinkModel
>
refreshDataBase
(
DataBaseLinkModel
dataBaseLinkModel
)
throws
Exception
{
//清空表单
this
.
remove
(
new
QueryWrapper
<>());
//连接数据库
Connection
connection
=
this
.
connectNewDatabase
(
dataBaseLinkModel
);
if
(
connection
==
null
)
return
null
;
List
<
DataBaseLinkModel
>
dataBaseLinkModels
=
new
ArrayList
<>();
Collection
<
DataBaseLink
>
dataBaseLinks
=
new
ArrayList
<>();
for
(
String
name
:
this
.
getDataBaseName
(
connection
))
{
if
(
name
==
null
)
break
;
DataBaseLinkModel
model
=
new
DataBaseLinkModel
();
BeanUtils
.
copyProperties
(
model
,
dataBaseLinkModel
);
model
.
setDbName
(
name
);
dataBaseLinkModels
.
add
(
model
);
dataBaseLinks
.
add
(
this
.
prepareEntity
(
model
));
}
this
.
saveBatch
(
dataBaseLinks
);
connection
.
close
();
return
dataBaseLinkModels
;
}
/**
* 连接数据库
*/
public
Connection
connectNewDatabase
(
DataBaseLinkModel
model
)
throws
Exception
{
...
...
@@ -104,6 +68,4 @@ public class DataBaseLinkService extends BaseService<DataBaseLinkModel, DataBase
return
model
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment