Browse Source

no message

xingzai 7 months ago
parent
commit
e1856f5613
3 changed files with 72 additions and 13 deletions
  1. 7 0
      models/article.go
  2. 52 1
      services/article.go
  3. 13 12
      utils/common.go

+ 7 - 0
models/article.go

@@ -757,6 +757,13 @@ func GetCygxCygxArticleList(condition string, pars []interface{}, startSize, pag
 	return
 }
 
+func ModifyArticleTitleByarticleId(articleId int, title string) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_article SET title= ?  WHERE article_id=? `
+	_, err = o.Raw(sql, title, articleId).Exec()
+	return
+}
+
 // 获取数量
 func GetCygxArticleCount(condition string, pars []interface{}) (count int, err error) {
 	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article as art WHERE 1= 1  `

+ 52 - 1
services/article.go

@@ -999,7 +999,9 @@ func HandleArticleListByApi(artcleId int) (err error) {
 				titleNew = v.Title + utils.WeekByDate(v.PublishDate)
 			}
 		}
-		if v.CategoryId == 80 {
+
+		//策略周度思考,医药周报,消费周报,消费周度思考,科技前言(周报)、智造精粹、智造本周荟 标题处理
+		if v.CategoryId == 80 || v.CategoryId == 52 || v.CategoryId == 10074 || v.CategoryId == 1008 || v.CategoryId == 10071 || v.CategoryId == 10073 || v.CategoryId == 50 {
 			titleNew = v.Title + utils.WeekByDate(v.PublishDate)
 		}
 
@@ -3081,3 +3083,52 @@ func HandleArticleListByApiInit13_5GuShou(artcleId int) (err error) {
 	AddCygxReportMappingCategoryGroupByArticleId(artcleId)
 	return err
 }
+
+// 需求池972 修改部分报告类型title
+func initweek() {
+	var category_id int
+	//category_id = 52
+	//category_id = 10074
+	//category_id = 1008
+	//category_id = 10071
+	//category_id = 10073
+	//category_id = 50
+	var condition string
+	var pars []interface{}
+	condition += ` AND category_id = ? AND  publish_date  > '2023-12-31'  `
+	pars = append(pars, category_id)
+	articleList, e := models.GetCygxCygxArticleList(condition, pars, 0, 1000)
+	if e != nil {
+		fmt.Println(e)
+		return
+	}
+	var clueApiUrl string
+	for _, v := range articleList {
+
+		clueApiUrl = fmt.Sprint(utils.ApiUrl, "articles/", v.ArticleId)
+		fmt.Println(clueApiUrl)
+
+		authorization := utils.ApiAuthorization
+		body, err := PublicGetDate(clueApiUrl, authorization)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+		var articleResultDate models.ArticleDetailResultApi
+		err = json.Unmarshal(body, &articleResultDate)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+		articleResult := articleResultDate.Data
+
+		titleWeek := articleResult.Title + utils.WeekByDate(articleResult.PublishDate)
+
+		fmt.Println(titleWeek)
+		e = models.ModifyArticleTitleByarticleId(v.ArticleId, titleWeek)
+		if e != nil {
+			fmt.Println(e)
+			return
+		}
+	}
+}

+ 13 - 12
utils/common.go

@@ -617,20 +617,21 @@ func TimeRemoveHms2(strTime string) string {
 func WeekByDate(t time.Time) string {
 	var resultSAtr string
 	//t = t.AddDate(0, 0, -8) // 减少八天跟老数据标题统一
-	yearDay := t.YearDay()
-	yearFirstDay := t.AddDate(0, 0, -yearDay+1)
-	firstDayInWeek := int(yearFirstDay.Weekday())
+	//yearDay := t.YearDay()
+	//yearFirstDay := t.AddDate(0, 0, -yearDay+1)
+	//firstDayInWeek := int(yearFirstDay.Weekday())
 	//今年第一周有几天
-	firstWeekDays := 1
-	if firstDayInWeek != 0 {
-		firstWeekDays = 7 - firstDayInWeek + 1
-	}
+	//firstWeekDays := 1
+	//if firstDayInWeek != 0 {
+	//	firstWeekDays = 7 - firstDayInWeek + 1
+	//}
+	//if yearDay <= firstWeekDays {
+	//	week = 1
+	//} else {
+	//	week = (yearDay-firstWeekDays)/7 + 2
+	//}
 	var week int
-	if yearDay <= firstWeekDays {
-		week = 1
-	} else {
-		week = (yearDay-firstWeekDays)/7 + 2
-	}
+	_, week = t.ISOWeek()
 	resultSAtr = "(" + strconv.Itoa(t.Year()) + "年第" + strconv.Itoa(week) + "周" + ")"
 	return resultSAtr
 }