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
ae126d6f
Commit
ae126d6f
authored
Aug 28, 2023
by
chenjinjing
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://123.207.147.179:8888/node_server/yafangsuo_dataServer
parents
fcefeeaa
e5bfd99d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
4 deletions
+44
-4
findData.ts
src/biz/mysql/findData.ts
+30
-1
mysqlTableConfig.ts
src/config/mysqlTableConfig.ts
+1
-1
mysqlRouter.ts
src/routers/mysqlRouter.ts
+13
-2
No files found.
src/biz/mysql/findData.ts
View file @
ae126d6f
...
@@ -7,7 +7,7 @@ function analysisParamToWhere(param, column) {
...
@@ -7,7 +7,7 @@ function analysisParamToWhere(param, column) {
let
where
let
where
for
(
let
key
in
param
)
{
// 模糊查询{"字段名":{"%like%":'三'}}
for
(
let
key
in
param
)
{
// 模糊查询{"字段名":{"%like%":'三'}}
if
(
param
[
key
][
"%like%"
])
{
if
(
param
[
key
][
"%like%"
])
{
where
[
key
]
=
{[
Op
.
like
]:
`%
${
param
[
key
]}
%`
};
where
[
key
]
=
{[
Op
.
like
]:
`%
${
param
[
key
]
[
"%like%"
]
}
%`
};
}
else
{
}
else
{
where
[
key
]
=
param
[
key
];
where
[
key
]
=
param
[
key
];
}
}
...
@@ -100,4 +100,32 @@ export async function selectDataToTableAssociation(tableModel, includeConf, para
...
@@ -100,4 +100,32 @@ export async function selectDataToTableAssociation(tableModel, includeConf, para
let
data
=
tableModel
.
findAll
(
selectParam
);
let
data
=
tableModel
.
findAll
(
selectParam
);
return
{
data
};
return
{
data
};
}
/**
* 多表联查
* @param tableModel
* @param includeConf {"表名":["",""] }
* @param param
* @param column
* @returns
*/
export
async
function
selectDataToTableAssociationToPage
(
tableModel
,
includeConf
,
param
,
column
,
pageNumber
:
number
,
pageSize
:
number
)
{
let
include
=
[];
for
(
let
tableName
in
includeConf
)
{
if
(
!
modelMap
[
tableName
])
throw
new
BizError
(
ERRORENUM
.
不存在表
,
`尝试进行多表联查,但是不存在
${
tableName
}
`
);
include
.
push
({
attributes
:
includeConf
[
tableName
],
module
:
modelMap
[
tableName
]
});
}
let
selectParam
:
any
=
analysisParamToWhere
(
param
,
column
);
selectParam
.
include
=
include
;
selectParam
.
limit
=
pageSize
||
10
;
selectParam
.
offset
=
(
pageNumber
-
1
)
*
10
;
let
data
=
tableModel
.
findAll
(
selectParam
);
return
{
data
};
}
}
\ No newline at end of file
src/config/mysqlTableConfig.ts
View file @
ae126d6f
...
@@ -57,7 +57,7 @@ export const TablesConfig = [
...
@@ -57,7 +57,7 @@ export const TablesConfig = [
departmentName
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
,
defaultValue
:
'[]'
},
//所属科室表id 枚举 [1,2] --多选
departmentName
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
,
defaultValue
:
'[]'
},
//所属科室表id 枚举 [1,2] --多选
askForTime
:
{
type
:
Sequelize
.
DATE
,
allowNull
:
false
},
//申请入党时间 --入党积极分子录入、入党申请录入
askForTime
:
{
type
:
Sequelize
.
DATE
,
allowNull
:
false
},
//申请入党时间 --入党积极分子录入、入党申请录入
listedAsActivistsTime
:
{
type
:
Sequelize
.
DATE
,
allowNull
:
false
},
//列为积极分子时间 --入党积极分子录入
listedAsActivistsTime
:
{
type
:
Sequelize
.
DATE
,
allowNull
:
false
},
//列为积极分子时间 --入党积极分子录入
liaison
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
,
defaultValue
:
'[]'
},
//联系人 --入党积极分子录入
["",""]
--多选
liaison
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
,
defaultValue
:
'[]'
},
//联系人 --入党积极分子录入
""
--多选
talkTime
:
{
type
:
Sequelize
.
DATE
,
allowNull
:
false
},
//谈话时间 --入党申请录入
talkTime
:
{
type
:
Sequelize
.
DATE
,
allowNull
:
false
},
//谈话时间 --入党申请录入
partyState
:
{
type
:
Sequelize
.
INTEGER
,
allowNull
:
false
,
defaultValue
:
1
},
//党员状态 1:在党、2:退党
partyState
:
{
type
:
Sequelize
.
INTEGER
,
allowNull
:
false
,
defaultValue
:
1
},
//党员状态 1:在党、2:退党
isAdmin
:
{
type
:
Sequelize
.
BOOLEAN
,
allowNull
:
false
,
defaultValue
:
false
},
//是否为管理员
isAdmin
:
{
type
:
Sequelize
.
BOOLEAN
,
allowNull
:
false
,
defaultValue
:
false
},
//是否为管理员
...
...
src/routers/mysqlRouter.ts
View file @
ae126d6f
...
@@ -19,6 +19,7 @@ export function setRouter(httpServer){
...
@@ -19,6 +19,7 @@ export function setRouter(httpServer){
httpServer
.
post
(
'/yfs/dataserver/mysql/table/find/manytopage'
,
checkMySqlSign
,
asyncHandler
(
findManyToPageData
));
httpServer
.
post
(
'/yfs/dataserver/mysql/table/find/manytopage'
,
checkMySqlSign
,
asyncHandler
(
findManyToPageData
));
httpServer
.
post
(
'/yfs/dataserver/mysql/table/find/count'
,
checkMySqlSign
,
asyncHandler
(
findCountData
));
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/aggragate'
,
checkMySqlSign
,
asyncHandler
(
findAggragateData
));
httpServer
.
post
(
'/yfs/dataserver/mysql/table/find/aggragatetopage'
,
checkMySqlSign
,
asyncHandler
(
findAggragateDataToPage
));
}
}
...
@@ -104,4 +105,15 @@ async function findAggragateData(req, res) {
...
@@ -104,4 +105,15 @@ async function findAggragateData(req, res) {
let
result
=
await
findBiz
.
selectDataToTableAssociation
(
table
,
includeConf
,
param
,
column
);
let
result
=
await
findBiz
.
selectDataToTableAssociation
(
table
,
includeConf
,
param
,
column
);
res
.
success
(
result
);
res
.
success
(
result
);
}
}
\ No newline at end of file
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
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