Bladeren bron

no message

xingzai 1 jaar geleden
bovenliggende
commit
7acf755bc5
9 gewijzigde bestanden met toevoegingen van 154 en 83 verwijderingen
  1. 7 7
      controllers/activity.go
  2. 3 1
      controllers/config.go
  3. 55 37
      controllers/home.go
  4. 0 1
      controllers/wechat.go
  5. 1 35
      models/activity.go
  6. 12 0
      models/resource_data.go
  7. 1 0
      models/user.go
  8. 75 0
      services/es_comprehensive.go
  9. 0 2
      services/tag.go

+ 7 - 7
controllers/activity.go

@@ -100,20 +100,20 @@ func (this *ActivityCoAntroller) ScheduleList() {
 	var condition string
 	var conditionCount string
 	var pars []interface{}
-	condition += ` AND art.publish_status = 1    `
+	condition += ` AND art.publish_status = 1  AND chart_permission_id  =  31    `
 	if source == 1 {
 		condition += ` AND art.yidong_activity_id = '' `
 		conditionCount += ` AND art.yidong_activity_id = '' `
 	}
-	total, err := models.GetScheduleCount(conditionCount, uid)
-	specialtotal, err := models.GetSpecialScheduleCount(uid)
-	page := paging.GetPaging(currentIndex, pageSize, total+specialtotal)
+	total, err := models.GetScheduleCount(conditionCount+condition, uid)
+
+	page := paging.GetPaging(currentIndex, pageSize, total)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
-	conditionCount = ` 	AND art.active_state = 2 `
+	conditionCount = ` 	AND art.active_state = 2  AND chart_permission_id  =  31 `
 	totalCount, err := models.GetScheduleCount(conditionCount, uid) //获取正在进行中的活动数量
 	if err != nil {
 		br.Msg = "获取失败"
@@ -135,7 +135,7 @@ func (this *ActivityCoAntroller) ScheduleList() {
 			return
 		}
 	} else if totalCount > currentIndex-1*pageSize && totalCount < currentIndex*pageSize { //部分是进行中的活动
-		condition = `  AND art.publish_status = 1 AND art.active_state IN(2) `
+		condition += `  AND art.publish_status = 1 AND art.active_state IN(2) `
 		if source == 1 {
 			condition += ` AND art.yidong_activity_id = '' `
 		}
@@ -147,7 +147,7 @@ func (this *ActivityCoAntroller) ScheduleList() {
 			return
 		}
 		pageSize = pageSize - len(listHave)
-		condition = ` AND art.publish_status = 1 AND art.active_state IN(1,3) `
+		condition = ` AND art.publish_status = 1 AND art.active_state IN(1,3)  AND chart_permission_id  =  31`
 		if source == 1 {
 			condition += ` AND art.yidong_activity_id = '' `
 		}

+ 3 - 1
controllers/config.go

@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"hongze/hongze_mfyx/models"
 	"hongze/hongze_mfyx/services"
+	"hongze/hongze_mfyx/utils"
 	"time"
 )
 
@@ -41,7 +42,8 @@ func (this *ConfigController) BrowseHistoryList() {
 	currentTime := time.Now()
 	starTime := currentTime.AddDate(0, 0, -8).Format("2006-01-02") + " 00:00:00"
 	endTime := currentTime.AddDate(0, 0, -1).Format("2006-01-02") + " 23:59:59"
-	condition += ` AND create_time < ` + "'" + endTime + "'" + `AND create_time > ` + "'" + starTime + "'"
+	condition += ` AND  register_platform = ? AND create_time < ` + "'" + endTime + "'" + `AND create_time > ` + "'" + starTime + "'"
+	pars = append(pars, utils.REGISTER_PLATFORM)
 	hotList, err := models.GetSearchKeyWordTop(condition, pars)
 	if err != nil {
 		br.Msg = "获取信息失败"

+ 55 - 37
controllers/home.go

@@ -64,52 +64,70 @@ func (this *HomeController) NewList() {
 
 	}
 
-	//var total int
+	var total int
+	var list []*models.CygxResourceDataResp
+	var err error
 	resp := new(models.HomeResourceDataListResp)
-	condition += " AND source IN ('article','activity','yanxuanspecial')   " // 只有研选的文章、研选的活动、研选的专栏这三种
 
-	if labelKeyword == "" {
-		//查询近一个月的数据
-		condition += " AND search_order_time  >   '" + time.Now().AddDate(0, 0, -60).Format(utils.FormatDateTime) + "'"
-		yanxuanActivityIds = services.GetYanxuanActivityIds() // 获取所有的研选活动ID
-		yanxuanArticleIds = services.GetYanxuanArticleIds()   //获取所有研选文章ID
-	} else {
-		var errIds error
-		yanxuanActivityIds, yanxuanArticleIds, errIds = services.GetConditionInitByTagIds(labelKeyword)
-		if errIds != nil {
+	if keyWord == "" {
+		condition += " AND source IN ('article','activity','yanxuanspecial')   " // 只有研选的文章、研选的活动、研选的专栏这三种
+		if labelKeyword == "" {
+			//查询近一个月的数据
+			condition += " AND search_order_time  >   '" + time.Now().AddDate(0, 0, -60).Format(utils.FormatDateTime) + "'"
+			yanxuanActivityIds = services.GetYanxuanActivityIds() // 获取所有的研选活动ID
+			yanxuanArticleIds = services.GetYanxuanArticleIds()   //获取所有研选文章ID
+		} else {
+			yanxuanActivityIds, yanxuanArticleIds, err = services.GetConditionInitByTagIds(labelKeyword)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取活动权限数据失败,GetConditionInitByTagIds Err:" + err.Error()
+				return
+			}
+			//如果不是 "全部报告" 、 "专栏" 的关键词查询,就不做研选专栏的查询
+			if labelKeyword != utils.LABEL_L2_1 && labelKeyword != utils.LABEL_L2_2 {
+				condition += `  AND IF ( source = 'yanxuanspecial' , source_id   IN (0) ,1=1 ) `
+			}
+		}
+
+		yanxuanArticleIds = append(yanxuanArticleIds, 0)
+		yanxuanActivityIds = append(yanxuanActivityIds, 0)
+		//yanxuanspecialIds = append(yanxuanspecialIds, 0)
+		condition += `  AND IF ( source = 'article' , source_id   IN (` + utils.GetOrmInReplace(len(yanxuanArticleIds)) + `) ,1=1 ) `
+		pars = append(pars, yanxuanArticleIds)
+
+		condition += `  AND IF ( source = 'activity' , source_id   IN (` + utils.GetOrmInReplace(len(yanxuanActivityIds)) + `) ,1=1 ) `
+		pars = append(pars, yanxuanActivityIds)
+
+		total, err = models.GetResourceDataCount(condition, pars)
+		if err != nil {
 			br.Msg = "获取失败"
-			br.ErrMsg = "获取活动权限数据失败,GetConditionInitByTagIds Err:" + errIds.Error()
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
 		}
-		//如果不是 "全部报告" 、 "专栏" 的关键词查询,就不做研选专栏的查询
-		if labelKeyword != utils.LABEL_L2_1 && labelKeyword != utils.LABEL_L2_2 {
-			condition += `  AND IF ( source = 'yanxuanspecial' , source_id   IN (0) ,1=1 ) `
+		list, err = services.GetResourceDataList(condition, pars, startSize, pageSize, user)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
 		}
-	}
-
-	yanxuanArticleIds = append(yanxuanArticleIds, 0)
-	yanxuanActivityIds = append(yanxuanActivityIds, 0)
-	//yanxuanspecialIds = append(yanxuanspecialIds, 0)
-	condition += `  AND IF ( source = 'article' , source_id   IN (` + utils.GetOrmInReplace(len(yanxuanArticleIds)) + `) ,1=1 ) `
-	pars = append(pars, yanxuanArticleIds)
-
-	condition += `  AND IF ( source = 'activity' , source_id   IN (` + utils.GetOrmInReplace(len(yanxuanActivityIds)) + `) ,1=1 ) `
-	pars = append(pars, yanxuanActivityIds)
+	} else {
 
-	total, err := models.GetResourceDataCount(condition, pars)
-	if err != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取数据失败,Err:" + err.Error()
-		return
+		tmpResult, tmpTotalResult, err := services.SqlComprehensiveSearch(keyWord, startSize, pageSize)
+		if err != nil {
+			br.Msg = "检索失败"
+			br.ErrMsg = "检索失败,Err:" + err.Error()
+			return
+		}
+		total = tmpTotalResult
+		list, err = services.GetResourceDataEsList(tmpResult, user)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
 	}
 	page := paging.GetPaging(currentIndex, pageSize, total)
-	list, err := services.GetResourceDataList(condition, pars, startSize, pageSize, user)
-	if err != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取数据失败,Err:" + err.Error()
-		return
-	}
-	page = paging.GetPaging(currentIndex, pageSize, total)
+
 	if currentIndex == 1 && keyWord != "" {
 		go services.AddSearchKeyWord(user, keyWord, 1)
 	}

+ 0 - 1
controllers/wechat.go

@@ -92,7 +92,6 @@ func (this *WechatCommonController) WechatLogin() {
 	resp.UserId = userId
 	resp.FirstLogin = firstLogin
 	resp.Authorization = token
-	resp.ProductName = fmt.Sprint(wxInfo.UnionID, "OpenID", wxInfo.OpenID)
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "登录成功"

+ 1 - 35
models/activity.go

@@ -448,42 +448,8 @@ func GetScheduleAndSpecilList(condition string, pars []interface{}, conditionSpe
 	if condition != `` {
 		sql += condition
 	}
-	sql += ` UNION ALL
-		SELECT
-			art.activity_id,
-			art.activity_time_text_by_day AS activity_time_text,
-			art.research_theme AS activity_name,
-			art.chart_permission_id,
-			"",
-			art.special_type AS activity_type,
-			art.chart_permission_name,
-			"",
-			"",
-			"",
-			art.trip_img_link_fix AS trip_img_link,
-			art.activity_time_end,
-			"",
-			"",
-			"",
-			"",
-			"",
-			2 AS source_type,
-			art.activity_time,
-			"",
-			"",
-			"",
-			"",
-			""
-		FROM
-			cygx_activity_special AS art
-			INNER JOIN cygx_activity_special_trip AS my ON my.activity_id = art.activity_id 
-		WHERE
-			1 = 1`
-	if conditionSpecil != "" {
-		sql += conditionSpecil
-	}
 	sql += ` ORDER BY activity_time DESC   LIMIT ?,?`
-	_, err = o.Raw(sql, pars, parsSpecil, startSize, pageSize).QueryRows(&items)
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
 	return
 }
 

+ 12 - 0
models/resource_data.go

@@ -144,3 +144,15 @@ func GetCygxResourceDataBySourceAndIdCount(sourceId int, source string) (count i
 	err = o.Raw(sqlCount, sourceId, source).QueryRow(&count)
 	return
 }
+
+// 列表
+func GetResourceDataListCondition(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxResourceData, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT	 *   FROM cygx_resource_data  WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `  ORDER BY search_order_time DESC   LIMIT ?,? `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 1 - 0
models/user.go

@@ -197,6 +197,7 @@ func GetArticleUserCollectList(startSize, pageSize, userId int) (items []*Articl
 			FROM cygx_article_collect AS a 
 			INNER JOIN cygx_article as art ON art.article_id = a.article_id
 			WHERE a.user_id=? 
+   			AND  art.article_type_id  > 0 
 			UNION ALL
 	SELECT
 		a.id AS article_id,

+ 75 - 0
services/es_comprehensive.go

@@ -960,3 +960,78 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 	}
 	return
 }
+
+func SqlComprehensiveSearch(keyWord string, startSize, pageSize int) (result []*SearchComprehensiveItem, total int, err error) {
+	keyWord = "%" + keyWord + "%"
+	var conditionTitle string
+	var parsTitle []interface{}
+	conditionTitle = " AND search_title LIKE ? "
+	parsTitle = append(parsTitle, keyWord)
+	totalTitle, e := models.GetResourceDataCount(conditionTitle, parsTitle)
+	if e != nil {
+		err = errors.New("GetResourceDataCount, Err: " + e.Error())
+		return
+	}
+
+	var conditionContent string
+	var parsContent []interface{}
+
+	conditionContent = " AND search_content LIKE ? AND search_title  NOT LIKE ?  "
+	parsContent = append(parsContent, keyWord, keyWord)
+	totalContent, e := models.GetResourceDataCount(conditionContent, parsContent)
+	if e != nil {
+		err = errors.New("AddCygxArticleViewRecord, Err: " + e.Error())
+		return
+	}
+	var searchTotal int
+	searchTotal = (startSize/pageSize + 1) * pageSize
+	var list []*models.CygxResourceData
+	fmt.Println("totalTitle", totalTitle)
+	fmt.Println("totalContent", totalContent)
+	fmt.Println(searchTotal)
+	if totalTitle >= searchTotal {
+		fmt.Println("1")
+		//全部都是标题搜索
+		list, e = models.GetResourceDataListCondition(conditionTitle, parsTitle, startSize, pageSize)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetResourceDataListCondition, Err: " + e.Error())
+			return
+		}
+	} else if totalTitle <= searchTotal-pageSize {
+		fmt.Println("2")
+		//全部都是内容搜索
+		startSize = startSize - totalTitle
+
+		list, e = models.GetResourceDataListCondition(conditionContent, parsContent, startSize, pageSize)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetResourceDataListCondition, Err: " + e.Error())
+			return
+		}
+	} else {
+		fmt.Println("3")
+		//一半标题搜索,一半内容搜索
+
+		list, e = models.GetResourceDataListCondition(conditionTitle, parsTitle, startSize, pageSize)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetResourceDataListCondition, Err: " + e.Error())
+			return
+		}
+		listContent, e := models.GetResourceDataListCondition(conditionContent, parsContent, 0, pageSize-totalContent%pageSize)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetResourceDataListCondition, Err: " + e.Error())
+			return
+		}
+		for _, v := range listContent {
+			list = append(list, v)
+		}
+	}
+
+	for _, v := range list {
+		item := new(SearchComprehensiveItem)
+		item.SourceId = v.SourceId
+		item.Source = v.Source
+		result = append(result, item)
+	}
+	total = totalTitle + totalContent
+	return
+}

+ 0 - 2
services/tag.go

@@ -118,7 +118,6 @@ func GetConditionInitByTagIds(labelKeyword string) (yanxuanActivityIdsResp, yanx
 			yanxuanArticleIds = append(yanxuanArticleIds, v.ArticleId)
 		}
 
-		yanxuanArticleIds = GetYanxuanArticleIds() //获取所有研选文章ID
 	case "买方沙龙": // 买方沙龙
 		condition = `  AND  article_type_id = 12  `
 		list, e := models.GetCygxCygxArticleIdList(condition, pars)
@@ -129,7 +128,6 @@ func GetConditionInitByTagIds(labelKeyword string) (yanxuanActivityIdsResp, yanx
 		for _, v := range list {
 			yanxuanArticleIds = append(yanxuanArticleIds, v.ArticleId)
 		}
-		yanxuanArticleIds = GetYanxuanArticleIds() //获取所有研选文章ID
 	}
 	yanxuanActivityIdsResp = yanxuanActivityIds
 	yanxuanArticleIdsResp = yanxuanArticleIds