@@ -11,6 +11,7 @@ import (
1111 "html/template"
1212 "regexp"
1313 "strings"
14+ "time"
1415
1516 "github.com/studygolang/studygolang/db"
1617)
@@ -53,7 +54,7 @@ func NewDocument(object interface{}, objectExt interface{}) *Document {
5354 case * Topic :
5455 viewnum , cmtnum , likenum := 0 , 0 , 0
5556 if objectExt != nil {
56- // 传递过来的是一个 *TopicEx 对象,类型是有的,即时值是 nil,这里也和 nil 是不等
57+ // 传递过来的是一个 *TopicEx 对象,类型是有的,即使值是 nil,这里也和 nil 是不等
5758 topicEx := objectExt .(* TopicUpEx )
5859 if topicEx != nil {
5960 viewnum = topicEx .View
@@ -62,11 +63,9 @@ func NewDocument(object interface{}, objectExt interface{}) *Document {
6263 }
6364 }
6465
65- var sortTime = NewOftenTime ()
66- if objdoc .Lastreplyuid != 0 {
66+ var sortTime = objdoc . Ctime
67+ if objdoc .Lastreplyuid != 0 && time . Since ( time . Time ( sortTime )) < 120 * 24 * time . Hour {
6768 sortTime = objdoc .Lastreplytime
68- } else {
69- sortTime = objdoc .Ctime
7069 }
7170
7271 userLogin := & UserLogin {}
@@ -102,11 +101,9 @@ func NewDocument(object interface{}, objectExt interface{}) *Document {
102101 uid = userLogin .Uid
103102 }
104103
105- var sortTime = NewOftenTime ()
106- if objdoc .Lastreplyuid != 0 {
104+ var sortTime = objdoc . Ctime
105+ if objdoc .Lastreplyuid != 0 && time . Since ( time . Time ( sortTime )) < 120 * 24 * time . Hour {
107106 sortTime = objdoc .Lastreplytime
108- } else {
109- sortTime = objdoc .Ctime
110107 }
111108
112109 document = & Document {
@@ -140,11 +137,9 @@ func NewDocument(object interface{}, objectExt interface{}) *Document {
140137 }
141138 }
142139
143- var sortTime = NewOftenTime ()
144- if objdoc .Lastreplyuid != 0 {
140+ var sortTime = objdoc . Ctime
141+ if objdoc .Lastreplyuid != 0 && time . Since ( time . Time ( sortTime )) < 120 * 24 * time . Hour {
145142 sortTime = objdoc .Lastreplytime
146- } else {
147- sortTime = objdoc .Ctime
148143 }
149144
150145 userLogin := & UserLogin {}
@@ -174,11 +169,9 @@ func NewDocument(object interface{}, objectExt interface{}) *Document {
174169 userLogin := & UserLogin {}
175170 db .MasterDB .Where ("username=?" , objdoc .Username ).Get (userLogin )
176171
177- var sortTime = NewOftenTime ()
178- if objdoc .Lastreplyuid != 0 {
172+ var sortTime = objdoc . Ctime
173+ if objdoc .Lastreplyuid != 0 && time . Since ( time . Time ( sortTime )) < 120 * 24 * time . Hour {
179174 sortTime = objdoc .Lastreplytime
180- } else {
181- sortTime = objdoc .Ctime
182175 }
183176
184177 document = & Document {
0 commit comments