Merge remote-tracking branch 'origin/test'
正在显示
21 个修改的文件
包含
391 行增加
和
7 行删除
@@ -98,6 +98,7 @@ func GetRequestHeader(ctx *context.Context) *protocol.RequestHeader { | @@ -98,6 +98,7 @@ func GetRequestHeader(ctx *context.Context) *protocol.RequestHeader { | ||
98 | h.Sign = ctx.Input.Header("x-mmm-sign") | 98 | h.Sign = ctx.Input.Header("x-mmm-sign") |
99 | h.Uuid = ctx.Input.Header("x-mmm-uuid") | 99 | h.Uuid = ctx.Input.Header("x-mmm-uuid") |
100 | h.TimeStamp = ctx.Input.Header("x-mmm-timestamp") | 100 | h.TimeStamp = ctx.Input.Header("x-mmm-timestamp") |
101 | + h.Version = ctx.Input.Header("x-mmm-version") | ||
101 | h.Uid, _ = strconv.ParseInt(ctx.Input.Header("uid"), 10, 64) //需要uid写入到header里面 | 102 | h.Uid, _ = strconv.ParseInt(ctx.Input.Header("uid"), 10, 64) //需要uid写入到header里面 |
102 | if h.Uid == 0 { | 103 | if h.Uid == 0 { |
103 | h.Uid, _ = strconv.ParseInt(ctx.Input.Header("x-mmm-uid"), 10, 64) | 104 | h.Uid, _ = strconv.ParseInt(ctx.Input.Header("x-mmm-uid"), 10, 64) |
1 | package v1 | 1 | package v1 |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "encoding/json" | ||
4 | "fmt" | 5 | "fmt" |
5 | "github.com/astaxie/beego" | 6 | "github.com/astaxie/beego" |
7 | + "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | ||
6 | "opp/controllers" | 8 | "opp/controllers" |
9 | + "opp/internal/aliyun" | ||
7 | "opp/internal/utils" | 10 | "opp/internal/utils" |
8 | "opp/protocol" | 11 | "opp/protocol" |
12 | + "opp/services/file" | ||
9 | "path/filepath" | 13 | "path/filepath" |
10 | "strings" | 14 | "strings" |
11 | ) | 15 | ) |
@@ -37,3 +41,24 @@ func (this *FileController) DownLoad() { | @@ -37,3 +41,24 @@ func (this *FileController) DownLoad() { | ||
37 | } | 41 | } |
38 | msg = protocol.NewReturnResponse(rsp, err) | 42 | msg = protocol.NewReturnResponse(rsp, err) |
39 | } | 43 | } |
44 | + | ||
45 | +//GetPlayInfo 获取播放信息 | ||
46 | +// @router /getPlayInfo [post] | ||
47 | +func (this *FileController) GetPlayInfo() { | ||
48 | + var msg *protocol.ResponseMessage | ||
49 | + defer func() { | ||
50 | + this.Resp(msg) | ||
51 | + }() | ||
52 | + var request *aliyun.GetPlayInfoRequest | ||
53 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
54 | + log.Error(err) | ||
55 | + msg = protocol.BadRequestParam(1) | ||
56 | + return | ||
57 | + } | ||
58 | + if b, m := this.Valid(request); !b { | ||
59 | + msg = m | ||
60 | + return | ||
61 | + } | ||
62 | + header := controllers.GetRequestHeader(this.Ctx) | ||
63 | + msg = protocol.NewReturnResponse(file.GetPlayInfo(header, request)) | ||
64 | +} |
@@ -2,8 +2,10 @@ package v1 | @@ -2,8 +2,10 @@ package v1 | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "bytes" | 4 | "bytes" |
5 | + "encoding/json" | ||
5 | "fmt" | 6 | "fmt" |
6 | "opp/controllers" | 7 | "opp/controllers" |
8 | + "opp/internal/aliyun" | ||
7 | "opp/protocol" | 9 | "opp/protocol" |
8 | "opp/services/upload" | 10 | "opp/services/upload" |
9 | 11 | ||
@@ -94,3 +96,24 @@ func (this *UploadController) Video() { | @@ -94,3 +96,24 @@ func (this *UploadController) Video() { | ||
94 | } | 96 | } |
95 | msg = protocol.NewReturnResponse(rsp, err) | 97 | msg = protocol.NewReturnResponse(rsp, err) |
96 | } | 98 | } |
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 | +} |
@@ -3,6 +3,7 @@ module opp | @@ -3,6 +3,7 @@ module opp | ||
3 | go 1.12 | 3 | go 1.12 |
4 | 4 | ||
5 | require ( | 5 | require ( |
6 | + github.com/aliyun/alibaba-cloud-sdk-go v1.60.348 | ||
6 | github.com/astaxie/beego v1.10.0 | 7 | github.com/astaxie/beego v1.10.0 |
7 | github.com/disintegration/imaging v1.6.2 | 8 | github.com/disintegration/imaging v1.6.2 |
8 | github.com/go-sql-driver/mysql v1.4.1 | 9 | github.com/go-sql-driver/mysql v1.4.1 |
internal/aliyun/const.go
0 → 100644
internal/aliyun/struct.go
0 → 100644
1 | +package aliyun | ||
2 | + | ||
3 | +//创建视频上传凭证 | ||
4 | +/*CreateUploadVideo */ | ||
5 | +type CreateUploadVideoRequest struct { | ||
6 | +} | ||
7 | + | ||
8 | +type CreateUploadVideoResponse struct { | ||
9 | + RequestId string `json:"requestId"` | ||
10 | + VideoId string `json:"videoId"` | ||
11 | + UploadAddress string `json:"uploadAddress"` | ||
12 | + UploadAuth string `json:"uploadAuth"` | ||
13 | +} | ||
14 | + | ||
15 | +/*GetPlayInfo 获取播放信息*/ | ||
16 | +type GetPlayInfoRequest struct { | ||
17 | + VideoId string `json:"videoId" xml:"VideoId"` | ||
18 | +} | ||
19 | + | ||
20 | +// GetPlayInfoResponse is the response struct for api GetPlayInfo | ||
21 | +type GetPlayInfoResponse struct { | ||
22 | + //*responses.BaseResponse | ||
23 | + //RequestId string `json:"RequestId" xml:"RequestId"` | ||
24 | + VideoBase VideoBase `json:"VideoBase" xml:"VideoBase"` | ||
25 | + PlayInfoList PlayInfoListInGetPlayInfo `json:"PlayInfoList" xml:"PlayInfoList"` | ||
26 | +} | ||
27 | + | ||
28 | +// VideoBase is a nested struct in vod response | ||
29 | +type VideoBase struct { | ||
30 | + OutputType string `json:"OutputType" xml:"OutputType"` | ||
31 | + CoverURL string `json:"CoverURL" xml:"CoverURL"` | ||
32 | + Duration string `json:"Duration" xml:"Duration"` | ||
33 | + Status string `json:"Status" xml:"Status"` | ||
34 | + Title string `json:"Title" xml:"Title"` | ||
35 | + VideoId string `json:"VideoId" xml:"VideoId"` | ||
36 | + MediaType string `json:"MediaType" xml:"MediaType"` | ||
37 | + CreationTime string `json:"CreationTime" xml:"CreationTime"` | ||
38 | + TranscodeMode string `json:"TranscodeMode" xml:"TranscodeMode"` | ||
39 | + //ThumbnailList ThumbnailListInGetPlayInfo `json:"ThumbnailList" xml:"ThumbnailList"` | ||
40 | +} | ||
41 | + | ||
42 | +type PlayInfoListInGetPlayInfo struct { | ||
43 | + PlayInfo []PlayInfo `json:"PlayInfo" xml:"PlayInfo"` | ||
44 | +} | ||
45 | + | ||
46 | +// PlayInfo is a nested struct in vod response | ||
47 | +type PlayInfo struct { | ||
48 | + JobId string `json:"JobId" xml:"JobId"` | ||
49 | + Format string `json:"Format" xml:"Format"` | ||
50 | + PreprocessStatus string `json:"PreprocessStatus" xml:"PreprocessStatus"` | ||
51 | + EncryptType string `json:"EncryptType" xml:"EncryptType"` | ||
52 | + Fps string `json:"Fps" xml:"Fps"` | ||
53 | + ModificationTime string `json:"ModificationTime" xml:"ModificationTime"` | ||
54 | + NarrowBandType string `json:"NarrowBandType" xml:"NarrowBandType"` | ||
55 | + Bitrate string `json:"Bitrate" xml:"Bitrate"` | ||
56 | + Encrypt int64 `json:"Encrypt" xml:"Encrypt"` | ||
57 | + Rand string `json:"Rand" xml:"Rand"` | ||
58 | + CreationTime string `json:"CreationTime" xml:"CreationTime"` | ||
59 | + StreamType string `json:"StreamType" xml:"StreamType"` | ||
60 | + Height int64 `json:"Height" xml:"Height"` | ||
61 | + WatermarkId string `json:"WatermarkId" xml:"WatermarkId"` | ||
62 | + Duration string `json:"Duration" xml:"Duration"` | ||
63 | + Complexity string `json:"Complexity" xml:"Complexity"` | ||
64 | + Width int64 `json:"Width" xml:"Width"` | ||
65 | + Size int64 `json:"Size" xml:"Size"` | ||
66 | + Status string `json:"Status" xml:"Status"` | ||
67 | + Definition string `json:"Definition" xml:"Definition"` | ||
68 | + Plaintext string `json:"Plaintext" xml:"Plaintext"` | ||
69 | + PlayURL string `json:"PlayURL" xml:"PlayURL"` | ||
70 | + Specification string `json:"Specification" xml:"Specification"` | ||
71 | +} |
internal/aliyun/vod.go
0 → 100644
1 | +package aliyun | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/aliyun/alibaba-cloud-sdk-go/sdk" | ||
6 | + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" | ||
7 | + "github.com/aliyun/alibaba-cloud-sdk-go/services/vod" | ||
8 | + "github.com/astaxie/beego" | ||
9 | + "gitlab.fjmaimaimai.com/mmm-go/gocomm/common" | ||
10 | + comm_time "gitlab.fjmaimaimai.com/mmm-go/gocomm/time" | ||
11 | + "path" | ||
12 | + "time" | ||
13 | +) | ||
14 | + | ||
15 | +//客户端 | ||
16 | +func DefaultVodClient() (client *vod.Client, err error) { | ||
17 | + return InitVodClient(AccessKeyID, AccessKeySecret) | ||
18 | +} | ||
19 | + | ||
20 | +//初始化客户端 | ||
21 | +func InitVodClient(accessKeyId string, accessKeySecret string) (client *vod.Client, err error) { | ||
22 | + // 点播服务接入区域 | ||
23 | + regionId := RegionID | ||
24 | + // 创建授权对象 | ||
25 | + credential := &credentials.AccessKeyCredential{ | ||
26 | + accessKeyId, | ||
27 | + accessKeySecret, | ||
28 | + } | ||
29 | + // 自定义config | ||
30 | + config := sdk.NewConfig() | ||
31 | + config.AutoRetry = true // 失败是否自动重试 | ||
32 | + config.MaxRetryTime = 3 // 最大重试次数 | ||
33 | + config.Timeout = 3000000000 // 连接超时,单位:纳秒;默认为3秒 | ||
34 | + // 创建vodClient实例 | ||
35 | + return vod.NewClientWithOptions(regionId, config, credential) | ||
36 | +} | ||
37 | + | ||
38 | +//获取视频上传地址和凭证,并创建视频信息 | ||
39 | +func CreateUploadVideo(client *vod.Client) (response *CreateUploadVideoResponse, err error) { | ||
40 | + request := vod.CreateCreateUploadVideoRequest() | ||
41 | + request.Title = getFileName(FileVideo, "video_file.mp4") | ||
42 | + request.FileName = getFileName(FileVideo, "video_file.mp4") | ||
43 | + //request.CoverURL = "http://img.alicdn.com/tps/TB1qnJ1PVXXXXXCXXXXXXXXXXXX-700-700.png" | ||
44 | + //request.Tags = "tag1,tag2" | ||
45 | + request.AcceptFormat = "JSON" | ||
46 | + rsp, err := client.CreateUploadVideo(request) | ||
47 | + if err != nil { | ||
48 | + return | ||
49 | + } | ||
50 | + response = &CreateUploadVideoResponse{ | ||
51 | + RequestId: rsp.RequestId, | ||
52 | + VideoId: rsp.VideoId, | ||
53 | + UploadAddress: rsp.UploadAddress, | ||
54 | + UploadAuth: rsp.UploadAuth, | ||
55 | + } | ||
56 | + return | ||
57 | +} | ||
58 | + | ||
59 | +//获取播放信息 | ||
60 | +func GetPlayInfo(client *vod.Client, videoId string) (response *vod.GetPlayInfoResponse, err error) { | ||
61 | + request := vod.CreateGetPlayInfoRequest() | ||
62 | + request.VideoId = videoId | ||
63 | + request.AcceptFormat = "JSON" | ||
64 | + return client.GetPlayInfo(request) | ||
65 | +} | ||
66 | + | ||
67 | +//fileType: video voice image | ||
68 | +func getFileName(fileType string, filename string) string { | ||
69 | + date := comm_time.GetTimeByYyyymmdd() | ||
70 | + subfix := path.Ext(filename) | ||
71 | + prefix := fmt.Sprintf("%v_%v", time.Now().Unix(), common.RandomString(32)) | ||
72 | + filename = fmt.Sprintf("%v%v", prefix, subfix) | ||
73 | + sourcePath := fmt.Sprintf("%v/%v/%v/%v/%v", beego.BConfig.AppName, beego.BConfig.RunMode, fileType, date, filename) | ||
74 | + return sourcePath | ||
75 | +} |
1 | package utils | 1 | package utils |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "bytes" | ||
5 | + "encoding/gob" | ||
4 | "encoding/json" | 6 | "encoding/json" |
5 | "errors" | 7 | "errors" |
6 | "fmt" | 8 | "fmt" |
7 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 9 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
8 | "reflect" | 10 | "reflect" |
11 | + "strconv" | ||
9 | "strings" | 12 | "strings" |
10 | ) | 13 | ) |
11 | 14 | ||
@@ -85,3 +88,36 @@ func JsonUnmarshal(jsonData string, v interface{}) { | @@ -85,3 +88,36 @@ func JsonUnmarshal(jsonData string, v interface{}) { | ||
85 | log.Error("json.unmarshal error data:", jsonData, e) | 88 | log.Error("json.unmarshal error data:", jsonData, e) |
86 | } | 89 | } |
87 | } | 90 | } |
91 | + | ||
92 | +//深度拷贝 | ||
93 | +func DeepCopy(dst, src interface{}) error { | ||
94 | + var buf bytes.Buffer | ||
95 | + if err := gob.NewEncoder(&buf).Encode(src); err != nil { | ||
96 | + return err | ||
97 | + } | ||
98 | + return gob.NewDecoder(&buf).Decode(dst) | ||
99 | +} | ||
100 | + | ||
101 | +//检查版本信息 | ||
102 | +func ValidVersion(current, compare string) bool { | ||
103 | + curVersions := strings.Split(current, ".") | ||
104 | + comVersions := strings.Split(compare, ".") | ||
105 | + for i := range curVersions { | ||
106 | + //v1,v2:=strings.TrimSpace(curVersions[i]),"" | ||
107 | + v1, _ := strconv.ParseInt(strings.TrimSpace(curVersions[i]), 10, 64) | ||
108 | + var v2 int64 | ||
109 | + if i < len(comVersions) { | ||
110 | + v2, _ = strconv.ParseInt(strings.TrimSpace(comVersions[i]), 10, 64) | ||
111 | + } | ||
112 | + if v1 == 0 && v2 == 0 { | ||
113 | + continue | ||
114 | + } | ||
115 | + if v1 >= v2 { | ||
116 | + return true | ||
117 | + } | ||
118 | + if v1 < v2 { | ||
119 | + return false | ||
120 | + } | ||
121 | + } | ||
122 | + return false | ||
123 | +} |
internal/utils/utils_test.go
0 → 100644
1 | +package utils | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "testing" | ||
6 | +) | ||
7 | + | ||
8 | +func Test_DeepCopy(t *testing.T) { | ||
9 | + type User1 struct { | ||
10 | + Name string | ||
11 | + Age int | ||
12 | + Address string | ||
13 | + } | ||
14 | + type User2 struct { | ||
15 | + Name string | ||
16 | + Age int | ||
17 | + Job string | ||
18 | + } | ||
19 | + var src = User1{Name: "foo", Age: 10, Address: "bar"} | ||
20 | + var dst *User2 | ||
21 | + if err := DeepCopy(&dst, src); err != nil { | ||
22 | + t.Fatal(err) | ||
23 | + } | ||
24 | + if src.Name != dst.Name { | ||
25 | + t.Fatal("deep copy fail.") | ||
26 | + } | ||
27 | + //t.Log(src,"\n",dst) | ||
28 | +} | ||
29 | + | ||
30 | +func TestValidVersion(t *testing.T) { | ||
31 | + inputs := []struct { | ||
32 | + In string | ||
33 | + Compare string | ||
34 | + Out bool | ||
35 | + }{ | ||
36 | + {In: "0.9.0", Compare: "0.8.0", Out: true}, | ||
37 | + {In: "0.8.11", Compare: "0.8.0", Out: true}, | ||
38 | + {In: "0.7.0", Compare: "0.8.0", Out: false}, | ||
39 | + {In: "0.8.0", Compare: "0.8.0", Out: true}, | ||
40 | + {In: "0.9", Compare: "0.8.0", Out: true}, | ||
41 | + {In: "0.10", Compare: "0.8.0", Out: true}, | ||
42 | + {In: "1.8.0", Compare: "0.8.0", Out: true}, | ||
43 | + {In: "0.99.0", Compare: "0.8.0", Out: true}, | ||
44 | + {In: "01.0.0", Compare: "0.8.0", Out: true}, | ||
45 | + } | ||
46 | + for i := range inputs { | ||
47 | + input := inputs[i] | ||
48 | + if ValidVersion(input.In, input.Compare) != input.Out { | ||
49 | + t.Fatal(fmt.Sprintf("valid version fail. input :%v compare:%v want:%v", input.In, input.Compare, input.Out)) | ||
50 | + } | ||
51 | + } | ||
52 | +} |
@@ -184,7 +184,7 @@ from audit_flow_process where uid=? and review_status in (%v) and enable_status | @@ -184,7 +184,7 @@ from audit_flow_process where uid=? and review_status in (%v) and enable_status | ||
184 | func GetChanceCollect(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) { | 184 | func GetChanceCollect(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) { |
185 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( | 185 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( |
186 | select a.*,b.user_id chance_user_id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total,b.publish_status,b.status from ( | 186 | select a.*,b.user_id chance_user_id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total,b.publish_status,b.status from ( |
187 | -select id collect_id,source_id,update_at,collect_time,chance_id from chance_favorite where (0=? or id<?) and user_id =? and enable_status=1 | 187 | +select id collect_id,source_id,update_at,collect_time,chance_id from chance_favorite where (0=? or unix_timestamp(collect_time)<?) and user_id =? and enable_status=1 |
188 | and source_type=1 | 188 | and source_type=1 |
189 | and (mark_flag&2)>0 | 189 | and (mark_flag&2)>0 |
190 | )a left outer join chance b on a.source_id = b.id | 190 | )a left outer join chance b on a.source_id = b.id |
@@ -207,7 +207,7 @@ limit ?`) | @@ -207,7 +207,7 @@ limit ?`) | ||
207 | func GetChanceThumbUp(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) { | 207 | func GetChanceThumbUp(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) { |
208 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( | 208 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( |
209 | select a.*,b.user_id chance_user_id,b.id chance_id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total,b.publish_status,b.status from ( | 209 | select a.*,b.user_id chance_user_id,b.id chance_id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total,b.publish_status,b.status from ( |
210 | -select id collect_id,source_id,update_at,zan_time from chance_favorite where (0=? or id<?) and user_id =? and enable_status=1 | 210 | +select id collect_id,source_id,update_at,zan_time from chance_favorite where (0=? or unix_timestamp(zan_time)<?) and user_id =? and enable_status=1 |
211 | and source_type=1 | 211 | and source_type=1 |
212 | and (mark_flag&1)>0 | 212 | and (mark_flag&1)>0 |
213 | )a left outer join chance b on a.source_id = b.id | 213 | )a left outer join chance b on a.source_id = b.id |
@@ -16,6 +16,7 @@ const ( | @@ -16,6 +16,7 @@ const ( | ||
16 | ) | 16 | ) |
17 | 17 | ||
18 | const TokenExpire = 3600 | 18 | const TokenExpire = 3600 |
19 | +const RefreshTokenExipre = 3600 * 24 * 30 * 3 //刷新token 三个月过期 | ||
19 | 20 | ||
20 | const SmscodeDayLimitTime = 10 //短信验证码每天最多发10次 | 21 | const SmscodeDayLimitTime = 10 //短信验证码每天最多发10次 |
21 | 22 | ||
@@ -23,6 +24,7 @@ var Nums = []byte("0123456789") | @@ -23,6 +24,7 @@ var Nums = []byte("0123456789") | ||
23 | 24 | ||
24 | type RequestHeader struct { | 25 | type RequestHeader struct { |
25 | TimeStamp string | 26 | TimeStamp string |
27 | + Version string | ||
26 | Uuid string | 28 | Uuid string |
27 | Sign string | 29 | Sign string |
28 | DeviceType int | 30 | DeviceType int |
@@ -77,7 +77,7 @@ const ( | @@ -77,7 +77,7 @@ const ( | ||
77 | var ( | 77 | var ( |
78 | MessageApproving = "提交了一条%v机会消息,需要您审核" | 78 | MessageApproving = "提交了一条%v机会消息,需要您审核" |
79 | MessageApproveSuccess = "审核通过你提交的%v机会" | 79 | MessageApproveSuccess = "审核通过你提交的%v机会" |
80 | - MessageApproveReject = "退回您了提交的%v机会" | 80 | + MessageApproveReject = "退回了您提交的%v机会" |
81 | 81 | ||
82 | MessageZanChance = "点赞了您发布的机会" | 82 | MessageZanChance = "点赞了您发布的机会" |
83 | MessageZanComment = "点赞了您发布的评论" | 83 | MessageZanComment = "点赞了您发布的评论" |
@@ -289,6 +289,14 @@ func init() { | @@ -289,6 +289,14 @@ func init() { | ||
289 | 289 | ||
290 | beego.GlobalControllerRouter["opp/controllers/v1:FileController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:FileController"], | 290 | beego.GlobalControllerRouter["opp/controllers/v1:FileController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:FileController"], |
291 | beego.ControllerComments{ | 291 | beego.ControllerComments{ |
292 | + Method: "GetPlayInfo", | ||
293 | + Router: `/getPlayInfo`, | ||
294 | + AllowHTTPMethods: []string{"post"}, | ||
295 | + MethodParams: param.Make(), | ||
296 | + Params: nil}) | ||
297 | + | ||
298 | + beego.GlobalControllerRouter["opp/controllers/v1:FileController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:FileController"], | ||
299 | + beego.ControllerComments{ | ||
292 | Method: "DownLoad", | 300 | Method: "DownLoad", |
293 | Router: `/opp/file`, | 301 | Router: `/opp/file`, |
294 | AllowHTTPMethods: []string{"post"}, | 302 | AllowHTTPMethods: []string{"post"}, |
@@ -393,6 +401,14 @@ func init() { | @@ -393,6 +401,14 @@ func init() { | ||
393 | 401 | ||
394 | beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"], | 402 | beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"], |
395 | beego.ControllerComments{ | 403 | beego.ControllerComments{ |
404 | + Method: "CreateUploadVideo", | ||
405 | + Router: `/createUploadVideo`, | ||
406 | + AllowHTTPMethods: []string{"post"}, | ||
407 | + MethodParams: param.Make(), | ||
408 | + Params: nil}) | ||
409 | + | ||
410 | + beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"], | ||
411 | + beego.ControllerComments{ | ||
396 | Method: "Image", | 412 | Method: "Image", |
397 | Router: `/image`, | 413 | Router: `/image`, |
398 | AllowHTTPMethods: []string{"post"}, | 414 | AllowHTTPMethods: []string{"post"}, |
@@ -23,6 +23,7 @@ func init() { | @@ -23,6 +23,7 @@ func init() { | ||
23 | beego.NSNamespace("message", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.MessageController{})), | 23 | beego.NSNamespace("message", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.MessageController{})), |
24 | beego.NSNamespace("department", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.DepartmentController{})), | 24 | beego.NSNamespace("department", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.DepartmentController{})), |
25 | beego.NSNamespace("config", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.ConfigController{})), | 25 | beego.NSNamespace("config", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.ConfigController{})), |
26 | + beego.NSNamespace("file", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.FileController{})), | ||
26 | ) | 27 | ) |
27 | beego.AddNamespace(nsV1) | 28 | beego.AddNamespace(nsV1) |
28 | 29 |
@@ -15,7 +15,7 @@ import ( | @@ -15,7 +15,7 @@ import ( | ||
15 | var ( | 15 | var ( |
16 | MessageApproving = "提交了一条%v机会消息,需要您审核" | 16 | MessageApproving = "提交了一条%v机会消息,需要您审核" |
17 | MessageApproveSuccess = "审核通过你提交的%v机会" | 17 | MessageApproveSuccess = "审核通过你提交的%v机会" |
18 | - MessageApproveReject = "退回您了提交的%v机会" | 18 | + MessageApproveReject = "退回了您提交的%v机会" |
19 | MessageApproveAutoPass = "自动审核通过你提交的%v机会" | 19 | MessageApproveAutoPass = "自动审核通过你提交的%v机会" |
20 | ) | 20 | ) |
21 | 21 |
@@ -51,6 +51,11 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp | @@ -51,6 +51,11 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp | ||
51 | err = protocol.NewErrWithMessage(2002, err) //账号不存在 | 51 | err = protocol.NewErrWithMessage(2002, err) //账号不存在 |
52 | return | 52 | return |
53 | } | 53 | } |
54 | + if !utils.ValidVersion(header.Version, protocol.RequireVersion) { | ||
55 | + log.Warn(fmt.Sprintf("版本不足 当前手机版本:%v 需要版本大于:%v", header.Version, protocol.RequireVersion)) | ||
56 | + err = protocol.NewCustomMessage(2002, "版本不足,请升级app") //账号不存在 | ||
57 | + return | ||
58 | + } | ||
54 | //获取最后一次公司编号给统一用户中心 | 59 | //获取最后一次公司编号给统一用户中心 |
55 | if u, e := models.GetUserAuthByUserId(user.Id, protocol.DeviceType); e == nil && user.UserCenterId == id { | 60 | if u, e := models.GetUserAuthByUserId(user.Id, protocol.DeviceType); e == nil && user.UserCenterId == id { |
56 | if company, e = models.GetCompanyById(u.CurrentCompanyId); e == nil { | 61 | if company, e = models.GetCompanyById(u.CurrentCompanyId); e == nil { |
@@ -215,7 +220,7 @@ func AccessToken(request *protocol.AccessTokenRequest) (rsp *protocol.AccessToke | @@ -215,7 +220,7 @@ func AccessToken(request *protocol.AccessTokenRequest) (rsp *protocol.AccessToke | ||
215 | userAuth.AccessToken = uid.NewV1().StringNoDash() | 220 | userAuth.AccessToken = uid.NewV1().StringNoDash() |
216 | userAuth.RefreshToken = uid.NewV1().StringNoDash() | 221 | userAuth.RefreshToken = uid.NewV1().StringNoDash() |
217 | userAuth.AccessTokenExp = time.Now().Add(protocol.TokenExpire * time.Second) | 222 | userAuth.AccessTokenExp = time.Now().Add(protocol.TokenExpire * time.Second) |
218 | - userAuth.RefreshTokenExp = time.Now().Add(protocol.TokenExpire * time.Second * 2) | 223 | + userAuth.RefreshTokenExp = time.Now().Add(protocol.RefreshTokenExipre * time.Second) |
219 | if err = models.UpdateUserAuthById(userAuth); err != nil { | 224 | if err = models.UpdateUserAuthById(userAuth); err != nil { |
220 | log.Error(err) | 225 | log.Error(err) |
221 | return | 226 | return |
@@ -248,7 +253,7 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT | @@ -248,7 +253,7 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT | ||
248 | userAuth.AccessToken = uid.NewV1().StringNoDash() | 253 | userAuth.AccessToken = uid.NewV1().StringNoDash() |
249 | userAuth.RefreshToken = uid.NewV1().StringNoDash() | 254 | userAuth.RefreshToken = uid.NewV1().StringNoDash() |
250 | userAuth.AccessTokenExp = time.Now().Add(protocol.TokenExpire * time.Second) | 255 | userAuth.AccessTokenExp = time.Now().Add(protocol.TokenExpire * time.Second) |
251 | - userAuth.RefreshTokenExp = time.Now().Add(protocol.TokenExpire * time.Second * 2) | 256 | + userAuth.RefreshTokenExp = time.Now().Add(protocol.RefreshTokenExipre * time.Second) |
252 | if err = models.UpdateUserAuthById(userAuth); err != nil { | 257 | if err = models.UpdateUserAuthById(userAuth); err != nil { |
253 | return | 258 | return |
254 | } | 259 | } |
@@ -1541,7 +1541,15 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect | @@ -1541,7 +1541,15 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect | ||
1541 | myChances []protocol.ChanceCollectItemOrm | 1541 | myChances []protocol.ChanceCollectItemOrm |
1542 | total int | 1542 | total int |
1543 | provider *protocol.BaseUserInfo | 1543 | provider *protocol.BaseUserInfo |
1544 | + favorite *models.ChanceFavorite | ||
1544 | ) | 1545 | ) |
1546 | + if request.LastId > 0 { | ||
1547 | + if favorite, err = models.GetChanceFavoriteById(request.LastId); err != nil { | ||
1548 | + log.Error("不存在", request.LastId, err) | ||
1549 | + return | ||
1550 | + } | ||
1551 | + request.LastId = favorite.CollectTime.Unix() | ||
1552 | + } | ||
1545 | if total, err = models.GetChanceCollect(header.UserId, request.LastId, request.PageSize, &myChances); err != nil { | 1553 | if total, err = models.GetChanceCollect(header.UserId, request.LastId, request.PageSize, &myChances); err != nil { |
1546 | if err == orm.ErrNoRows { | 1554 | if err == orm.ErrNoRows { |
1547 | err = nil | 1555 | err = nil |
@@ -1624,7 +1632,15 @@ func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUp | @@ -1624,7 +1632,15 @@ func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUp | ||
1624 | myChances []protocol.ChanceThumbUpItemOrm | 1632 | myChances []protocol.ChanceThumbUpItemOrm |
1625 | total int | 1633 | total int |
1626 | provider *protocol.BaseUserInfo | 1634 | provider *protocol.BaseUserInfo |
1635 | + favorite *models.ChanceFavorite | ||
1627 | ) | 1636 | ) |
1637 | + if request.LastId > 0 { | ||
1638 | + if favorite, err = models.GetChanceFavoriteById(request.LastId); err != nil { | ||
1639 | + log.Error("不存在", request.LastId, err) | ||
1640 | + return | ||
1641 | + } | ||
1642 | + request.LastId = favorite.ZanTime.Unix() | ||
1643 | + } | ||
1628 | if total, err = models.GetChanceThumbUp(header.UserId, request.LastId, request.PageSize, &myChances); err != nil { | 1644 | if total, err = models.GetChanceThumbUp(header.UserId, request.LastId, request.PageSize, &myChances); err != nil { |
1629 | if err == orm.ErrNoRows { | 1645 | if err == orm.ErrNoRows { |
1630 | err = nil | 1646 | err = nil |
services/file/vod.go
0 → 100644
1 | +package file | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/prometheus/common/log" | ||
5 | + "opp/internal/aliyun" | ||
6 | + "opp/internal/utils" | ||
7 | + "opp/protocol" | ||
8 | +) | ||
9 | + | ||
10 | +//GetPlayInfo 获取播放信息 | ||
11 | +func GetPlayInfo(header *protocol.RequestHeader, request *aliyun.GetPlayInfoRequest) (rsp *aliyun.GetPlayInfoResponse, err error) { | ||
12 | + var () | ||
13 | + client, e := aliyun.DefaultVodClient() | ||
14 | + if e != nil { | ||
15 | + log.Error(e) | ||
16 | + err = e | ||
17 | + return | ||
18 | + } | ||
19 | + response, e := aliyun.GetPlayInfo(client, request.VideoId) | ||
20 | + if e != nil { | ||
21 | + log.Error(e) | ||
22 | + err = e | ||
23 | + return | ||
24 | + } | ||
25 | + rsp = &aliyun.GetPlayInfoResponse{} | ||
26 | + if err = utils.DeepCopy(&rsp, response); err != nil { | ||
27 | + log.Error(err) | ||
28 | + return | ||
29 | + } | ||
30 | + return | ||
31 | +} |
@@ -5,6 +5,7 @@ import ( | @@ -5,6 +5,7 @@ import ( | ||
5 | "github.com/disintegration/imaging" | 5 | "github.com/disintegration/imaging" |
6 | "io" | 6 | "io" |
7 | "mime/multipart" | 7 | "mime/multipart" |
8 | + "opp/internal/aliyun" | ||
8 | "os" | 9 | "os" |
9 | "path" | 10 | "path" |
10 | "path/filepath" | 11 | "path/filepath" |
@@ -133,3 +134,16 @@ func GetSortFileKeys(files map[string][]*multipart.FileHeader) (keys []string) { | @@ -133,3 +134,16 @@ func GetSortFileKeys(files map[string][]*multipart.FileHeader) (keys []string) { | ||
133 | sort.Strings(keys) | 134 | sort.Strings(keys) |
134 | return | 135 | return |
135 | } | 136 | } |
137 | + | ||
138 | +//创建视频上传凭证 | ||
139 | +func CreateUploadVideo(header *protocol.RequestHeader, request *aliyun.CreateUploadVideoRequest) (rsp *aliyun.CreateUploadVideoResponse, err error) { | ||
140 | + var () | ||
141 | + client, e := aliyun.DefaultVodClient() | ||
142 | + if e != nil { | ||
143 | + log.Error(e) | ||
144 | + err = e | ||
145 | + return | ||
146 | + } | ||
147 | + rsp, err = aliyun.CreateUploadVideo(client) | ||
148 | + return | ||
149 | +} |
-
请 注册 或 登录 后发表评论