|
@@ -0,0 +1,159 @@
|
|
|
+package cygx
|
|
|
+
|
|
|
+import (
|
|
|
+ //"github.com/beego/beego/v2/client/orm"
|
|
|
+ //"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
+ //"strconv"
|
|
|
+ //"strings"
|
|
|
+ "github.com/beego/beego/v2/client/orm"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+type CygxAskserieVideo struct {
|
|
|
+ AskserieVideoId int `orm:"column(askserie_video_id);pk"description:"视频id"`
|
|
|
+ VideoName string `description:"视频标题"`
|
|
|
+ VideoUrl string `description:"视频地址"`
|
|
|
+ VideoDuration string `description:"视频时长"`
|
|
|
+ ChartPermissionId int `description:"行业ID"`
|
|
|
+ ChartPermissionName string `description:"行业名称"`
|
|
|
+ PublishStatus int `description:"发布状态 1发布 0没有"`
|
|
|
+ VideoCounts int `description:"播放量"`
|
|
|
+ BackgroundImg string `description:"封面图片"`
|
|
|
+ ShareImg string `description:"分享图片"`
|
|
|
+ AdminId int `description:"管理员、销售ID"`
|
|
|
+ ModifyDate time.Time `description:"更新时间"`
|
|
|
+ PublishDate time.Time `description:"发布时间"`
|
|
|
+ CreateTime time.Time `description:"创建时间"`
|
|
|
+}
|
|
|
+
|
|
|
+type AddAskserieVideoReq struct {
|
|
|
+ AskserieVideoId int `description:"askserie_video_id"`
|
|
|
+ VideoName string `description:"视频标题"`
|
|
|
+ VideoUrl string `description:"视频地址"`
|
|
|
+ VideoDuration string `description:"视频时长"`
|
|
|
+ ChartPermissionId int `description:"行业ID"`
|
|
|
+ ChartPermissionName string `description:"行业名称"`
|
|
|
+ IndustrialManagementIds string `description:"产业id 多个用 , 隔开"`
|
|
|
+ BackgroundImg string `description:"封面图片"`
|
|
|
+ ShareImg string `description:"分享图片"`
|
|
|
+}
|
|
|
+
|
|
|
+type CygxAskserieVideoResp struct {
|
|
|
+ AskserieVideoId int `orm:"column(askserie_video_id);pk"description:"视频id"`
|
|
|
+ VideoName string `description:"视频标题"`
|
|
|
+ VideoUrl string `description:"视频地址"`
|
|
|
+ VideoDuration string `description:"视频时长"`
|
|
|
+ ChartPermissionId int `description:"行业ID"`
|
|
|
+ ChartPermissionName string `description:"行业名称"`
|
|
|
+ PublishStatus int `description:"发布状态 1发布 0没有"`
|
|
|
+ VideoCounts int `description:"播放量"`
|
|
|
+ BackgroundImg string `description:"封面图片"`
|
|
|
+ ShareImg string `description:"分享图片"`
|
|
|
+ AdminId int `description:"管理员、销售ID"`
|
|
|
+ ModifyDate time.Time `description:"更新时间"`
|
|
|
+ PublishDate time.Time `description:"发布时间"`
|
|
|
+ CreateTime time.Time `description:"创建时间"`
|
|
|
+}
|
|
|
+
|
|
|
+// 通过ID获取详情
|
|
|
+func GetCygxAskserieVideoDetail(askserieVideoId int) (item *CygxAskserieVideoResp, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("hz_cygx")
|
|
|
+ sql := `SELECT * FROM cygx_askserie_video WHERE askserie_video_id=? `
|
|
|
+ err = o.Raw(sql, askserieVideoId).QueryRow(&item)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 添加
|
|
|
+func AddCygxAskserieVideo(item *CygxAskserieVideo, industrialManagementIds string) (err error) {
|
|
|
+ o := orm.NewOrmUsingDB("hz_cygx")
|
|
|
+ to, err := o.Begin()
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ _ = to.Rollback()
|
|
|
+ } else {
|
|
|
+ _ = to.Commit()
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ newId, err := to.Insert(item)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //添加与产业的关联
|
|
|
+ //new(cygx.CygxIndustrialAskserieVideoGroupManagement),
|
|
|
+ industrialManagementIdList := strings.Split(industrialManagementIds, ",")
|
|
|
+ for _, v := range industrialManagementIdList {
|
|
|
+ itemIndustrialManagementGroup := new(CygxIndustrialAskserieVideoGroupManagement)
|
|
|
+ newIndustrialId, _ := strconv.Atoi(v)
|
|
|
+ itemIndustrialManagementGroup.CreateTime = time.Now()
|
|
|
+ itemIndustrialManagementGroup.AskserieVideoId = int(newId)
|
|
|
+ itemIndustrialManagementGroup.IndustrialManagementId = newIndustrialId
|
|
|
+ _, err = to.Insert(itemIndustrialManagementGroup)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 修改
|
|
|
+func UpdateCygxAskserieVideo(item *CygxAskserieVideo, industrialManagementIds string) (err error) {
|
|
|
+ o := orm.NewOrmUsingDB("hz_cygx")
|
|
|
+ to, err := o.Begin()
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ _ = to.Rollback()
|
|
|
+ } else {
|
|
|
+ _ = to.Commit()
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ updateParams := make(map[string]interface{})
|
|
|
+ updateParams["VideoName"] = item.VideoName
|
|
|
+ updateParams["VideoUrl"] = item.VideoUrl
|
|
|
+ updateParams["VideoDuration"] = item.VideoDuration
|
|
|
+ updateParams["ChartPermissionId"] = item.ChartPermissionId
|
|
|
+ updateParams["ChartPermissionName"] = item.ChartPermissionName
|
|
|
+ updateParams["BackgroundImg"] = item.BackgroundImg
|
|
|
+ updateParams["ShareImg"] = item.ShareImg
|
|
|
+ updateParams["ModifyDate"] = time.Now()
|
|
|
+ ptrStructOrTableName := "cygx_askserie_video"
|
|
|
+ whereParam := map[string]interface{}{"askserie_video_id": item.AskserieVideoId}
|
|
|
+ qs := to.QueryTable(ptrStructOrTableName)
|
|
|
+ for expr, exprV := range whereParam {
|
|
|
+ qs = qs.Filter(expr, exprV)
|
|
|
+ }
|
|
|
+ _, err = qs.Update(updateParams)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除关联产业 (避免截断表时产生的脏数据,故不用update而是先删除再增加)
|
|
|
+ sql := ` DELETE FROM cygx_industrial_askserie_video_group_management WHERE askserie_video_id = ?`
|
|
|
+ _, err = to.Raw(sql, item.AskserieVideoId).Exec()
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ industrialManagementIdList := strings.Split(industrialManagementIds, ",")
|
|
|
+ for _, v := range industrialManagementIdList {
|
|
|
+ itemIndustrialManagementGroup := new(CygxIndustrialAskserieVideoGroupManagement)
|
|
|
+ newIndustrialId, _ := strconv.Atoi(v)
|
|
|
+ itemIndustrialManagementGroup.CreateTime = time.Now()
|
|
|
+ itemIndustrialManagementGroup.AskserieVideoId = item.AskserieVideoId
|
|
|
+ itemIndustrialManagementGroup.IndustrialManagementId = newIndustrialId
|
|
|
+ _, err = to.Insert(itemIndustrialManagementGroup)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+}
|