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
3dfd0b68
Commit
3dfd0b68
authored
Aug 29, 2023
by
lixinming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修bug
parent
62b04a20
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
14 deletions
+15
-14
findData.ts
src/biz/mysql/findData.ts
+10
-9
mysqlRouter.ts
src/routers/mysqlRouter.ts
+5
-5
No files found.
src/biz/mysql/findData.ts
View file @
3dfd0b68
...
...
@@ -4,7 +4,7 @@ import { modelMap } from "../../model/modelBind";
import
{
BizError
}
from
"../../util/bizError"
;
function
analysisParamToWhere
(
param
,
column
)
{
let
where
let
where
=
{};
for
(
let
key
in
param
)
{
// 模糊查询{"字段名":{"%like%":'三'}}
if
(
param
[
key
][
"%like%"
])
{
where
[
key
]
=
{[
Op
.
like
]:
`%
${
param
[
key
][
"%like%"
]}
%`
};
...
...
@@ -14,8 +14,8 @@ function analysisParamToWhere(param, column) {
}
let
selectParam
:
any
=
{
where
};
if
(
column
.
length
)
selectParam
.
attributes
=
column
;
return
selectParam
if
(
column
&&
column
.
length
)
selectParam
.
attributes
=
column
;
return
selectParam
;
}
/**
...
...
@@ -26,7 +26,7 @@ function analysisParamToWhere(param, column) {
*/
export
async
function
selectOneDataByParam
(
tableModel
,
param
,
column
)
{
let
selectParam
=
analysisParamToWhere
(
param
,
column
);
let
data
=
tableModel
.
findOne
(
selectParam
);
let
data
=
await
tableModel
.
findOne
(
selectParam
);
return
{
data
};
}
...
...
@@ -39,7 +39,7 @@ export async function selectOneDataByParam(tableModel, param, column) {
*/
export
async
function
selectDataListByParam
(
tableModel
,
param
,
column
)
{
let
selectParam
=
analysisParamToWhere
(
param
,
column
);
let
data
=
tableModel
.
findAll
(
selectParam
);
let
data
=
await
tableModel
.
findAll
(
selectParam
);
return
{
data
};
}
...
...
@@ -56,13 +56,13 @@ export async function selectDataListToPageByParam(tableModel, param, column, pag
let
selectParam
:
any
=
analysisParamToWhere
(
param
,
column
);
selectParam
.
limit
=
pageSize
||
10
;
selectParam
.
offset
=
(
pageNumber
-
1
)
*
10
;
let
data
=
tableModel
.
findAll
(
selectParam
);
let
data
=
await
tableModel
.
findAll
(
selectParam
);
return
{
data
};
}
export
async
function
selectDataCountByParam
(
tableModel
,
param
)
{
let
selectParam
:
any
=
analysisParamToWhere
(
param
,
[]);
let
data
=
tableModel
.
count
(
selectParam
);
let
data
=
await
tableModel
.
count
(
selectParam
);
return
{
data
};
}
...
...
@@ -98,7 +98,7 @@ export async function selectDataToTableAssociation(tableModel, includeConf, para
let
selectParam
:
any
=
analysisParamToWhere
(
param
,
column
);
selectParam
.
include
=
include
;
let
data
=
tableModel
.
findAll
(
selectParam
);
let
data
=
await
tableModel
.
findAll
(
selectParam
);
return
{
data
};
}
...
...
@@ -126,6 +126,6 @@ export async function selectDataToTableAssociationToPage(tableModel, includeConf
selectParam
.
limit
=
pageSize
||
10
;
selectParam
.
offset
=
(
pageNumber
-
1
)
*
10
;
let
data
=
tableModel
.
findAll
(
selectParam
);
let
data
=
await
tableModel
.
findAll
(
selectParam
);
return
{
data
};
}
\ No newline at end of file
src/routers/mysqlRouter.ts
View file @
3dfd0b68
...
...
@@ -64,7 +64,7 @@ async function findOneData(req, res) {
let
table
=
req
.
tableModel
;
let
reqConf
=
{
param
:
'Object'
,
column
:
"[String]"
};
let
{
param
,
column
}
=
eccReqParamater
(
reqConf
,
req
.
body
);
let
{
param
,
column
}
=
eccReqParamater
(
reqConf
,
req
.
body
,
[
"column"
]
);
let
result
=
await
findBiz
.
selectOneDataByParam
(
table
,
param
,
column
);
res
.
success
(
result
);
...
...
@@ -75,7 +75,7 @@ async function findManyData(req, res) {
let
table
=
req
.
tableModel
;
let
reqConf
=
{
param
:
'Object'
,
column
:
"[String]"
};
let
{
param
,
column
}
=
eccReqParamater
(
reqConf
,
req
.
body
);
let
{
param
,
column
}
=
eccReqParamater
(
reqConf
,
req
.
body
,
[
"column"
]
);
let
result
=
await
findBiz
.
selectDataListByParam
(
table
,
param
,
column
);
res
.
success
(
result
);
...
...
@@ -86,7 +86,7 @@ async function findManyToPageData(req, res) {
let
table
=
req
.
tableModel
;
let
reqConf
=
{
param
:
'Object'
,
pageNumber
:
'Number'
,
pageSize
:
'Number'
,
column
:
"[String]"
};
let
{
param
,
pageNumber
,
pageSize
,
column
}
=
eccReqParamater
(
reqConf
,
req
.
body
);
let
{
param
,
pageNumber
,
pageSize
,
column
}
=
eccReqParamater
(
reqConf
,
req
.
body
,
[
"column"
]
);
let
result
=
await
findBiz
.
selectDataListToPageByParam
(
table
,
param
,
column
,
pageNumber
,
pageSize
);
res
.
success
(
result
);
...
...
@@ -108,7 +108,7 @@ async function findAggragateData(req, res) {
let
table
=
req
.
tableModel
;
let
reqConf
=
{
param
:
'Object'
,
includeConf
:
'Object'
,
column
:
"[String]"
};
let
{
param
,
includeConf
,
column
}
=
eccReqParamater
(
reqConf
,
req
.
body
);
let
{
param
,
includeConf
,
column
}
=
eccReqParamater
(
reqConf
,
req
.
body
,
[
"column"
]
);
let
result
=
await
findBiz
.
selectDataToTableAssociation
(
table
,
includeConf
,
param
,
column
);
res
.
success
(
result
);
...
...
@@ -119,7 +119,7 @@ async function findAggragateDataToPage(req, res) {
let
table
=
req
.
tableModel
;
let
reqConf
=
{
param
:
'Object'
,
includeConf
:
'Object'
,
column
:
"[String]"
,
pageNumber
:
'Number'
,
pageSize
:
'Number'
,
};
let
{
param
,
includeConf
,
column
,
pageNumber
,
pageSize
}
=
eccReqParamater
(
reqConf
,
req
.
body
);
let
{
param
,
includeConf
,
column
,
pageNumber
,
pageSize
}
=
eccReqParamater
(
reqConf
,
req
.
body
,
[
"column"
]
);
let
result
=
await
findBiz
.
selectDataToTableAssociationToPage
(
table
,
includeConf
,
param
,
column
,
pageNumber
,
pageSize
);
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