Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
E
ezijing-node-server
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
ezijing-node-server
Commits
f06fb71f
提交
f06fb71f
authored
6月 29, 2020
作者:
zyx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增 微信过审接口
上级
ba30e812
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
125 行增加
和
0 行删除
+125
-0
launch.json
.vscode/launch.json
+1
-0
CkeditorMonitor.js
server/controller/CkeditorMonitor.js
+77
-0
wxChartSuccessMonitor.js
server/controller/wxChartSuccessMonitor.js
+40
-0
index.js
server/routes/index.js
+7
-0
没有找到文件。
.vscode/launch.json
浏览文件 @
f06fb71f
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
"request"
:
"launch"
,
"request"
:
"launch"
,
"name"
:
"Launch Program"
,
"name"
:
"Launch Program"
,
"program"
:
"${workspaceFolder}/server/distRun.js"
,
"program"
:
"${workspaceFolder}/server/distRun.js"
,
"runtimeExecutable"
:
"/usr/local/bin/node"
,
"env"
:
{
"env"
:
{
"SERVER_PORT"
:
"5101"
,
"SERVER_PORT"
:
"5101"
,
"NODE_ENV"
:
"production"
"NODE_ENV"
:
"production"
...
...
server/controller/CkeditorMonitor.js
0 → 100644
浏览文件 @
f06fb71f
const
fs
=
require
(
'fs'
)
const
conf
=
require
(
'../config'
)
const
com
=
require
(
'@god/node-com'
)
const
axios
=
require
(
'axios'
)
/* 支持 finally函数 */
require
(
'promise.prototype.finally'
).
shim
()
const
ckeditorUpload
=
(
req
,
res
)
=>
{
/* 文件上传 ckeditor4.5以上返回格式 */
function
sendHtml
(
url
,
msg
)
{
res
.
json
({
'uploaded'
:
url
?
1
:
0
,
'fileName'
:
'image'
,
'url'
:
url
,
'error'
:
{
'message'
:
msg
}
})
}
if
(
req
.
files
.
length
)
{
if
(
!
req
.
files
[
0
].
mimetype
.
startsWith
(
'image'
))
{
sendHtml
(
''
,
'文件类型错误,请上传图片'
);
return
}
if
(
req
.
files
[
0
].
size
>
10
*
1024
*
1024
)
{
sendHtml
(
''
,
'图片大小超限'
);
return
}
req
.
files
[
0
].
fieldname
=
'image'
let
headers
=
req
.
headers
let
options
=
{}
options
=
{
timeout
:
30
*
1000
,
url
:
'util/upload-image'
,
baseURL
:
conf
.
agentApiUrl
,
method
:
req
.
method
,
data
:
req
.
body
,
params
:
req
.
query
}
headers
[
'accept'
]
=
'*/*'
delete
headers
[
'accept-language'
]
let
_fileName
=
com
.
Tool
.
ReqType
.
toFormData
(
req
,
options
)
headers
[
'token'
]
=
com
.
Tool
.
Cookie
.
getTicketByCAS
(
'_SUP'
,
req
)
headers
[
'tenant'
]
=
'classes'
headers
[
'apikey'
]
=
'ITol9gsbkEb85gnaxIu7oWfHDOaKgwbH'
headers
[
'Host'
]
=
'ep-api.ezijing.com'
headers
[
'host'
]
=
'ep-api.ezijing.com'
axios
.
defaults
.
headers
=
headers
/* 重新转发请求 */
axios
(
options
).
then
((
data
)
=>
{
if
(
data
.
data
.
success
)
{
sendHtml
(
data
.
data
.
url
,
''
)
}
else
{
sendHtml
(
''
,
'上传错误,请重试'
)
}
req
.
files
.
forEach
((
elem
,
i
)
=>
{
fs
.
stat
(
elem
.
destination
+
elem
.
originalname
,
(
error
,
stats
)
=>
{
if
(
error
)
{
return
}
fs
.
unlink
(
elem
.
destination
+
elem
.
originalname
,
(
error
)
=>
{
if
(
error
)
console
.
log
(
error
)
})
})
})
}).
catch
((
e
)
=>
{
sendHtml
(
''
,
'上传错误,请重试1'
)
}).
finally
(()
=>
{
/* 请求结束,删除服务器端 缓存文件 */
if
(
_fileName
.
length
)
{
for
(
let
i
=
0
;
i
<
_fileName
.
length
;
i
++
)
{
fs
.
unlinkSync
(
_fileName
[
i
])
}
}
})
}
}
module
.
exports
=
{
ckeditorUpload
:
ckeditorUpload
}
server/controller/wxChartSuccessMonitor.js
0 → 100644
浏览文件 @
f06fb71f
const
fs
=
require
(
'fs'
)
const
path
=
require
(
'path'
)
const
com
=
require
(
'@god/node-com'
)
const
_mkdir
=
com
.
Tool
.
Directory
.
mkdir
const
get
=
(
req
,
res
)
=>
{
let
path1
=
path
.
resolve
(
process
.
cwd
(),
'../node-server-data/wxchart-success.json'
)
if
(
!
fs
.
existsSync
(
path1
))
{
_mkdir
(
path1
.
replace
(
/
\/[^\/]
*
?
$/gi
,
''
),
()
=>
{
fs
.
writeFileSync
(
path1
,
JSON
.
stringify
({}),
'utf8'
)
})
res
.
status
(
200
).
json
({
'msg'
:
'文件不存在,创建文件'
})
return
}
let
_json
=
JSON
.
parse
(
fs
.
readFileSync
(
path1
).
toString
()
||
'{}'
)
let
keyStr
=
req
.
baseUrl
.
replace
(
/
\/
get
\/
wx-chart
\/
/gi
,
''
)
/* 获取对应值 */
res
.
status
(
200
).
json
({
code
:
_json
[
keyStr
]
||
-
1
})
}
const
set
=
(
req
,
res
)
=>
{
let
path1
=
path
.
resolve
(
process
.
cwd
(),
'../node-server-data/wxchart-success.json'
)
if
(
!
fs
.
existsSync
(
path1
))
{
_mkdir
(
path1
.
replace
(
/
\/[^\/]
*
?
$/gi
,
''
))
res
.
status
(
200
).
json
({
'msg'
:
'文件不存在,创建文件'
})
return
}
let
_json
=
JSON
.
parse
(
fs
.
readFileSync
(
path1
).
toString
()
||
'{}'
)
let
keyStr
=
req
.
baseUrl
.
replace
(
/
\/
set
\/
wx-chart
\/
/gi
,
''
)
_json
[
keyStr
]
=
parseInt
(
req
.
query
.
val
||
0
)
/* 设置对应值 */
fs
.
writeFileSync
(
path1
,
JSON
.
stringify
(
_json
),
'utf8'
)
res
.
status
(
200
).
json
(
_json
)
}
module
.
exports
=
{
get
:
get
,
set
:
set
}
server/routes/index.js
浏览文件 @
f06fb71f
...
@@ -12,6 +12,8 @@ const _rtmp = require('../controller/RTMPMonitor')
...
@@ -12,6 +12,8 @@ const _rtmp = require('../controller/RTMPMonitor')
const
_sccm
=
require
(
'../controller/setCloudClassMonitor'
)
const
_sccm
=
require
(
'../controller/setCloudClassMonitor'
)
const
_nts
=
require
(
'../controller/NextToSend'
)
const
_nts
=
require
(
'../controller/NextToSend'
)
const
_pr
=
require
(
'../controller/ProxyRequest'
)
const
_pr
=
require
(
'../controller/ProxyRequest'
)
const
_wxcsm
=
require
(
'../controller/wxChartSuccessMonitor'
)
// const _cm = require('../controller/CkeditorMonitor')
router
.
use
(
bodyParser
.
json
({
limit
:
'60mb'
}))
router
.
use
(
bodyParser
.
json
({
limit
:
'60mb'
}))
router
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
,
limit
:
'60mb'
}))
router
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
,
limit
:
'60mb'
}))
...
@@ -59,6 +61,11 @@ router.post('/set/cloud-class', _sccm.setTable)
...
@@ -59,6 +61,11 @@ router.post('/set/cloud-class', _sccm.setTable)
router
.
get
(
'/abc/test/cba/*'
,
_nts
.
getData
)
router
.
get
(
'/abc/test/cba/*'
,
_nts
.
getData
)
// 接口转发 - 解决跨域问题
// 接口转发 - 解决跨域问题
router
.
use
(
'/v1/pay/wechat/*'
,
_pr
.
use
)
router
.
use
(
'/v1/pay/wechat/*'
,
_pr
.
use
)
// 支持微信过审 - 接口
router
.
use
(
'/get/wx-chart/*'
,
_wxcsm
.
get
)
router
.
use
(
'/set/wx-chart/*'
,
_wxcsm
.
set
)
// 支持 ckeditor 图片上传
// router.use('/form/ckeditor-upload', upload.any(), _cm.ckeditorUpload)
router
.
use
(
'/api/*'
,
upload
.
any
(),
(
req
,
res
)
=>
{
res
.
send
(
'暂无该接口'
)
})
router
.
use
(
'/api/*'
,
upload
.
any
(),
(
req
,
res
)
=>
{
res
.
send
(
'暂无该接口'
)
})
router
.
use
(
'*'
,
upload
.
any
(),
(
req
,
res
)
=>
{
res
.
send
(
'接口未定义'
)
})
router
.
use
(
'*'
,
upload
.
any
(),
(
req
,
res
)
=>
{
res
.
send
(
'接口未定义'
)
})
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论