Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zjxcxServer
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
zjxcxServer
Commits
5fc514e9
Commit
5fc514e9
authored
Feb 10, 2023
by
lixinming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
29156d22
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
18 deletions
+76
-18
base.ts
src/biz/fuHuqQi/base.ts
+18
-5
admin.ts
src/routers/admin.ts
+7
-12
tools.ts
src/util/tools.ts
+51
-1
No files found.
src/biz/fuHuqQi/base.ts
View file @
5fc514e9
...
...
@@ -9,7 +9,7 @@ import { findEnterpriseCount, findEnterpriseCountByFuHuaQiUscc, groupFindEnterpr
import
{
findFuHuaQiByUSCC
,
findFuHuaQiCount
,
findFuHuaQiList
}
from
"../../data/fuHuaQi/fuhuaqi"
;
import
*
as
tools
from
"../../util/tools"
;
import
{
FuHuaQiHomeDataConfig
,
FuHuaQiBaseListConfig
,
FuHuaQiBaseDataConfig
}
from
"../../config/ojbectResultKeyConfig"
;
import
{
FUHUAQILV
,
INSTITUTIONALNATURE
}
from
"../../config/enum"
;
import
{
FUHUA
INDUSTRY
,
FUHUAQILNVESTMENTSTYLE
,
FUHUA
QILV
,
INSTITUTIONALNATURE
}
from
"../../config/enum"
;
import
{
extractData
}
from
"../../util/tools"
;
...
...
@@ -42,7 +42,7 @@ export async function homeData(uscc:string) {
export
async
function
selectFuHuaQiBaseData
(
uscc
:
string
)
{
let
dataBaseInfo
=
await
findFuHuaQiByUSCC
(
uscc
);
let
enterpriseTotal
=
await
findEnterpriseCount
({
fuHuaQiUscc
:
uscc
}
);
//企业总数
let
enterpriseTotal
=
await
findEnterpriseCount
ByFuHuaQiUscc
(
uscc
);
//企业总数
let
data
:
any
=
extractData
(
FuHuaQiBaseDataConfig
,
dataBaseInfo
);
...
...
@@ -93,13 +93,26 @@ export async function fuHuaQiBaseList(lv:number, institutionalNature:number, ind
if
(
institutionalNature
)
selectParam
.
institutionalNature
=
institutionalNature
;
if
(
industry
)
selectParam
.
industry
=
industry
;
let
enterpriseMap
=
await
groupFindEnterprise
();
let
enterpriseMap
=
await
groupFindEnterprise
();
//企业总数
let
dataBaseList
=
await
findFuHuaQiList
(
selectParam
,
(
page
-
1
)
*
10
);
let
count
=
await
findFuHuaQiCount
(
selectParam
);
let
dataList
=
[];
dataBaseList
.
forEach
(
info
=>
{
let
changeData
=
tools
.
extractData
(
FuHuaQiBaseListConfig
,
info
);
const
Count
=
enterpriseMap
[
info
.
uscc
]
||
0
;
let
changeData
:
any
=
tools
.
extractData
(
FuHuaQiBaseListConfig
,
info
);
let
enterpriseTotal
=
enterpriseMap
[
info
.
uscc
]
||
0
;
let
numOfEntities
=
enterpriseTotal
-
(
info
.
virtualEnterpriseNum
||
0
);
numOfEntities
=
numOfEntities
<
0
?
0
:
numOfEntities
;
changeData
.
enterpriseTotal
=
enterpriseTotal
;
changeData
.
numOfEntities
=
numOfEntities
;
changeData
.
lv
=
tools
.
changeEnumValue
(
FUHUAQILV
,
changeData
.
lv
);
changeData
.
industry
=
tools
.
changeEnumValue
(
FUHUAINDUSTRY
,
changeData
.
industry
);
changeData
.
institutionalNature
=
tools
.
changeEnumValue
(
INSTITUTIONALNATURE
,
changeData
.
institutionalNature
);
dataList
.
push
(
changeData
);
});
...
...
src/routers/admin.ts
View file @
5fc514e9
...
...
@@ -4,7 +4,7 @@ import * as baseBiz from '../biz/fuHuqQi/base';
import
*
as
enterpriseBiz
from
'../biz/enterprise/enterprise'
;
import
*
as
financingBiz
from
'../biz/enterprise/financing'
;
import
*
as
guanWeiHuiBiz
from
'../biz/guanWeiHui/user'
;
import
{
checkReqParam
}
from
'../util/tools'
;
import
{
check
ParamaterType
,
check
ReqParam
}
from
'../util/tools'
;
import
{
BizError
}
from
'../util/bizError'
;
import
{
ERRORENUM
}
from
'../config/errorEnum'
;
...
...
@@ -45,11 +45,8 @@ async function login(req, res) {
* @param res
*/
async
function
fuHuaQiBaseList
(
req
,
res
)
{
let
{
lv
,
institutionalNature
,
industry
,
page
}
=
req
.
body
;
if
(
typeof
lv
!=
'number'
||
typeof
institutionalNature
!=
'number'
||
typeof
industry
!=
'number'
)
{
throw
new
BizError
(
ERRORENUM
.
参数错误
,
lv
,
institutionalNature
,
industry
);
}
if
(
!
page
||
typeof
page
!=
"number"
)
throw
new
BizError
(
ERRORENUM
.
参数错误
,
`page:
${
page
}
`
);
let
reqConf
=
{
lv
:
'Number'
,
institutionalNature
:
'Number'
,
industry
:
'Number'
,
page
:
'Number'
};
let
{
lv
,
institutionalNature
,
industry
,
page
}
=
checkParamaterType
(
reqConf
,
req
.
body
);
let
result
=
await
baseBiz
.
fuHuaQiBaseList
(
lv
,
institutionalNature
,
industry
,
page
);
...
...
@@ -64,7 +61,7 @@ async function fuHuaQiBaseList(req, res) {
*/
async
function
getFuHuaQiUserList
(
req
,
res
)
{
let
reqConf
=
{
operationName
:
'String'
,
page
:
'Number'
};
let
{
operationName
,
page
}
=
check
ReqParam
(
reqConf
,
req
.
body
);
let
{
operationName
,
page
}
=
check
ParamaterType
(
reqConf
,
req
.
body
);
const
Uscc
=
req
.
headers
.
uscc
;
let
result
=
await
userBiz
.
fuHuaQiUserList
(
operationName
,
page
);
...
...
@@ -78,9 +75,8 @@ async function fuHuaQiBaseList(req, res) {
* @param res
*/
async
function
getFinancingList
(
req
,
res
)
{
let
reqConf
=
{
monthData
:
'String'
,
fuHuaQiName
:
'String'
,
industry
:
'[Number]'
,
fuHuaQiInvestment
:
'Boolean'
,
page
:
'Number'
};
let
{
monthData
,
fuHuaQiName
,
industry
,
fuHuaQiInvestment
,
page
}
=
checkReqParam
(
reqConf
,
req
.
body
);
const
Uscc
=
req
.
headers
.
uscc
;
let
reqConf
=
{
monthData
:
'String'
,
fuHuaQiName
:
'String'
,
fuHuaQiInvestment
:
'Boolean'
,
industry
:
'[Number]'
,
page
:
'Number'
};
let
{
monthData
,
fuHuaQiName
,
industry
,
fuHuaQiInvestment
,
page
}
=
checkParamaterType
(
reqConf
,
req
.
body
);
let
result
=
await
financingBiz
.
financingList
(
monthData
,
fuHuaQiName
,
industry
,
fuHuaQiInvestment
,
page
);
res
.
success
(
result
);
...
...
@@ -94,8 +90,7 @@ async function fuHuaQiBaseList(req, res) {
*/
async
function
getEnterpriseList
(
req
,
res
)
{
let
reqConf
=
{
time
:
'Number'
,
fuHuaQiUscc
:
'String'
,
industry
:
'Number'
,
isNaturalPersonHolding
:
'Boolean'
,
page
:
'Number'
};
let
{
time
,
fuHuaQiUscc
,
industry
,
isNaturalPersonHolding
,
page
}
=
checkReqParam
(
reqConf
,
req
.
body
);
const
Uscc
=
req
.
headers
.
uscc
;
let
{
time
,
fuHuaQiUscc
,
industry
,
isNaturalPersonHolding
,
page
}
=
checkParamaterType
(
reqConf
,
req
.
body
);
let
result
=
await
enterpriseBiz
.
enterpriseList
(
time
,
fuHuaQiUscc
,
industry
,
isNaturalPersonHolding
,
page
);
res
.
success
(
result
);
...
...
src/util/tools.ts
View file @
5fc514e9
...
...
@@ -96,6 +96,7 @@ export function getPwdMd5(uscc:string, pwd:string) {
/**
* 校验请求参数
* 判断参数为必填
* @param conf
* @param param
* @returns
...
...
@@ -141,6 +142,53 @@ export function checkReqParam(conf, param) {
return
param
;
}
/**
* 校验请求参数
* 判断参数可以不填
* @param conf
* @param param
* @returns
*/
export
function
checkParamaterType
(
conf
,
param
)
{
for
(
let
key
in
conf
)
{
if
(
!
param
[
key
])
continue
;
let
type
=
typeof
param
[
key
];
switch
(
conf
[
key
])
{
case
'Number'
:
if
(
type
!=
'number'
)
throw
new
BizError
(
ERRORENUM
.
参数错误
,
`
${
key
}
应是number型 而不是
${
type
}
`
);
break
;
case
'String'
:
if
(
type
!=
'string'
)
throw
new
BizError
(
ERRORENUM
.
参数错误
,
`
${
key
}
应是string型 而不是
${
type
}
`
);
break
;
case
'Boolean'
:
if
(
type
!=
'boolean'
)
throw
new
BizError
(
ERRORENUM
.
参数错误
,
`
${
key
}
应是boolean型 而不是
${
type
}
`
);
break
;
case
'[Number]'
:
if
(
!
Array
.
isArray
(
param
[
key
])
)
throw
new
BizError
(
ERRORENUM
.
参数错误
,
`
${
key
}
应是数组型 而不是
${
type
}
`
);
for
(
let
i
=
0
;
i
<
param
[
key
].
length
;
i
++
)
{
let
item
=
param
[
key
][
i
];
if
(
typeof
item
!=
'number'
)
{
throw
new
BizError
(
ERRORENUM
.
参数错误
,
`
${
key
}
应是number型数组其中下标
${
i
}
是
${
typeof
item
}
`
);
}
}
break
;
case
'Object'
:
if
(
type
!=
'object'
)
throw
new
BizError
(
ERRORENUM
.
参数错误
,
`
${
key
}
应是Object型 而不是
${
type
}
`
);
if
(
Array
.
isArray
(
param
[
key
])
)
throw
new
BizError
(
ERRORENUM
.
参数错误
,
`
${
key
}
应是Object型 而不是array`
);
try
{
JSON
.
stringify
(
param
[
key
]);
}
catch
(
err
)
{
throw
new
BizError
(
ERRORENUM
.
参数错误
,
`
${
key
}
应是Object型 转换JSON时失败`
);
}
break
;
}
}
for
(
let
key
in
param
)
{
if
(
!
conf
[
key
])
throw
new
BizError
(
ERRORENUM
.
表单校验失败
,
name
,
`多余
${
key
}
字段`
);
}
return
param
;
}
/**
* 获取token
...
...
@@ -201,8 +249,10 @@ export function changeEnumValue(enumConf, value:any) {
return
enumConf
[
value
];
}
let
str
=
""
;
value
.
forEach
(
item
=>
{
value
.
forEach
(
(
item
,
index
)
=>
{
str
+=
enumConf
[
item
];
if
(
index
==
value
.
length
-
1
)
str
+=
""
;
else
str
+=
","
});
return
str
;
...
...
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