xingzai il y a 1 an
Parent
commit
0926e19b24

+ 11 - 0
models/cygx/activity_video.go

@@ -169,6 +169,17 @@ func GetActivityVideoList(condition string, pars []interface{}) (items []*CygxAc
 	return
 }
 
+// 列表
+func GetCygxActivityVideoList(condition string, pars []interface{}) (items []*CygxActivityVideo, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := ` SELECT  * FROM  cygx_activity_video  WHERE  1=1  `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
 // MicroRoadShowDefaultImgList 微路演行业默认背景图列表
 type MicroRoadShowDefaultImgList struct {
 	Audio []*MicroRoadShowDefaultImg `description:"音频"`

+ 8 - 0
models/cygx/askserie_video.go

@@ -204,3 +204,11 @@ func EditCygxAskserieVideoStatus(status, askserieVideoId int) (err error) {
 	_, err = o.Raw(sql, status, askserieVideoId).Exec()
 	return
 }
+
+// 修改是否展示
+func EditCygxAskserieVideoShareImg(shareImg string, askserieVideoId int) (err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `UPDATE cygx_askserie_video SET share_img=?   WHERE askserie_video_id=? `
+	_, err = o.Raw(sql, shareImg, askserieVideoId).Exec()
+	return
+}

+ 26 - 0
models/cygx/micro_roadshow.go

@@ -68,6 +68,17 @@ func GetMicroRoadshowVideoList(condition, sortStr string, pars []interface{}, st
 	return
 }
 
+func GetCygxMicroRoadshowVideoList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxMicroRoadshowVideo, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := ` SELECT * FROM cygx_micro_roadshow_video as v  WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,? `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
 func GetMicroRoadshowVideoListCount(condition string, pars []interface{}) (count int, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
 	sql := `SELECT COUNT(1) AS count FROM cygx_micro_roadshow_video WHERE 1=1 `
@@ -131,6 +142,21 @@ func EditVideo(item *CygxMicroRoadshowVideo) (err error) {
 	return
 }
 
+// 修改
+func UpdateCygxMicroRoadshowVideo(item *CygxMicroRoadshowVideo) (err error) {
+	to := orm.NewOrmUsingDB("hz_cygx")
+	updateParams := make(map[string]interface{})
+	updateParams["ShareImgUrl"] = item.ShareImgUrl
+	ptrStructOrTableName := "cygx_micro_roadshow_video"
+	whereParam := map[string]interface{}{"video_id": item.VideoId}
+	qs := to.QueryTable(ptrStructOrTableName)
+	for expr, exprV := range whereParam {
+		qs = qs.Filter(expr, exprV)
+	}
+	_, err = qs.Update(updateParams)
+	return
+}
+
 func PublishVideoCancel(videoId, publishOrCancle int) (err error) {
 
 	if publishOrCancle == 0 {

+ 77 - 0
services/cygx/askserie_video.go

@@ -134,3 +134,80 @@ func init12() {
 		}
 	}
 }
+
+func initpy() {
+
+	//python3 main.py
+
+	var condition string
+	var pars []interface{}
+	//listVoice, err := cygx.GetActivityVoiceList(condition, pars)
+	//if err != nil && err.Error() != utils.ErrNoRow() {
+	//	fmt.Println(err)
+	//	return
+	//}
+	//
+	//for _, v := range listVoice {
+	//	shareImg, _ := MakeCygxMp3HtmlImg(v.VoicePlaySeconds) //生成分享图片
+	//	v.ShareImg = shareImg
+	//	err = cygx.UpdateCygxActivityVoice(v)
+	//	if err != nil {
+	//		err = errors.New("UpdateCygxActivityVoice" + err.Error())
+	//		return
+	//	}
+	//	fmt.Println(err)
+	//}
+
+	//listVideo, err := cygx.GetCygxActivityVideoList(condition, pars)
+	//if err != nil && err.Error() != utils.ErrNoRow() {
+	//	fmt.Println(err)
+	//	return
+	//}
+	//
+	//for _, v := range listVideo {
+	//	shareImg, _ := MakeCygxMp4HtmlImg(v.VideoDuration) //生成分享图片
+	//	v.ShareImg = shareImg
+	//	err = cygx.UpdateCygxActivityVideo(v)
+	//	if err != nil {
+	//		err = errors.New("UpdateCygxActivityVideo" + err.Error())
+	//		return
+	//	}
+	//	fmt.Println(err)
+	//}
+
+	//listVideo, err := cygx.GetCygxMicroRoadshowVideoList(condition, pars, 0, 1000)
+	//if err != nil && err.Error() != utils.ErrNoRow() {
+	//	fmt.Println(err)
+	//	return
+	//}
+	//
+	//for _, v := range listVideo {
+	//	shareImg, _ := MakeCygxMp4HtmlImg(v.VideoDuration) //生成分享图片
+	//	v.ShareImgUrl = shareImg
+	//	err = cygx.UpdateCygxMicroRoadshowVideo(v)
+	//	if err != nil {
+	//		err = errors.New("UpdateCygxMicroRoadshowVideo" + err.Error())
+	//		return
+	//	}
+	//	fmt.Println(err)
+	//}
+
+	listVoice, err := cygx.GetCygxAskserieVideoList(condition, pars, 0, 1000)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		fmt.Println(err)
+		return
+	}
+
+	for _, v := range listVoice {
+		shareImg, _ := MakeCygxMp3HtmlImg(v.VideoDuration) //生成分享图片
+		v.ShareImg = shareImg
+		err = cygx.EditCygxAskserieVideoShareImg(shareImg, v.AskserieVideoId)
+		if err != nil {
+			err = errors.New("EditCygxAskserieVideoShareImg" + err.Error())
+			return
+		}
+		fmt.Println(err)
+	}
+
+	return
+}