diff --git a/docs/docs.go b/docs/docs.go index 119db1fe..eb99dfca 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -4709,6 +4709,9 @@ const docTemplate = `{ }, "title": { "type": "string" + }, + "username": { + "type": "string" } } }, diff --git a/docs/swagger.json b/docs/swagger.json index 097f3938..6af9f310 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -4697,6 +4697,9 @@ }, "title": { "type": "string" + }, + "username": { + "type": "string" } } }, diff --git a/docs/swagger.yaml b/docs/swagger.yaml index a3f3ce70..abd78c89 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -99,6 +99,8 @@ definitions: type: string title: type: string + username: + type: string type: object schema.ActObjectTimeline: properties: diff --git a/internal/entity/question_entity.go b/internal/entity/question_entity.go index fd459e71..93d94cd6 100644 --- a/internal/entity/question_entity.go +++ b/internal/entity/question_entity.go @@ -31,7 +31,7 @@ type QuestionTag struct { type Question struct { ID string `xorm:"not null pk BIGINT(20) id"` CreatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP TIMESTAMP created_at"` - UpdatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP TIMESTAMP updated_at"` + UpdatedAt time.Time `xorm:"updated_at TIMESTAMP"` UserID string `xorm:"not null default 0 BIGINT(20) INDEX user_id"` Title string `xorm:"not null default '' VARCHAR(150) title"` OriginalText string `xorm:"not null MEDIUMTEXT original_text"` @@ -45,7 +45,7 @@ type Question struct { FollowCount int `xorm:"not null default 0 INT(11) follow_count"` AcceptedAnswerID string `xorm:"not null default 0 BIGINT(20) accepted_answer_id"` LastAnswerID string `xorm:"not null default 0 BIGINT(20) last_answer_id"` - PostUpdateTime time.Time `xorm:"default CURRENT_TIMESTAMP TIMESTAMP post_update_time"` + PostUpdateTime time.Time `xorm:"post_update_time TIMESTAMP"` RevisionID string `xorm:"not null default 0 BIGINT(20) revision_id"` } diff --git a/internal/service/question_common/question.go b/internal/service/question_common/question.go index 479238eb..72cfba92 100644 --- a/internal/service/question_common/question.go +++ b/internal/service/question_common/question.go @@ -380,7 +380,13 @@ func (qs *QuestionCommon) ShowFormat(ctx context.Context, data *entity.Question) info.CreateTime = data.CreatedAt.Unix() info.UpdateTime = data.UpdatedAt.Unix() info.PostUpdateTime = data.PostUpdateTime.Unix() + if data.PostUpdateTime.Unix() < 1 { + info.PostUpdateTime = 0 + } info.QuestionUpdateTime = data.UpdatedAt.Unix() + if data.UpdatedAt.Unix() < 1 { + info.QuestionUpdateTime = 0 + } info.Status = data.Status info.UserID = data.UserID info.Tags = make([]*schema.TagResp, 0) diff --git a/internal/service/question_service.go b/internal/service/question_service.go index 08c84b0b..1c929ece 100644 --- a/internal/service/question_service.go +++ b/internal/service/question_service.go @@ -149,11 +149,11 @@ func (qs *QuestionService) AddQuestion(ctx context.Context, req *schema.Question question.ParsedText = req.HTML question.AcceptedAnswerID = "0" question.LastAnswerID = "0" - question.PostUpdateTime = now + //question.PostUpdateTime = nil question.Status = entity.QuestionStatusAvailable question.RevisionID = "0" question.CreatedAt = now - // question.UpdatedAt = now + //question.UpdatedAt = nil err = qs.questionRepo.AddQuestion(ctx, question) if err != nil { return