瀏覽代碼

no message

xingzai 1 年之前
父節點
當前提交
d91169aa95

+ 1 - 1
controllers/yanxuan_special.go

@@ -191,7 +191,7 @@ func (this *YanxuanSpecialController) Detail() {
 			resp.Tags += ","
 		}
 		resp.Tags += item.IndustryTags
-		resp.IndustryTags = append(resp.IndustryTags, item.IndustryTags)
+		resp.IndustryTags = strings.Split(item.IndustryTags, ",")
 	}
 
 	//如果状态未审核通过,而且查看的不是本人,不是审核人员,就无法查看详情

+ 14 - 0
models/cygx_yanxuan_special.go

@@ -316,6 +316,20 @@ func UpdateYanxuanSpecialUv(id int) (err error) {
 	return
 }
 
+func UpdateYanxuanSpecialPvNUm(pv, id int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_yanxuan_special SET pv = ? WHERE id = ? `
+	_, err = o.Raw(sql, pv, id).Exec()
+	return
+}
+
+func UpdateYanxuanSpecialUvUm(pv, id int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_yanxuan_special SET uv = ? WHERE id = ? `
+	_, err = o.Raw(sql, pv, id).Exec()
+	return
+}
+
 // 增加收藏数量
 func UpdateYanxuanSpecialarticleCollectNumIncrease(id int) (err error) {
 	o := orm.NewOrm()

+ 9 - 0
models/cygx_yanxuan_special_record.go

@@ -59,6 +59,15 @@ func GetCygxYanxuanSpecialRecordCount(condition string, pars []interface{}) (cou
 	return
 }
 
+// 获取数量
+func GetCygxYanxuanSpecialRecordCountGroup(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT	 count(*) AS count FROM
+	( SELECT COUNT(*) FROM cygx_yanxuan_special_record AS art WHERE 1 = 1 ` + condition + ` GROUP BY user_id ) f `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
 // 判断一个用户是否阅读过 某一篇研选专栏
 func GetCygxYanxuanSpecialRecordCountByUser(userId, yanxuanSpecialId int) (count int, err error) {
 	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_yanxuan_special_record as a  WHERE user_id= ?    AND yanxuan_special_id  = ? `

+ 14 - 0
models/cygx_yanxuan_special_user.go

@@ -247,3 +247,17 @@ func UdpateYanxuanSpecialauthorArticleNum(articleNum, userId int) (err error) {
 	_, err = o.Raw(sql, articleNum, userId).Exec()
 	return
 }
+
+func UpdateYanxuanSpecialauthorPvNUm(pv, userId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_yanxuan_special_author SET pv = ? WHERE user_id = ? `
+	_, err = o.Raw(sql, pv, userId).Exec()
+	return
+}
+
+func UpdateYanxuanSpecialauthorUvUm(pv, userId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_yanxuan_special_author SET uv = ? WHERE user_id = ? `
+	_, err = o.Raw(sql, pv, userId).Exec()
+	return
+}

+ 80 - 0
services/init12.8.go

@@ -152,3 +152,83 @@ func initFansNum() {
 		UdpateYanxuanSpecialFansNum(v.UserId)
 	}
 }
+
+// 专栏Pv
+func initPv() {
+	var condition string
+	var pars []interface{}
+	list, tmpErr := models.GetYanxuanSpecialList(0, condition, pars, 0, 99999)
+
+	fmt.Println(len(list))
+	fmt.Println(tmpErr)
+
+	for _, v := range list {
+		condition = ""
+		pars = make([]interface{}, 0)
+		condition = " AND  company_id != 16   AND  user_id > 0  AND yanxuan_special_id = ? "
+		pars = append(pars, v.Id)
+		totalYanxuanSpecial, err := models.GetCygxYanxuanSpecialRecordCount(condition, pars)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+
+		totalYanxuanSpecialUv, err := models.GetCygxYanxuanSpecialRecordCountGroup(condition, pars)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+
+		fmt.Println(totalYanxuanSpecial, "____", totalYanxuanSpecialUv)
+		err = models.UpdateYanxuanSpecialPvNUm(totalYanxuanSpecial, v.Id)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+		err = models.UpdateYanxuanSpecialUvUm(totalYanxuanSpecialUv, v.Id)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+	}
+}
+
+// 作者Pv
+func inituser() {
+	var condition string
+	var pars []interface{}
+	list, tmpErr := models.GetYanxuanSpecialAuthorList(condition, pars, 0, 9999)
+
+	fmt.Println(len(list))
+	fmt.Println(tmpErr)
+
+	for _, v := range list {
+		condition = ""
+		pars = make([]interface{}, 0)
+		condition = " AND  company_id != 16   AND  user_id > 0  AND yanxuan_special_id IN ( SELECT  id  FROM cygx_yanxuan_special WHERE user_id = ?   ) "
+		pars = append(pars, v.UserId)
+		totalYanxuanSpecial, err := models.GetCygxYanxuanSpecialRecordCount(condition, pars)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+
+		totalYanxuanSpecialUv, err := models.GetCygxYanxuanSpecialRecordCountGroup(condition, pars)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+
+		fmt.Println(totalYanxuanSpecial, "____", totalYanxuanSpecialUv)
+		err = models.UpdateYanxuanSpecialauthorPvNUm(totalYanxuanSpecial, v.UserId)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+		err = models.UpdateYanxuanSpecialauthorUvUm(totalYanxuanSpecialUv, v.UserId)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+	}
+}