Merge branch 'feat/0.5.0/timeline_ai' into test

This commit is contained in:
aichy126 2022-12-01 14:40:19 +08:00
commit e6a42e62ea
3 changed files with 8 additions and 3 deletions

View File

@ -20,7 +20,7 @@ var CmsAnswerSearchStatus = map[string]int{
type Answer struct {
ID string `xorm:"not null pk autoincr BIGINT(20) id"`
CreatedAt time.Time `xorm:"created 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"`
QuestionID string `xorm:"not null default 0 BIGINT(20) question_id"`
UserID string `xorm:"not null default 0 BIGINT(20) INDEX user_id"`
OriginalText string `xorm:"not null MEDIUMTEXT original_text"`

View File

@ -68,6 +68,9 @@ func (as *AnswerCommon) ShowFormat(ctx context.Context, data *entity.Answer) *sc
info.VoteCount = data.VoteCount
info.CreateTime = data.CreatedAt.Unix()
info.UpdateTime = data.UpdatedAt.Unix()
if data.UpdatedAt.Unix() < 1 {
info.UpdateTime = 0
}
info.UserID = data.UserID
return &info
}
@ -80,6 +83,9 @@ func (as *AnswerCommon) AdminShowFormat(ctx context.Context, data *entity.Answer
info.VoteCount = data.VoteCount
info.CreateTime = data.CreatedAt.Unix()
info.UpdateTime = data.UpdatedAt.Unix()
if data.UpdatedAt.Unix() < 1 {
info.UpdateTime = 0
}
info.UserID = data.UserID
info.Description = htmltext.FetchExcerpt(data.ParsedText, "...", 240)
return &info

View File

@ -134,7 +134,6 @@ func (as *AnswerService) Insert(ctx context.Context, req *schema.AnswerAddReq) (
if !exist {
return "", errors.BadRequest(reason.QuestionNotFound)
}
now := time.Now()
insertData := new(entity.Answer)
insertData.UserID = req.UserID
insertData.OriginalText = req.Content
@ -143,7 +142,7 @@ func (as *AnswerService) Insert(ctx context.Context, req *schema.AnswerAddReq) (
insertData.QuestionID = req.QuestionID
insertData.RevisionID = "0"
insertData.Status = entity.AnswerStatusAvailable
insertData.UpdatedAt = now
//insertData.UpdatedAt = now
if err = as.answerRepo.AddAnswer(ctx, insertData); err != nil {
return "", err
}