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
023d4cb5
Project 'vue-project/liangXing/frontEnd' was moved to 'vue-project/ZhangJian/ZhangJianFrontEnd'. Please update any links and bookmarks that may still have the old path.
Commit
023d4cb5
authored
Aug 30, 2023
by
chenjinjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
eb4e6d5d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
4 deletions
+43
-4
findData.ts
src/biz/mysql/findData.ts
+43
-4
No files found.
src/biz/mysql/findData.ts
View file @
023d4cb5
...
@@ -3,16 +3,55 @@ import { ERRORENUM } from "../../config/errorEnum";
...
@@ -3,16 +3,55 @@ import { ERRORENUM } from "../../config/errorEnum";
import
{
modelMap
}
from
"../../model/modelBind"
;
import
{
modelMap
}
from
"../../model/modelBind"
;
import
{
BizError
}
from
"../../util/bizError"
;
import
{
BizError
}
from
"../../util/bizError"
;
/**
*
* @param param
* %like%:模糊查询 {列名: {"%like%": }}
* %gt%:大于 {列名: {"%gt%": }}
* %gte%:大于等于 {列名: {"%gte%": }}
* %lt%:小于 {列名: {"%lt%": }}
* %lte%:小于等于 {列名: {"%lte%": }}
* %between%:查询范围内数据 {列名: {"%between%": ["开始参数", "结束参数"]}} ---BETWEEN 开始参数 AND 结束参数
* %notBetween%:查询不在范围内数据 {列名: {"%notBetween%": ["开始参数", "结束参数"]}} ---NOT BETWEEN 开始参数 AND 结束参数
* @param column
* @returns
*/
function
analysisParamToWhere
(
param
,
column
)
{
function
analysisParamToWhere
(
param
,
column
)
{
let
where
=
{};
let
where
=
{};
for
(
let
key
in
param
)
{
// 模糊查询{"字段名":{"%like%":'三'}}
for
(
let
key
in
param
)
{
if
(
param
[
key
][
"%like%"
])
{
where
[
key
]
=
{};
where
[
key
]
=
{[
Op
.
like
]:
`%
${
param
[
key
][
"%like%"
]}
%`
};
for
(
let
whereKey
in
param
[
key
]){
}
else
{
switch
(
whereKey
)
{
case
"%like%"
:
where
[
key
][
Op
.
like
]
=
`%
${
param
[
key
][
"%like%"
]}
%`
;
break
;
case
"%gt%"
:
where
[
key
][
Op
.
gt
]
=
param
[
key
][
"%gt%"
];
break
;
case
"%gte%"
:
where
[
key
][
Op
.
gte
]
=
param
[
key
][
"%gte%"
];
break
;
case
"%lt%"
:
where
[
key
][
Op
.
lt
]
=
param
[
key
][
"%lt%"
];
break
;
case
"%lte%"
:
where
[
key
][
Op
.
lte
]
=
param
[
key
][
"%lte%"
];
break
;
case
"%between%"
:
where
[
key
][
Op
.
between
]
=
param
[
key
][
"%between%"
];
break
;
case
"%notBetween%"
:
where
[
key
][
Op
.
notBetween
]
=
param
[
key
][
"%notBetween%"
];
break
;
default
:
where
[
key
]
=
param
[
key
];
where
[
key
]
=
param
[
key
];
break
;
}
}
}
}
}
let
selectParam
:
any
=
{
where
};
let
selectParam
:
any
=
{
where
};
if
(
column
&&
column
.
length
)
selectParam
.
attributes
=
column
;
if
(
column
&&
column
.
length
)
selectParam
.
attributes
=
column
;
return
selectParam
;
return
selectParam
;
...
...
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