作者 yangfu

版本V2初始化

正在显示 44 个修改的文件 包含 72 行增加149 行删除
package main
import (
"fmt"
"github.com/astaxie/beego"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/config"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"openapi/internal/utils"
_ "openapi/routers"
"time"
)
func init() {
time.Local = time.FixedZone("CST", 3600*8)
log.InitLog(config.Logger{
Filename: beego.AppConfig.String("aliyun_logs_access"),
Level: fmt.Sprintf("%v", utils.ResolveLogLevel(beego.AppConfig.String("log_level"))),
})
}
_ "openapi/pkg/port/beego"
)
func main() {
defer func() {
log.Info("open-api on stop!")
log.Info("server on stop!")
}()
log.Info("open-api on start!")
log.Info("Beego Run Mode:", beego.BConfig.RunMode)
log.Info("server on start!")
beego.Run()
}
... ...
... ... @@ -3,10 +3,10 @@ package push
import (
"encoding/json"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"openapi/internal/push"
"openapi/internal/push/getui"
"openapi/internal/utils"
"openapi/protocol"
protocol "openapi/pkg/domain"
"openapi/pkg/infrastructure/push"
"openapi/pkg/infrastructure/push/getui"
"openapi/pkg/infrastructure/utils"
)
//推送信息
... ...
package vod
package service
import (
"openapi/internal/aliyun"
"openapi/protocol"
protocol "openapi/pkg/domain"
"openapi/pkg/infrastructure/aliyun"
)
//错误处理
... ...
package vod
package service
import (
"github.com/astaxie/beego"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"openapi/internal/aliyun"
"openapi/internal/utils"
"openapi/protocol"
protocol "openapi/pkg/domain"
"openapi/pkg/infrastructure/aliyun"
"openapi/pkg/infrastructure/utils"
)
//创建视频上传凭证
... ...
package constant
... ...
package constant
... ...
package protocol
package domain
const RelateSplit = "/"
... ...
package protocol
package domain
import (
"encoding/json"
... ...
package protocol
package domain
import (
"fmt"
... ...
package protocol
package domain
var errmessge ErrorMap = map[int]string{
0: "成功",
... ...
package protocol
package domain
import "encoding/json"
... ...
package protocol
package domain
import "mime/multipart"
... ...
... ... @@ -9,7 +9,7 @@ import (
"gitlab.fjmaimaimai.com/mmm-go/gocomm/common"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
comm_time "gitlab.fjmaimaimai.com/mmm-go/gocomm/time"
"openapi/internal/utils"
"openapi/pkg/infrastructure/utils"
"path"
"path/filepath"
"time"
... ...
... ... @@ -5,8 +5,8 @@ import (
"fmt"
"github.com/astaxie/beego/httplib"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"openapi/internal/push"
"openapi/internal/utils"
"openapi/pkg/infrastructure/push"
"openapi/pkg/infrastructure/utils"
"strings"
"sync"
"time"
... ...
package getui
import (
"openapi/internal/push"
"openapi/internal/utils"
"openapi/pkg/infrastructure/push"
"openapi/pkg/infrastructure/utils"
"testing"
)
... ...
... ... @@ -2,7 +2,7 @@ package getui
import (
"gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/uid"
"openapi/internal/push"
"openapi/pkg/infrastructure/push"
)
//1.消息模板
... ...
... ... @@ -7,7 +7,7 @@ import (
"github.com/astaxie/beego/httplib"
"io/ioutil"
"net/http"
"openapi/internal/push"
"openapi/pkg/infrastructure/push"
"strings"
"time"
)
... ...
package beego
import (
_ "openapi/pkg/port/beego/routers"
)
func init() {
}
... ...
... ... @@ -7,7 +7,7 @@ import (
"fmt"
"github.com/astaxie/beego/plugins/cors"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/time"
"openapi/protocol"
protocol "openapi/pkg/domain"
"strconv"
"strings"
... ...
... ... @@ -3,9 +3,9 @@ package v1
import (
"encoding/json"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"openapi/controllers"
"openapi/protocol"
"openapi/services/push"
push "openapi/pkg/application/push/service"
protocol "openapi/pkg/domain"
"openapi/pkg/port/beego/controllers"
)
type PushController struct {
... ...
... ... @@ -3,10 +3,10 @@ package v1
import (
"encoding/json"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"openapi/controllers"
"openapi/internal/aliyun"
"openapi/protocol"
"openapi/services/vod"
vod "openapi/pkg/application/vod/service"
"openapi/pkg/domain"
"openapi/pkg/infrastructure/aliyun"
"openapi/pkg/port/beego/controllers"
)
type VodController struct {
... ... @@ -16,14 +16,14 @@ type VodController struct {
//创建视频上传凭证 CreateUploadVideo
// @router /createUploadVideo [post]
func (this *VodController) CreateUploadVideo() {
var msg *protocol.ResponseMessage
var msg *domain.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *aliyun.CreateUploadVideoRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
msg = domain.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
... ... @@ -34,13 +34,13 @@ func (this *VodController) CreateUploadVideo() {
request.FileName = aliyun.DefaultVideoFileName
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(vod.CreateUploadVideo(header, request))
msg = domain.NewReturnResponse(vod.CreateUploadVideo(header, request))
}
//创建视频上传凭证(多个) CreateUploadVideos
// @router /createUploadVideos [post]
func (this *VodController) CreateUploadVideos() {
var msg *protocol.ResponseMessage
var msg *domain.ResponseMessage
var response *aliyun.CreateUploadVideosResponse = &aliyun.CreateUploadVideosResponse{
List: make([]*aliyun.CreateUploadVideoResponse, 0),
}
... ... @@ -50,7 +50,7 @@ func (this *VodController) CreateUploadVideos() {
var request *aliyun.CreateUploadVideosRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
msg = domain.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
... ... @@ -60,7 +60,7 @@ func (this *VodController) CreateUploadVideos() {
header := controllers.GetRequestHeader(this.Ctx)
var err error
if len(request.Items) == 0 {
msg = protocol.BadRequestParam(2)
msg = domain.BadRequestParam(2)
}
for i := range request.Items {
r := request.Items[i]
... ... @@ -71,20 +71,20 @@ func (this *VodController) CreateUploadVideos() {
response.List = append(response.List, rsp)
}
}
msg = protocol.NewReturnResponse(response, err)
msg = domain.NewReturnResponse(response, err)
}
//刷新视频上传凭证 RefreshUploadVideo
// @router /refreshUploadVideo [post]
func (this *VodController) RefreshUploadVideo() {
var msg *protocol.ResponseMessage
var msg *domain.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *aliyun.RefreshUploadVideoRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
msg = domain.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
... ... @@ -92,20 +92,20 @@ func (this *VodController) RefreshUploadVideo() {
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(vod.RefreshUploadVideo(header, request))
msg = domain.NewReturnResponse(vod.RefreshUploadVideo(header, request))
}
//创建图片上传凭证 CreateUploadImage
// @router /createUploadImage [post]
func (this *VodController) CreateUploadImage() {
var msg *protocol.ResponseMessage
var msg *domain.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *aliyun.CreateUploadImageRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
msg = domain.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
... ... @@ -114,13 +114,13 @@ func (this *VodController) CreateUploadImage() {
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(vod.CreateUploadImage(header, request))
msg = domain.NewReturnResponse(vod.CreateUploadImage(header, request))
}
//创建图片上传凭证 CreateUploadImages
// @router /createUploadImages [post]
func (this *VodController) CreateUploadImages() {
var msg *protocol.ResponseMessage
var msg *domain.ResponseMessage
defer func() {
this.Resp(msg)
}()
... ... @@ -132,7 +132,7 @@ func (this *VodController) CreateUploadImages() {
)
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
msg = domain.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
... ... @@ -141,7 +141,7 @@ func (this *VodController) CreateUploadImages() {
}
var err error
if len(request.Items) == 0 {
msg = protocol.BadRequestParam(2)
msg = domain.BadRequestParam(2)
}
header := controllers.GetRequestHeader(this.Ctx)
for i := range request.Items {
... ... @@ -153,20 +153,20 @@ func (this *VodController) CreateUploadImages() {
response.List = append(response.List, rsp)
}
}
msg = protocol.NewReturnResponse(response, err)
msg = domain.NewReturnResponse(response, err)
}
//获取视频播放地址 GetPlayInfo
// @router /getPlayInfo [post]
func (this *VodController) GetPlayInfo() {
var msg *protocol.ResponseMessage
var msg *domain.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *aliyun.GetPlayInfoRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
msg = domain.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
... ... @@ -174,20 +174,20 @@ func (this *VodController) GetPlayInfo() {
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(vod.GetPlayInfo(header, request))
msg = domain.NewReturnResponse(vod.GetPlayInfo(header, request))
}
//获取视频播放凭证 GetVideoPlayAuth
// @router /getVideoPlayAuth [post]
func (this *VodController) GetVideoPlayAuth() {
var msg *protocol.ResponseMessage
var msg *domain.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *aliyun.GetVideoPlayAuthRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
msg = domain.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
... ... @@ -195,5 +195,5 @@ func (this *VodController) GetVideoPlayAuth() {
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(vod.GetVideoPlayAuth(header, request))
msg = domain.NewReturnResponse(vod.GetVideoPlayAuth(header, request))
}
... ...
... ... @@ -2,8 +2,8 @@ package routers
import (
"github.com/astaxie/beego"
"openapi/controllers"
"openapi/controllers/v1"
"openapi/pkg/port/beego/controllers"
"openapi/pkg/port/beego/controllers/v1"
)
var nsV1 *beego.Namespace
... ... @@ -12,7 +12,6 @@ func init() {
nsV1 := beego.NewNamespace("v1",
beego.NSNamespace("vod", beego.NSBefore(controllers.AllowOption), beego.NSInclude(&v1.VodController{})),
beego.NSNamespace("push", beego.NSBefore(controllers.AllowOption), beego.NSInclude(&v1.PushController{})),
//beego.NSNamespace("vod", beego.NSBefore(controllers.FilterComm), beego.NSBefore(controllers.AllowOption), beego.NSInclude(&v1.VodController{})),
)
beego.SetStaticPath("/log", beego.AppConfig.String("aliyun_logs_access"))
beego.AddNamespace(nsV1)
... ...
package routers
import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/context/param"
)
func init() {
beego.GlobalControllerRouter["openapi/controllers/v1:PushController"] = append(beego.GlobalControllerRouter["openapi/controllers/v1:PushController"],
beego.ControllerComments{
Method: "PushInfo",
Router: `/pushInfo`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["openapi/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["openapi/controllers/v1:VodController"],
beego.ControllerComments{
Method: "CreateUploadImage",
Router: `/createUploadImage`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["openapi/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["openapi/controllers/v1:VodController"],
beego.ControllerComments{
Method: "CreateUploadImages",
Router: `/createUploadImages`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["openapi/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["openapi/controllers/v1:VodController"],
beego.ControllerComments{
Method: "CreateUploadVideo",
Router: `/createUploadVideo`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["openapi/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["openapi/controllers/v1:VodController"],
beego.ControllerComments{
Method: "CreateUploadVideos",
Router: `/createUploadVideos`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["openapi/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["openapi/controllers/v1:VodController"],
beego.ControllerComments{
Method: "GetPlayInfo",
Router: `/getPlayInfo`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["openapi/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["openapi/controllers/v1:VodController"],
beego.ControllerComments{
Method: "GetVideoPlayAuth",
Router: `/getVideoPlayAuth`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["openapi/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["openapi/controllers/v1:VodController"],
beego.ControllerComments{
Method: "RefreshUploadVideo",
Router: `/refreshUploadVideo`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
}