浏览代码

fix:seo发布时间展示问题修改

duxin 2 月之前
父节点
当前提交
2c33f594ba
共有 2 个文件被更改,包括 14 次插入3 次删除
  1. 7 1
      internal/service/detailStruct.go
  2. 7 2
      internal/service/queryStruct.go

+ 7 - 1
internal/service/detailStruct.go

@@ -40,7 +40,13 @@ func (dRoot *DetailRoot) GetDetail(ctx context.Context, seoId string, isLogin bo
 			obj = Filter(obj)
 			obj = Filter(obj)
 		}
 		}
 		obj["title"] = gconv.String(fmt.Sprintf("【%s】%s", consts.TopTypeMap[gconv.String(obj["toptype"])], obj["title"]))
 		obj["title"] = gconv.String(fmt.Sprintf("【%s】%s", consts.TopTypeMap[gconv.String(obj["toptype"])], obj["title"]))
-		obj["time"] = time.Unix(gconv.Int64(obj["publishtime"])+3600*24, 0).Format("2006-01-02")
+		var publishTime int64
+		if gconv.Int64(obj["publish_time"])+3600*24 > time.Now().Unix() {
+			publishTime = gconv.Int64(obj["publish_time"])
+		} else {
+			publishTime = gconv.Int64(obj["publish_time"]) + 3600*24
+		}
+		obj["time"] = time.Unix(publishTime, 0).Format("2006-01-02")
 		var _detail = gconv.String(obj["detail"])
 		var _detail = gconv.String(obj["detail"])
 		for _, v := range []string{"table", "div"} {
 		for _, v := range []string{"table", "div"} {
 			var intOpen = strings.Count(_detail, "<"+v)
 			var intOpen = strings.Count(_detail, "<"+v)

+ 7 - 2
internal/service/queryStruct.go

@@ -10,6 +10,7 @@ import (
 	"jybxseo/internal/consts"
 	"jybxseo/internal/consts"
 	"jybxseo/utility"
 	"jybxseo/utility"
 	"strings"
 	"strings"
+	"time"
 )
 )
 
 
 type (
 type (
@@ -85,7 +86,12 @@ func (query *SeoBiddingQuery) dataFormat(data []map[string]interface{}) (bList [
 	if len(data) > 0 {
 	if len(data) > 0 {
 		titleReduction := map[string]int{}
 		titleReduction := map[string]int{}
 		for _, v := range data {
 		for _, v := range data {
-			publishTime := gconv.Int64(v["publish_time"]) + 3600*24
+			var publishTime int64
+			if gconv.Int64(v["publish_time"])+3600*24 > time.Now().Unix() {
+				publishTime = gconv.Int64(v["publish_time"])
+			} else {
+				publishTime = gconv.Int64(v["publish_time"]) + 3600*24
+			}
 			bl := &InfoList{
 			bl := &InfoList{
 				Title:   gconv.String(fmt.Sprintf("【%s】%s", consts.TopTypeMap[gconv.String(v["toptype"])], v["title"])),
 				Title:   gconv.String(fmt.Sprintf("【%s】%s", consts.TopTypeMap[gconv.String(v["toptype"])], v["title"])),
 				Url:     fmt.Sprintf("/jybx/%s_%s.html", gtime.NewFromTimeStamp(publishTime).Format("Ymd"), gconv.String(v["seo_id"])),
 				Url:     fmt.Sprintf("/jybx/%s_%s.html", gtime.NewFromTimeStamp(publishTime).Format("Ymd"), gconv.String(v["seo_id"])),
@@ -100,7 +106,6 @@ func (query *SeoBiddingQuery) dataFormat(data []map[string]interface{}) (bList [
 			if val := titleReduction[bl.Title]; val > 1 {
 			if val := titleReduction[bl.Title]; val > 1 {
 				bl.Title = fmt.Sprintf("%s%d", bl.Title, val-1)
 				bl.Title = fmt.Sprintf("%s%d", bl.Title, val-1)
 			}
 			}
-
 			bl.PublishTime = publishTime //增加一天 更新天数
 			bl.PublishTime = publishTime //增加一天 更新天数
 
 
 			if gconv.String(v["area"]) == "剑鱼信息发布平台" {
 			if gconv.String(v["area"]) == "剑鱼信息发布平台" {