正在显示
59 个修改的文件
包含
500 行增加
和
166 行删除
| @@ -7,10 +7,7 @@ aliyun_logs_access ="${aliyun_logs_access||F:/log/app.log}" | @@ -7,10 +7,7 @@ aliyun_logs_access ="${aliyun_logs_access||F:/log/app.log}" | ||
| 7 | #阿里云基础配置 | 7 | #阿里云基础配置 |
| 8 | AccessKeyID ="LTAI4FhiZ3UktC6N1u3H5GFC" | 8 | AccessKeyID ="LTAI4FhiZ3UktC6N1u3H5GFC" |
| 9 | AccessKeySecret ="UyspWwdni55CYQ02hUCint4qY2jNYO" | 9 | AccessKeySecret ="UyspWwdni55CYQ02hUCint4qY2jNYO" |
| 10 | -#AccessKeyID ="LTAI4Fz1LUBW2fXp6QWaJHRS" | ||
| 11 | -#AccessKeySecret ="aLZXwK8pgrs10Ws03qcN7NsrSXFVsg" | ||
| 12 | -#阿里云->绑定域名 cname = https://media.goexample.live/ | ||
| 13 | -cname ="https://media.fjmaimaimai.com/" | 10 | +cname ="https://media.goexample.live/" |
| 14 | 11 | ||
| 15 | 12 | ||
| 16 | #友盟推送 | 13 | #友盟推送 |
| @@ -7,5 +7,5 @@ AccessKeySecret ="aLZXwK8pgrs10Ws03qcN7NsrSXFVsg" | @@ -7,5 +7,5 @@ AccessKeySecret ="aLZXwK8pgrs10Ws03qcN7NsrSXFVsg" | ||
| 7 | log_level = "${LOG_LEVEL||debug}" | 7 | log_level = "${LOG_LEVEL||debug}" |
| 8 | aliyun_logs_access ="${aliyun_logs_access||F:/log/app.log}" | 8 | aliyun_logs_access ="${aliyun_logs_access||F:/log/app.log}" |
| 9 | 9 | ||
| 10 | -#阿里云 https://media.goexample.live/ | 10 | +#阿里云 |
| 11 | cname ="https://media.fjmaimaimai.com/" | 11 | cname ="https://media.fjmaimaimai.com/" |
| @@ -3,11 +3,25 @@ module openapi | @@ -3,11 +3,25 @@ module openapi | ||
| 3 | go 1.12 | 3 | go 1.12 |
| 4 | 4 | ||
| 5 | require ( | 5 | require ( |
| 6 | + github.com/ajg/form v1.5.1 // indirect | ||
| 6 | github.com/aliyun/alibaba-cloud-sdk-go v1.60.348 | 7 | github.com/aliyun/alibaba-cloud-sdk-go v1.60.348 |
| 7 | github.com/aliyun/aliyun-sts-go-sdk v0.0.0-20171106034748-98d3903a2309 | 8 | github.com/aliyun/aliyun-sts-go-sdk v0.0.0-20171106034748-98d3903a2309 |
| 8 | github.com/astaxie/beego v1.10.0 | 9 | github.com/astaxie/beego v1.10.0 |
| 10 | + github.com/fatih/structs v1.1.0 // indirect | ||
| 11 | + github.com/gavv/httpexpect v2.0.0+incompatible | ||
| 12 | + github.com/google/go-querystring v1.0.0 // indirect | ||
| 13 | + github.com/imkira/go-interpol v1.1.0 // indirect | ||
| 9 | github.com/klauspost/cpuid v1.2.3 // indirect | 14 | github.com/klauspost/cpuid v1.2.3 // indirect |
| 15 | + github.com/moul/http2curl v1.0.0 // indirect | ||
| 16 | + github.com/onsi/ginkgo v1.10.3 | ||
| 17 | + github.com/onsi/gomega v1.7.1 | ||
| 10 | github.com/satori/go.uuid v1.2.0 | 18 | github.com/satori/go.uuid v1.2.0 |
| 19 | + github.com/sergi/go-diff v1.1.0 // indirect | ||
| 20 | + github.com/valyala/fasthttp v1.13.1 // indirect | ||
| 21 | + github.com/xeipuuv/gojsonschema v1.2.0 // indirect | ||
| 22 | + github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect | ||
| 23 | + github.com/yudai/gojsondiff v1.0.0 // indirect | ||
| 24 | + github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect | ||
| 11 | gitlab.fjmaimaimai.com/mmm-go/gocomm v0.0.1 | 25 | gitlab.fjmaimaimai.com/mmm-go/gocomm v0.0.1 |
| 12 | ) | 26 | ) |
| 13 | 27 |
| 1 | package main | 1 | package main |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | - "fmt" | ||
| 5 | "github.com/astaxie/beego" | 4 | "github.com/astaxie/beego" |
| 6 | - "gitlab.fjmaimaimai.com/mmm-go/gocomm/config" | ||
| 7 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
| 8 | - "openapi/internal/utils" | ||
| 9 | - _ "openapi/routers" | ||
| 10 | - "time" | ||
| 11 | -) | 6 | + "openapi/pkg/constant" |
| 12 | 7 | ||
| 13 | -func init() { | ||
| 14 | - time.Local = time.FixedZone("CST", 3600*8) | ||
| 15 | - log.InitLog(config.Logger{ | ||
| 16 | - Filename: beego.AppConfig.String("aliyun_logs_access"), | ||
| 17 | - Level: fmt.Sprintf("%v", utils.ResolveLogLevel(beego.AppConfig.String("log_level"))), | ||
| 18 | - }) | ||
| 19 | -} | 8 | + _ "openapi/pkg/log" |
| 9 | + _ "openapi/pkg/port/beego" | ||
| 10 | +) | ||
| 20 | 11 | ||
| 21 | func main() { | 12 | func main() { |
| 22 | defer func() { | 13 | defer func() { |
| 23 | - log.Info("open-api on stop!") | 14 | + log.Info("server on stop!") |
| 24 | }() | 15 | }() |
| 25 | - | ||
| 26 | - log.Info("open-api on start!") | ||
| 27 | - log.Info("Beego Run Mode:", beego.BConfig.RunMode) | ||
| 28 | - | 16 | + log.Info("server on start!") |
| 17 | + constant.DebugConfig() | ||
| 29 | beego.Run() | 18 | beego.Run() |
| 30 | } | 19 | } |
| @@ -3,10 +3,10 @@ package push | @@ -3,10 +3,10 @@ package push | ||
| 3 | import ( | 3 | import ( |
| 4 | "encoding/json" | 4 | "encoding/json" |
| 5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
| 6 | - "openapi/internal/push" | ||
| 7 | - "openapi/internal/push/getui" | ||
| 8 | - "openapi/internal/utils" | ||
| 9 | - "openapi/protocol" | 6 | + protocol "openapi/pkg/domain" |
| 7 | + "openapi/pkg/infrastructure/push" | ||
| 8 | + "openapi/pkg/infrastructure/push/getui" | ||
| 9 | + "openapi/pkg/infrastructure/utils" | ||
| 10 | ) | 10 | ) |
| 11 | 11 | ||
| 12 | //推送信息 | 12 | //推送信息 |
| 1 | -package vod | 1 | +package service |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | - "github.com/astaxie/beego" | ||
| 5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 4 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
| 6 | - "openapi/internal/aliyun" | ||
| 7 | - "openapi/internal/utils" | ||
| 8 | - "openapi/protocol" | 5 | + "openapi/pkg/constant" |
| 6 | + protocol "openapi/pkg/domain" | ||
| 7 | + "openapi/pkg/infrastructure/aliyun" | ||
| 8 | + "openapi/pkg/infrastructure/utils" | ||
| 9 | ) | 9 | ) |
| 10 | 10 | ||
| 11 | //创建视频上传凭证 | 11 | //创建视频上传凭证 |
| @@ -44,7 +44,7 @@ func CreateUploadVideo(header *protocol.RequestHeader, request *aliyun.CreateUpl | @@ -44,7 +44,7 @@ func CreateUploadVideo(header *protocol.RequestHeader, request *aliyun.CreateUpl | ||
| 44 | return | 44 | return |
| 45 | } | 45 | } |
| 46 | rsp.FileName = fileName | 46 | rsp.FileName = fileName |
| 47 | - rsp.FileURL = up.GetFileUrl(beego.AppConfig.String("cname")) | 47 | + rsp.FileURL = up.GetFileUrl(constant.CName) |
| 48 | return | 48 | return |
| 49 | } | 49 | } |
| 50 | 50 |
pkg/constant/common.go
0 → 100644
| 1 | +package constant | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | ||
| 6 | +) | ||
| 7 | + | ||
| 8 | +var ( | ||
| 9 | + LogFilePath string = "F:/log/app.log" | ||
| 10 | + LogLevel string = "error" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func init() { | ||
| 14 | + LogLevel = config.StringDefault("log_level", LogLevel) | ||
| 15 | + LogFilePath = config.StringDefault("aliyun_logs_access", LogFilePath) | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func DebugConfig() { | ||
| 19 | + for i := range config.HistorySort { | ||
| 20 | + k := config.HistorySort[i] | ||
| 21 | + v, ok := config.History[k] | ||
| 22 | + if !ok { | ||
| 23 | + continue | ||
| 24 | + } | ||
| 25 | + log.Debug(fmt.Sprintf("【load config】 %v=%v", k, v)) | ||
| 26 | + } | ||
| 27 | +} |
pkg/constant/loader.go
0 → 100644
| 1 | +package constant | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/astaxie/beego" | ||
| 5 | +) | ||
| 6 | + | ||
| 7 | +var config = NewConfigLoader() | ||
| 8 | + | ||
| 9 | +type ConfigLoader struct { | ||
| 10 | + History map[string]interface{} | ||
| 11 | + HistorySort []string | ||
| 12 | +} | ||
| 13 | + | ||
| 14 | +func NewConfigLoader() *ConfigLoader { | ||
| 15 | + return &ConfigLoader{ | ||
| 16 | + History: make(map[string]interface{}), | ||
| 17 | + HistorySort: make([]string, 0), | ||
| 18 | + } | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +func (c *ConfigLoader) String(key string) (ret string, ok bool) { | ||
| 22 | + if ret = beego.AppConfig.String(key); len(ret) != 0 { | ||
| 23 | + ok = true | ||
| 24 | + c.SetHistory(key, ret) | ||
| 25 | + return | ||
| 26 | + } | ||
| 27 | + return | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +func (c *ConfigLoader) StringDefault(key string, defaultValue string) string { | ||
| 31 | + if ret, ok := c.String(key); ok { | ||
| 32 | + return ret | ||
| 33 | + } | ||
| 34 | + return defaultValue | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +func (c *ConfigLoader) SetHistory(key string, value interface{}) { | ||
| 38 | + if _, ok := c.History[key]; !ok { | ||
| 39 | + c.History[key] = value | ||
| 40 | + c.HistorySort = append(c.HistorySort, key) | ||
| 41 | + } | ||
| 42 | +} |
pkg/constant/vod.go
0 → 100644
| 1 | +package constant | ||
| 2 | + | ||
| 3 | +var ( | ||
| 4 | + RegionID = "cn-shanghai" | ||
| 5 | + AccessKeyID string = "LTAI4FhiZ3UktC6N1u3H5GFC" | ||
| 6 | + AccessKeySecret string = "UyspWwdni55CYQ02hUCint4qY2jNYO" | ||
| 7 | + CName string = "https://media.goexample.live/" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +func init() { | ||
| 11 | + AccessKeyID = config.StringDefault("AccessKeyID", AccessKeyID) | ||
| 12 | + AccessKeySecret = config.StringDefault("AccessKeySecret", AccessKeySecret) | ||
| 13 | + CName = config.StringDefault("cname", CName) | ||
| 14 | +} |
| 1 | package aliyun | 1 | package aliyun |
| 2 | 2 | ||
| 3 | -import "github.com/astaxie/beego" | ||
| 4 | - | ||
| 5 | var ( | 3 | var ( |
| 6 | - RegionID = "cn-shanghai" | ||
| 7 | - AccessKeyID = beego.AppConfig.String("AccessKeyID") | ||
| 8 | - AccessKeySecret = beego.AppConfig.String("AccessKeySecret") | 4 | +//RegionID = "cn-shanghai" |
| 5 | +//AccessKeyID = beego.AppConfig.String("AccessKeyID") | ||
| 6 | +//AccessKeySecret = beego.AppConfig.String("AccessKeySecret") | ||
| 9 | ) | 7 | ) |
| 10 | 8 | ||
| 11 | const ( | 9 | const ( |
| @@ -9,7 +9,8 @@ import ( | @@ -9,7 +9,8 @@ import ( | ||
| 9 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/common" | 9 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/common" |
| 10 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 10 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
| 11 | comm_time "gitlab.fjmaimaimai.com/mmm-go/gocomm/time" | 11 | comm_time "gitlab.fjmaimaimai.com/mmm-go/gocomm/time" |
| 12 | - "openapi/internal/utils" | 12 | + "openapi/pkg/constant" |
| 13 | + "openapi/pkg/infrastructure/utils" | ||
| 13 | "path" | 14 | "path" |
| 14 | "path/filepath" | 15 | "path/filepath" |
| 15 | "time" | 16 | "time" |
| @@ -17,13 +18,13 @@ import ( | @@ -17,13 +18,13 @@ import ( | ||
| 17 | 18 | ||
| 18 | //客户端 | 19 | //客户端 |
| 19 | func DefaultVodClient() (client *vod.Client, err error) { | 20 | func DefaultVodClient() (client *vod.Client, err error) { |
| 20 | - return InitVodClient(AccessKeyID, AccessKeySecret) | 21 | + return InitVodClient(constant.AccessKeyID, constant.AccessKeySecret) |
| 21 | } | 22 | } |
| 22 | 23 | ||
| 23 | //初始化客户端 | 24 | //初始化客户端 |
| 24 | func InitVodClient(accessKeyId string, accessKeySecret string) (client *vod.Client, err error) { | 25 | func InitVodClient(accessKeyId string, accessKeySecret string) (client *vod.Client, err error) { |
| 25 | // 点播服务接入区域 | 26 | // 点播服务接入区域 |
| 26 | - regionId := RegionID | 27 | + regionId := constant.RegionID |
| 27 | // 创建授权对象 | 28 | // 创建授权对象 |
| 28 | credential := &credentials.AccessKeyCredential{ | 29 | credential := &credentials.AccessKeyCredential{ |
| 29 | accessKeyId, | 30 | accessKeyId, |
| @@ -73,7 +74,7 @@ func RefreshUploadVideo(client *vod.Client, r *RefreshUploadVideoRequest) (respo | @@ -73,7 +74,7 @@ func RefreshUploadVideo(client *vod.Client, r *RefreshUploadVideoRequest) (respo | ||
| 73 | if up, e := ParseUploadAddress(rsp.UploadAddress); e != nil { | 74 | if up, e := ParseUploadAddress(rsp.UploadAddress); e != nil { |
| 74 | log.Error(e) | 75 | log.Error(e) |
| 75 | } else { | 76 | } else { |
| 76 | - response.FileURL = up.GetFileUrl(beego.AppConfig.String("cname")) | 77 | + response.FileURL = up.GetFileUrl(constant.CName) |
| 77 | } | 78 | } |
| 78 | return | 79 | return |
| 79 | } | 80 | } |
| @@ -5,8 +5,8 @@ import ( | @@ -5,8 +5,8 @@ import ( | ||
| 5 | "fmt" | 5 | "fmt" |
| 6 | "github.com/astaxie/beego/httplib" | 6 | "github.com/astaxie/beego/httplib" |
| 7 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 7 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
| 8 | - "openapi/internal/push" | ||
| 9 | - "openapi/internal/utils" | 8 | + "openapi/pkg/infrastructure/push" |
| 9 | + "openapi/pkg/infrastructure/utils" | ||
| 10 | "strings" | 10 | "strings" |
| 11 | "sync" | 11 | "sync" |
| 12 | "time" | 12 | "time" |
| @@ -7,7 +7,7 @@ import ( | @@ -7,7 +7,7 @@ import ( | ||
| 7 | "github.com/astaxie/beego/httplib" | 7 | "github.com/astaxie/beego/httplib" |
| 8 | "io/ioutil" | 8 | "io/ioutil" |
| 9 | "net/http" | 9 | "net/http" |
| 10 | - "openapi/internal/push" | 10 | + "openapi/pkg/infrastructure/push" |
| 11 | "strings" | 11 | "strings" |
| 12 | "time" | 12 | "time" |
| 13 | ) | 13 | ) |
pkg/log/logger.go
0 → 100644
| 1 | +package log | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "gitlab.fjmaimaimai.com/mmm-go/gocomm/config" | ||
| 6 | + "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | ||
| 7 | + "openapi/pkg/constant" | ||
| 8 | + "openapi/pkg/infrastructure/utils" | ||
| 9 | +) | ||
| 10 | + | ||
| 11 | +func init() { | ||
| 12 | + log.InitLog(config.Logger{ | ||
| 13 | + Filename: constant.LogFilePath, | ||
| 14 | + Level: fmt.Sprintf("%v", utils.ResolveLogLevel(constant.LogLevel)), | ||
| 15 | + }) | ||
| 16 | +} |
pkg/port/beego/beego.go
0 → 100644
| @@ -7,7 +7,7 @@ import ( | @@ -7,7 +7,7 @@ import ( | ||
| 7 | "fmt" | 7 | "fmt" |
| 8 | "github.com/astaxie/beego/plugins/cors" | 8 | "github.com/astaxie/beego/plugins/cors" |
| 9 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/time" | 9 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/time" |
| 10 | - "openapi/protocol" | 10 | + protocol "openapi/pkg/domain" |
| 11 | "strconv" | 11 | "strconv" |
| 12 | "strings" | 12 | "strings" |
| 13 | 13 |
| @@ -3,9 +3,9 @@ package v1 | @@ -3,9 +3,9 @@ package v1 | ||
| 3 | import ( | 3 | import ( |
| 4 | "encoding/json" | 4 | "encoding/json" |
| 5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
| 6 | - "openapi/controllers" | ||
| 7 | - "openapi/protocol" | ||
| 8 | - "openapi/services/push" | 6 | + push "openapi/pkg/application/push/service" |
| 7 | + protocol "openapi/pkg/domain" | ||
| 8 | + "openapi/pkg/port/beego/controllers" | ||
| 9 | ) | 9 | ) |
| 10 | 10 | ||
| 11 | type PushController struct { | 11 | type PushController struct { |
| @@ -3,10 +3,10 @@ package v1 | @@ -3,10 +3,10 @@ package v1 | ||
| 3 | import ( | 3 | import ( |
| 4 | "encoding/json" | 4 | "encoding/json" |
| 5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
| 6 | - "openapi/controllers" | ||
| 7 | - "openapi/internal/aliyun" | ||
| 8 | - "openapi/protocol" | ||
| 9 | - "openapi/services/vod" | 6 | + vod "openapi/pkg/application/vod/service" |
| 7 | + "openapi/pkg/domain" | ||
| 8 | + "openapi/pkg/infrastructure/aliyun" | ||
| 9 | + "openapi/pkg/port/beego/controllers" | ||
| 10 | ) | 10 | ) |
| 11 | 11 | ||
| 12 | type VodController struct { | 12 | type VodController struct { |
| @@ -16,14 +16,14 @@ type VodController struct { | @@ -16,14 +16,14 @@ type VodController struct { | ||
| 16 | //创建视频上传凭证 CreateUploadVideo | 16 | //创建视频上传凭证 CreateUploadVideo |
| 17 | // @router /createUploadVideo [post] | 17 | // @router /createUploadVideo [post] |
| 18 | func (this *VodController) CreateUploadVideo() { | 18 | func (this *VodController) CreateUploadVideo() { |
| 19 | - var msg *protocol.ResponseMessage | 19 | + var msg *domain.ResponseMessage |
| 20 | defer func() { | 20 | defer func() { |
| 21 | this.Resp(msg) | 21 | this.Resp(msg) |
| 22 | }() | 22 | }() |
| 23 | var request *aliyun.CreateUploadVideoRequest | 23 | var request *aliyun.CreateUploadVideoRequest |
| 24 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { | 24 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { |
| 25 | log.Error(err) | 25 | log.Error(err) |
| 26 | - msg = protocol.BadRequestParam(1) | 26 | + msg = domain.BadRequestParam(1) |
| 27 | return | 27 | return |
| 28 | } | 28 | } |
| 29 | if b, m := this.Valid(request); !b { | 29 | if b, m := this.Valid(request); !b { |
| @@ -34,13 +34,13 @@ func (this *VodController) CreateUploadVideo() { | @@ -34,13 +34,13 @@ func (this *VodController) CreateUploadVideo() { | ||
| 34 | request.FileName = aliyun.DefaultVideoFileName | 34 | request.FileName = aliyun.DefaultVideoFileName |
| 35 | } | 35 | } |
| 36 | header := controllers.GetRequestHeader(this.Ctx) | 36 | header := controllers.GetRequestHeader(this.Ctx) |
| 37 | - msg = protocol.NewReturnResponse(vod.CreateUploadVideo(header, request)) | 37 | + msg = domain.NewReturnResponse(vod.CreateUploadVideo(header, request)) |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | //创建视频上传凭证(多个) CreateUploadVideos | 40 | //创建视频上传凭证(多个) CreateUploadVideos |
| 41 | // @router /createUploadVideos [post] | 41 | // @router /createUploadVideos [post] |
| 42 | func (this *VodController) CreateUploadVideos() { | 42 | func (this *VodController) CreateUploadVideos() { |
| 43 | - var msg *protocol.ResponseMessage | 43 | + var msg *domain.ResponseMessage |
| 44 | var response *aliyun.CreateUploadVideosResponse = &aliyun.CreateUploadVideosResponse{ | 44 | var response *aliyun.CreateUploadVideosResponse = &aliyun.CreateUploadVideosResponse{ |
| 45 | List: make([]*aliyun.CreateUploadVideoResponse, 0), | 45 | List: make([]*aliyun.CreateUploadVideoResponse, 0), |
| 46 | } | 46 | } |
| @@ -50,7 +50,7 @@ func (this *VodController) CreateUploadVideos() { | @@ -50,7 +50,7 @@ func (this *VodController) CreateUploadVideos() { | ||
| 50 | var request *aliyun.CreateUploadVideosRequest | 50 | var request *aliyun.CreateUploadVideosRequest |
| 51 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { | 51 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { |
| 52 | log.Error(err) | 52 | log.Error(err) |
| 53 | - msg = protocol.BadRequestParam(1) | 53 | + msg = domain.BadRequestParam(1) |
| 54 | return | 54 | return |
| 55 | } | 55 | } |
| 56 | if b, m := this.Valid(request); !b { | 56 | if b, m := this.Valid(request); !b { |
| @@ -60,7 +60,7 @@ func (this *VodController) CreateUploadVideos() { | @@ -60,7 +60,7 @@ func (this *VodController) CreateUploadVideos() { | ||
| 60 | header := controllers.GetRequestHeader(this.Ctx) | 60 | header := controllers.GetRequestHeader(this.Ctx) |
| 61 | var err error | 61 | var err error |
| 62 | if len(request.Items) == 0 { | 62 | if len(request.Items) == 0 { |
| 63 | - msg = protocol.BadRequestParam(2) | 63 | + msg = domain.BadRequestParam(2) |
| 64 | } | 64 | } |
| 65 | for i := range request.Items { | 65 | for i := range request.Items { |
| 66 | r := request.Items[i] | 66 | r := request.Items[i] |
| @@ -71,20 +71,20 @@ func (this *VodController) CreateUploadVideos() { | @@ -71,20 +71,20 @@ func (this *VodController) CreateUploadVideos() { | ||
| 71 | response.List = append(response.List, rsp) | 71 | response.List = append(response.List, rsp) |
| 72 | } | 72 | } |
| 73 | } | 73 | } |
| 74 | - msg = protocol.NewReturnResponse(response, err) | 74 | + msg = domain.NewReturnResponse(response, err) |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | //刷新视频上传凭证 RefreshUploadVideo | 77 | //刷新视频上传凭证 RefreshUploadVideo |
| 78 | // @router /refreshUploadVideo [post] | 78 | // @router /refreshUploadVideo [post] |
| 79 | func (this *VodController) RefreshUploadVideo() { | 79 | func (this *VodController) RefreshUploadVideo() { |
| 80 | - var msg *protocol.ResponseMessage | 80 | + var msg *domain.ResponseMessage |
| 81 | defer func() { | 81 | defer func() { |
| 82 | this.Resp(msg) | 82 | this.Resp(msg) |
| 83 | }() | 83 | }() |
| 84 | var request *aliyun.RefreshUploadVideoRequest | 84 | var request *aliyun.RefreshUploadVideoRequest |
| 85 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { | 85 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { |
| 86 | log.Error(err) | 86 | log.Error(err) |
| 87 | - msg = protocol.BadRequestParam(1) | 87 | + msg = domain.BadRequestParam(1) |
| 88 | return | 88 | return |
| 89 | } | 89 | } |
| 90 | if b, m := this.Valid(request); !b { | 90 | if b, m := this.Valid(request); !b { |
| @@ -92,20 +92,20 @@ func (this *VodController) RefreshUploadVideo() { | @@ -92,20 +92,20 @@ func (this *VodController) RefreshUploadVideo() { | ||
| 92 | return | 92 | return |
| 93 | } | 93 | } |
| 94 | header := controllers.GetRequestHeader(this.Ctx) | 94 | header := controllers.GetRequestHeader(this.Ctx) |
| 95 | - msg = protocol.NewReturnResponse(vod.RefreshUploadVideo(header, request)) | 95 | + msg = domain.NewReturnResponse(vod.RefreshUploadVideo(header, request)) |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | //创建图片上传凭证 CreateUploadImage | 98 | //创建图片上传凭证 CreateUploadImage |
| 99 | // @router /createUploadImage [post] | 99 | // @router /createUploadImage [post] |
| 100 | func (this *VodController) CreateUploadImage() { | 100 | func (this *VodController) CreateUploadImage() { |
| 101 | - var msg *protocol.ResponseMessage | 101 | + var msg *domain.ResponseMessage |
| 102 | defer func() { | 102 | defer func() { |
| 103 | this.Resp(msg) | 103 | this.Resp(msg) |
| 104 | }() | 104 | }() |
| 105 | var request *aliyun.CreateUploadImageRequest | 105 | var request *aliyun.CreateUploadImageRequest |
| 106 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { | 106 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { |
| 107 | log.Error(err) | 107 | log.Error(err) |
| 108 | - msg = protocol.BadRequestParam(1) | 108 | + msg = domain.BadRequestParam(1) |
| 109 | return | 109 | return |
| 110 | } | 110 | } |
| 111 | if b, m := this.Valid(request); !b { | 111 | if b, m := this.Valid(request); !b { |
| @@ -114,13 +114,13 @@ func (this *VodController) CreateUploadImage() { | @@ -114,13 +114,13 @@ func (this *VodController) CreateUploadImage() { | ||
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | header := controllers.GetRequestHeader(this.Ctx) | 116 | header := controllers.GetRequestHeader(this.Ctx) |
| 117 | - msg = protocol.NewReturnResponse(vod.CreateUploadImage(header, request)) | 117 | + msg = domain.NewReturnResponse(vod.CreateUploadImage(header, request)) |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | //创建图片上传凭证 CreateUploadImages | 120 | //创建图片上传凭证 CreateUploadImages |
| 121 | // @router /createUploadImages [post] | 121 | // @router /createUploadImages [post] |
| 122 | func (this *VodController) CreateUploadImages() { | 122 | func (this *VodController) CreateUploadImages() { |
| 123 | - var msg *protocol.ResponseMessage | 123 | + var msg *domain.ResponseMessage |
| 124 | defer func() { | 124 | defer func() { |
| 125 | this.Resp(msg) | 125 | this.Resp(msg) |
| 126 | }() | 126 | }() |
| @@ -132,7 +132,7 @@ func (this *VodController) CreateUploadImages() { | @@ -132,7 +132,7 @@ func (this *VodController) CreateUploadImages() { | ||
| 132 | ) | 132 | ) |
| 133 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { | 133 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { |
| 134 | log.Error(err) | 134 | log.Error(err) |
| 135 | - msg = protocol.BadRequestParam(1) | 135 | + msg = domain.BadRequestParam(1) |
| 136 | return | 136 | return |
| 137 | } | 137 | } |
| 138 | if b, m := this.Valid(request); !b { | 138 | if b, m := this.Valid(request); !b { |
| @@ -141,7 +141,7 @@ func (this *VodController) CreateUploadImages() { | @@ -141,7 +141,7 @@ func (this *VodController) CreateUploadImages() { | ||
| 141 | } | 141 | } |
| 142 | var err error | 142 | var err error |
| 143 | if len(request.Items) == 0 { | 143 | if len(request.Items) == 0 { |
| 144 | - msg = protocol.BadRequestParam(2) | 144 | + msg = domain.BadRequestParam(2) |
| 145 | } | 145 | } |
| 146 | header := controllers.GetRequestHeader(this.Ctx) | 146 | header := controllers.GetRequestHeader(this.Ctx) |
| 147 | for i := range request.Items { | 147 | for i := range request.Items { |
| @@ -153,20 +153,20 @@ func (this *VodController) CreateUploadImages() { | @@ -153,20 +153,20 @@ func (this *VodController) CreateUploadImages() { | ||
| 153 | response.List = append(response.List, rsp) | 153 | response.List = append(response.List, rsp) |
| 154 | } | 154 | } |
| 155 | } | 155 | } |
| 156 | - msg = protocol.NewReturnResponse(response, err) | 156 | + msg = domain.NewReturnResponse(response, err) |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | //获取视频播放地址 GetPlayInfo | 159 | //获取视频播放地址 GetPlayInfo |
| 160 | // @router /getPlayInfo [post] | 160 | // @router /getPlayInfo [post] |
| 161 | func (this *VodController) GetPlayInfo() { | 161 | func (this *VodController) GetPlayInfo() { |
| 162 | - var msg *protocol.ResponseMessage | 162 | + var msg *domain.ResponseMessage |
| 163 | defer func() { | 163 | defer func() { |
| 164 | this.Resp(msg) | 164 | this.Resp(msg) |
| 165 | }() | 165 | }() |
| 166 | var request *aliyun.GetPlayInfoRequest | 166 | var request *aliyun.GetPlayInfoRequest |
| 167 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { | 167 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { |
| 168 | log.Error(err) | 168 | log.Error(err) |
| 169 | - msg = protocol.BadRequestParam(1) | 169 | + msg = domain.BadRequestParam(1) |
| 170 | return | 170 | return |
| 171 | } | 171 | } |
| 172 | if b, m := this.Valid(request); !b { | 172 | if b, m := this.Valid(request); !b { |
| @@ -174,20 +174,20 @@ func (this *VodController) GetPlayInfo() { | @@ -174,20 +174,20 @@ func (this *VodController) GetPlayInfo() { | ||
| 174 | return | 174 | return |
| 175 | } | 175 | } |
| 176 | header := controllers.GetRequestHeader(this.Ctx) | 176 | header := controllers.GetRequestHeader(this.Ctx) |
| 177 | - msg = protocol.NewReturnResponse(vod.GetPlayInfo(header, request)) | 177 | + msg = domain.NewReturnResponse(vod.GetPlayInfo(header, request)) |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | //获取视频播放凭证 GetVideoPlayAuth | 180 | //获取视频播放凭证 GetVideoPlayAuth |
| 181 | // @router /getVideoPlayAuth [post] | 181 | // @router /getVideoPlayAuth [post] |
| 182 | func (this *VodController) GetVideoPlayAuth() { | 182 | func (this *VodController) GetVideoPlayAuth() { |
| 183 | - var msg *protocol.ResponseMessage | 183 | + var msg *domain.ResponseMessage |
| 184 | defer func() { | 184 | defer func() { |
| 185 | this.Resp(msg) | 185 | this.Resp(msg) |
| 186 | }() | 186 | }() |
| 187 | var request *aliyun.GetVideoPlayAuthRequest | 187 | var request *aliyun.GetVideoPlayAuthRequest |
| 188 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { | 188 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { |
| 189 | log.Error(err) | 189 | log.Error(err) |
| 190 | - msg = protocol.BadRequestParam(1) | 190 | + msg = domain.BadRequestParam(1) |
| 191 | return | 191 | return |
| 192 | } | 192 | } |
| 193 | if b, m := this.Valid(request); !b { | 193 | if b, m := this.Valid(request); !b { |
| @@ -195,5 +195,5 @@ func (this *VodController) GetVideoPlayAuth() { | @@ -195,5 +195,5 @@ func (this *VodController) GetVideoPlayAuth() { | ||
| 195 | return | 195 | return |
| 196 | } | 196 | } |
| 197 | header := controllers.GetRequestHeader(this.Ctx) | 197 | header := controllers.GetRequestHeader(this.Ctx) |
| 198 | - msg = protocol.NewReturnResponse(vod.GetVideoPlayAuth(header, request)) | 198 | + msg = domain.NewReturnResponse(vod.GetVideoPlayAuth(header, request)) |
| 199 | } | 199 | } |
| @@ -2,8 +2,9 @@ package routers | @@ -2,8 +2,9 @@ package routers | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "github.com/astaxie/beego" | 4 | "github.com/astaxie/beego" |
| 5 | - "openapi/controllers" | ||
| 6 | - "openapi/controllers/v1" | 5 | + "openapi/pkg/constant" |
| 6 | + "openapi/pkg/port/beego/controllers" | ||
| 7 | + "openapi/pkg/port/beego/controllers/v1" | ||
| 7 | ) | 8 | ) |
| 8 | 9 | ||
| 9 | var nsV1 *beego.Namespace | 10 | var nsV1 *beego.Namespace |
| @@ -12,8 +13,7 @@ func init() { | @@ -12,8 +13,7 @@ func init() { | ||
| 12 | nsV1 := beego.NewNamespace("v1", | 13 | nsV1 := beego.NewNamespace("v1", |
| 13 | beego.NSNamespace("vod", beego.NSBefore(controllers.AllowOption), beego.NSInclude(&v1.VodController{})), | 14 | beego.NSNamespace("vod", beego.NSBefore(controllers.AllowOption), beego.NSInclude(&v1.VodController{})), |
| 14 | beego.NSNamespace("push", beego.NSBefore(controllers.AllowOption), beego.NSInclude(&v1.PushController{})), | 15 | beego.NSNamespace("push", beego.NSBefore(controllers.AllowOption), beego.NSInclude(&v1.PushController{})), |
| 15 | - //beego.NSNamespace("vod", beego.NSBefore(controllers.FilterComm), beego.NSBefore(controllers.AllowOption), beego.NSInclude(&v1.VodController{})), | ||
| 16 | ) | 16 | ) |
| 17 | - beego.SetStaticPath("/log", beego.AppConfig.String("aliyun_logs_access")) | 17 | + beego.SetStaticPath("/log", constant.LogFilePath) |
| 18 | beego.AddNamespace(nsV1) | 18 | beego.AddNamespace(nsV1) |
| 19 | } | 19 | } |
routers/commentsRouter_controllers_v1.go
已删除
100644 → 0
| 1 | -package routers | ||
| 2 | - | ||
| 3 | -import ( | ||
| 4 | - "github.com/astaxie/beego" | ||
| 5 | - "github.com/astaxie/beego/context/param" | ||
| 6 | -) | ||
| 7 | - | ||
| 8 | -func init() { | ||
| 9 | - | ||
| 10 | - beego.GlobalControllerRouter["openapi/controllers/v1:PushController"] = append(beego.GlobalControllerRouter["openapi/controllers/v1:PushController"], | ||
| 11 | - beego.ControllerComments{ | ||
| 12 | - Method: "PushInfo", | ||
| 13 | - Router: `/pushInfo`, | ||
| 14 | - AllowHTTPMethods: []string{"post"}, | ||
| 15 | - MethodParams: param.Make(), | ||
| 16 | - Params: nil}) | ||
| 17 | - | ||
| 18 | - beego.GlobalControllerRouter["openapi/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["openapi/controllers/v1:VodController"], | ||
| 19 | - beego.ControllerComments{ | ||
| 20 | - Method: "CreateUploadImage", | ||
| 21 | - Router: `/createUploadImage`, | ||
| 22 | - AllowHTTPMethods: []string{"post"}, | ||
| 23 | - MethodParams: param.Make(), | ||
| 24 | - Params: nil}) | ||
| 25 | - | ||
| 26 | - beego.GlobalControllerRouter["openapi/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["openapi/controllers/v1:VodController"], | ||
| 27 | - beego.ControllerComments{ | ||
| 28 | - Method: "CreateUploadImages", | ||
| 29 | - Router: `/createUploadImages`, | ||
| 30 | - AllowHTTPMethods: []string{"post"}, | ||
| 31 | - MethodParams: param.Make(), | ||
| 32 | - Params: nil}) | ||
| 33 | - | ||
| 34 | - beego.GlobalControllerRouter["openapi/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["openapi/controllers/v1:VodController"], | ||
| 35 | - beego.ControllerComments{ | ||
| 36 | - Method: "CreateUploadVideo", | ||
| 37 | - Router: `/createUploadVideo`, | ||
| 38 | - AllowHTTPMethods: []string{"post"}, | ||
| 39 | - MethodParams: param.Make(), | ||
| 40 | - Params: nil}) | ||
| 41 | - | ||
| 42 | - beego.GlobalControllerRouter["openapi/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["openapi/controllers/v1:VodController"], | ||
| 43 | - beego.ControllerComments{ | ||
| 44 | - Method: "CreateUploadVideos", | ||
| 45 | - Router: `/createUploadVideos`, | ||
| 46 | - AllowHTTPMethods: []string{"post"}, | ||
| 47 | - MethodParams: param.Make(), | ||
| 48 | - Params: nil}) | ||
| 49 | - | ||
| 50 | - beego.GlobalControllerRouter["openapi/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["openapi/controllers/v1:VodController"], | ||
| 51 | - beego.ControllerComments{ | ||
| 52 | - Method: "GetPlayInfo", | ||
| 53 | - Router: `/getPlayInfo`, | ||
| 54 | - AllowHTTPMethods: []string{"post"}, | ||
| 55 | - MethodParams: param.Make(), | ||
| 56 | - Params: nil}) | ||
| 57 | - | ||
| 58 | - beego.GlobalControllerRouter["openapi/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["openapi/controllers/v1:VodController"], | ||
| 59 | - beego.ControllerComments{ | ||
| 60 | - Method: "GetVideoPlayAuth", | ||
| 61 | - Router: `/getVideoPlayAuth`, | ||
| 62 | - AllowHTTPMethods: []string{"post"}, | ||
| 63 | - MethodParams: param.Make(), | ||
| 64 | - Params: nil}) | ||
| 65 | - | ||
| 66 | - beego.GlobalControllerRouter["openapi/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["openapi/controllers/v1:VodController"], | ||
| 67 | - beego.ControllerComments{ | ||
| 68 | - Method: "RefreshUploadVideo", | ||
| 69 | - Router: `/refreshUploadVideo`, | ||
| 70 | - AllowHTTPMethods: []string{"post"}, | ||
| 71 | - MethodParams: param.Make(), | ||
| 72 | - Params: nil}) | ||
| 73 | - | ||
| 74 | -} |
| 1 | +package push | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/gavv/httpexpect" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "net/http" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +var _ = ginkgo.Describe("消息推送测试", func() { | ||
| 10 | + ginkgo.Describe("消息推送测试", func() { | ||
| 11 | + ginkgo.Context("", func() { | ||
| 12 | + ginkgo.It("", func() { | ||
| 13 | + httpExpect := httpexpect.New(ginkgo.GinkgoT(), server.URL) | ||
| 14 | + body := map[string]interface{}{ | ||
| 15 | + "mmmType": 1, | ||
| 16 | + "deviceToken": "", | ||
| 17 | + "clientId": "b5fff5f6b0af551da5f381fa47991828", | ||
| 18 | + "appkey": "5AjJeDOSOZ5ojQpXJFjhg9", | ||
| 19 | + "secret": "9VnM8MaA6n84Y5VnOIaSvA", | ||
| 20 | + "appId": "TkpBI4awmg9fBUx3NWKXS6", | ||
| 21 | + "title": " hello", | ||
| 22 | + "content": " hello content", | ||
| 23 | + "ext": map[string]interface{}{"transData": "trans-content"}, | ||
| 24 | + } | ||
| 25 | + httpExpect.POST("/v1/push/pushInfo"). | ||
| 26 | + WithJSON(body). | ||
| 27 | + Expect(). | ||
| 28 | + Status(http.StatusOK). | ||
| 29 | + JSON(). | ||
| 30 | + Object(). | ||
| 31 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 32 | + ContainsKey("msg").ValueEqual("msg", "成功") | ||
| 33 | + }) | ||
| 34 | + }) | ||
| 35 | + }) | ||
| 36 | +}) |
| 1 | +package push | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/astaxie/beego" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "github.com/onsi/gomega" | ||
| 7 | + "net/http" | ||
| 8 | + "net/http/httptest" | ||
| 9 | + _ "openapi/pkg/port/beego" | ||
| 10 | + "testing" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func TestPush(t *testing.T) { | ||
| 14 | + gomega.RegisterFailHandler(ginkgo.Fail) | ||
| 15 | + ginkgo.RunSpecs(t, "Beego Port Config Correlations Test Case Suite") | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +var handler http.Handler | ||
| 19 | +var server *httptest.Server | ||
| 20 | + | ||
| 21 | +var _ = ginkgo.BeforeSuite(func() { | ||
| 22 | + handler = beego.BeeApp.Handlers | ||
| 23 | + beego.BConfig.CopyRequestBody = true | ||
| 24 | + server = httptest.NewServer(handler) | ||
| 25 | +}) | ||
| 26 | + | ||
| 27 | +var _ = ginkgo.AfterSuite(func() { | ||
| 28 | + server.Close() | ||
| 29 | +}) |
| 1 | +package vod | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/gavv/httpexpect" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "net/http" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +var _ = ginkgo.Describe("创建图片上传凭证(单图片)", func() { | ||
| 10 | + ginkgo.Describe("创建图片上传凭证(单图片)", func() { | ||
| 11 | + ginkgo.Context("", func() { | ||
| 12 | + ginkgo.It("", func() { | ||
| 13 | + httpExpect := httpexpect.New(ginkgo.GinkgoT(), server.URL) | ||
| 14 | + body := map[string]interface{}{ | ||
| 15 | + "fileName": "test.jpg", | ||
| 16 | + } | ||
| 17 | + httpExpect.POST("/v1/vod/createUploadImage"). | ||
| 18 | + WithJSON(body). | ||
| 19 | + WithHeader("x-mmm-appproject", "opportunity"). | ||
| 20 | + Expect(). | ||
| 21 | + Status(http.StatusOK). | ||
| 22 | + JSON(). | ||
| 23 | + Object(). | ||
| 24 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 25 | + ContainsKey("msg").ValueEqual("msg", "成功") | ||
| 26 | + }) | ||
| 27 | + }) | ||
| 28 | + }) | ||
| 29 | +}) |
| 1 | +package vod | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/gavv/httpexpect" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "net/http" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +var _ = ginkgo.Describe("创建图片上传凭证(多图片)", func() { | ||
| 10 | + ginkgo.Describe("创建图片上传凭证(多图片)", func() { | ||
| 11 | + ginkgo.Context("", func() { | ||
| 12 | + ginkgo.It("", func() { | ||
| 13 | + httpExpect := httpexpect.New(ginkgo.GinkgoT(), server.URL) | ||
| 14 | + body := map[string]interface{}{ | ||
| 15 | + "items": []struct { | ||
| 16 | + FileName string `json:"fileName"` | ||
| 17 | + }{{FileName: "test.jpg"}}, | ||
| 18 | + } | ||
| 19 | + httpExpect.POST("/v1/vod/createUploadImages"). | ||
| 20 | + WithJSON(body). | ||
| 21 | + WithHeader("x-mmm-appproject", "opportunity"). | ||
| 22 | + Expect(). | ||
| 23 | + Status(http.StatusOK). | ||
| 24 | + JSON(). | ||
| 25 | + Object(). | ||
| 26 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 27 | + ContainsKey("msg").ValueEqual("msg", "成功") | ||
| 28 | + }) | ||
| 29 | + }) | ||
| 30 | + }) | ||
| 31 | +}) |
| 1 | +package vod | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/gavv/httpexpect" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "net/http" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +var _ = ginkgo.Describe("创建视频上传凭证(单视频)", func() { | ||
| 10 | + ginkgo.Describe("创建视频上传凭证(单视频)", func() { | ||
| 11 | + ginkgo.Context("", func() { | ||
| 12 | + ginkgo.It("", func() { | ||
| 13 | + httpExpect := httpexpect.New(ginkgo.GinkgoT(), server.URL) | ||
| 14 | + body := map[string]interface{}{ | ||
| 15 | + "fileName": "test.mp4", | ||
| 16 | + } | ||
| 17 | + httpExpect.POST("/v1/vod/createUploadVideos"). | ||
| 18 | + WithJSON(body). | ||
| 19 | + WithHeader("x-mmm-appproject", "opportunity"). | ||
| 20 | + Expect(). | ||
| 21 | + Status(http.StatusOK). | ||
| 22 | + JSON(). | ||
| 23 | + Object(). | ||
| 24 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 25 | + ContainsKey("msg").ValueEqual("msg", "成功") | ||
| 26 | + }) | ||
| 27 | + }) | ||
| 28 | + }) | ||
| 29 | +}) |
| 1 | +package vod | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/gavv/httpexpect" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "net/http" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +var _ = ginkgo.Describe("创建视频上传凭证(多视频)", func() { | ||
| 10 | + ginkgo.Describe("创建视频上传凭证(多视频)", func() { | ||
| 11 | + ginkgo.Context("", func() { | ||
| 12 | + ginkgo.It("", func() { | ||
| 13 | + httpExpect := httpexpect.New(ginkgo.GinkgoT(), server.URL) | ||
| 14 | + body := map[string]interface{}{ | ||
| 15 | + "items": []struct { | ||
| 16 | + FileName string `json:"fileName"` | ||
| 17 | + }{{FileName: "test.mp4"}}, | ||
| 18 | + } | ||
| 19 | + httpExpect.POST("/v1/vod/createUploadVideos"). | ||
| 20 | + WithJSON(body). | ||
| 21 | + WithHeader("x-mmm-appproject", "opportunity"). | ||
| 22 | + Expect(). | ||
| 23 | + Status(http.StatusOK). | ||
| 24 | + JSON(). | ||
| 25 | + Object(). | ||
| 26 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 27 | + ContainsKey("msg").ValueEqual("msg", "成功") | ||
| 28 | + }) | ||
| 29 | + }) | ||
| 30 | + }) | ||
| 31 | +}) |
| 1 | +package vod | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/gavv/httpexpect" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "net/http" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +var _ = ginkgo.Describe("获取播放信息测试", func() { | ||
| 10 | + ginkgo.Describe("获取播放信息测试", func() { | ||
| 11 | + ginkgo.Context("", func() { | ||
| 12 | + ginkgo.It("", func() { | ||
| 13 | + httpExpect := httpexpect.New(ginkgo.GinkgoT(), server.URL) | ||
| 14 | + body := map[string]interface{}{ | ||
| 15 | + "videoId": "7be8e50dd65e45d285908bf28c8e94b2", | ||
| 16 | + } | ||
| 17 | + httpExpect.POST("/v1/vod/getPlayInfo"). | ||
| 18 | + WithJSON(body). | ||
| 19 | + WithHeader("x-mmm-appproject", "opportunity"). | ||
| 20 | + Expect(). | ||
| 21 | + Status(http.StatusOK). | ||
| 22 | + JSON(). | ||
| 23 | + Object(). | ||
| 24 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 25 | + ContainsKey("msg").ValueEqual("msg", "成功") | ||
| 26 | + }) | ||
| 27 | + }) | ||
| 28 | + }) | ||
| 29 | +}) |
| 1 | +package vod | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/gavv/httpexpect" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "net/http" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +var _ = ginkgo.Describe("获取播放凭证测试", func() { | ||
| 10 | + ginkgo.Describe("获取播放凭证测试", func() { | ||
| 11 | + ginkgo.Context("", func() { | ||
| 12 | + ginkgo.It("", func() { | ||
| 13 | + httpExpect := httpexpect.New(ginkgo.GinkgoT(), server.URL) | ||
| 14 | + body := map[string]interface{}{ | ||
| 15 | + "videoId": "7be8e50dd65e45d285908bf28c8e94b2", | ||
| 16 | + } | ||
| 17 | + httpExpect.POST("/v1/vod/getVideoPlayAuth"). | ||
| 18 | + WithJSON(body). | ||
| 19 | + WithHeader("x-mmm-appproject", "opportunity"). | ||
| 20 | + Expect(). | ||
| 21 | + Status(http.StatusOK). | ||
| 22 | + JSON(). | ||
| 23 | + Object(). | ||
| 24 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 25 | + ContainsKey("msg").ValueEqual("msg", "成功") | ||
| 26 | + }) | ||
| 27 | + }) | ||
| 28 | + }) | ||
| 29 | +}) |
| 1 | +package vod | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/gavv/httpexpect" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "net/http" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +var _ = ginkgo.Describe("刷新视频上次凭证", func() { | ||
| 10 | + ginkgo.Describe("刷新视频上次凭证", func() { | ||
| 11 | + ginkgo.Context("", func() { | ||
| 12 | + ginkgo.It("", func() { | ||
| 13 | + httpExpect := httpexpect.New(ginkgo.GinkgoT(), server.URL) | ||
| 14 | + body := map[string]interface{}{ | ||
| 15 | + "videoId": "1023bc472c69499dbe332afa785ee610", | ||
| 16 | + } | ||
| 17 | + httpExpect.POST("/v1/vod/refreshUploadVideo"). | ||
| 18 | + WithJSON(body). | ||
| 19 | + WithHeader("x-mmm-appproject", "opportunity"). | ||
| 20 | + Expect(). | ||
| 21 | + Status(http.StatusOK). | ||
| 22 | + JSON(). | ||
| 23 | + Object(). | ||
| 24 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 25 | + ContainsKey("msg").ValueEqual("msg", "成功") | ||
| 26 | + }) | ||
| 27 | + }) | ||
| 28 | + }) | ||
| 29 | +}) |
test/integration/beego/vod/vod_suite_test.go
0 → 100644
| 1 | +package vod | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/astaxie/beego" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "github.com/onsi/gomega" | ||
| 7 | + "net/http" | ||
| 8 | + "net/http/httptest" | ||
| 9 | + _ "openapi/pkg/port/beego" | ||
| 10 | + "testing" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func TestPush(t *testing.T) { | ||
| 14 | + gomega.RegisterFailHandler(ginkgo.Fail) | ||
| 15 | + ginkgo.RunSpecs(t, "Beego Port Config Correlations Test Case Suite") | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +var handler http.Handler | ||
| 19 | +var server *httptest.Server | ||
| 20 | + | ||
| 21 | +var _ = ginkgo.BeforeSuite(func() { | ||
| 22 | + handler = beego.BeeApp.Handlers | ||
| 23 | + beego.BConfig.CopyRequestBody = true | ||
| 24 | + server = httptest.NewServer(handler) | ||
| 25 | +}) | ||
| 26 | + | ||
| 27 | +var _ = ginkgo.AfterSuite(func() { | ||
| 28 | + server.Close() | ||
| 29 | +}) |
-
请 注册 或 登录 后发表评论