正在显示
4 个修改的文件
包含
37 行增加
和
9 行删除
@@ -30,25 +30,38 @@ router.post('/upLoadDoc',uploaddemo, async (ctx, next) => { | @@ -30,25 +30,38 @@ router.post('/upLoadDoc',uploaddemo, async (ctx, next) => { | ||
30 | try { | 30 | try { |
31 | const businessId = ctx.query.businessId; | 31 | const businessId = ctx.query.businessId; |
32 | const category = ctx.query.category; | 32 | const category = ctx.query.category; |
33 | + const siteId = ctx.query.siteId; | ||
33 | let w = await fs.rename(applacation.uploade+ctx.req.file.filename,applacation.uploade+ctx.req.file.originalname) | 34 | let w = await fs.rename(applacation.uploade+ctx.req.file.filename,applacation.uploade+ctx.req.file.originalname) |
34 | let path = 'http://localhost:10000/'+ctx.req.file.originalname | 35 | let path = 'http://localhost:10000/'+ctx.req.file.originalname |
35 | attachmentData = { | 36 | attachmentData = { |
36 | id:uuid.db32(), | 37 | id:uuid.db32(), |
37 | businessId:businessId, | 38 | businessId:businessId, |
38 | category:category, | 39 | category:category, |
39 | - path:path | 40 | + path:path, |
41 | + siteId:siteId | ||
40 | } | 42 | } |
41 | - let oldAttachment = await attachmentModel.findOne({where:{businessId:businessId}}) | ||
42 | - | ||
43 | - if(oldAttachment){ | ||
44 | - let oldAttachment = await attachmentModel.update({path:path},{where:{businessId:businessId}}) | 43 | + let oldAttachment = await attachmentModel.findOne({where:{businessId:businessId,category:1}}) |
44 | + if(category==2){ | ||
45 | + let oldAttachment2 = await attachmentModel.findAll({where:{category:2,siteId:siteId}}) | ||
46 | + if(oldAttachment2.length>5){ | ||
47 | + throw new Error('最多上传5张') | ||
48 | + }else { | ||
49 | + let oldAttachment2one = await attachmentModel.findOne({where:{businessId:businessId,category:2,siteId:siteId}}) | ||
50 | + if(oldAttachment2one){ | ||
51 | + let oldAttachment = await attachmentModel.update({path:path},{where:{businessId:businessId,category:2,siteId:siteId}}) | ||
52 | + }else{ | ||
53 | + let attachment = await attachmentModel.create(attachmentData) | ||
54 | + } | ||
55 | + } | ||
56 | + }else if(oldAttachment){ | ||
57 | + let oldAttachment = await attachmentModel.update({path:path},{where:{businessId:businessId,category:1}}) | ||
45 | }else{ | 58 | }else{ |
46 | let attachment = await attachmentModel.create(attachmentData) | 59 | let attachment = await attachmentModel.create(attachmentData) |
47 | } | 60 | } |
48 | ctx.response.status= 200; | 61 | ctx.response.status= 200; |
49 | ctx.body = { | 62 | ctx.body = { |
50 | code:200, | 63 | code:200, |
51 | - fileUrl:path+ctx.req.file.originalname | 64 | + fileUrl:path |
52 | } | 65 | } |
53 | } catch (error) { | 66 | } catch (error) { |
54 | console.log(error) | 67 | console.log(error) |
@@ -58,6 +71,21 @@ router.post('/upLoadDoc',uploaddemo, async (ctx, next) => { | @@ -58,6 +71,21 @@ router.post('/upLoadDoc',uploaddemo, async (ctx, next) => { | ||
58 | 71 | ||
59 | }) | 72 | }) |
60 | 73 | ||
74 | +router.post('/getImgBySiteId',async(ctx, next)=>{ | ||
75 | + try{ | ||
76 | + let img = await attachmentModel.findAll({ | ||
77 | + where:{ | ||
78 | + siteId:ctx.request.body.siteId, | ||
79 | + category:2 | ||
80 | + } | ||
81 | + }); | ||
82 | + status.successTemp(ctx,200,img); | ||
83 | + }catch(e){ | ||
84 | + console.log(e) | ||
85 | + status.catchError(ctx,400,e.message); | ||
86 | + } | ||
87 | +}) | ||
88 | + | ||
61 | router.post('/tgpCallback', async (ctx, next) => { | 89 | router.post('/tgpCallback', async (ctx, next) => { |
62 | 90 | ||
63 | //let s = await uploaddemo(ctx.req,ctx.res,next) | 91 | //let s = await uploaddemo(ctx.req,ctx.res,next) |
@@ -102,7 +102,7 @@ meetingService.prototype.getMeeting = async(queryData,page = 1,pageno =12) =>{ | @@ -102,7 +102,7 @@ meetingService.prototype.getMeeting = async(queryData,page = 1,pageno =12) =>{ | ||
102 | FROM | 102 | FROM |
103 | 3m_attachment | 103 | 3m_attachment |
104 | WHERE | 104 | WHERE |
105 | - 3m_attachment.business_id = 3m_meeting.id | 105 | + 3m_attachment.business_id = 3m_meeting.id and 3m_attachment.category = 1 |
106 | ) meetingPhoto, | 106 | ) meetingPhoto, |
107 | ( | 107 | ( |
108 | SELECT | 108 | SELECT |
@@ -140,7 +140,7 @@ studentMeetingService.prototype.getStudentMeetingByStudentId = async(id,page=1,p | @@ -140,7 +140,7 @@ studentMeetingService.prototype.getStudentMeetingByStudentId = async(id,page=1,p | ||
140 | FROM | 140 | FROM |
141 | 3m_attachment | 141 | 3m_attachment |
142 | WHERE | 142 | WHERE |
143 | - 3m_attachment.business_id = 3meet.id | 143 | + 3m_attachment.business_id = 3meet.id and 3m_attachment.category = 1 |
144 | ) meetingPhoto | 144 | ) meetingPhoto |
145 | FROM | 145 | FROM |
146 | 3m_student_meeting 3sm | 146 | 3m_student_meeting 3sm |
@@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
7 | <script src="http://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script> | 7 | <script src="http://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script> |
8 | </head> | 8 | </head> |
9 | <body> | 9 | <body> |
10 | - <form action="/upload/upLoadDoc?businessId=0aJeQOYgLAo5yB1mE14Rvzb69V7mpZKD&category=1" method="post" enctype="multipart/form-data" target="http://baidu.com"> | 10 | + <form action="/upload/upLoadDoc?businessId=8a9945605e7a0d74015e8388f9f022d6&category=2&siteId=networkschool" method="post" enctype="multipart/form-data" target="http://baidu.com"> |
11 | <input type="file" name="file"/> | 11 | <input type="file" name="file"/> |
12 | <input type="submit" value="ok"/> | 12 | <input type="submit" value="ok"/> |
13 | </form> | 13 | </form> |
-
请 注册 或 登录 后发表评论