Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

update Adopt to Accept

aichyb8077d37b3ab
diff --git a/docs/docs.go b/docs/docs.go
index aa9df9cb..ea930eba 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -1671,7 +1671,7 @@ const docTemplate = `{
"ApiKeyAuth": []
}
],
- "description": "Adopted",
+ "description": "Accepted",
"consumes": [
"application/json"
],
@@ -1681,15 +1681,15 @@ const docTemplate = `{
"tags": [
"api-answer"
],
- "summary": "Adopted",
+ "summary": "Accepted",
"parameters": [
{
- "description": "AnswerAdoptedReq",
+ "description": "AnswerAcceptedReq",
"name": "data",
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/schema.AnswerAdoptedReq"
+ "$ref": "#/definitions/schema.AnswerAcceptedReq"
}
}
],
@@ -5490,30 +5490,30 @@ const docTemplate = `{
}
}
},
- "schema.AnswerAddReq": {
+ "schema.AnswerAcceptedReq": {
"type": "object",
"properties": {
- "content": {
- "description": "content",
- "type": "string"
- },
- "html": {
- "description": "html",
+ "answer_id": {
"type": "string"
},
"question_id": {
- "description": "question_id",
"type": "string"
}
}
},
- "schema.AnswerAdoptedReq": {
+ "schema.AnswerAddReq": {
"type": "object",
"properties": {
- "answer_id": {
+ "content": {
+ "description": "content",
+ "type": "string"
+ },
+ "html": {
+ "description": "html",
"type": "string"
},
"question_id": {
+ "description": "question_id",
"type": "string"
}
}
diff --git a/docs/swagger.json b/docs/swagger.json
index 5eb74132..883e57cb 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -1659,7 +1659,7 @@
"ApiKeyAuth": []
}
],
- "description": "Adopted",
+ "description": "Accepted",
"consumes": [
"application/json"
],
@@ -1669,15 +1669,15 @@
"tags": [
"api-answer"
],
- "summary": "Adopted",
+ "summary": "Accepted",
"parameters": [
{
- "description": "AnswerAdoptedReq",
+ "description": "AnswerAcceptedReq",
"name": "data",
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/schema.AnswerAdoptedReq"
+ "$ref": "#/definitions/schema.AnswerAcceptedReq"
}
}
],
@@ -5478,30 +5478,30 @@
}
}
},
- "schema.AnswerAddReq": {
+ "schema.AnswerAcceptedReq": {
"type": "object",
"properties": {
- "content": {
- "description": "content",
- "type": "string"
- },
- "html": {
- "description": "html",
+ "answer_id": {
"type": "string"
},
"question_id": {
- "description": "question_id",
"type": "string"
}
}
},
- "schema.AnswerAdoptedReq": {
+ "schema.AnswerAddReq": {
"type": "object",
"properties": {
- "answer_id": {
+ "content": {
+ "description": "content",
+ "type": "string"
+ },
+ "html": {
+ "description": "html",
"type": "string"
},
"question_id": {
+ "description": "question_id",
"type": "string"
}
}
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 03c30592..a5499337 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -207,6 +207,13 @@ definitions:
status:
type: string
type: object
+ schema.AnswerAcceptedReq:
+ properties:
+ answer_id:
+ type: string
+ question_id:
+ type: string
+ type: object
schema.AnswerAddReq:
properties:
content:
@@ -219,13 +226,6 @@ definitions:
description: question_id
type: string
type: object
- schema.AnswerAdoptedReq:
- properties:
- answer_id:
- type: string
- question_id:
- type: string
- type: object
schema.AnswerUpdateReq:
properties:
content:
@@ -2881,14 +2881,14 @@ paths:
post:
consumes:
- application/json
- description: Adopted
+ description: Accepted
parameters:
- - description: AnswerAdoptedReq
+ - description: AnswerAcceptedReq
in: body
name: data
required: true
schema:
- $ref: '#/definitions/schema.AnswerAdoptedReq'
+ $ref: '#/definitions/schema.AnswerAcceptedReq'
produces:
- application/json
responses:
@@ -2898,7 +2898,7 @@ paths:
type: string
security:
- ApiKeyAuth: []
- summary: Adopted
+ summary: Accepted
tags:
- api-answer
/answer/api/v1/answer/info:
diff --git a/i18n/de_DE.yaml b/i18n/de_DE.yaml
index 0d7825ae..20fd4aa4 100644
--- a/i18n/de_DE.yaml
+++ b/i18n/de_DE.yaml
@@ -205,7 +205,7 @@ backend:
other: "answered question"
update_answer:
other: "updated answer"
- adopt_answer:
+ accept_answer:
other: "accepted answer"
comment_question:
other: "commented question"
diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml
index e5a67c36..ab5c5141 100644
--- a/i18n/en_US.yaml
+++ b/i18n/en_US.yaml
@@ -210,7 +210,7 @@ backend:
other: "answered question"
update_answer:
other: "updated answer"
- adopt_answer:
+ accept_answer:
other: "accepted answer"
comment_question:
other: "commented question"
diff --git a/i18n/es_ES.yaml b/i18n/es_ES.yaml
index 0d7825ae..20fd4aa4 100644
--- a/i18n/es_ES.yaml
+++ b/i18n/es_ES.yaml
@@ -205,7 +205,7 @@ backend:
other: "answered question"
update_answer:
other: "updated answer"
- adopt_answer:
+ accept_answer:
other: "accepted answer"
comment_question:
other: "commented question"
diff --git a/i18n/fr_FR.yaml b/i18n/fr_FR.yaml
index 0d7825ae..20fd4aa4 100644
--- a/i18n/fr_FR.yaml
+++ b/i18n/fr_FR.yaml
@@ -205,7 +205,7 @@ backend:
other: "answered question"
update_answer:
other: "updated answer"
- adopt_answer:
+ accept_answer:
other: "accepted answer"
comment_question:
other: "commented question"
diff --git a/i18n/it_IT.yaml b/i18n/it_IT.yaml
index b03f54ba..a84add71 100644
--- a/i18n/it_IT.yaml
+++ b/i18n/it_IT.yaml
@@ -205,8 +205,8 @@ backend:
other: "domanda risposta"
update_answer:
other: "risposta aggiornata"
- adopt_answer:
- other: "risposta accettata"
+ accept_answer:
+ other: "risposta accepted"
comment_question:
other: "domanda commentata"
comment_answer:
diff --git a/i18n/ja_JP.yaml b/i18n/ja_JP.yaml
index 0d7825ae..20fd4aa4 100644
--- a/i18n/ja_JP.yaml
+++ b/i18n/ja_JP.yaml
@@ -205,7 +205,7 @@ backend:
other: "answered question"
update_answer:
other: "updated answer"
- adopt_answer:
+ accept_answer:
other: "accepted answer"
comment_question:
other: "commented question"
diff --git a/i18n/ko_KR.yaml b/i18n/ko_KR.yaml
index 0d7825ae..20fd4aa4 100644
--- a/i18n/ko_KR.yaml
+++ b/i18n/ko_KR.yaml
@@ -205,7 +205,7 @@ backend:
other: "answered question"
update_answer:
other: "updated answer"
- adopt_answer:
+ accept_answer:
other: "accepted answer"
comment_question:
other: "commented question"
diff --git a/i18n/pt_PT.yaml b/i18n/pt_PT.yaml
index 0d7825ae..20fd4aa4 100644
--- a/i18n/pt_PT.yaml
+++ b/i18n/pt_PT.yaml
@@ -205,7 +205,7 @@ backend:
other: "answered question"
update_answer:
other: "updated answer"
- adopt_answer:
+ accept_answer:
other: "accepted answer"
comment_question:
other: "commented question"
diff --git a/i18n/ru_RU.yaml b/i18n/ru_RU.yaml
index 0d7825ae..20fd4aa4 100644
--- a/i18n/ru_RU.yaml
+++ b/i18n/ru_RU.yaml
@@ -205,7 +205,7 @@ backend:
other: "answered question"
update_answer:
other: "updated answer"
- adopt_answer:
+ accept_answer:
other: "accepted answer"
comment_question:
other: "commented question"
diff --git a/i18n/vi_VN.yaml b/i18n/vi_VN.yaml
index 0d7825ae..20fd4aa4 100644
--- a/i18n/vi_VN.yaml
+++ b/i18n/vi_VN.yaml
@@ -205,7 +205,7 @@ backend:
other: "answered question"
update_answer:
other: "updated answer"
- adopt_answer:
+ accept_answer:
other: "accepted answer"
comment_question:
other: "commented question"
diff --git a/i18n/zh_CN.yaml b/i18n/zh_CN.yaml
index 909559fa..126ebefb 100644
--- a/i18n/zh_CN.yaml
+++ b/i18n/zh_CN.yaml
@@ -206,7 +206,7 @@ backend:
other: "回答了问题"
update_answer:
other: "更新了答案"
- adopt_answer:
+ accept_answer:
other: "接受了答案"
comment_question:
other: "评论了问题"
diff --git a/i18n/zh_TW.yaml b/i18n/zh_TW.yaml
index f9348d80..9f643136 100644
--- a/i18n/zh_TW.yaml
+++ b/i18n/zh_TW.yaml
@@ -205,7 +205,7 @@ backend:
other: "answered question"
update_answer:
other: "updated answer"
- adopt_answer:
+ accept_answer:
other: "accepted answer"
comment_question:
other: "commented question"
diff --git a/internal/base/constant/notification.go b/internal/base/constant/notification.go
index fe9fbf41..83856f64 100644
--- a/internal/base/constant/notification.go
+++ b/internal/base/constant/notification.go
@@ -7,8 +7,8 @@ const (
AnswerTheQuestion = "notification.action.answer_the_question"
// UpdateAnswer update answer
UpdateAnswer = "notification.action.update_answer"
- // AdoptAnswer adopt answer
- AdoptAnswer = "notification.action.adopt_answer"
+ // AcceptAnswer accept answer
+ AcceptAnswer = "notification.action.accept_answer"
// CommentQuestion comment question
CommentQuestion = "notification.action.comment_question"
// CommentAnswer comment answer
diff --git a/internal/controller/answer_controller.go b/internal/controller/answer_controller.go
index 7ca1f898..684988ef 100644
--- a/internal/controller/answer_controller.go
+++ b/internal/controller/answer_controller.go
@@ -232,18 +232,18 @@ func (ac *AnswerController) AnswerList(ctx *gin.Context) {
})
}
-// Adopted godoc
-// @Summary Adopted
-// @Description Adopted
+// Accepted godoc
+// @Summary Accepted
+// @Description Accepted
// @Tags api-answer
// @Accept json
// @Produce json
// @Security ApiKeyAuth
-// @Param data body schema.AnswerAdoptedReq true "AnswerAdoptedReq"
+// @Param data body schema.AnswerAcceptedReq true "AnswerAcceptedReq"
// @Success 200 {string} string ""
// @Router /answer/api/v1/answer/acceptance [post]
-func (ac *AnswerController) Adopted(ctx *gin.Context) {
- req := &schema.AnswerAdoptedReq{}
+func (ac *AnswerController) Accepted(ctx *gin.Context) {
+ req := &schema.AnswerAcceptedReq{}
if handler.BindAndCheck(ctx, req) {
return
}
@@ -259,7 +259,7 @@ func (ac *AnswerController) Adopted(ctx *gin.Context) {
return
}
- err = ac.answerService.UpdateAdopted(ctx, req)
+ err = ac.answerService.UpdateAccepted(ctx, req)
handler.HandleResponse(ctx, err, nil)
}
diff --git a/internal/controller/template_controller.go b/internal/controller/template_controller.go
index cf02268c..54316467 100644
--- a/internal/controller/template_controller.go
+++ b/internal/controller/template_controller.go
@@ -264,7 +264,7 @@ func (tc *TemplateController) QuestionInfo(ctx *gin.Context) {
jsonLD.MainEntity.Author.Name = detail.UserInfo.DisplayName
answerList := make([]*schema.SuggestedAnswerItem, 0)
for _, answer := range answers {
- if answer.Adopted == schema.AnswerAdoptedEnable {
+ if answer.Accepted == schema.AnswerAcceptedEnable {
acceptedAnswerItem := &schema.AcceptedAnswerItem{}
acceptedAnswerItem.Type = "Answer"
acceptedAnswerItem.Text = answer.HTML
diff --git a/internal/entity/answer_entity.go b/internal/entity/answer_entity.go
index 7cc4ec83..8c3bcdb1 100644
--- a/internal/entity/answer_entity.go
+++ b/internal/entity/answer_entity.go
@@ -27,7 +27,7 @@ type Answer struct {
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"`
+ Accepted 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"`
diff --git a/internal/repo/activity/answer_repo.go b/internal/repo/activity/answer_repo.go
index a6eb47cc..cb0d25f2 100644
--- a/internal/repo/activity/answer_repo.go
+++ b/internal/repo/activity/answer_repo.go
@@ -214,7 +214,7 @@ func (ar *AnswerActivityRepo) AcceptAnswer(ctx context.Context,
if act.UserID != questionUserID {
msg.TriggerUserID = questionUserID
msg.ObjectType = constant.AnswerObjectType
- msg.NotificationAction = constant.AdoptAnswer
+ msg.NotificationAction = constant.AcceptAnswer
notice_queue.AddNotification(msg)
}
}
diff --git a/internal/repo/answer/answer_repo.go b/internal/repo/answer/answer_repo.go
index 04409176..97734343 100644
--- a/internal/repo/answer/answer_repo.go
+++ b/internal/repo/answer/answer_repo.go
@@ -133,22 +133,22 @@ func (ar *answerRepo) GetAnswerPage(ctx context.Context, page, pageSize int, ans
return
}
-// UpdateAdopted
+// UpdateAccepted
// If no answer is selected, the answer id can be 0
-func (ar *answerRepo) UpdateAdopted(ctx context.Context, id string, questionID string) error {
+func (ar *answerRepo) UpdateAccepted(ctx context.Context, id string, questionID string) error {
if questionID == "" {
return nil
}
var data entity.Answer
data.ID = id
- data.Adopted = schema.AnswerAdoptedFailed
+ data.Accepted = schema.AnswerAcceptedFailed
_, err := ar.data.DB.Where("question_id =?", questionID).Cols("adopted").Update(&data)
if err != nil {
return err
}
if id != "0" {
- data.Adopted = schema.AnswerAdoptedEnable
+ data.Accepted = schema.AnswerAcceptedEnable
_, err = ar.data.DB.Where("id = ?", id).Cols("adopted").Update(&data)
if err != nil {
return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
diff --git a/internal/repo/search_common/search_repo.go b/internal/repo/search_common/search_repo.go
index 8f3799e2..13f76185 100644
--- a/internal/repo/search_common/search_repo.go
+++ b/internal/repo/search_common/search_repo.go
@@ -344,8 +344,8 @@ func (sr *searchRepo) SearchAnswers(ctx context.Context, words []string, tagIDs
// check limit accepted
if accepted {
- b.Where(builder.Eq{"adopted": schema.AnswerAdoptedEnable})
- args = append(args, schema.AnswerAdoptedEnable)
+ b.Where(builder.Eq{"adopted": schema.AnswerAcceptedEnable})
+ args = append(args, schema.AnswerAcceptedEnable)
}
// check question id
diff --git a/internal/router/answer_api_router.go b/internal/router/answer_api_router.go
index 5d1b1c8a..c4c02c49 100644
--- a/internal/router/answer_api_router.go
+++ b/internal/router/answer_api_router.go
@@ -194,7 +194,7 @@ func (a *AnswerAPIRouter) RegisterAnswerAPIRouter(r *gin.RouterGroup) {
// answer
r.POST("/answer", a.answerController.Add)
r.PUT("/answer", a.answerController.Update)
- r.POST("/answer/acceptance", a.answerController.Adopted)
+ r.POST("/answer/acceptance", a.answerController.Accepted)
r.DELETE("/answer", a.answerController.RemoveAnswer)
// user
diff --git a/internal/schema/answer_schema.go b/internal/schema/answer_schema.go
index c6f47485..724d9af9 100644
--- a/internal/schema/answer_schema.go
+++ b/internal/schema/answer_schema.go
@@ -15,8 +15,8 @@ type RemoveAnswerReq struct {
}
const (
- AnswerAdoptedFailed = 1
- AnswerAdoptedEnable = 2
+ AnswerAcceptedFailed = 1
+ AnswerAcceptedEnable = 2
)
type AnswerAddReq struct {
@@ -74,7 +74,7 @@ type AnswerInfo struct {
HTML string `json:"html" xorm:"html"` // html
CreateTime int64 `json:"create_time" xorm:"created"` // create_time
UpdateTime int64 `json:"update_time" xorm:"updated"` // update_time
- Adopted int `json:"adopted"` // 1 Failed 2 Adopted
+ Accepted int `json:"accepted"` // 1 Failed 2 accepted
UserID string `json:"-" `
UpdateUserID string `json:"-" `
UserInfo *UserBasicInfo `json:"user_info,omitempty"`
@@ -94,7 +94,7 @@ type AdminAnswerInfo struct {
Description string `json:"description"`
CreateTime int64 `json:"create_time"`
UpdateTime int64 `json:"update_time"`
- Adopted int `json:"adopted"`
+ Accepted int `json:"accepted"`
UserID string `json:"-" `
UpdateUserID string `json:"-" `
UserInfo *UserBasicInfo `json:"user_info"`
@@ -104,7 +104,7 @@ type AdminAnswerInfo struct {
} `json:"question_info"`
}
-type AnswerAdoptedReq struct {
+type AnswerAcceptedReq struct {
QuestionID string `json:"question_id"`
AnswerID string `json:"answer_id"`
UserID string `json:"-" `
diff --git a/internal/schema/question_schema.go b/internal/schema/question_schema.go
index c83f6696..f5689297 100644
--- a/internal/schema/question_schema.go
+++ b/internal/schema/question_schema.go
@@ -199,7 +199,7 @@ type GetCloseTypeResp struct {
type UserAnswerInfo struct {
AnswerID string `json:"answer_id"`
QuestionID string `json:"question_id"`
- Adopted int `json:"adopted"`
+ Accepted int `json:"accepted"`
VoteCount int `json:"vote_count"`
CreateTime int `json:"create_time"`
UpdateTime int `json:"update_time"`
diff --git a/internal/service/answer_common/answer.go b/internal/service/answer_common/answer.go
index b2d42581..758908e1 100644
--- a/internal/service/answer_common/answer.go
+++ b/internal/service/answer_common/answer.go
@@ -15,7 +15,7 @@ type AnswerRepo interface {
GetAnswer(ctx context.Context, id string) (answer *entity.Answer, exist bool, err error)
GetAnswerList(ctx context.Context, answer *entity.Answer) (answerList []*entity.Answer, err error)
GetAnswerPage(ctx context.Context, page, pageSize int, answer *entity.Answer) (answerList []*entity.Answer, total int64, err error)
- UpdateAdopted(ctx context.Context, id string, questionID string) error
+ UpdateAccepted(ctx context.Context, id string, questionID string) error
GetByID(ctx context.Context, id string) (*entity.Answer, bool, error)
GetByUserIDQuestionID(ctx context.Context, userID string, questionID string) (*entity.Answer, bool, error)
SearchList(ctx context.Context, search *entity.AnswerSearch) ([]*entity.Answer, int64, error)
@@ -64,7 +64,7 @@ func (as *AnswerCommon) ShowFormat(ctx context.Context, data *entity.Answer) *sc
info.QuestionID = data.QuestionID
info.Content = data.OriginalText
info.HTML = data.ParsedText
- info.Adopted = data.Adopted
+ info.Accepted = data.Accepted
info.VoteCount = data.VoteCount
info.CreateTime = data.CreatedAt.Unix()
info.UpdateTime = data.UpdatedAt.Unix()
@@ -80,7 +80,7 @@ func (as *AnswerCommon) AdminShowFormat(ctx context.Context, data *entity.Answer
info := schema.AdminAnswerInfo{}
info.ID = data.ID
info.QuestionID = data.QuestionID
- info.Adopted = data.Adopted
+ info.Accepted = data.Accepted
info.VoteCount = data.VoteCount
info.CreateTime = data.CreatedAt.Unix()
info.UpdateTime = data.UpdatedAt.Unix()
diff --git a/internal/service/answer_service.go b/internal/service/answer_service.go
index 96212c6d..7d0949de 100644
--- a/internal/service/answer_service.go
+++ b/internal/service/answer_service.go
@@ -80,7 +80,7 @@ func (as *AnswerService) RemoveAnswer(ctx context.Context, req *schema.RemoveAns
if answerInfo.VoteCount > 0 {
return errors.BadRequest(reason.AnswerCannotDeleted)
}
- if answerInfo.Adopted == schema.AnswerAdoptedEnable {
+ if answerInfo.Accepted == schema.AnswerAcceptedEnable {
return errors.BadRequest(reason.AnswerCannotDeleted)
}
questionInfo, exist, err := as.questionRepo.GetQuestion(ctx, answerInfo.QuestionID)
@@ -138,7 +138,7 @@ func (as *AnswerService) Insert(ctx context.Context, req *schema.AnswerAddReq) (
insertData.UserID = req.UserID
insertData.OriginalText = req.Content
insertData.ParsedText = req.HTML
- insertData.Adopted = schema.AnswerAdoptedFailed
+ insertData.Accepted = schema.AnswerAcceptedFailed
insertData.QuestionID = req.QuestionID
insertData.RevisionID = "0"
insertData.LastEditUserID = "0"
@@ -285,8 +285,8 @@ func (as *AnswerService) Update(ctx context.Context, req *schema.AnswerUpdateReq
return insertData.ID, nil
}
-// UpdateAdopted
-func (as *AnswerService) UpdateAdopted(ctx context.Context, req *schema.AnswerAdoptedReq) error {
+// UpdateAccepted
+func (as *AnswerService) UpdateAccepted(ctx context.Context, req *schema.AnswerAcceptedReq) error {
if req.AnswerID == "" {
req.AnswerID = "0"
}
@@ -330,7 +330,7 @@ func (as *AnswerService) UpdateAdopted(ctx context.Context, req *schema.AnswerAd
}
}
- err = as.answerRepo.UpdateAdopted(ctx, req.AnswerID, req.QuestionID)
+ err = as.answerRepo.UpdateAccepted(ctx, req.AnswerID, req.QuestionID)
if err != nil {
return err
}
diff --git a/internal/service/notification_common/notification.go b/internal/service/notification_common/notification.go
index bf5ac725..5bb23f38 100644
--- a/internal/service/notification_common/notification.go
+++ b/internal/service/notification_common/notification.go
@@ -191,7 +191,7 @@ func (ns *NotificationCommon) SendNotificationToAllFollower(ctx context.Context,
if msg.NotificationAction != constant.UpdateQuestion &&
msg.NotificationAction != constant.AnswerTheQuestion &&
msg.NotificationAction != constant.UpdateAnswer &&
- msg.NotificationAction != constant.AdoptAnswer {
+ msg.NotificationAction != constant.AcceptAnswer {
return
}
condObjectID := msg.ObjectID