浏览代码

培训视频详情接口

hsun 1 年之前
父节点
当前提交
bc9b480427
共有 2 个文件被更改,包括 72 次插入3 次删除
  1. 63 3
      controllers/eta_training_video/eta_training_video.go
  2. 9 0
      routers/commentsRouter.go

+ 63 - 3
controllers/eta_training_video/eta_training_video.go

@@ -376,7 +376,7 @@ func (this *EtaTrainingVideoController) Edit() {
 	ob := new(eta_training_video.EtaTrainingVideo)
 	item, e := ob.GetItemById(req.VideoId)
 	if e != nil {
-		if e.Error() != utils.ErrNoRow() {
+		if e.Error() == utils.ErrNoRow() {
 			br.Msg = "视频不存在, 请刷新页面"
 			return
 		}
@@ -535,7 +535,7 @@ func (this *EtaTrainingVideoController) Publish() {
 	ob := new(eta_training_video.EtaTrainingVideo)
 	item, e := ob.GetItemById(req.VideoId)
 	if e != nil {
-		if e.Error() != utils.ErrNoRow() {
+		if e.Error() == utils.ErrNoRow() {
 			br.Msg = "视频不存在, 请刷新页面"
 			return
 		}
@@ -614,7 +614,7 @@ func (this *EtaTrainingVideoController) Remove() {
 	ob := new(eta_training_video.EtaTrainingVideo)
 	item, e := ob.GetItemById(req.VideoId)
 	if e != nil {
-		if e.Error() != utils.ErrNoRow() {
+		if e.Error() == utils.ErrNoRow() {
 			br.Ret = 200
 			br.Success = true
 			br.Msg = "操作成功"
@@ -662,3 +662,63 @@ func (this *EtaTrainingVideoController) Remove() {
 	br.Success = true
 	br.Msg = "操作成功"
 }
+
+// Detail
+// @Title 视频详情
+// @Description 视频详情
+// @Param   VideoId		query	int		false	"视频ID"
+// @Success 200 Ret=200 操作成功
+// @router /detail [get]
+func (this *EtaTrainingVideoController) Detail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	videoId, _ := this.GetInt("VideoId", 0)
+	if videoId <= 0 {
+		br.Msg = "参数有误"
+		br.ErrMsg = fmt.Sprint("参数有误, 视频ID: ", videoId)
+		return
+	}
+
+	ob := new(eta_training_video.EtaTrainingVideo)
+	item, e := ob.GetItemById(videoId)
+	if e != nil {
+		if e.Error() == utils.ErrNoRow() {
+			br.Msg = "视频不存在, 请刷新页面"
+			return
+		}
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取ETA培训视频失败, Err: " + e.Error()
+		return
+	}
+
+	list := make([]*eta_training_video.EtaTrainingVideo, 0)
+	list = append(list, item)
+	formats, e := etaTrainingVideoService.FormatVideosToVideoItems(list)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "格式化视频信息失败, Err: " + e.Error()
+		return
+	}
+	result := new(eta_training_video.EtaTrainingVideoItem)
+	if len(formats) > 0 {
+		result = formats[0]
+	}
+
+	br.Data = result
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}

+ 9 - 0
routers/commentsRouter.go

@@ -6685,6 +6685,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/eta_training_video:EtaTrainingVideoController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/eta_training_video:EtaTrainingVideoController"],
+        beego.ControllerComments{
+            Method: "Detail",
+            Router: `/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/eta_training_video:EtaTrainingVideoController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/eta_training_video:EtaTrainingVideoController"],
         beego.ControllerComments{
             Method: "Edit",