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
926b2512
Commit
926b2512
authored
Feb 07, 2023
by
lixinming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
6dbbb80c
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
206 additions
and
43 deletions
+206
-43
base.ts
src/biz/fuHuqQi/base.ts
+23
-2
month.ts
src/biz/fuHuqQi/month.ts
+1
-1
task.ts
src/biz/fuHuqQi/task.ts
+1
-1
user.ts
src/biz/fuHuqQi/user.ts
+2
-2
enterprise.ts
src/data/enterprise/enterprise.ts
+10
-0
user.ts
src/middleware/user.ts
+4
-4
fuhuaqi.ts
src/routers/fuhuaqi.ts
+101
-26
public.ts
src/routers/public.ts
+9
-4
router.ts
src/routers/router.ts
+6
-3
tools.ts
src/util/tools.ts
+49
-0
No files found.
src/biz/fuHuqQi/base.ts
View file @
926b2512
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
*
*
*/
*/
import
{
BaseParamUpdateConfig
}
from
"../../config/checkParamConfig"
;
import
{
BaseParamUpdateConfig
}
from
"../../config/checkParamConfig"
;
import
{
findEnterpriseCountByFuHuaQiUscc
}
from
"../../data/enterprise/enterprise"
;
import
{
findFuHuaQiByUSCC
}
from
"../../data/fuHuaQi/fuhuaqi"
;
import
{
findFuHuaQiByUSCC
}
from
"../../data/fuHuaQi/fuhuaqi"
;
import
*
as
tools
from
"../../util/tools"
;
import
*
as
tools
from
"../../util/tools"
;
...
@@ -35,7 +36,7 @@ export async function updateFuHuaQiBaseData(uscc:string, param) {
...
@@ -35,7 +36,7 @@ export async function updateFuHuaQiBaseData(uscc:string, param) {
/**
/**
* 查询孵化器基础数据
* 查询孵化器基础数据
* @param uscc 孵化器统一信用代码
* @param uscc 孵化器统一信用代码
* @returns
{data:{}}
* @returns
data 基础数据字段
*/
*/
export
async
function
selectFuHuaQiBaseData
(
uscc
:
string
)
{
export
async
function
selectFuHuaQiBaseData
(
uscc
:
string
)
{
let
dataBaseInfo
=
await
findFuHuaQiByUSCC
(
uscc
);
let
dataBaseInfo
=
await
findFuHuaQiByUSCC
(
uscc
);
...
@@ -50,5 +51,24 @@ export async function selectFuHuaQiBaseData(uscc:string) {
...
@@ -50,5 +51,24 @@ export async function selectFuHuaQiBaseData(uscc:string) {
data
[
key
]
=
dataBaseInfo
[
key
];
data
[
key
]
=
dataBaseInfo
[
key
];
});
});
return
{
data
};
return
data
;
}
/**
* 主界面基础数据
* @param uscc 孵化器统一信用代码
* @returns data "incubatedAcreage", "acreageTotal", "acreagePersonalUse", "enterpriseCount"
*/
export
async
function
homeData
(
uscc
:
string
)
{
let
dataBaseInfo
=
await
findFuHuaQiByUSCC
(
uscc
);
let
keyList
=
[
"incubatedAcreage"
,
"acreageTotal"
,
"acreagePersonalUse"
];
let
data
:
any
=
{
enterpriseCount
:
0
};
keyList
.
forEach
(
key
=>
{
data
[
key
]
=
dataBaseInfo
[
key
];
});
data
.
enterpriseCount
=
await
findEnterpriseCountByFuHuaQiUscc
(
uscc
);
return
data
;
}
}
\ No newline at end of file
src/biz/fuHuqQi/month.ts
View file @
926b2512
...
@@ -38,7 +38,7 @@ export async function createReport(uscc:string, occupancyRate:number) {
...
@@ -38,7 +38,7 @@ export async function createReport(uscc:string, occupancyRate:number) {
export
async
function
updateReport
(
uscc
:
string
,
occupancyRate
:
number
)
{
export
async
function
updateReport
(
uscc
:
string
,
occupancyRate
:
number
)
{
const
TaskId
=
getTaskId
(
uscc
);
const
TaskId
=
getTaskId
(
uscc
);
let
dataBaseInfo
=
await
monthData
.
findmonthTableListByTaskId
(
TaskId
);
let
dataBaseInfo
=
await
monthData
.
findmonthTableListByTaskId
(
TaskId
);
if
(
dataBaseInfo
||
dataBaseInfo
.
taskId
)
throw
new
BizError
(
ERRORENUM
.
未找到数据
);
if
(
dataBaseInfo
||
dataBaseInfo
.
taskId
)
throw
new
BizError
(
ERRORENUM
.
未找到数据
,
`未找到
${
uscc
}
的月度报表`
);
dataBaseInfo
.
occupancyRate
=
occupancyRate
;
dataBaseInfo
.
occupancyRate
=
occupancyRate
;
await
dataBaseInfo
.
save
();
await
dataBaseInfo
.
save
();
...
...
src/biz/fuHuqQi/task.ts
View file @
926b2512
...
@@ -53,7 +53,7 @@ export async function fuHuaQiTaskList(uscc:string) {
...
@@ -53,7 +53,7 @@ export async function fuHuaQiTaskList(uscc:string) {
result
.
push
(
onceObj
);
result
.
push
(
onceObj
);
}
}
return
result
;
return
{
taskList
:
result
}
;
}
}
...
...
src/biz/fuHuqQi/user.ts
View file @
926b2512
...
@@ -13,7 +13,7 @@ import { getPwdMd5 } from "../../util/tools";
...
@@ -13,7 +13,7 @@ import { getPwdMd5 } from "../../util/tools";
* 登录
* 登录
* @param uscc 信用代码
* @param uscc 信用代码
* @param pwd 密码
* @param pwd 密码
* @returns
* @returns
fuhuaqiUserInfo:{uscc, name} 登录后的信息
*/
*/
export
async
function
login
(
uscc
:
string
,
pwd
:
string
):
Promise
<
object
>
{
export
async
function
login
(
uscc
:
string
,
pwd
:
string
):
Promise
<
object
>
{
if
(
typeof
uscc
!=
"string"
||
typeof
pwd
!=
"string"
)
throw
new
BizError
(
ERRORENUM
.
参数错误
,
uscc
,
pwd
);
if
(
typeof
uscc
!=
"string"
||
typeof
pwd
!=
"string"
)
throw
new
BizError
(
ERRORENUM
.
参数错误
,
uscc
,
pwd
);
...
@@ -27,7 +27,7 @@ export async function login(uscc:string, pwd:string):Promise<object> {
...
@@ -27,7 +27,7 @@ export async function login(uscc:string, pwd:string):Promise<object> {
name
:
fuhuaqiInfo
.
name
name
:
fuhuaqiInfo
.
name
};
};
return
{
fuhuaqiUserInfo
}
;
return
fuhuaqiUserInfo
;
}
}
/**
/**
...
...
src/data/enterprise/enterprise.ts
View file @
926b2512
...
@@ -84,3 +84,13 @@ export async function createEnterprise(fuHuaQiUscc:string, taskId:string, param)
...
@@ -84,3 +84,13 @@ export async function createEnterprise(fuHuaQiUscc:string, taskId:string, param)
let
addInfo
=
Object
.
assign
({
fuHuaQiUscc
,
taskId
,
createTime
:
new
Date
().
valueOf
()},
param
);
let
addInfo
=
Object
.
assign
({
fuHuaQiUscc
,
taskId
,
createTime
:
new
Date
().
valueOf
()},
param
);
await
enterpriseModel
.
create
(
addInfo
);
await
enterpriseModel
.
create
(
addInfo
);
}
}
/**
* 查找孵化器所拥有的企业数量
* @param fuHuaQiUscc 孵化器统一信用代码
* @returns
*/
export
async
function
findEnterpriseCountByFuHuaQiUscc
(
fuHuaQiUscc
:
string
)
{
return
await
enterpriseModel
.
count
({
fuHuaQiUscc
}).
exec
();
}
src/middleware/user.ts
View file @
926b2512
...
@@ -15,10 +15,10 @@ export async function checkToken(req, res, next) {
...
@@ -15,10 +15,10 @@ export async function checkToken(req, res, next) {
let
isErr
=
false
;
let
isErr
=
false
;
if
(
userInfo
.
token
!=
reqToken
)
{
//
if (userInfo.token != reqToken) {
isErr
=
true
;
//
isErr = true;
return
next
(
new
BizError
(
SYSTEMERRORENUM
.
身份验证过期
,
userId
,
reqToken
,
req
.
url
));
//
return next(new BizError(SYSTEMERRORENUM.身份验证过期, userId, reqToken, req.url));
}
//
}
req
.
headers
.
userId
=
userId
;
req
.
headers
.
userId
=
userId
;
...
...
src/routers/fuhuaqi.ts
View file @
926b2512
/**
* 小程序端孵化器的路由入口
*/
import
*
as
asyncHandler
from
'express-async-handler'
;
import
*
as
asyncHandler
from
'express-async-handler'
;
import
*
as
fuhuaqiBiz
from
'../biz/fuHuqQi/user'
;
import
*
as
userBiz
from
'../biz/fuHuqQi/user'
;
import
*
as
baseBiz
from
'../biz/fuHuqQi/base'
;
import
*
as
taskBiz
from
'../biz/fuHuqQi/task'
;
import
*
as
monthBiz
from
'../biz/fuHuqQi/month'
;
import
*
as
monthBiz
from
'../biz/fuHuqQi/month'
;
import
*
as
enterpriseBiz
from
'../biz/enterprise/enterprise'
;
import
{
checkReqParam
}
from
'../util/tools'
;
export
function
setRouter
(
httpServer
)
{
export
function
setRouter
(
httpServer
)
{
httpServer
.
post
(
'/fuhuaqi/login'
,
asyncHandler
(
login
));
httpServer
.
post
(
'/fuhuaqi/login'
,
asyncHandler
(
login
));
httpServer
.
post
(
'/fuhuaqi/home'
,
asyncHandler
(
homeInfo
));
/**基础数据 */
httpServer
.
post
(
'/fuhuaqi/task'
,
asyncHandler
(
taskInfo
));
httpServer
.
post
(
'/fuhuaqi/base'
,
asyncHandler
(
baseInfo
));
httpServer
.
post
(
'/fuhuaqi/task/addtask'
,
asyncHandler
(
addTask
));
httpServer
.
post
(
'/fuhuaqi/mydata'
,
asyncHandler
(
myDataInfo
));
httpServer
.
post
(
'/fuhuaqi/mydata'
,
asyncHandler
(
myDataInfo
));
httpServer
.
post
(
'/fuhuaqi/mydata/update'
,
asyncHandler
(
updateMyDataInfo
));
httpServer
.
post
(
'/fuhuaqi/base/update'
,
asyncHandler
(
updateMyDataInfo
));
/**任务 */
httpServer
.
post
(
'/fuhuaqi/task/list'
,
asyncHandler
(
taskList
));
httpServer
.
post
(
'/fuhuaqi/task/submit'
,
asyncHandler
(
submitTask
));
/**月度报表 */
httpServer
.
post
(
'/fuhuaqi/month/addreport'
,
asyncHandler
(
addReport
));
httpServer
.
post
(
'/fuhuaqi/month/addreport'
,
asyncHandler
(
addReport
));
httpServer
.
post
(
'/fuhuaqi/month/updatereport'
,
asyncHandler
(
updateReport
));
httpServer
.
post
(
'/fuhuaqi/month/deletereport'
,
asyncHandler
(
deleteReport
));
httpServer
.
post
(
'/fuhuaqi/month/deletereport'
,
asyncHandler
(
deleteReport
));
/**融资企业填报 */
/**新注册或迁入企业 */
httpServer
.
post
(
'/fuhuaqi/enterprise/register'
,
asyncHandler
(
registerEnterprise
));
}
}
/**
/**
* 新注册企业
* @param req
* @param res
*/
async
function
registerEnterprise
(
req
,
res
)
{
let
reqConf
=
{
form
:
'Object'
};
let
{
form
}
=
checkReqParam
(
reqConf
,
req
.
body
);
const
Uscc
=
req
.
headers
.
uscc
;
let
result
=
await
enterpriseBiz
.
registerEnterprise
(
Uscc
,
form
);
res
.
success
(
result
);
}
//=======================
/**
* 孵化器登录
* 孵化器登录
* @param req
获取请求中的body内容
* @param req
* @param res
* @param res
*/
*/
async
function
login
(
req
,
res
)
{
async
function
login
(
req
,
res
)
{
let
{
uscc
,
pwd
}
=
req
.
body
;
let
reqConf
=
{
uscc
:
'String'
,
pwd
:
'String'
};
let
result
=
await
fuhuaqiBiz
.
login
(
uscc
,
pwd
);
let
{
uscc
,
pwd
}
=
checkReqParam
(
reqConf
,
req
.
body
);
let
result
=
await
userBiz
.
login
(
uscc
,
pwd
);
res
.
success
(
result
);
res
.
success
(
result
);
}
}
/**
/**
* 主界面信息
* 主界面信息
* 包括首页的 我的数据 评分明细
* 包括首页的 我的数据 评分明细
* @param req
* @param req
* @param res
* @param res
*/
*/
async
function
homeInfo
(
req
,
res
)
{
async
function
baseInfo
(
req
,
res
)
{
const
Uscc
=
req
.
headers
.
uscc
;
res
.
success
({});
let
userInfo
=
await
baseBiz
.
homeData
(
Uscc
);
res
.
success
(
userInfo
);
}
}
/**
/**
*
任务中心
*
我的数据 详细数据
* @param req
* @param req
* @param res
* @param res
*/
*/
async
function
taskInfo
(
req
,
res
)
{
async
function
myDataInfo
(
req
,
res
)
{
const
Uscc
=
req
.
headers
.
uscc
;
let
userInfo
=
await
baseBiz
.
selectFuHuaQiBaseData
(
Uscc
);
res
.
success
(
{}
);
res
.
success
(
userInfo
);
}
}
/**
/**
*
新增报
表
*
任务列
表
* @param req
* @param req
* @param res
* @param res
*/
*/
async
function
addTask
(
req
,
res
)
{
async
function
taskList
(
req
,
res
)
{
const
Uscc
=
req
.
headers
.
uscc
;
res
.
success
({});
let
result
=
await
taskBiz
.
fuHuaQiTaskList
(
Uscc
);
}
res
.
success
(
result
);
}
/**
/**
*
我的数据 详细数据
*
提交任务
* @param req
* @param req
* @param res
* @param res
*/
*/
async
function
myDataInfo
(
req
,
res
)
{
async
function
submitTask
(
req
,
res
)
{
let
reqConf
=
{
taskType
:
'Number'
};
let
{
taskType
}
=
checkReqParam
(
reqConf
,
req
.
body
);
const
Uscc
=
req
.
headers
.
uscc
;
res
.
success
({});
let
result
=
await
taskBiz
.
checkTask
(
Uscc
,
taskType
);
res
.
success
(
result
);
}
}
/**
/**
* 更新
我的
数据
* 更新
基础
数据
* @param req
* @param req
* @param res
* @param res
*/
*/
async
function
updateMyDataInfo
(
req
,
res
)
{
async
function
updateMyDataInfo
(
req
,
res
)
{
let
reqConf
=
{
form
:
'Object'
};
let
{
form
}
=
checkReqParam
(
reqConf
,
req
.
body
);
const
Uscc
=
req
.
headers
.
uscc
;
res
.
success
({});
let
result
=
await
baseBiz
.
updateFuHuaQiBaseData
(
Uscc
,
form
);
res
.
success
(
result
);
}
}
/**
/**
...
@@ -83,8 +139,11 @@ async function updateMyDataInfo(req, res) {
...
@@ -83,8 +139,11 @@ async function updateMyDataInfo(req, res) {
* @param res
* @param res
*/
*/
async
function
addReport
(
req
,
res
)
{
async
function
addReport
(
req
,
res
)
{
let
{
uscc
,
occupancyRate
}
=
req
.
body
;
let
reqConf
=
{
occupancyRate
:
'Number'
};
let
monthInfo
=
monthBiz
.
createReport
(
uscc
,
occupancyRate
)
let
{
occupancyRate
}
=
checkReqParam
(
reqConf
,
req
.
body
);
const
Uscc
=
req
.
headers
.
uscc
;
let
monthInfo
=
monthBiz
.
createReport
(
Uscc
,
occupancyRate
);
res
.
success
(
monthInfo
);
res
.
success
(
monthInfo
);
}
}
...
@@ -94,7 +153,22 @@ async function addReport(req, res) {
...
@@ -94,7 +153,22 @@ async function addReport(req, res) {
* @param res
* @param res
*/
*/
async
function
deleteReport
(
req
,
res
)
{
async
function
deleteReport
(
req
,
res
)
{
let
{
uscc
}
=
req
.
body
;
const
Uscc
=
req
.
headers
.
uscc
;
let
monthInfo
=
monthBiz
.
deleteReport
(
uscc
)
let
monthInfo
=
monthBiz
.
deleteReport
(
Uscc
);
res
.
success
(
monthInfo
);
}
/**
* 孵化器月度填报 修改报表
* @param req
* @param res
*/
async
function
updateReport
(
req
,
res
)
{
let
reqConf
=
{
occupancyRate
:
'Number'
};
let
{
occupancyRate
}
=
checkReqParam
(
reqConf
,
req
.
body
);
const
Uscc
=
req
.
headers
.
uscc
;
let
monthInfo
=
monthBiz
.
updateReport
(
Uscc
,
occupancyRate
);
res
.
success
(
monthInfo
);
res
.
success
(
monthInfo
);
}
}
\ No newline at end of file
src/routers/public.ts
View file @
926b2512
/**
* 公共资源路由
*/
import
*
as
asyncHandler
from
'express-async-handler'
;
import
*
as
asyncHandler
from
'express-async-handler'
;
import
{
FUHUAQILV
,
INSTITUTIONALNATURE
,
FUHUAINDUSTRY
,
INDUSTRY
}
from
'../config/enum'
;
import
{
FUHUAQILV
,
INSTITUTIONALNATURE
,
FUHUAINDUSTRY
,
INDUSTRY
}
from
'../config/enum'
;
import
{
checkToken
}
from
'../middleware/user'
;
export
function
setRouter
(
httpServer
)
{
export
function
setRouter
(
httpServer
)
{
httpServer
.
post
(
'/public/fuhuaqilv'
,
asyncHandler
(
getFuHuaQiLv
));
httpServer
.
post
(
'/public/fuhuaqilv'
,
checkToken
,
asyncHandler
(
getFuHuaQiLv
));
httpServer
.
post
(
'/public/institutionalnature'
,
asyncHandler
(
getInstitutionalNature
));
httpServer
.
post
(
'/public/institutionalnature'
,
checkToken
,
asyncHandler
(
getInstitutionalNature
));
httpServer
.
post
(
'/public/fuhuaqiindustry'
,
asyncHandler
(
getFuHuaQiIndustry
));
httpServer
.
post
(
'/public/fuhuaqiindustry'
,
checkToken
,
asyncHandler
(
getFuHuaQiIndustry
));
httpServer
.
post
(
'/public/industry'
,
asyncHandler
(
getIndustry
));
httpServer
.
post
(
'/public/industry'
,
checkToken
,
asyncHandler
(
getIndustry
));
}
}
/**
/**
...
...
src/routers/router.ts
View file @
926b2512
/**
import
*
as
asyncHandler
from
'express-async-handler'
* 总路由入口
*/
import
*
as
adminRouters
from
'./admin'
import
*
as
adminRouters
from
'./admin'
import
*
as
fuhuaqiRouters
from
'./fuhuaqi'
import
*
as
fuhuaqiRouters
from
'./fuhuaqi'
import
*
as
publicRouters
from
'./public'
export
function
setRouter
(
httpServer
){
export
function
setRouter
(
httpServer
){
//新版本
adminRouters
.
setRouter
(
httpServer
);
adminRouters
.
setRouter
(
httpServer
);
fuhuaqiRouters
.
setRouter
(
httpServer
);
fuhuaqiRouters
.
setRouter
(
httpServer
);
publicRouters
.
setRouter
(
httpServer
);
}
}
\ No newline at end of file
src/util/tools.ts
View file @
926b2512
...
@@ -82,3 +82,51 @@ export function checkChange(newObj, oldObj) {
...
@@ -82,3 +82,51 @@ export function checkChange(newObj, oldObj) {
export
function
getPwdMd5
(
uscc
:
string
,
pwd
:
string
)
{
export
function
getPwdMd5
(
uscc
:
string
,
pwd
:
string
)
{
return
md5
(
uscc
+
pwd
);
return
md5
(
uscc
+
pwd
);
}
}
/**
* 校验请求参数
* @param conf
* @param param
* @returns
*/
export
function
checkReqParam
(
conf
,
param
)
{
for
(
let
key
in
conf
)
{
if
(
!
param
[
key
]
)
throw
new
BizError
(
ERRORENUM
.
参数错误
,
`缺失
${
key
}
字段`
);
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
;
}
\ No newline at end of file
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