正在显示
8 个修改的文件
包含
128 行增加
和
34 行删除
@@ -2,10 +2,8 @@ package v1 | @@ -2,10 +2,8 @@ package v1 | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "bytes" | 4 | "bytes" |
5 | - "encoding/json" | ||
6 | "fmt" | 5 | "fmt" |
7 | "opp/controllers" | 6 | "opp/controllers" |
8 | - "opp/internal/aliyun" | ||
9 | "opp/protocol" | 7 | "opp/protocol" |
10 | "opp/services/upload" | 8 | "opp/services/upload" |
11 | 9 | ||
@@ -96,24 +94,3 @@ func (this *UploadController) Video() { | @@ -96,24 +94,3 @@ func (this *UploadController) Video() { | ||
96 | } | 94 | } |
97 | msg = protocol.NewReturnResponse(rsp, err) | 95 | msg = protocol.NewReturnResponse(rsp, err) |
98 | } | 96 | } |
99 | - | ||
100 | -//创建视频上传凭证 CreateUploadVideo | ||
101 | -// @router /createUploadVideo [post] | ||
102 | -func (this *UploadController) CreateUploadVideo() { | ||
103 | - var msg *protocol.ResponseMessage | ||
104 | - defer func() { | ||
105 | - this.Resp(msg) | ||
106 | - }() | ||
107 | - var request *aliyun.CreateUploadVideoRequest | ||
108 | - if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
109 | - log.Error(err) | ||
110 | - msg = protocol.BadRequestParam(1) | ||
111 | - return | ||
112 | - } | ||
113 | - if b, m := this.Valid(request); !b { | ||
114 | - msg = m | ||
115 | - return | ||
116 | - } | ||
117 | - header := controllers.GetRequestHeader(this.Ctx) | ||
118 | - msg = protocol.NewReturnResponse(upload.CreateUploadVideo(header, request)) | ||
119 | -} |
controllers/v1/vod.go
0 → 100644
1 | +package v1 | ||
2 | + | ||
3 | +import ( | ||
4 | + "encoding/json" | ||
5 | + "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | ||
6 | + "opp/controllers" | ||
7 | + "opp/internal/aliyun" | ||
8 | + "opp/protocol" | ||
9 | + "opp/services/upload" | ||
10 | +) | ||
11 | + | ||
12 | +type VodController struct { | ||
13 | + controllers.BaseController | ||
14 | +} | ||
15 | + | ||
16 | +//创建视频上传凭证 CreateUploadVideo | ||
17 | +// @router /createUploadVideo [post] | ||
18 | +func (this *VodController) CreateUploadVideo() { | ||
19 | + var msg *protocol.ResponseMessage | ||
20 | + defer func() { | ||
21 | + this.Resp(msg) | ||
22 | + }() | ||
23 | + var request *aliyun.CreateUploadVideoRequest | ||
24 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
25 | + log.Error(err) | ||
26 | + msg = protocol.BadRequestParam(1) | ||
27 | + return | ||
28 | + } | ||
29 | + if b, m := this.Valid(request); !b { | ||
30 | + msg = m | ||
31 | + return | ||
32 | + } | ||
33 | + header := controllers.GetRequestHeader(this.Ctx) | ||
34 | + msg = protocol.NewReturnResponse(upload.CreateUploadVideo(header, request)) | ||
35 | +} | ||
36 | + | ||
37 | +//创建图片上传凭证 CreateUploadImage | ||
38 | +// @router /createUploadImage [post] | ||
39 | +func (this *VodController) CreateUploadImage() { | ||
40 | + var msg *protocol.ResponseMessage | ||
41 | + defer func() { | ||
42 | + this.Resp(msg) | ||
43 | + }() | ||
44 | + var request *aliyun.CreateUploadImageRequest | ||
45 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
46 | + log.Error(err) | ||
47 | + msg = protocol.BadRequestParam(1) | ||
48 | + return | ||
49 | + } | ||
50 | + if b, m := this.Valid(request); !b { | ||
51 | + msg = m | ||
52 | + return | ||
53 | + } | ||
54 | + header := controllers.GetRequestHeader(this.Ctx) | ||
55 | + msg = protocol.NewReturnResponse(upload.CreateUploadImage(header, request)) | ||
56 | +} |
internal/aliyun/struct_image.go
0 → 100644
1 | +package aliyun | ||
2 | + | ||
3 | +type CreateUploadImageRequest struct { | ||
4 | +} | ||
5 | + | ||
6 | +type CreateUploadImageResponse struct { | ||
7 | + RequestId string `json:"requestId" xml:"RequestId"` | ||
8 | + ImageId string `json:"imageId" xml:"ImageId"` | ||
9 | + ImageURL string `json:"imageURL" xml:"ImageURL"` | ||
10 | + UploadAddress string `json:"uploadAddress" xml:"UploadAddress"` | ||
11 | + UploadAuth string `json:"uploadAuth" xml:"UploadAuth"` | ||
12 | + FileURL string `json:"fileURL" xml:"FileURL"` | ||
13 | +} |
@@ -8,6 +8,7 @@ import ( | @@ -8,6 +8,7 @@ import ( | ||
8 | "github.com/astaxie/beego" | 8 | "github.com/astaxie/beego" |
9 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/common" | 9 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/common" |
10 | comm_time "gitlab.fjmaimaimai.com/mmm-go/gocomm/time" | 10 | comm_time "gitlab.fjmaimaimai.com/mmm-go/gocomm/time" |
11 | + "opp/internal/utils" | ||
11 | "path" | 12 | "path" |
12 | "time" | 13 | "time" |
13 | ) | 14 | ) |
@@ -36,7 +37,7 @@ func InitVodClient(accessKeyId string, accessKeySecret string) (client *vod.Clie | @@ -36,7 +37,7 @@ func InitVodClient(accessKeyId string, accessKeySecret string) (client *vod.Clie | ||
36 | } | 37 | } |
37 | 38 | ||
38 | //获取视频上传地址和凭证,并创建视频信息 | 39 | //获取视频上传地址和凭证,并创建视频信息 |
39 | -func CreateUploadVideo(client *vod.Client) (response *CreateUploadVideoResponse, err error) { | 40 | +func CreateUploadVideo(client *vod.Client, r *CreateUploadVideoRequest) (response *CreateUploadVideoResponse, err error) { |
40 | request := vod.CreateCreateUploadVideoRequest() | 41 | request := vod.CreateCreateUploadVideoRequest() |
41 | request.Title = getFileName(FileVideo, "video_file.mp4") | 42 | request.Title = getFileName(FileVideo, "video_file.mp4") |
42 | request.FileName = getFileName(FileVideo, "video_file.mp4") | 43 | request.FileName = getFileName(FileVideo, "video_file.mp4") |
@@ -56,6 +57,19 @@ func CreateUploadVideo(client *vod.Client) (response *CreateUploadVideoResponse, | @@ -56,6 +57,19 @@ func CreateUploadVideo(client *vod.Client) (response *CreateUploadVideoResponse, | ||
56 | return | 57 | return |
57 | } | 58 | } |
58 | 59 | ||
60 | +//获取图片上传地址和凭证,并创建视频信息 | ||
61 | +func CreateUploadImage(client *vod.Client, r *CreateUploadImageRequest) (response *CreateUploadImageResponse, err error) { | ||
62 | + request := vod.CreateCreateUploadImageRequest() | ||
63 | + request.ImageType = "default" | ||
64 | + request.AcceptFormat = "JSON" | ||
65 | + rsp, err := client.CreateUploadImage(request) | ||
66 | + if err != nil { | ||
67 | + return | ||
68 | + } | ||
69 | + err = utils.DeepCopy(&response, &rsp) | ||
70 | + return | ||
71 | +} | ||
72 | + | ||
59 | //获取播放信息 | 73 | //获取播放信息 |
60 | func GetPlayInfo(client *vod.Client, videoId string) (response *vod.GetPlayInfoResponse, err error) { | 74 | func GetPlayInfo(client *vod.Client, videoId string) (response *vod.GetPlayInfoResponse, err error) { |
61 | request := vod.CreateGetPlayInfoRequest() | 75 | request := vod.CreateGetPlayInfoRequest() |
@@ -58,7 +58,7 @@ func (s SelfChecks) Static() SelfCheckResults { | @@ -58,7 +58,7 @@ func (s SelfChecks) Static() SelfCheckResults { | ||
58 | for i := range s { | 58 | for i := range s { |
59 | check := (s)[i] | 59 | check := (s)[i] |
60 | for k := range results { | 60 | for k := range results { |
61 | - if strings.EqualFold(results[k].Item, check.Answer) { | 61 | + if strings.EqualFold(results[k].Item, strings.TrimSpace(check.Answer)) { |
62 | results[k].Total = results[k].Total + 1 | 62 | results[k].Total = results[k].Total + 1 |
63 | break | 63 | break |
64 | } | 64 | } |
@@ -153,6 +153,14 @@ func init() { | @@ -153,6 +153,14 @@ func init() { | ||
153 | 153 | ||
154 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | 154 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], |
155 | beego.ControllerComments{ | 155 | beego.ControllerComments{ |
156 | + Method: "CheckQuestions", | ||
157 | + Router: `/checkQuestions`, | ||
158 | + AllowHTTPMethods: []string{"post"}, | ||
159 | + MethodParams: param.Make(), | ||
160 | + Params: nil}) | ||
161 | + | ||
162 | + beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | ||
163 | + beego.ControllerComments{ | ||
156 | Method: "CommentDetailsMulti", | 164 | Method: "CommentDetailsMulti", |
157 | Router: `/commentDetailsMulti`, | 165 | Router: `/commentDetailsMulti`, |
158 | AllowHTTPMethods: []string{"post"}, | 166 | AllowHTTPMethods: []string{"post"}, |
@@ -513,14 +521,6 @@ func init() { | @@ -513,14 +521,6 @@ func init() { | ||
513 | 521 | ||
514 | beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"], | 522 | beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"], |
515 | beego.ControllerComments{ | 523 | beego.ControllerComments{ |
516 | - Method: "CreateUploadVideo", | ||
517 | - Router: `/createUploadVideo`, | ||
518 | - AllowHTTPMethods: []string{"post"}, | ||
519 | - MethodParams: param.Make(), | ||
520 | - Params: nil}) | ||
521 | - | ||
522 | - beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"], | ||
523 | - beego.ControllerComments{ | ||
524 | Method: "Image", | 524 | Method: "Image", |
525 | Router: `/image`, | 525 | Router: `/image`, |
526 | AllowHTTPMethods: []string{"post"}, | 526 | AllowHTTPMethods: []string{"post"}, |
@@ -615,4 +615,20 @@ func init() { | @@ -615,4 +615,20 @@ func init() { | ||
615 | MethodParams: param.Make(), | 615 | MethodParams: param.Make(), |
616 | Params: nil}) | 616 | Params: nil}) |
617 | 617 | ||
618 | + beego.GlobalControllerRouter["opp/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:VodController"], | ||
619 | + beego.ControllerComments{ | ||
620 | + Method: "CreateUploadImage", | ||
621 | + Router: `/createUploadImage`, | ||
622 | + AllowHTTPMethods: []string{"post"}, | ||
623 | + MethodParams: param.Make(), | ||
624 | + Params: nil}) | ||
625 | + | ||
626 | + beego.GlobalControllerRouter["opp/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:VodController"], | ||
627 | + beego.ControllerComments{ | ||
628 | + Method: "CreateUploadVideo", | ||
629 | + Router: `/createUploadVideo`, | ||
630 | + AllowHTTPMethods: []string{"post"}, | ||
631 | + MethodParams: param.Make(), | ||
632 | + Params: nil}) | ||
633 | + | ||
618 | } | 634 | } |
@@ -35,7 +35,9 @@ func init() { | @@ -35,7 +35,9 @@ func init() { | ||
35 | beego.AddNamespace(nsV2) | 35 | beego.AddNamespace(nsV2) |
36 | 36 | ||
37 | nsH5 := beego.NewNamespace("h5", beego.NSBefore(controllers.LogRequestData), beego.NSBefore(controllers.AllowOption), beego.NSInclude(&controllers.H5Controller{})) | 37 | nsH5 := beego.NewNamespace("h5", beego.NSBefore(controllers.LogRequestData), beego.NSBefore(controllers.AllowOption), beego.NSInclude(&controllers.H5Controller{})) |
38 | + nsVod := beego.NewNamespace("vod", beego.NSBefore(controllers.LogRequestData), beego.NSBefore(controllers.AllowOption), beego.NSInclude(&v1.VodController{})) | ||
38 | beego.AddNamespace(nsH5) | 39 | beego.AddNamespace(nsH5) |
40 | + beego.AddNamespace(nsVod) | ||
39 | //post 下载文件 | 41 | //post 下载文件 |
40 | beego.Router("/file/opp/*", &v1.FileController{}, "post:DownLoad") | 42 | beego.Router("/file/opp/*", &v1.FileController{}, "post:DownLoad") |
41 | //get 直接获取文件 | 43 | //get 直接获取文件 |
@@ -144,6 +144,22 @@ func CreateUploadVideo(header *protocol.RequestHeader, request *aliyun.CreateUpl | @@ -144,6 +144,22 @@ func CreateUploadVideo(header *protocol.RequestHeader, request *aliyun.CreateUpl | ||
144 | err = e | 144 | err = e |
145 | return | 145 | return |
146 | } | 146 | } |
147 | - rsp, err = aliyun.CreateUploadVideo(client) | 147 | + rsp, err = aliyun.CreateUploadVideo(client, request) |
148 | + return | ||
149 | +} | ||
150 | + | ||
151 | +//创建图片上传凭证 | ||
152 | +func CreateUploadImage(header *protocol.RequestHeader, request *aliyun.CreateUploadImageRequest) (rsp *aliyun.CreateUploadImageResponse, err error) { | ||
153 | + var () | ||
154 | + client, e := aliyun.DefaultVodClient() | ||
155 | + if e != nil { | ||
156 | + log.Error(e) | ||
157 | + err = e | ||
158 | + return | ||
159 | + } | ||
160 | + rsp, err = aliyun.CreateUploadImage(client, request) | ||
161 | + if err != nil { | ||
162 | + log.Error(err) | ||
163 | + } | ||
148 | return | 164 | return |
149 | } | 165 | } |
-
请 注册 或 登录 后发表评论