Browse Source

no message

xingzai 10 months ago
parent
commit
c3bbaf25a6
4 changed files with 128 additions and 78 deletions
  1. 2 0
      models/cygx_yanxuan_special_user.go
  2. 71 20
      models/resource_data.go
  3. 40 45
      services/es_comprehensive.go
  4. 15 13
      utils/constants.go

+ 2 - 0
models/cygx_yanxuan_special_user.go

@@ -47,6 +47,8 @@ type CygxYanxuanSpecialAuthorItem struct {
 	IsFollow             int                                 // 是否已关注 1已关注 0 未关注
 	HasChangeHeadImg     int                                 // 是否更换过默认头像 1是,0否
 	MomentsImg           string                              `description:"分享到朋友圈的封面图片"`
+	FansNum              int                                 // 粉丝数量
+	LabelKeywordImgLink  string                              `description:"标签关键词ico"`
 	YanxuanSpecialCenter *CygxYanxuanSpecialCenterAuthorResp // 研选专栏文章内容
 }
 

+ 71 - 20
models/resource_data.go

@@ -23,26 +23,27 @@ type CygxResourceData struct {
 }
 
 type CygxResourceDataResp struct {
-	Id                 int                                     `orm:"column(id);pk"`
-	BodyHighlight      []string                                `description:"搜索高亮展示结果"`
-	IsSummary          int                                     `description:"是否是纪要"`
-	SourceId           int                                     `description:"资源ID"`
-	Source             string                                  `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
-	PublishDate        string                                  `description:"发布时间"`
-	Article            *HomeArticle                            `description:"文章"`
-	Roadshow           *MicroRoadShowPageList                  `description:"微路演"`
-	Activity           *ActivityDetail                         `description:"活动"`
-	Activityvideo      *MicroRoadShowPageList                  `description:"活动视频"`
-	Activityvoice      *MicroRoadShowPageList                  `description:"活动音频"`
-	Activityspecial    *CygxActivitySpecialDetail              `description:"专项调研活动"`
-	Researchsummary    *CygxReportSelectionRep                 `description:"本周研究汇总"`
-	Minutessummary     *CygxReportSelectionRep                 `description:"上周纪要汇总"`
-	Meetingreviewchapt *CygxMorningMeetingGatherDetailListResp `description:"晨会精华"`
-	ProductInterior    *CygxProductInteriorResp                `description:"产品内测"`
-	IndustrialResource *IndustrialManagementHotResp            `description:"产业资源包"`
-	ReportSelection    *CygxReportSelectionRep                 `description:"重点公司(原报告精选)"`
-	YanxuanSpecial     *CygxYanxuanSpecialCenterResp           `description:"研选专栏"`
-	AskserieVideo      *MicroRoadShowPageList                  `description:"活动音频"`
+	Id                   int                                     `orm:"column(id);pk"`
+	BodyHighlight        []string                                `description:"搜索高亮展示结果"`
+	IsSummary            int                                     `description:"是否是纪要"`
+	SourceId             int                                     `description:"资源ID"`
+	Source               string                                  `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
+	PublishDate          string                                  `description:"发布时间"`
+	Article              *HomeArticle                            `description:"文章"`
+	Roadshow             *MicroRoadShowPageList                  `description:"微路演"`
+	Activity             *ActivityDetail                         `description:"活动"`
+	Activityvideo        *MicroRoadShowPageList                  `description:"活动视频"`
+	Activityvoice        *MicroRoadShowPageList                  `description:"活动音频"`
+	Activityspecial      *CygxActivitySpecialDetail              `description:"专项调研活动"`
+	Researchsummary      *CygxReportSelectionRep                 `description:"本周研究汇总"`
+	Minutessummary       *CygxReportSelectionRep                 `description:"上周纪要汇总"`
+	Meetingreviewchapt   *CygxMorningMeetingGatherDetailListResp `description:"晨会精华"`
+	ProductInterior      *CygxProductInteriorResp                `description:"产品内测"`
+	IndustrialResource   *IndustrialManagementHotResp            `description:"产业资源包"`
+	ReportSelection      *CygxReportSelectionRep                 `description:"重点公司(原报告精选)"`
+	YanxuanSpecial       *CygxYanxuanSpecialCenterResp           `description:"研选专栏"`
+	AskserieVideo        *MicroRoadShowPageList                  `description:"活动音频"`
+	YanxuanSpecialAuthor *CygxYanxuanSpecialAuthorItem           `description:"活动音频"`
 }
 
 // Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
@@ -71,6 +72,19 @@ func GetResourceDataCount(condition string, pars []interface{}) (count int, err
 	return
 }
 
+// 获取首页最新表,与研选专栏作者表的数量
+func GetResourceDataAndYanxuanSpecialAuthorCount(condition string, pars []interface{}, conditionContentYxAuthor string, parsContentYxAuthor []interface{}) (count int, err error) {
+	sqlCount := `SELECT
+	COUNT( 1 ) total   FROM
+	( SELECT id FROM cygx_resource_data WHERE 1 = 1  ` + condition + `
+	  UNION ALL
+	  SELECT id FROM cygx_yanxuan_special_author WHERE 1 = 1 ` + conditionContentYxAuthor + `
+	 ) z`
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars, parsContentYxAuthor).QueryRow(&count)
+	return
+}
+
 // 添加
 func AddCygxResourceData(item *CygxResourceData) (lastId int64, err error) {
 	o := orm.NewOrm()
@@ -159,3 +173,40 @@ func GetResourceDataListCondition(condition string, pars []interface{}, startSiz
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
 	return
 }
+
+// 获取首页最新表,与研选专栏作者表的列表
+func GetResourceDataAndYanxuanSpecialAuthorListCondition(condition string, pars []interface{}, conditionContentYxAuthor string, parsContentYxAuthor []interface{}, startSize, pageSize int) (items []*CygxResourceData, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+		title,
+		publish_date,
+		abstract,
+		annotation,
+		source_id,
+		source,
+		create_time,
+		search_tag,
+		search_order_time 
+	FROM
+		cygx_resource_data 
+	WHERE
+		1 = 1  ` + condition + `
+	 UNION ALL
+SELECT
+	'' AS title,
+	'' AS publish_date,
+	'' AS abstract,
+	'' AS annotation,
+	id AS source_id,
+	'yanxuanspecialauthor',
+	'' AS create_time,
+	'' AS search_tag,
+	modify_time AS search_order_time 
+FROM
+	cygx_yanxuan_special_author 
+WHERE
+	1 = 1  ` + conditionContentYxAuthor
+	sql += `  ORDER BY search_order_time DESC   LIMIT ?,? `
+	_, err = o.Raw(sql, pars, parsContentYxAuthor, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 40 - 45
services/es_comprehensive.go

@@ -448,54 +448,20 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 		mapItems[fmt.Sprint(v.Source, v.SourceId)] = item
 	}
 
-	var articleIds []int
-	var newchartIds []int
-	var roadshowIds []string
-	var activityIds []int
-	var activityvideoIds []string
-	var activityvoiceIds []string
-	var activityspecialIds []int
-	var researchsummaryIds []int
-	var minutessummaryIds []int
-	var meetingreviewchaptIds []int
-	var productinteriorIds []int
-	var industrialResourceIdsHz []int // 弘则产业资源包
-	var industrialResourceIdsYx []int // 研选产业资源包
+	var articleIds []int              //报告
+	var activityIds []int             //活动
 	var yanxuanSpecialIds []int       // 研选专栏
-	var askserieVideoIds []string     //问答系列视频
+	var yanxuanspecialauthorIds []int //研选作者ID
 	//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial 、 本周研究汇总: researchsummary 、 上周纪要汇总 :minutessummary 、晨会精华 :meetingreviewchapt "`
 	for _, v := range list {
 		if v.Source == "article" {
 			articleIds = append(articleIds, v.SourceId)
-		} else if v.Source == "newchart" {
-			newchartIds = append(newchartIds, v.SourceId)
-		} else if v.Source == "roadshow" {
-			roadshowIds = append(roadshowIds, strconv.Itoa(v.SourceId))
 		} else if v.Source == "activity" {
 			activityIds = append(activityIds, v.SourceId)
-		} else if v.Source == "activityvideo" {
-			activityvideoIds = append(activityvideoIds, strconv.Itoa(v.SourceId))
-		} else if v.Source == "activityvoice" {
-			activityvoiceIds = append(activityvoiceIds, strconv.Itoa(v.SourceId))
-		} else if v.Source == "activityspecial" {
-			activityspecialIds = append(activityspecialIds, v.SourceId)
-		} else if v.Source == "researchsummary" {
-			researchsummaryIds = append(researchsummaryIds, v.SourceId)
-		} else if v.Source == "minutessummary" {
-			minutessummaryIds = append(minutessummaryIds, v.SourceId)
-		} else if v.Source == "meetingreviewchapt" {
-			meetingreviewchaptIds = append(meetingreviewchaptIds, v.SourceId)
-		} else if v.Source == "productinterior" {
-			productinteriorIds = append(productinteriorIds, v.SourceId)
-		} else if v.Source == "industrialsourceHz" {
-			industrialResourceIdsHz = append(industrialResourceIdsHz, v.SourceId)
-		} else if v.Source == "industrialsourceYx" {
-			industrialResourceIdsYx = append(industrialResourceIdsYx, v.SourceId)
 		} else if v.Source == utils.CYGX_OBJ_YANXUANSPECIAL {
 			yanxuanSpecialIds = append(yanxuanSpecialIds, v.SourceId)
-			yanXuanbodyHighlight[v.SourceId] = v.Body
-		} else if v.Source == utils.CYGX_OBJ_ASKSERIEVIDEO {
-			askserieVideoIds = append(askserieVideoIds, strconv.Itoa(v.SourceId))
+		} else if v.Source == utils.CYGX_OBJ_YANXUANSPECIAL_AUTHOR {
+			yanxuanspecialauthorIds = append(yanxuanspecialauthorIds, v.SourceId)
 		}
 	}
 	//处理文章
@@ -628,6 +594,25 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 		}
 	}
 
+	//处理研选专栏作者
+	lenyanxuanspecialauthorIds := len(yanxuanspecialauthorIds)
+	if lenyanxuanspecialauthorIds > 0 {
+		pars = make([]interface{}, 0)
+		condition = ` AND a.id IN (` + utils.GetOrmInReplace(lenyanxuanspecialauthorIds) + `) `
+		condition += ` ORDER BY  latest_publish_time DESC `
+		pars = append(pars, yanxuanspecialauthorIds)
+		listAuthor, e := models.GetYanxuanSpecialAuthorList(condition, pars, 0, lenyanxuanspecialauthorIds)
+		if e != nil {
+			err = errors.New("GetYanxuanSpecialAuthorList, Err: " + e.Error())
+			return
+		}
+		for _, v := range listAuthor {
+			v.LatestPublishDate = v.LatestPublishTime.Format(utils.FormatDate)
+			v.LabelKeywordImgLink = utils.LABEL_ICO_9
+			mapItems[fmt.Sprint(utils.CYGX_OBJ_YANXUANSPECIAL_AUTHOR, v.Id)].YanxuanSpecialAuthor = v
+		}
+	}
+
 	for _, vList := range list {
 		for _, v := range mapItems {
 			//如果这些类型都为空,那么就不合并
@@ -678,9 +663,17 @@ func SqlComprehensiveSearch(user *models.WxUserItem, keyWord string, startSize,
 	var parsTitle []interface{}
 	conditionTitle = " AND search_title LIKE ? " + condition
 	parsTitle = append(parsTitle, keyWord)
-	totalTitle, e := models.GetResourceDataCount(conditionTitle, parsTitle)
+
+	var conditionContentYxAuthor string // 研选专栏作者搜索条件
+	var parsContentYxAuthor []interface{}
+
+	conditionContentYxAuthor = " AND  (special_name LIKE  ?  OR  nick_name LIKE  ? )  "
+	parsContentYxAuthor = append(parsContentYxAuthor, keyWord, keyWord)
+	totalTitle, e := models.GetResourceDataAndYanxuanSpecialAuthorCount(conditionTitle, parsTitle, conditionContentYxAuthor, parsContentYxAuthor)
+
+	//totalTitle, e := models.GetResourceDataCount(conditionTitle, parsTitle)
 	if e != nil {
-		err = errors.New("GetResourceDataCount, Err: " + e.Error())
+		err = errors.New("GetResourceDataAndYanxuanSpecialAuthorCount, Err: " + e.Error())
 		return
 	}
 
@@ -703,9 +696,10 @@ func SqlComprehensiveSearch(user *models.WxUserItem, keyWord string, startSize,
 	if totalTitle >= searchTotal {
 		fmt.Println("1")
 		//全部都是标题搜索
-		list, e = models.GetResourceDataListCondition(conditionTitle, parsTitle, startSize, pageSize)
+		//list, e = models.GetResourceDataListCondition(conditionTitle, parsTitle, startSize, pageSize)
+		list, e = models.GetResourceDataAndYanxuanSpecialAuthorListCondition(conditionTitle, parsTitle, conditionContentYxAuthor, parsContentYxAuthor, startSize, pageSize)
 		if e != nil && e.Error() != utils.ErrNoRow() {
-			err = errors.New("GetResourceDataListCondition, Err: " + e.Error())
+			err = errors.New("GetResourceDataAndYanxuanSpecialAuthorListCondition, Err: " + e.Error())
 			return
 		}
 	} else if totalTitle <= searchTotal-pageSize {
@@ -722,9 +716,10 @@ func SqlComprehensiveSearch(user *models.WxUserItem, keyWord string, startSize,
 		fmt.Println("3")
 		//一半标题搜索,一半内容搜索
 
-		list, e = models.GetResourceDataListCondition(conditionTitle, parsTitle, startSize, pageSize)
+		//list, e = models.GetResourceDataListCondition(conditionTitle, parsTitle, startSize, pageSize)
+		list, e = models.GetResourceDataAndYanxuanSpecialAuthorListCondition(conditionTitle, parsTitle, conditionContentYxAuthor, parsContentYxAuthor, startSize, pageSize)
 		if e != nil && e.Error() != utils.ErrNoRow() {
-			err = errors.New("GetResourceDataListCondition, Err: " + e.Error())
+			err = errors.New("GetResourceDataAndYanxuanSpecialAuthorListCondition, Err: " + e.Error())
 			return
 		}
 		listContent, e := models.GetResourceDataListCondition(conditionContent, parsContent, 0, pageSize-totalContent%pageSize)

+ 15 - 13
utils/constants.go

@@ -260,19 +260,20 @@ const (
 )
 
 const (
-	CYGX_OBJ_ARTICLE            string = "article"            // 对象类型:文章
-	CYGX_OBJ_ACTIVITY           string = "activity"           // 对象类型:活动
-	CYGX_OBJ_ACTIVITYVIDEO      string = "activityvideo"      // 对象类型:活动视频
-	CYGX_OBJ_ACTIVITYVOICE      string = "activityvoice"      // 对象类型:活动音频
-	CYGX_OBJ_ACTIVITYSPECIAL    string = "activityspecial"    // 对象类型:专项调研活动
-	CYGX_OBJ_MEETINGREVIEWCHAPT string = "meetingreviewchapt" // 对象类型:晨会精华
-	CYGX_OBJ_ROADSHOW           string = "roadshow"           // 对象类型:路演
-	CYGX_OBJ_REPORTSELECTION    string = "reportselection"    // 对象类型:报告精选(重点公司)
-	CYGX_OBJ_PRODUCTINTERIOR    string = "productinterior"    // 对象类型:产品内测
-	CYGX_OBJ_RESEARCHSUMMARY    string = "researchsummary"    // 对象类型:本周研究汇总
-	CYGX_OBJ_MINUTESSUMMARY     string = "minutessummary"     // 对象类型:上周纪要汇总
-	CYGX_OBJ_YANXUANSPECIAL     string = "yanxuanspecial"     // 对象类型:研选专栏
-	CYGX_OBJ_ASKSERIEVIDEO      string = "askserievideo"      // 对象类型:问答系列视频
+	CYGX_OBJ_ARTICLE               string = "article"              // 对象类型:文章
+	CYGX_OBJ_ACTIVITY              string = "activity"             // 对象类型:活动
+	CYGX_OBJ_ACTIVITYVIDEO         string = "activityvideo"        // 对象类型:活动视频
+	CYGX_OBJ_ACTIVITYVOICE         string = "activityvoice"        // 对象类型:活动音频
+	CYGX_OBJ_ACTIVITYSPECIAL       string = "activityspecial"      // 对象类型:专项调研活动
+	CYGX_OBJ_MEETINGREVIEWCHAPT    string = "meetingreviewchapt"   // 对象类型:晨会精华
+	CYGX_OBJ_ROADSHOW              string = "roadshow"             // 对象类型:路演
+	CYGX_OBJ_REPORTSELECTION       string = "reportselection"      // 对象类型:报告精选(重点公司)
+	CYGX_OBJ_PRODUCTINTERIOR       string = "productinterior"      // 对象类型:产品内测
+	CYGX_OBJ_RESEARCHSUMMARY       string = "researchsummary"      // 对象类型:本周研究汇总
+	CYGX_OBJ_MINUTESSUMMARY        string = "minutessummary"       // 对象类型:上周纪要汇总
+	CYGX_OBJ_YANXUANSPECIAL        string = "yanxuanspecial"       // 对象类型:研选专栏
+	CYGX_OBJ_ASKSERIEVIDEO         string = "askserievideo"        // 对象类型:问答系列视频
+	CYGX_OBJ_YANXUANSPECIAL_AUTHOR string = "yanxuanspecialauthor" // 对象类型:研选作者更新时间
 )
 
 const (
@@ -336,4 +337,5 @@ const (
 	LABEL_ICO_6 string = "https://hzstatic.hzinsights.com/mfyx/config/maifangshalong.png"           // 买方沙龙
 	LABEL_ICO_7 string = "https://hzstatic.hzinsights.com/mfyx/config/rika.png"                     // 日卡图标
 	LABEL_ICO_8 string = "https://hzstatic.hzinsights.com/mfyx/config/yueka.png"                    // 月卡图标
+	LABEL_ICO_9 string = "https://hzstatic.hzinsights.com/mfyx/config/zhuanlan_author.png"          // 专栏作者
 )