mirror of https://gitee.com/answerdev/answer.git
update question edit userid
This commit is contained in:
parent
bfd9530b1f
commit
b093358e0c
118
docs/docs.go
118
docs/docs.go
|
@ -3074,7 +3074,7 @@ const docTemplate = `{
|
|||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "check can update question",
|
||||
"description": "check can update revision",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
|
@ -3084,7 +3084,7 @@ const docTemplate = `{
|
|||
"tags": [
|
||||
"Revision"
|
||||
],
|
||||
"summary": "check can update question",
|
||||
"summary": "check can update revision",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
|
@ -3141,10 +3141,22 @@ const docTemplate = `{
|
|||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/schema.GetRevisionResp"
|
||||
}
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/pager.PageModel"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"list": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/schema.GetUnreviewedRevisionResp"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3470,10 +3482,7 @@ const docTemplate = `{
|
|||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/schema.GetTagSynonymsResp"
|
||||
}
|
||||
"$ref": "#/definitions/schema.GetTagSynonymsResp"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4701,6 +4710,9 @@ const docTemplate = `{
|
|||
"answer_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"display_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"object_type": {
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -5547,21 +5559,33 @@ const docTemplate = `{
|
|||
"schema.GetTagSynonymsResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"display_name": {
|
||||
"description": "display name",
|
||||
"member_actions": {
|
||||
"description": "MemberActions",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/schema.PermissionMemberAction"
|
||||
}
|
||||
},
|
||||
"synonyms": {
|
||||
"description": "synonyms",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/schema.TagSynonym"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.GetUnreviewedRevisionResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"info": {
|
||||
"$ref": "#/definitions/schema.UnreviewedRevisionInfoInfo"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"main_tag_slug_name": {
|
||||
"description": "if main tag slug name is not empty, this tag is synonymous with the main tag",
|
||||
"type": "string"
|
||||
},
|
||||
"slug_name": {
|
||||
"description": "slug name",
|
||||
"type": "string"
|
||||
},
|
||||
"tag_id": {
|
||||
"description": "tag id",
|
||||
"type": "string"
|
||||
"unreviewed_info": {
|
||||
"$ref": "#/definitions/schema.GetRevisionResp"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -6203,9 +6227,7 @@ const docTemplate = `{
|
|||
"type": "object",
|
||||
"required": [
|
||||
"contact_email",
|
||||
"description",
|
||||
"name",
|
||||
"short_description",
|
||||
"site_url"
|
||||
],
|
||||
"properties": {
|
||||
|
@ -6235,9 +6257,7 @@ const docTemplate = `{
|
|||
"type": "object",
|
||||
"required": [
|
||||
"contact_email",
|
||||
"description",
|
||||
"name",
|
||||
"short_description",
|
||||
"site_url"
|
||||
],
|
||||
"properties": {
|
||||
|
@ -6425,6 +6445,50 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.TagSynonym": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"display_name": {
|
||||
"description": "display name",
|
||||
"type": "string"
|
||||
},
|
||||
"main_tag_slug_name": {
|
||||
"description": "if main tag slug name is not empty, this tag is synonymous with the main tag",
|
||||
"type": "string"
|
||||
},
|
||||
"slug_name": {
|
||||
"description": "slug name",
|
||||
"type": "string"
|
||||
},
|
||||
"tag_id": {
|
||||
"description": "tag id",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.UnreviewedRevisionInfoInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "string"
|
||||
},
|
||||
"html": {
|
||||
"type": "string"
|
||||
},
|
||||
"object_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/schema.TagResp"
|
||||
}
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.UpdateCommentReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
@ -3062,7 +3062,7 @@
|
|||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "check can update question",
|
||||
"description": "check can update revision",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
|
@ -3072,7 +3072,7 @@
|
|||
"tags": [
|
||||
"Revision"
|
||||
],
|
||||
"summary": "check can update question",
|
||||
"summary": "check can update revision",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
|
@ -3129,10 +3129,22 @@
|
|||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/schema.GetRevisionResp"
|
||||
}
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/pager.PageModel"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"list": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/schema.GetUnreviewedRevisionResp"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3458,10 +3470,7 @@
|
|||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/schema.GetTagSynonymsResp"
|
||||
}
|
||||
"$ref": "#/definitions/schema.GetTagSynonymsResp"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4689,6 +4698,9 @@
|
|||
"answer_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"display_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"object_type": {
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -5535,21 +5547,33 @@
|
|||
"schema.GetTagSynonymsResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"display_name": {
|
||||
"description": "display name",
|
||||
"member_actions": {
|
||||
"description": "MemberActions",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/schema.PermissionMemberAction"
|
||||
}
|
||||
},
|
||||
"synonyms": {
|
||||
"description": "synonyms",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/schema.TagSynonym"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.GetUnreviewedRevisionResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"info": {
|
||||
"$ref": "#/definitions/schema.UnreviewedRevisionInfoInfo"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"main_tag_slug_name": {
|
||||
"description": "if main tag slug name is not empty, this tag is synonymous with the main tag",
|
||||
"type": "string"
|
||||
},
|
||||
"slug_name": {
|
||||
"description": "slug name",
|
||||
"type": "string"
|
||||
},
|
||||
"tag_id": {
|
||||
"description": "tag id",
|
||||
"type": "string"
|
||||
"unreviewed_info": {
|
||||
"$ref": "#/definitions/schema.GetRevisionResp"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -6191,9 +6215,7 @@
|
|||
"type": "object",
|
||||
"required": [
|
||||
"contact_email",
|
||||
"description",
|
||||
"name",
|
||||
"short_description",
|
||||
"site_url"
|
||||
],
|
||||
"properties": {
|
||||
|
@ -6223,9 +6245,7 @@
|
|||
"type": "object",
|
||||
"required": [
|
||||
"contact_email",
|
||||
"description",
|
||||
"name",
|
||||
"short_description",
|
||||
"site_url"
|
||||
],
|
||||
"properties": {
|
||||
|
@ -6413,6 +6433,50 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.TagSynonym": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"display_name": {
|
||||
"description": "display name",
|
||||
"type": "string"
|
||||
},
|
||||
"main_tag_slug_name": {
|
||||
"description": "if main tag slug name is not empty, this tag is synonymous with the main tag",
|
||||
"type": "string"
|
||||
},
|
||||
"slug_name": {
|
||||
"description": "slug name",
|
||||
"type": "string"
|
||||
},
|
||||
"tag_id": {
|
||||
"description": "tag id",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.UnreviewedRevisionInfoInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "string"
|
||||
},
|
||||
"html": {
|
||||
"type": "string"
|
||||
},
|
||||
"object_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/schema.TagResp"
|
||||
}
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.UpdateCommentReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
@ -93,6 +93,8 @@ definitions:
|
|||
properties:
|
||||
answer_id:
|
||||
type: string
|
||||
display_name:
|
||||
type: string
|
||||
object_type:
|
||||
type: string
|
||||
question_id:
|
||||
|
@ -697,19 +699,25 @@ definitions:
|
|||
type: object
|
||||
schema.GetTagSynonymsResp:
|
||||
properties:
|
||||
display_name:
|
||||
description: display name
|
||||
type: string
|
||||
main_tag_slug_name:
|
||||
description: if main tag slug name is not empty, this tag is synonymous with
|
||||
the main tag
|
||||
type: string
|
||||
slug_name:
|
||||
description: slug name
|
||||
type: string
|
||||
tag_id:
|
||||
description: tag id
|
||||
member_actions:
|
||||
description: MemberActions
|
||||
items:
|
||||
$ref: '#/definitions/schema.PermissionMemberAction'
|
||||
type: array
|
||||
synonyms:
|
||||
description: synonyms
|
||||
items:
|
||||
$ref: '#/definitions/schema.TagSynonym'
|
||||
type: array
|
||||
type: object
|
||||
schema.GetUnreviewedRevisionResp:
|
||||
properties:
|
||||
info:
|
||||
$ref: '#/definitions/schema.UnreviewedRevisionInfoInfo'
|
||||
type:
|
||||
type: string
|
||||
unreviewed_info:
|
||||
$ref: '#/definitions/schema.GetRevisionResp'
|
||||
type: object
|
||||
schema.GetUserPageResp:
|
||||
properties:
|
||||
|
@ -1189,9 +1197,7 @@ definitions:
|
|||
type: string
|
||||
required:
|
||||
- contact_email
|
||||
- description
|
||||
- name
|
||||
- short_description
|
||||
- site_url
|
||||
type: object
|
||||
schema.SiteGeneralResp:
|
||||
|
@ -1213,9 +1219,7 @@ definitions:
|
|||
type: string
|
||||
required:
|
||||
- contact_email
|
||||
- description
|
||||
- name
|
||||
- short_description
|
||||
- site_url
|
||||
type: object
|
||||
schema.SiteInterfaceReq:
|
||||
|
@ -1330,6 +1334,37 @@ definitions:
|
|||
slug_name:
|
||||
type: string
|
||||
type: object
|
||||
schema.TagSynonym:
|
||||
properties:
|
||||
display_name:
|
||||
description: display name
|
||||
type: string
|
||||
main_tag_slug_name:
|
||||
description: if main tag slug name is not empty, this tag is synonymous with
|
||||
the main tag
|
||||
type: string
|
||||
slug_name:
|
||||
description: slug name
|
||||
type: string
|
||||
tag_id:
|
||||
description: tag id
|
||||
type: string
|
||||
type: object
|
||||
schema.UnreviewedRevisionInfoInfo:
|
||||
properties:
|
||||
content:
|
||||
type: string
|
||||
html:
|
||||
type: string
|
||||
object_id:
|
||||
type: string
|
||||
tags:
|
||||
items:
|
||||
$ref: '#/definitions/schema.TagResp'
|
||||
type: array
|
||||
title:
|
||||
type: string
|
||||
type: object
|
||||
schema.UpdateCommentReq:
|
||||
properties:
|
||||
comment_id:
|
||||
|
@ -3510,7 +3545,7 @@ paths:
|
|||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: check can update question
|
||||
description: check can update revision
|
||||
parameters:
|
||||
- default: string
|
||||
description: id
|
||||
|
@ -3527,7 +3562,7 @@ paths:
|
|||
$ref: '#/definitions/handler.RespBody'
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: check can update question
|
||||
summary: check can update revision
|
||||
tags:
|
||||
- Revision
|
||||
/answer/api/v1/revisions/unreviewed:
|
||||
|
@ -3549,9 +3584,14 @@ paths:
|
|||
- $ref: '#/definitions/handler.RespBody'
|
||||
- properties:
|
||||
data:
|
||||
items:
|
||||
$ref: '#/definitions/schema.GetRevisionResp'
|
||||
type: array
|
||||
allOf:
|
||||
- $ref: '#/definitions/pager.PageModel'
|
||||
- properties:
|
||||
list:
|
||||
items:
|
||||
$ref: '#/definitions/schema.GetUnreviewedRevisionResp'
|
||||
type: array
|
||||
type: object
|
||||
type: object
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
|
@ -3753,9 +3793,7 @@ paths:
|
|||
- $ref: '#/definitions/handler.RespBody'
|
||||
- properties:
|
||||
data:
|
||||
items:
|
||||
$ref: '#/definitions/schema.GetTagSynonymsResp'
|
||||
type: array
|
||||
$ref: '#/definitions/schema.GetTagSynonymsResp'
|
||||
type: object
|
||||
summary: get tag synonyms
|
||||
tags:
|
||||
|
|
|
@ -18,18 +18,19 @@ var CmsAnswerSearchStatus = map[string]int{
|
|||
|
||||
// Answer answer
|
||||
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:"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"`
|
||||
ParsedText string `xorm:"not null MEDIUMTEXT parsed_text"`
|
||||
Status int `xorm:"not null default 1 INT(11) status"`
|
||||
Adopted int `xorm:"not null default 1 INT(11) adopted"`
|
||||
CommentCount int `xorm:"not null default 0 INT(11) comment_count"`
|
||||
VoteCount int `xorm:"not null default 0 INT(11) vote_count"`
|
||||
RevisionID string `xorm:"not null default 0 BIGINT(20) revision_id"`
|
||||
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:"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"`
|
||||
LastEditUserID string `xorm:"not null default 0 BIGINT(20) last_edit_user_id"`
|
||||
OriginalText string `xorm:"not null MEDIUMTEXT original_text"`
|
||||
ParsedText string `xorm:"not null MEDIUMTEXT parsed_text"`
|
||||
Status int `xorm:"not null default 1 INT(11) status"`
|
||||
Adopted int `xorm:"not null default 1 INT(11) adopted"`
|
||||
CommentCount int `xorm:"not null default 0 INT(11) comment_count"`
|
||||
VoteCount int `xorm:"not null default 0 INT(11) vote_count"`
|
||||
RevisionID string `xorm:"not null default 0 BIGINT(20) revision_id"`
|
||||
}
|
||||
|
||||
type AnswerSearch struct {
|
||||
|
|
|
@ -33,6 +33,7 @@ type Question struct {
|
|||
CreatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP TIMESTAMP created_at"`
|
||||
UpdatedAt time.Time `xorm:"updated_at TIMESTAMP"`
|
||||
UserID string `xorm:"not null default 0 BIGINT(20) INDEX user_id"`
|
||||
LastEditUserID string `xorm:"not null default 0 BIGINT(20) last_edit_user_id"`
|
||||
Title string `xorm:"not null default '' VARCHAR(150) title"`
|
||||
OriginalText string `xorm:"not null MEDIUMTEXT original_text"`
|
||||
ParsedText string `xorm:"not null MEDIUMTEXT parsed_text"`
|
||||
|
|
|
@ -57,6 +57,7 @@ type AnswerInfo struct {
|
|||
UpdateTime int64 `json:"update_time" xorm:"updated"` // update_time
|
||||
Adopted int `json:"adopted"` // 1 Failed 2 Adopted
|
||||
UserID string `json:"-" `
|
||||
UpdateUserID string `json:"-" `
|
||||
UserInfo *UserBasicInfo `json:"user_info,omitempty"`
|
||||
UpdateUserInfo *UserBasicInfo `json:"update_user_info,omitempty"`
|
||||
Collected bool `json:"collected"`
|
||||
|
@ -76,6 +77,7 @@ type AdminAnswerInfo struct {
|
|||
UpdateTime int64 `json:"update_time"`
|
||||
Adopted int `json:"adopted"`
|
||||
UserID string `json:"-" `
|
||||
UpdateUserID string `json:"-" `
|
||||
UserInfo *UserBasicInfo `json:"user_info"`
|
||||
VoteCount int `json:"vote_count"`
|
||||
QuestionInfo struct {
|
||||
|
|
|
@ -106,6 +106,8 @@ type QuestionInfo struct {
|
|||
Status int `json:"status"`
|
||||
Operation *Operation `json:"operation,omitempty"`
|
||||
UserID string `json:"-" `
|
||||
LastEditUserID string `json:"-" `
|
||||
LastAnsweredUserID string `json:"-" `
|
||||
UserInfo *UserBasicInfo `json:"user_info"`
|
||||
UpdateUserInfo *UserBasicInfo `json:"update_user_info,omitempty"`
|
||||
LastAnsweredUserInfo *UserBasicInfo `json:"last_answered_user_info,omitempty"`
|
||||
|
|
|
@ -72,6 +72,7 @@ func (as *AnswerCommon) ShowFormat(ctx context.Context, data *entity.Answer) *sc
|
|||
info.UpdateTime = 0
|
||||
}
|
||||
info.UserID = data.UserID
|
||||
info.UpdateUserID = data.LastEditUserID
|
||||
return &info
|
||||
}
|
||||
|
||||
|
@ -87,6 +88,7 @@ func (as *AnswerCommon) AdminShowFormat(ctx context.Context, data *entity.Answer
|
|||
info.UpdateTime = 0
|
||||
}
|
||||
info.UserID = data.UserID
|
||||
info.UpdateUserID = data.LastEditUserID
|
||||
info.Description = htmltext.FetchExcerpt(data.ParsedText, "...", 240)
|
||||
return &info
|
||||
}
|
||||
|
|
|
@ -225,11 +225,15 @@ func (as *AnswerService) Update(ctx context.Context, req *schema.AnswerUpdateReq
|
|||
insertData := new(entity.Answer)
|
||||
insertData.ID = req.ID
|
||||
insertData.QuestionID = req.QuestionID
|
||||
insertData.UserID = req.UserID
|
||||
insertData.OriginalText = req.Content
|
||||
insertData.ParsedText = req.HTML
|
||||
insertData.UpdatedAt = now
|
||||
|
||||
insertData.LastEditUserID = "0"
|
||||
if answerInfo.UserID != req.UserID {
|
||||
insertData.LastEditUserID = req.UserID
|
||||
}
|
||||
|
||||
revisionDTO := &schema.AddRevisionDTO{
|
||||
UserID: req.UserID,
|
||||
ObjectID: req.ID,
|
||||
|
@ -457,6 +461,7 @@ func (as *AnswerService) SearchFormatInfo(ctx context.Context, answers []*entity
|
|||
list = append(list, item)
|
||||
objectIDs = append(objectIDs, info.ID)
|
||||
userIDs = append(userIDs, info.UserID)
|
||||
userIDs = append(userIDs, info.LastEditUserID)
|
||||
if req.UserID != "" {
|
||||
item.VoteStatus = as.voteRepo.GetVoteStatus(ctx, item.ID, req.UserID)
|
||||
}
|
||||
|
@ -469,7 +474,10 @@ func (as *AnswerService) SearchFormatInfo(ctx context.Context, answers []*entity
|
|||
_, ok := userInfoMap[item.UserID]
|
||||
if ok {
|
||||
item.UserInfo = userInfoMap[item.UserID]
|
||||
item.UpdateUserInfo = userInfoMap[item.UserID]
|
||||
}
|
||||
_, ok = userInfoMap[item.UpdateUserID]
|
||||
if ok {
|
||||
item.UpdateUserInfo = userInfoMap[item.UpdateUserID]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -234,6 +234,9 @@ func (qs *QuestionCommon) ListFormat(ctx context.Context, questionList []*entity
|
|||
list = append(list, item)
|
||||
objectIds = append(objectIds, item.ID)
|
||||
userIds = append(userIds, questionInfo.UserID)
|
||||
userIds = append(userIds, questionInfo.LastEditUserID)
|
||||
userIds = append(userIds, item.LastAnsweredUserID)
|
||||
|
||||
}
|
||||
tagsMap, err := qs.tagCommon.BatchGetObjectTag(ctx, objectIds)
|
||||
if err != nil {
|
||||
|
@ -254,7 +257,14 @@ func (qs *QuestionCommon) ListFormat(ctx context.Context, questionList []*entity
|
|||
if ok {
|
||||
item.UserInfo = userInfoMap[item.UserID]
|
||||
item.UpdateUserInfo = userInfoMap[item.UserID]
|
||||
item.LastAnsweredUserInfo = userInfoMap[item.UserID]
|
||||
}
|
||||
_, ok = userInfoMap[item.LastEditUserID]
|
||||
if ok {
|
||||
item.UpdateUserInfo = userInfoMap[item.UserID]
|
||||
}
|
||||
_, ok = userInfoMap[item.LastAnsweredUserID]
|
||||
if ok {
|
||||
item.LastAnsweredUserInfo = userInfoMap[item.LastAnsweredUserID]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -389,6 +399,18 @@ func (qs *QuestionCommon) ShowFormat(ctx context.Context, data *entity.Question)
|
|||
}
|
||||
info.Status = data.Status
|
||||
info.UserID = data.UserID
|
||||
info.LastEditUserID = data.LastEditUserID
|
||||
if data.LastAnswerID != "0" {
|
||||
answerInfo, exist, err := qs.answerRepo.GetAnswer(ctx, data.LastAnswerID)
|
||||
if err == nil && exist {
|
||||
if answerInfo.LastEditUserID != "0" {
|
||||
info.LastAnsweredUserID = answerInfo.LastEditUserID
|
||||
} else {
|
||||
info.LastAnsweredUserID = answerInfo.UserID
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
info.Tags = make([]*schema.TagResp, 0)
|
||||
return &info
|
||||
}
|
||||
|
|
|
@ -284,7 +284,6 @@ func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.Quest
|
|||
|
||||
now := time.Now()
|
||||
question := &entity.Question{}
|
||||
question.UserID = req.UserID
|
||||
question.Title = req.Title
|
||||
question.OriginalText = req.Content
|
||||
question.ParsedText = req.HTML
|
||||
|
@ -298,6 +297,10 @@ func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.Quest
|
|||
if !has {
|
||||
return
|
||||
}
|
||||
question.LastEditUserID = "0"
|
||||
if dbinfo.UserID != req.UserID {
|
||||
question.LastEditUserID = req.UserID
|
||||
}
|
||||
|
||||
oldTags, tagerr := qs.tagCommon.GetObjectEntityTag(ctx, question.ID)
|
||||
if tagerr != nil {
|
||||
|
@ -377,7 +380,7 @@ func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.Quest
|
|||
//Direct modification
|
||||
revisionDTO.Status = entity.RevisionReviewPassStatus
|
||||
//update question to db
|
||||
saveerr := qs.questionRepo.UpdateQuestion(ctx, question, []string{"title", "original_text", "parsed_text", "updated_at", "post_update_time"})
|
||||
saveerr := qs.questionRepo.UpdateQuestion(ctx, question, []string{"title", "original_text", "parsed_text", "updated_at", "post_update_time", "last_edit_user_id"})
|
||||
if saveerr != nil {
|
||||
return questionInfo, saveerr
|
||||
}
|
||||
|
|
|
@ -128,7 +128,8 @@ func (rs *RevisionService) revisionAuditQuestion(ctx context.Context, revisionit
|
|||
question.ParsedText = questioninfo.HTML
|
||||
question.UpdatedAt = now
|
||||
question.PostUpdateTime = now
|
||||
saveerr := rs.questionRepo.UpdateQuestion(ctx, question, []string{"title", "original_text", "parsed_text", "updated_at", "post_update_time"})
|
||||
question.LastEditUserID = revisionitem.UserID
|
||||
saveerr := rs.questionRepo.UpdateQuestion(ctx, question, []string{"title", "original_text", "parsed_text", "updated_at", "post_update_time", "last_edit_user_id"})
|
||||
if saveerr != nil {
|
||||
return saveerr
|
||||
}
|
||||
|
@ -165,7 +166,8 @@ func (rs *RevisionService) revisionAuditAnswer(ctx context.Context, revisionitem
|
|||
insertData.OriginalText = answerinfo.Content
|
||||
insertData.ParsedText = answerinfo.HTML
|
||||
insertData.UpdatedAt = now
|
||||
saveerr := rs.answerRepo.UpdateAnswer(ctx, insertData, []string{"original_text", "parsed_text", "update_time"})
|
||||
insertData.LastEditUserID = revisionitem.UserID
|
||||
saveerr := rs.answerRepo.UpdateAnswer(ctx, insertData, []string{"original_text", "parsed_text", "update_time", "last_edit_user_id"})
|
||||
if saveerr != nil {
|
||||
return saveerr
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue