This commit is contained in:
aichy126 2022-11-29 14:56:22 +08:00
parent 80d0a8fbd3
commit 22e683a0b8
6 changed files with 18 additions and 4 deletions

View File

@ -4709,6 +4709,9 @@ const docTemplate = `{
},
"title": {
"type": "string"
},
"username": {
"type": "string"
}
}
},

View File

@ -4697,6 +4697,9 @@
},
"title": {
"type": "string"
},
"username": {
"type": "string"
}
}
},

View File

@ -99,6 +99,8 @@ definitions:
type: string
title:
type: string
username:
type: string
type: object
schema.ActObjectTimeline:
properties:

View File

@ -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"`
}

View File

@ -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)

View File

@ -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