|
@@ -1289,6 +1289,73 @@ func UpdateAskserieVideoResourceData(sourceId int) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// 更新产业资源包 写入首页最新 cygx_resource_data 表
|
|
|
+func UpdateIndustrialsourceHzResourceData(sourceId int, sourceType string) {
|
|
|
+ var err error
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ go alarm_msg.SendAlarmMsg(fmt.Sprint("UpdateIndustrialsourceHzResourceData 失败: ", sourceId, err.Error()), 2)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ var source string
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition = ` AND publish_status = 1 AND askserie_video_id = ? `
|
|
|
+ pars = append(pars, sourceId)
|
|
|
+ total, e := cygx.GetCygxAskserieVideoCount(condition, pars)
|
|
|
+
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxAskserieVideoCount, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //如果取消发布了就做删除处理
|
|
|
+ if total == 0 {
|
|
|
+ e = cygx.DeleteResourceData(sourceId, source)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("DeleteResourceData, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //判断是否存在,如果不存在就新增,存在就更新
|
|
|
+ totalData, e := cygx.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxResourceDataBySourceAndIdCount, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ detail, e := cygx.GetCygxAskserieVideoDetail(sourceId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxAskserieVideoDetail, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ publishDate := time.Now().Format(utils.FormatDateTime)
|
|
|
+ item := new(cygx.CygxResourceData)
|
|
|
+ item.SourceId = sourceId
|
|
|
+ item.Source = source
|
|
|
+ item.PublishDate = publishDate
|
|
|
+ item.ChartPermissionId = detail.ChartPermissionId
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.SearchTitle = detail.VideoName
|
|
|
+ item.SearchContent = detail.IndustryName
|
|
|
+ item.SearchOrderTime = detail.PublishDate
|
|
|
+ if totalData == 0 {
|
|
|
+ _, e := cygx.AddCygxResourceData(item)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("AddCygxResourceData, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ e = cygx.UpdateResourceDataByItem(item)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
func init300() {
|
|
|
//var condition string
|
|
|
//var pars []interface{}
|