Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
付智勇
/
koa2_Sequelize_project
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
付智勇
8 years ago
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
94d0ce6cd94d2741b959f55d120e19d2b934569d
94d0ce6c
1 parent
cd349c48
上传轮播
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
37 行增加
和
9 行删除
routes/upload.js
services/meetingService.js
services/studentMeetingService.js
views/index.html
routes/upload.js
查看文件 @
94d0ce6
...
...
@@ -30,25 +30,38 @@ router.post('/upLoadDoc',uploaddemo, async (ctx, next) => {
try
{
const
businessId
=
ctx
.
query
.
businessId
;
const
category
=
ctx
.
query
.
category
;
const
siteId
=
ctx
.
query
.
siteId
;
let
w
=
await
fs
.
rename
(
applacation
.
uploade
+
ctx
.
req
.
file
.
filename
,
applacation
.
uploade
+
ctx
.
req
.
file
.
originalname
)
let
path
=
'http://localhost:10000/'
+
ctx
.
req
.
file
.
originalname
attachmentData
=
{
id
:
uuid
.
db32
(),
businessId
:
businessId
,
category
:
category
,
path
:
path
path
:
path
,
siteId
:
siteId
}
let
oldAttachment
=
await
attachmentModel
.
findOne
({
where
:{
businessId
:
businessId
}})
if
(
oldAttachment
){
let
oldAttachment
=
await
attachmentModel
.
update
({
path
:
path
},{
where
:{
businessId
:
businessId
}})
let
oldAttachment
=
await
attachmentModel
.
findOne
({
where
:{
businessId
:
businessId
,
category
:
1
}})
if
(
category
==
2
){
let
oldAttachment2
=
await
attachmentModel
.
findAll
({
where
:{
category
:
2
,
siteId
:
siteId
}})
if
(
oldAttachment2
.
length
>
5
){
throw
new
Error
(
'最多上传5张'
)
}
else
{
let
oldAttachment2one
=
await
attachmentModel
.
findOne
({
where
:{
businessId
:
businessId
,
category
:
2
,
siteId
:
siteId
}})
if
(
oldAttachment2one
){
let
oldAttachment
=
await
attachmentModel
.
update
({
path
:
path
},{
where
:{
businessId
:
businessId
,
category
:
2
,
siteId
:
siteId
}})
}
else
{
let
attachment
=
await
attachmentModel
.
create
(
attachmentData
)
}
}
}
else
if
(
oldAttachment
){
let
oldAttachment
=
await
attachmentModel
.
update
({
path
:
path
},{
where
:{
businessId
:
businessId
,
category
:
1
}})
}
else
{
let
attachment
=
await
attachmentModel
.
create
(
attachmentData
)
}
ctx
.
response
.
status
=
200
;
ctx
.
body
=
{
code
:
200
,
fileUrl
:
path
+
ctx
.
req
.
file
.
originalname
fileUrl
:
path
}
}
catch
(
error
)
{
console
.
log
(
error
)
...
...
@@ -58,6 +71,21 @@ router.post('/upLoadDoc',uploaddemo, async (ctx, next) => {
})
router
.
post
(
'/getImgBySiteId'
,
async
(
ctx
,
next
)
=>
{
try
{
let
img
=
await
attachmentModel
.
findAll
({
where
:{
siteId
:
ctx
.
request
.
body
.
siteId
,
category
:
2
}
});
status
.
successTemp
(
ctx
,
200
,
img
);
}
catch
(
e
){
console
.
log
(
e
)
status
.
catchError
(
ctx
,
400
,
e
.
message
);
}
})
router
.
post
(
'/tgpCallback'
,
async
(
ctx
,
next
)
=>
{
//let s = await uploaddemo(ctx.req,ctx.res,next)
...
...
services/meetingService.js
查看文件 @
94d0ce6
...
...
@@ -102,7 +102,7 @@ meetingService.prototype.getMeeting = async(queryData,page = 1,pageno =12) =>{
FROM
3
m_attachment
WHERE
3
m_attachment
.
business_id
=
3
m_meeting
.
id
3
m_attachment
.
business_id
=
3
m_meeting
.
id
and
3
m_attachment
.
category
=
1
)
meetingPhoto
,
(
SELECT
...
...
services/studentMeetingService.js
查看文件 @
94d0ce6
...
...
@@ -140,7 +140,7 @@ studentMeetingService.prototype.getStudentMeetingByStudentId = async(id,page=1,p
FROM
3m_attachment
WHERE
3m_attachment.business_id = 3meet.id
3m_attachment.business_id = 3meet.id
and 3m_attachment.category = 1
) meetingPhoto
FROM
3m_student_meeting 3sm
...
...
views/index.html
查看文件 @
94d0ce6
...
...
@@ -7,7 +7,7 @@
<script
src=
"http://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"
></script>
</head>
<body>
<form
action=
"/upload/upLoadDoc?businessId=
0aJeQOYgLAo5yB1mE14Rvzb69V7mpZKD&category=1
"
method=
"post"
enctype=
"multipart/form-data"
target=
"http://baidu.com"
>
<form
action=
"/upload/upLoadDoc?businessId=
8a9945605e7a0d74015e8388f9f022d6&category=2&siteId=networkschool
"
method=
"post"
enctype=
"multipart/form-data"
target=
"http://baidu.com"
>
<input
type=
"file"
name=
"file"
/>
<input
type=
"submit"
value=
"ok"
/>
</form>
...
...
请
注册
或
登录
后发表评论