Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yafangsuo_dataServer
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
node_server
yafangsuo_dataServer
Commits
f5a0b1e8
Commit
f5a0b1e8
authored
Sep 14, 2023
by
lixinming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
410ecfa4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
3 deletions
+41
-3
findData.ts
src/biz/mysql/findData.ts
+28
-3
mysqlRouter.ts
src/routers/mysqlRouter.ts
+13
-0
No files found.
src/biz/mysql/findData.ts
View file @
f5a0b1e8
...
...
@@ -134,7 +134,7 @@ export async function associationSelect(tableName:string, param) {
/**
* 多表联查
* 多表联查
列表
* @param tableModel
* @param includeConf {"表名":["",""] }
* @param param
...
...
@@ -186,4 +186,30 @@ export async function selectDataToTableAssociationToPage(tableModel, includeConf
let
data
=
await
tableModel
.
findAll
(
selectParam
);
return
{
data
};
}
\ No newline at end of file
}
/**
* 多表查询单个
* @param tableModel
* @param includeConf
* @param param
* @param column
* @returns
*/
export
async
function
selectOneDataToTableAssociation
(
tableModel
,
includeConf
,
param
,
column
)
{
let
include
=
[];
for
(
let
tableName
in
includeConf
)
{
if
(
!
mysqlModelMap
[
tableName
])
throw
new
BizError
(
ERRORENUM
.
不存在表
,
`尝试进行多表联查,但是不存在
${
tableName
}
`
);
include
.
push
({
attributes
:
includeConf
[
tableName
],
model
:
mysqlModelMap
[
tableName
]
});
}
let
selectParam
:
any
=
analysisParamToWhere
(
param
,
column
);
selectParam
.
include
=
include
;
let
data
=
await
tableModel
.
findOne
(
selectParam
);
return
{
data
};
}
src/routers/mysqlRouter.ts
View file @
f5a0b1e8
...
...
@@ -20,6 +20,8 @@ export function setRouter(httpServer){
httpServer
.
post
(
'/yfs/dataserver/mysql/table/find/count'
,
checkMySqlSign
,
asyncHandler
(
findCountData
));
httpServer
.
post
(
'/yfs/dataserver/mysql/table/find/aggragate'
,
checkMySqlSign
,
asyncHandler
(
findAggragateData
));
httpServer
.
post
(
'/yfs/dataserver/mysql/table/find/aggragatetopage'
,
checkMySqlSign
,
asyncHandler
(
findAggragateDataToPage
));
httpServer
.
post
(
'/yfs/dataserver/mysql/table/find/aggragateone'
,
checkMySqlSign
,
asyncHandler
(
selectOneDataToTableAssociation
));
}
...
...
@@ -125,3 +127,14 @@ async function findAggragateDataToPage(req, res) {
res
.
success
(
result
);
}
async
function
selectOneDataToTableAssociation
(
req
,
res
)
{
let
table
=
req
.
tableModel
;
let
reqConf
=
{
param
:
'Object'
,
includeConf
:
'Object'
,
column
:
"[String]"
};
let
{
param
,
includeConf
,
column
}
=
eccReqParamater
(
reqConf
,
req
.
body
,
[
"column"
]);
let
result
=
await
findBiz
.
selectOneDataToTableAssociation
(
table
,
includeConf
,
param
,
column
);
res
.
success
(
result
);
}
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