作者 yangfu

上传修改

package v1
import (
"fmt"
"opp/controllers"
"opp/protocol"
"opp/services/upload"
... ... @@ -18,25 +19,27 @@ func (this *UploadController) Image() {
var (
msg *protocol.ResponseMessage
err error
rsp *protocol.FileResponse = &protocol.FileResponse{}
)
defer func() {
this.Resp(msg)
}()
var request = &protocol.FileRequest{}
//if err:=json.Unmarshal(this.ByteBody,&request);err!=nil{
// log.Error(err)
// msg = protocol.ReturnResponse(1)
// return
//}
//if b,m :=this.Valid(request);!b{
// msg = m
// return
//}
if request.Files, err = this.GetFiles("image"); err != nil {
log.Error(err)
return
for i := 1; i <= 9; i++ {
var tmp *protocol.FileResponse
key := fmt.Sprintf("%v%v", "image", i)
if request.Files, err = this.GetFiles(key); err != nil {
log.Error(key, err)
err = nil
break
}
if tmp, err = upload.Image(request); err != nil {
log.Error(err)
return
}
rsp.Paths = append(rsp.Paths, tmp.Paths...)
}
msg = protocol.NewReturnResponse(upload.Image(request))
msg = protocol.NewReturnResponse(rsp, err)
}
// Voice
... ... @@ -45,25 +48,27 @@ func (this *UploadController) Voice() {
var (
msg *protocol.ResponseMessage
err error
rsp *protocol.FileResponse = &protocol.FileResponse{}
)
defer func() {
this.Resp(msg)
}()
var request = &protocol.FileRequest{}
//if err:=json.Unmarshal(this.ByteBody,&request);err!=nil{
// log.Error(err)
// msg = protocol.ReturnResponse(1)
// return
//}
//if b,m :=this.Valid(request);!b{
// msg = m
// return
//}
if request.Files, err = this.GetFiles("file"); err != nil {
log.Error(err)
return
for i := 1; i <= 9; i++ {
var tmp *protocol.FileResponse
key := fmt.Sprintf("%v%v", "voice", i)
if request.Files, err = this.GetFiles(key); err != nil {
log.Error(key, err)
err = nil
break
}
if tmp, err = upload.Voice(request); err != nil {
log.Error(err)
return
}
rsp.Paths = append(rsp.Paths, tmp.Paths...)
}
msg = protocol.NewReturnResponse(upload.Voice(request))
msg = protocol.NewReturnResponse(rsp, err)
}
// Video
... ... @@ -76,10 +81,12 @@ func (this *UploadController) Video() {
defer func() {
this.Resp(msg)
}()
var request = &protocol.FileRequest{}
if request.Files, err = this.GetFiles("file"); err != nil {
log.Error(err)
return
for i := 1; i <= 9; i++ {
var request = &protocol.FileRequest{}
if request.Files, err = this.GetFiles("file"); err != nil {
log.Error(err)
return
}
msg = protocol.NewReturnResponse(upload.Video(request))
}
msg = protocol.NewReturnResponse(upload.Video(request))
}
... ...
... ... @@ -119,7 +119,7 @@ type Form struct {
type ChanceSubmitRequest struct {
Id int64 `json:"id"` // = 0添加 >0 编辑
AuditTemplateId int64 `json:"auditTemplateId" valid:"Required"`
Content string `json:"content" valid:"Required"`
Content string `json:"content"`
FormList []*Form `json:"formList" valid:"Required"`
Speechs []Speech `json:"speechs"`
Pictures []Picture `json:"pictures"`
... ...