Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nnjcy-data-model
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
梁家彪
nnjcy-data-model
Commits
4a7ea6af
Commit
4a7ea6af
authored
Nov 24, 2023
by
wqc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
关联表通用查询
parent
4190cf2d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
1 deletions
+25
-1
dataoperation-server/src/main/java/com/zq/dataoperation/controller/CommonQueryController.java
+6
-0
dataoperation-server/src/main/java/com/zq/dataoperation/service/CommonQueryService.java
+18
-0
dataoperation-server/src/main/java/com/zq/dataoperation/service/DataCleanRecordService.java
+1
-1
No files found.
dataoperation-server/src/main/java/com/zq/dataoperation/controller/CommonQueryController.java
View file @
4a7ea6af
...
...
@@ -104,6 +104,12 @@ public class CommonQueryController {
return
ResultVo
.
success
(
commonQueryService
.
runSelect
(
body
));
}
@ApiOperation
(
"自定义sql查询"
)
@PostMapping
(
"/customSelect"
)
public
ResultVo
customSelect
(
@RequestBody
Map
<
String
,
Object
>
body
)
throws
Exception
{
return
ResultVo
.
success
(
commonQueryService
.
customSelect
(
body
));
}
@ApiOperation
(
"获取库下的所有表"
)
@PostMapping
(
"/showTables"
)
public
ResultVo
showTables
(
@RequestBody
Map
<
String
,
Object
>
body
)
throws
Exception
{
...
...
dataoperation-server/src/main/java/com/zq/dataoperation/service/CommonQueryService.java
View file @
4a7ea6af
...
...
@@ -120,6 +120,24 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
return
commonQuery
(
sql
,
queryDbId
);
}
public
List
<
Map
<
String
,
Object
>>
customSelect
(
Map
<
String
,
Object
>
body
)
throws
Exception
{
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
body
);
Integer
queryDbId
=
Integer
.
valueOf
(
jsonObject
.
get
(
"queryDbId"
).
toString
());
String
tableOne
=
jsonObject
.
get
(
"tableOne"
).
toString
();
String
tableTwo
=
jsonObject
.
get
(
"tableTwo"
).
toString
();
String
pkMetaOne
=
jsonObject
.
get
(
"pkMetaOne"
).
toString
();
String
pkMetaTwo
=
jsonObject
.
get
(
"pkMetaTwo"
).
toString
();
String
querySql
=
jsonObject
.
get
(
"querySql"
).
toString
();
if
(
StringUtils
.
isBlank
(
tableTwo
)||
StringUtils
.
isBlank
(
pkMetaTwo
)){
String
sql
=
"SELECT * FROM "
+
tableOne
+
" "
+
querySql
;
return
commonQuery
(
sql
,
queryDbId
);
}
else
{
String
leftSql
=
"SELECT * FROM "
+
tableOne
+
" t LEFT JOIN "
+
tableTwo
+
" h ON t."
+
pkMetaOne
+
" = h."
+
pkMetaTwo
+
" "
+
querySql
;
return
commonQuery
(
leftSql
,
queryDbId
);
}
}
public
Object
showTables
(
@RequestBody
Map
<
String
,
Object
>
body
)
throws
Exception
{
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
body
);
int
page
=
(
int
)
jsonObject
.
get
(
"page"
);
...
...
dataoperation-server/src/main/java/com/zq/dataoperation/service/DataCleanRecordService.java
View file @
4a7ea6af
...
...
@@ -40,7 +40,7 @@ public class DataCleanRecordService extends ServiceImpl<DataCleanRecordDao, Data
QueryDb
queryDb
=
queryDbDao
.
selectById
(
dataCleanRecord
.
getQueryDbId
());
AssertUtils
.
notNull
(
queryDb
,
"无连接表ID"
);
LambdaQueryWrapper
<
DataCollectSetting
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
DataCollectSetting:
:
getToDbId
,
queryDb
.
getId
()).
eq
(
DataCollectSetting:
:
get
ToDbId
,
1
);
//数据库类型
wrapper
.
eq
(
DataCollectSetting:
:
getToDbId
,
queryDb
.
getId
()).
eq
(
DataCollectSetting:
:
get
DataType
,
1
);
//数据库类型
List
<
DataCollectSetting
>
dataCollectSettings
=
dataCollectMapper
.
selectList
(
wrapper
);
Integer
collectSettingId
=
null
;
for
(
DataCollectSetting
collectSetting
:
dataCollectSettings
)
{
...
...
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