Browse Source

no message

xingzai 1 year ago
parent
commit
54de41f8ed

+ 3 - 3
controllers/yanxuan_special.go

@@ -224,7 +224,7 @@ func (this *YanxuanSpecialController) Detail() {
 		return
 	}
 	if hasStyle || strings.Contains(item.DocUrl, "http") || hasImg {
-		item.ContentHasStyle = true
+		resp.ContentHasStyle = true
 	}
 
 	br.Data = resp
@@ -600,7 +600,7 @@ func (this *YanxuanSpecialController) Collect() {
 		}
 		br.Msg = "取消收藏成功"
 	}
-	go services.UdpateYanxuanSpecialCollect(user, req.Id, req.Status)
+	go services.UdpateYanxuanSpecialCollect(req.Id)
 	br.Ret = 200
 	br.Success = true
 }
@@ -784,7 +784,7 @@ func (this *YanxuanSpecialController) Follow() {
 		}
 		br.Msg = "取消关注成功"
 	}
-	go services.UdpateYanxuanSpecialFansNum(user, req.FollowUserId, req.Status)
+	go services.UdpateYanxuanSpecialFansNum(req.FollowUserId)
 	br.Ret = 200
 	br.Success = true
 }

+ 15 - 5
models/cygx_yanxuan_special.go

@@ -99,11 +99,12 @@ type CygxYanxuanSpecialCenterResp struct {
 	ContentHasImg   int  //正文是否包含图片 1包含 0不包含
 	ContentHasStyle bool //正文是否包含格式
 	Docs            []Doc
-	Annotation      string `description:"核心观点"`
-	Source          string `description:"来源"`
-	Pv              string `description:"Pv"`
-	Uv              string `description:"Uv"`
-	PublishDate     string // 提审过审或驳回时间      string `description:"核心观点"`
+	Annotation      string   `description:"核心观点"`
+	Source          string   `description:"来源"`
+	Pv              string   `description:"Pv"`
+	Uv              string   `description:"Uv"`
+	PublishDate     string   // 提审过审或驳回时间      string `description:"核心观点"`
+	BodyHighlight   []string `description:"搜索高亮展示结果"`
 }
 
 type Doc struct {
@@ -332,3 +333,12 @@ func UpdateYanxuanSpecialarticleCollectNumReduce(id int) (err error) {
 	_, err = o.Raw(sql, id).Exec()
 	return
 }
+
+// 更新收藏数量
+func UpdateYanxuanSpecialarticleCollectNum(collectNum, id int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special SET article_collect_num = ?  WHERE id = ? `
+	_, err = o.Raw(sql, collectNum, id).Exec()
+	return
+}

+ 24 - 13
models/cygx_yanxuan_special_collect.go

@@ -7,17 +7,17 @@ import (
 
 type CygxYanxuanSpecialCollect struct {
 	CygxYanxuanSpecialCollectId int       `orm:"column(cygx_yanxuan_special_collect_id);pk"`
-	UserId                      int        // 用户ID
-	Mobile                      string     // 手机号
-	Email                       string     // 邮箱
-	CompanyId                   int        // 公司ID
-	CompanyName                 string     // 公司名称
-	RealName                    string     // 用户实际名称
-	SellerName                  string     // 所属销售
-	CreateTime                  time.Time  // 创建时间
-	ModifyTime                  time.Time  // 修改时间
-	RegisterPlatform            int        // 来源 1小程序,2:网页
-	YanxuanSpecialId            int        // cygx_yanxuan_special 表主键ID
+	UserId                      int       // 用户ID
+	Mobile                      string    // 手机号
+	Email                       string    // 邮箱
+	CompanyId                   int       // 公司ID
+	CompanyName                 string    // 公司名称
+	RealName                    string    // 用户实际名称
+	SellerName                  string    // 所属销售
+	CreateTime                  time.Time // 创建时间
+	ModifyTime                  time.Time // 修改时间
+	RegisterPlatform            int       // 来源 1小程序,2:网页
+	YanxuanSpecialId            int       // cygx_yanxuan_special 表主键ID
 }
 
 func AddCygxYanxuanSpecialCollect(item *CygxYanxuanSpecialCollect) (lastId int64, err error) {
@@ -27,8 +27,8 @@ func AddCygxYanxuanSpecialCollect(item *CygxYanxuanSpecialCollect) (lastId int64
 }
 
 type CollectCygxYanxuanSpecialReq struct {
-	Id     int    // 文章id
-	Status int    // 1收藏2取消收藏
+	Id     int // 文章id
+	Status int // 1收藏2取消收藏
 }
 
 func DelCygxYanxuanSpecialCollect(userId, articleId int) (err error) {
@@ -37,3 +37,14 @@ func DelCygxYanxuanSpecialCollect(userId, articleId int) (err error) {
 	_, err = o.Raw(sql, userId, articleId).Exec()
 	return
 }
+
+// 获取数量
+func GetCygxYanxuanSpecialCollectCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_yanxuan_special_collect as a  WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}

+ 24 - 13
models/cygx_yanxuan_special_follow.go

@@ -6,19 +6,19 @@ import (
 )
 
 type CygxYanxuanSpecialFollow struct {
-	CygxYanxuanSpecialFollowId int        `orm:"column(cygx_yanxuan_special_follow_id);pk"`
-	UserId                     int        // 用户ID
-	FollowUserId               int        // 被关注用户ID
-	Mobile                     string     // 手机号
-	Email                      string     // 邮箱
-	CompanyId                  int        // 公司ID
-	CompanyName                string     // 公司名称
-	RealName                   string     // 用户实际名称
-	SellerName                 string     // 所属销售
-	CreateTime                 time.Time  // 创建时间
-	ModifyTime                 time.Time  // 修改时间
-	RegisterPlatform           int        // 来源 1小程序,2:网页
-	YanxuanSpecialId           int        // cygx_yanxuan_special 表主键ID
+	CygxYanxuanSpecialFollowId int       `orm:"column(cygx_yanxuan_special_follow_id);pk"`
+	UserId                     int       // 用户ID
+	FollowUserId               int       // 被关注用户ID
+	Mobile                     string    // 手机号
+	Email                      string    // 邮箱
+	CompanyId                  int       // 公司ID
+	CompanyName                string    // 公司名称
+	RealName                   string    // 用户实际名称
+	SellerName                 string    // 所属销售
+	CreateTime                 time.Time // 创建时间
+	ModifyTime                 time.Time // 修改时间
+	RegisterPlatform           int       // 来源 1小程序,2:网页
+	YanxuanSpecialId           int       // cygx_yanxuan_special 表主键ID
 }
 
 type FollowCygxYanxuanSpecialReq struct {
@@ -55,3 +55,14 @@ WHERE
 	_, err = o.Raw(sql, followUserId).QueryRows(&items)
 	return
 }
+
+// 获取数量
+func GetCygxYanxuanSpecialFollowCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_yanxuan_special_follow as a  WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}

+ 18 - 0
models/cygx_yanxuan_special_user.go

@@ -203,6 +203,15 @@ func UpdateYanxuanSpecialAuthorArticleCollectNumReduce(userId int) (err error) {
 	return
 }
 
+// 更新收藏数量
+func UpdateYanxuanSpecialAuthorArticleCollectNum(collectNum, userId int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET article_collect_num = ?  WHERE user_id = ? `
+	_, err = o.Raw(sql, collectNum, userId).Exec()
+	return
+}
+
 // 增加粉丝数量
 func UpdateYanxuanSpecialAuthorFansNumIncrease(userId int) (err error) {
 	o := orm.NewOrm()
@@ -221,6 +230,15 @@ func UpdateYanxuanSpecialAuthorFansNumReduce(userId int) (err error) {
 	return
 }
 
+// 更新粉丝数量
+func UpdateYanxuanSpecialAuthorFansNum(fansNum, userId int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET fans_num = ?  WHERE user_id = ? `
+	_, err = o.Raw(sql, fansNum, userId).Exec()
+	return
+}
+
 // 更新作者发布文章的数量
 func UdpateYanxuanSpecialauthorArticleNum(articleNum, userId int) (err error) {
 	o := orm.NewOrm()

+ 47 - 47
services/cygx_yanxuan_special.go

@@ -394,12 +394,12 @@ func AddAddCygxYanxuanSpecialApprovalLog(user *models.WxUserItem, specialId, sta
 }
 
 // 更新文章收藏数量
-func UdpateYanxuanSpecialCollect(user *models.WxUserItem, specialId, status int) {
+func UdpateYanxuanSpecialCollect(specialId int) {
 	var err error
 	defer func() {
 		if err != nil {
 			fmt.Println(err)
-			go utils.SendAlarmMsg(fmt.Sprint("更新文章收藏数量失败,UdpateYanxuanSpecialCollect Err ", err, "userId", user.UserId), 2)
+			go utils.SendAlarmMsg(fmt.Sprint("更新文章收藏数量失败,UdpateYanxuanSpecialCollect Err ", err, "specialId:", specialId), 2)
 		}
 	}()
 	detail, e := models.GetYanxuanSpecialBySpecialId(specialId)
@@ -414,67 +414,67 @@ func UdpateYanxuanSpecialCollect(user *models.WxUserItem, specialId, status int)
 		return
 	}
 
-	if status == 1 {
-		//更新文章被收藏数量
-		e = models.UpdateYanxuanSpecialarticleCollectNumIncrease(specialId)
-		if e != nil {
-			err = errors.New("UpdateYanxuanSpecialarticleCollectNumIncrease, Err: " + e.Error())
-			return
-		}
+	var condition string
+	var pars []interface{}
+	condition = "  AND yanxuan_special_id = ? "
+	pars = append(pars, specialId)
+	//专栏被收藏的数量
+	totalSpecial, e := models.GetCygxYanxuanSpecialCollectCount(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxYanxuanSpecialCollectCount, Err: " + e.Error())
+		return
+	}
 
-		//更新作者文章被收藏数量
-		e = models.UpdateYanxuanSpecialAuthorArticleCollectNumIncrease(specialAuthor.Id)
-		if e != nil {
-			err = errors.New("UpdateYanxuanSpecialAuthorArticleCollectNumIncrease, Err: " + e.Error())
-			return
-		}
-	} else {
-		//更新文章被收藏数量
-		e = models.UpdateYanxuanSpecialarticleCollectNumReduce(specialId)
-		if e != nil {
-			err = errors.New("UpdateYanxuanSpecialarticleCollectNumReduce, Err: " + e.Error())
-			return
-		}
+	pars = make([]interface{}, 0)
+	condition = "  AND yanxuan_special_id  IN (SELECT id FROM cygx_yanxuan_special AS a WHERE user_id = ?)  "
+	pars = append(pars, specialAuthor.UserId)
+	//作者被收藏的数量
+	totalAuthor, e := models.GetCygxYanxuanSpecialCollectCount(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxYanxuanSpecialCollectCount, Err: " + e.Error())
+		return
+	}
 
-		//更新作者文章被收藏数量
-		e = models.UpdateYanxuanSpecialAuthorArticleCollectNumReduce(specialAuthor.Id)
-		if e != nil {
-			err = errors.New("UpdateYanxuanSpecialAuthorArticleCollectNumReduce, Err: " + e.Error())
-			return
-		}
+	//更新文章被收藏数量
+	e = models.UpdateYanxuanSpecialarticleCollectNum(totalSpecial, specialId)
+	if e != nil {
+		err = errors.New("UpdateYanxuanSpecialarticleCollectNum, Err: " + e.Error())
+		return
+	}
+
+	//更新作者文章被收藏数量
+	e = models.UpdateYanxuanSpecialAuthorArticleCollectNum(totalAuthor, specialAuthor.UserId)
+	if e != nil {
+		err = errors.New("UpdateYanxuanSpecialAuthorArticleCollectNum, Err: " + e.Error())
+		return
 	}
 	return
 }
 
 // 更新作者粉丝数量
-func UdpateYanxuanSpecialFansNum(user *models.WxUserItem, specialUserIdId, status int) {
+func UdpateYanxuanSpecialFansNum(specialUserIdId int) {
 	var err error
 	defer func() {
 		if err != nil {
 			fmt.Println(err)
-			go utils.SendAlarmMsg(fmt.Sprint("更新作者粉丝数量失败,UdpateYanxuanSpecialFansNum Err ", err, "userId", user.UserId), 2)
+			go utils.SendAlarmMsg(fmt.Sprint("更新作者粉丝数量失败,UdpateYanxuanSpecialFansNum Err ", err, "specialUserIdId", specialUserIdId), 2)
 		}
 	}()
-	specialAuthor, e := models.GetCygxYanxuanSpecialAuthorByUserId(specialUserIdId)
+
+	var condition string
+	var pars []interface{}
+	condition = "  AND follow_user_id = ? "
+	pars = append(pars, specialUserIdId)
+	//作者粉丝数量
+	total, e := models.GetCygxYanxuanSpecialFollowCount(condition, pars)
 	if e != nil {
-		err = errors.New("GetCygxYanxuanSpecialAuthorByUserId, Err: " + e.Error())
+		err = errors.New("GetCygxYanxuanSpecialFollowCount, Err: " + e.Error())
 		return
 	}
-
-	if status == 1 {
-		//更新作者粉丝数量
-		e := models.UpdateYanxuanSpecialAuthorFansNumIncrease(specialAuthor.Id)
-		if e != nil {
-			err = errors.New("UpdateYanxuanSpecialAuthorFansNumIncrease, Err: " + e.Error())
-			return
-		}
-	} else {
-		//更新作者粉丝数量
-		e := models.UpdateYanxuanSpecialAuthorFansNumReduce(specialAuthor.Id)
-		if e != nil {
-			err = errors.New("UpdateYanxuanSpecialAuthorFansNumReduce, Err: " + e.Error())
-			return
-		}
+	e = models.UpdateYanxuanSpecialAuthorFansNum(total, specialUserIdId)
+	if e != nil {
+		err = errors.New("UpdateYanxuanSpecialAuthorFansNum, Err: " + e.Error())
+		return
 	}
 	return
 }

+ 12 - 1
services/es_comprehensive.go

@@ -613,7 +613,7 @@ func EsAddYanxuanSpecial(sourceId int) {
 	item.BodyText = bodyText
 	item.Abstract = bodyText
 	item.IndustryName = detail.IndustryTags
-	item.SubjectNames = detail.SpecialName
+	item.SubjectNames = detail.CompanyTags + detail.Tags
 	if detail.Status == 3 {
 		EsAddOrEditComprehensiveData(item) //如果发布了就新增
 	} else {
@@ -968,6 +968,7 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 	uid := user.UserId
 	titleHighlight := make(map[int]string)
 	bodyHighlight := make(map[int][]string)
+	yanXuanbodyHighlight := make(map[int][]string)
 	//var bodyHighlight []string
 	mapItems := make(map[string]*models.CygxResourceDataResp)
 	for _, v := range list {
@@ -1032,6 +1033,7 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 			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))
 		}
@@ -1451,6 +1453,11 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 		for _, v := range listyanxuanSpecial {
 			v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
 			v.Annotation, _ = GetReportContentTextSubNew(v.Content)
+			if len(yanXuanbodyHighlight[v.Id]) > 0 {
+				v.BodyHighlight = yanXuanbodyHighlight[v.Id]
+			} else {
+				v.BodyHighlight = append(v.BodyHighlight, v.Annotation)
+			}
 			// Source  PublishDate 字段兼容前端样式
 			v.Source = utils.CYGX_OBJ_YANXUANSPECIAL
 			v.PublishDate = v.PublishTime
@@ -1498,6 +1505,10 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 			//if v.IndustrialResource != nil && v.SourceId == vList.SourceId {
 			//	v.IndustrialResource.UpdateTime = vList.PublishDate
 			//}
+
+			if v.YanxuanSpecial != nil && v.SourceId == vList.SourceId {
+				v.YanxuanSpecial.Title = vList.Title
+			}
 			if v.SourceId == vList.SourceId && v.Source == vList.Source {
 				items = append(items, v)
 			}

+ 31 - 0
services/init12.8.go

@@ -121,3 +121,34 @@ func init77() {
 	}
 
 }
+
+// 更新文章收藏数量
+func initcc() {
+	var condition string
+	var pars []interface{}
+	list, e := models.GetYanxuanSpecialListBycondition(condition, pars, 0, 9999)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		fmt.Println(e)
+		return
+	}
+
+	for _, v := range list {
+		fmt.Println(v.Id)
+		UdpateYanxuanSpecialCollect(v.Id)
+	}
+}
+
+// 更新作者粉丝数量
+func initFansNum() {
+	var condition string
+	var pars []interface{}
+	list, tmpErr := models.GetYanxuanSpecialAuthorList(condition, pars, 0, 9999)
+	if tmpErr != nil {
+		fmt.Println(tmpErr)
+		return
+	}
+	for _, v := range list {
+		fmt.Println(v.UserId)
+		UdpateYanxuanSpecialFansNum(v.UserId)
+	}
+}