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
ff107f04
Commit
ff107f04
authored
Sep 06, 2023
by
chenjinjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
b91db75d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
6 deletions
+24
-6
findData.ts
src/biz/mysql/findData.ts
+20
-3
mysqlTableConfig.ts
src/config/mysqlTableConfig.ts
+4
-3
No files found.
src/biz/mysql/findData.ts
View file @
ff107f04
import
{
Op
}
from
"sequelize"
;
import
{
Op
,
Sequelize
}
from
"sequelize"
;
import
{
ERRORENUM
}
from
"../../config/errorEnum"
;
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"
;
...
@@ -14,12 +14,16 @@ import { BizError } from "../../util/bizError";
...
@@ -14,12 +14,16 @@ import { BizError } from "../../util/bizError";
* %lte%:小于等于 {列名: {"%lte%": }}
* %lte%:小于等于 {列名: {"%lte%": }}
* %between%:查询范围内数据 {列名: {"%between%": ["开始参数", "结束参数"]}} ---BETWEEN 开始参数 AND 结束参数
* %between%:查询范围内数据 {列名: {"%between%": ["开始参数", "结束参数"]}} ---BETWEEN 开始参数 AND 结束参数
* %notBetween%:查询不在范围内数据 {列名: {"%notBetween%": ["开始参数", "结束参数"]}} ---NOT BETWEEN 开始参数 AND 结束参数
* %notBetween%:查询不在范围内数据 {列名: {"%notBetween%": ["开始参数", "结束参数"]}} ---NOT BETWEEN 开始参数 AND 结束参数
* %orderDesc%: order by DESC {"%orderDesc%": "列名"}
* %limit%: {"%limit%": 数量}
* @param column
* @param column
* @returns
* @returns
*/
*/
function
analysisParamToWhere
(
param
,
column
)
{
function
analysisParamToWhere
(
param
,
column
)
{
let
where
=
{};
let
where
=
{};
for
(
let
key
in
param
)
{
let
order
=
[];
let
limit
=
0
;
for
(
let
key
in
param
)
{
if
(
typeof
param
[
key
]
==
"object"
)
{
if
(
typeof
param
[
key
]
==
"object"
)
{
where
[
key
]
=
{};
where
[
key
]
=
{};
for
(
let
whereKey
in
param
[
key
]){
for
(
let
whereKey
in
param
[
key
]){
...
@@ -48,12 +52,25 @@ function analysisParamToWhere(param, column) {
...
@@ -48,12 +52,25 @@ function analysisParamToWhere(param, column) {
}
}
}
}
}
else
{
}
else
{
where
[
key
]
=
param
[
key
];
switch
(
key
)
{
case
"%orderDesc%"
:
order
=
[[
Sequelize
.
col
(
param
[
key
]),
"DESC"
]];
break
;
case
"%orderAsc%"
:
order
=
[[
Sequelize
.
col
(
param
[
key
]),
"ASC"
]];
break
;
case
"%limit%"
:
limit
=
param
[
key
];
break
;
default
:
where
[
key
]
=
param
[
key
];
}
}
}
}
}
let
selectParam
:
any
=
{
where
};
let
selectParam
:
any
=
{
where
};
if
(
column
&&
column
.
length
)
selectParam
.
attributes
=
column
;
if
(
column
&&
column
.
length
)
selectParam
.
attributes
=
column
;
if
(
order
)
selectParam
.
order
=
order
;
if
(
limit
)
selectParam
.
limit
=
limit
;
return
selectParam
;
return
selectParam
;
}
}
...
...
src/config/mysqlTableConfig.ts
View file @
ff107f04
...
@@ -250,11 +250,12 @@ export const TablesConfig = [
...
@@ -250,11 +250,12 @@ export const TablesConfig = [
autoIncrement
:
true
,
//允许自增
autoIncrement
:
true
,
//允许自增
unique
:
true
//表示该列的值必须唯一
unique
:
true
//表示该列的值必须唯一
},
},
pmId
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
},
//党员id
外键
pmId
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
},
//党员id
partyMemberName
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
},
//党员姓名
partyMemberName
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
},
//党员姓名
bId
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
,
defaultValue
:
'[]'
},
//支部表id 外键 [1,2] --多选
bId
:
{
type
:
Sequelize
.
INTEGER
,
allowNull
:
false
},
//支部表id 外键
monthIntegral
:
{
type
:
Sequelize
.
INTEGER
,
allowNull
:
false
},
//本月
积分
dayIntegral
:
{
type
:
Sequelize
.
INTEGER
,
allowNull
:
false
},
//当日
积分
totalIntegral
:
{
type
:
Sequelize
.
INTEGER
,
allowNull
:
false
},
//总积分
totalIntegral
:
{
type
:
Sequelize
.
INTEGER
,
allowNull
:
false
},
//总积分
dataTime
:
{
type
:
Sequelize
.
DATE
,
allowNull
:
false
},
//数据时间
fileName
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
,
defaultValue
:
'[]'
},
//文件名称 ["",""] --多选
fileName
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
,
defaultValue
:
'[]'
},
//文件名称 ["",""] --多选
fileType
:
{
type
:
Sequelize
.
INTEGER
,
allowNull
:
false
},
//文件类型
fileType
:
{
type
:
Sequelize
.
INTEGER
,
allowNull
:
false
},
//文件类型
uploadTime
:
{
type
:
Sequelize
.
DATE
,
allowNull
:
false
,
defaultValue
:
Sequelize
.
NOW
},
//上传时间
uploadTime
:
{
type
:
Sequelize
.
DATE
,
allowNull
:
false
,
defaultValue
:
Sequelize
.
NOW
},
//上传时间
...
...
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