作者 yangfu

批量插入自查数据

... ... @@ -2,10 +2,8 @@ package v1
import (
"bytes"
"encoding/json"
"fmt"
"opp/controllers"
"opp/internal/aliyun"
"opp/protocol"
"opp/services/upload"
... ... @@ -96,24 +94,3 @@ func (this *UploadController) Video() {
}
msg = protocol.NewReturnResponse(rsp, err)
}
//创建视频上传凭证 CreateUploadVideo
// @router /createUploadVideo [post]
func (this *UploadController) CreateUploadVideo() {
var msg *protocol.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)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(upload.CreateUploadVideo(header, request))
}
... ...
package v1
import (
"encoding/json"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"opp/controllers"
"opp/internal/aliyun"
"opp/protocol"
"opp/services/upload"
)
type VodController struct {
controllers.BaseController
}
//创建视频上传凭证 CreateUploadVideo
// @router /createUploadVideo [post]
func (this *VodController) CreateUploadVideo() {
var msg *protocol.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)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(upload.CreateUploadVideo(header, request))
}
//创建图片上传凭证 CreateUploadImage
// @router /createUploadImage [post]
func (this *VodController) CreateUploadImage() {
var msg *protocol.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)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(upload.CreateUploadImage(header, request))
}
... ...
package aliyun
type CreateUploadImageRequest struct {
}
type CreateUploadImageResponse struct {
RequestId string `json:"requestId" xml:"RequestId"`
ImageId string `json:"imageId" xml:"ImageId"`
ImageURL string `json:"imageURL" xml:"ImageURL"`
UploadAddress string `json:"uploadAddress" xml:"UploadAddress"`
UploadAuth string `json:"uploadAuth" xml:"UploadAuth"`
FileURL string `json:"fileURL" xml:"FileURL"`
}
... ...
... ... @@ -8,6 +8,7 @@ import (
"github.com/astaxie/beego"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/common"
comm_time "gitlab.fjmaimaimai.com/mmm-go/gocomm/time"
"opp/internal/utils"
"path"
"time"
)
... ... @@ -36,7 +37,7 @@ func InitVodClient(accessKeyId string, accessKeySecret string) (client *vod.Clie
}
//获取视频上传地址和凭证,并创建视频信息
func CreateUploadVideo(client *vod.Client) (response *CreateUploadVideoResponse, err error) {
func CreateUploadVideo(client *vod.Client, r *CreateUploadVideoRequest) (response *CreateUploadVideoResponse, err error) {
request := vod.CreateCreateUploadVideoRequest()
request.Title = getFileName(FileVideo, "video_file.mp4")
request.FileName = getFileName(FileVideo, "video_file.mp4")
... ... @@ -56,6 +57,19 @@ func CreateUploadVideo(client *vod.Client) (response *CreateUploadVideoResponse,
return
}
//获取图片上传地址和凭证,并创建视频信息
func CreateUploadImage(client *vod.Client, r *CreateUploadImageRequest) (response *CreateUploadImageResponse, err error) {
request := vod.CreateCreateUploadImageRequest()
request.ImageType = "default"
request.AcceptFormat = "JSON"
rsp, err := client.CreateUploadImage(request)
if err != nil {
return
}
err = utils.DeepCopy(&response, &rsp)
return
}
//获取播放信息
func GetPlayInfo(client *vod.Client, videoId string) (response *vod.GetPlayInfoResponse, err error) {
request := vod.CreateGetPlayInfoRequest()
... ...
... ... @@ -58,7 +58,7 @@ func (s SelfChecks) Static() SelfCheckResults {
for i := range s {
check := (s)[i]
for k := range results {
if strings.EqualFold(results[k].Item, check.Answer) {
if strings.EqualFold(results[k].Item, strings.TrimSpace(check.Answer)) {
results[k].Total = results[k].Total + 1
break
}
... ...
... ... @@ -153,6 +153,14 @@ func init() {
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "CheckQuestions",
Router: `/checkQuestions`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "CommentDetailsMulti",
Router: `/commentDetailsMulti`,
AllowHTTPMethods: []string{"post"},
... ... @@ -513,14 +521,6 @@ func init() {
beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"],
beego.ControllerComments{
Method: "CreateUploadVideo",
Router: `/createUploadVideo`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"],
beego.ControllerComments{
Method: "Image",
Router: `/image`,
AllowHTTPMethods: []string{"post"},
... ... @@ -615,4 +615,20 @@ func init() {
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:VodController"],
beego.ControllerComments{
Method: "CreateUploadImage",
Router: `/createUploadImage`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:VodController"],
beego.ControllerComments{
Method: "CreateUploadVideo",
Router: `/createUploadVideo`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
}
... ...
... ... @@ -35,7 +35,9 @@ func init() {
beego.AddNamespace(nsV2)
nsH5 := beego.NewNamespace("h5", beego.NSBefore(controllers.LogRequestData), beego.NSBefore(controllers.AllowOption), beego.NSInclude(&controllers.H5Controller{}))
nsVod := beego.NewNamespace("vod", beego.NSBefore(controllers.LogRequestData), beego.NSBefore(controllers.AllowOption), beego.NSInclude(&v1.VodController{}))
beego.AddNamespace(nsH5)
beego.AddNamespace(nsVod)
//post 下载文件
beego.Router("/file/opp/*", &v1.FileController{}, "post:DownLoad")
//get 直接获取文件
... ...
... ... @@ -144,6 +144,22 @@ func CreateUploadVideo(header *protocol.RequestHeader, request *aliyun.CreateUpl
err = e
return
}
rsp, err = aliyun.CreateUploadVideo(client)
rsp, err = aliyun.CreateUploadVideo(client, request)
return
}
//创建图片上传凭证
func CreateUploadImage(header *protocol.RequestHeader, request *aliyun.CreateUploadImageRequest) (rsp *aliyun.CreateUploadImageResponse, err error) {
var ()
client, e := aliyun.DefaultVodClient()
if e != nil {
log.Error(e)
err = e
return
}
rsp, err = aliyun.CreateUploadImage(client, request)
if err != nil {
log.Error(err)
}
return
}
... ...