mirror of https://gitee.com/answerdev/answer.git
feat(reason): translator review reasons.
This commit is contained in:
parent
952d846340
commit
e26d608aaf
|
@ -288,6 +288,36 @@ backend:
|
|||
other: This post requires staff attention for another reason not listed above.
|
||||
placeholder:
|
||||
other: Let us know specifically what you are concerned about
|
||||
community_specific:
|
||||
name:
|
||||
other: a community-specific reason
|
||||
desc:
|
||||
other: This question doesn’t meet a community guideline.
|
||||
not_clarity:
|
||||
name:
|
||||
other: needs details or clarity
|
||||
desc:
|
||||
other: This question currently includes multiple questions in one. It should focus on one problem only.
|
||||
looks_ok:
|
||||
name:
|
||||
other: looks ok
|
||||
desc:
|
||||
other: This post is good as-is and not low quality.
|
||||
needs_edit:
|
||||
name:
|
||||
other: needs edit, and I did it
|
||||
desc:
|
||||
other: Improve and correct problems with this post yourself.
|
||||
needs_close:
|
||||
name:
|
||||
other: needs close
|
||||
desc:
|
||||
other: A closed question can’t answer, but still can edit, vote and comment.
|
||||
needs_delete:
|
||||
name:
|
||||
other: needs delete
|
||||
desc:
|
||||
other: All reputation gained and lost will be restored.
|
||||
question:
|
||||
close:
|
||||
duplicate:
|
||||
|
|
|
@ -278,6 +278,36 @@ backend:
|
|||
other: 此帖子需要工作人员关注,因为是上述所列以外的其他理由。
|
||||
placeholder:
|
||||
other: 让我们具体了解你所关注的内容
|
||||
community_specific:
|
||||
name:
|
||||
other: 特定社区原因
|
||||
desc:
|
||||
other: 这个问题不符合社区准则。
|
||||
not_clarity:
|
||||
name:
|
||||
other: 需要细节或澄清
|
||||
desc:
|
||||
other: 此问题目前包含多个问题。它应该只关注一个问题。
|
||||
looks_ok:
|
||||
name:
|
||||
other: 看起来不错
|
||||
desc:
|
||||
other: 这篇文章很好,不是低质量的。
|
||||
needs_edit:
|
||||
name:
|
||||
other: 需要编辑,我已经编辑了
|
||||
desc:
|
||||
other: 自己改善和纠正这篇文章中的问题。
|
||||
needs_close:
|
||||
name:
|
||||
other: 需要关闭
|
||||
desc:
|
||||
other: 关闭的问题不能回答,但仍然可以编辑、投票和评论。
|
||||
needs_delete:
|
||||
name:
|
||||
other: 需要删除
|
||||
desc:
|
||||
other: 所有获得和失去的声望都将被恢复。
|
||||
question:
|
||||
close:
|
||||
duplicate:
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
package constant
|
||||
|
||||
const (
|
||||
ReportSpamName = "report.spam.name"
|
||||
ReportSpamDescription = "report.spam.description"
|
||||
ReportRudeName = "report.rude.name"
|
||||
ReportRudeDescription = "report.rude.description"
|
||||
ReportDuplicateName = "report.duplicate.name"
|
||||
ReportDuplicateDescription = "report.duplicate.description"
|
||||
ReportOtherName = "report.other.name"
|
||||
ReportOtherDescription = "report.other.description"
|
||||
ReportNotAnswerName = "report.not_answer.name"
|
||||
ReportNotAnswerDescription = "report.not_answer.description"
|
||||
ReportNotNeedName = "report.not_need.name"
|
||||
ReportNotNeedDescription = "report.not_need.description"
|
||||
// question close
|
||||
QuestionCloseDuplicateName = "question.close.duplicate.name"
|
||||
QuestionCloseDuplicateDescription = "question.close.duplicate.description"
|
||||
QuestionCloseGuidelineName = "question.close.guideline.name"
|
||||
QuestionCloseGuidelineDescription = "question.close.guideline.description"
|
||||
QuestionCloseMultipleName = "question.close.multiple.name"
|
||||
QuestionCloseMultipleDescription = "question.close.multiple.description"
|
||||
QuestionCloseOtherName = "question.close.other.name"
|
||||
QuestionCloseOtherDescription = "question.close.other.description"
|
||||
)
|
||||
|
||||
const (
|
||||
// TODO put this in database
|
||||
// TODO need reason controller to resolve
|
||||
QuestionCloseJSON = `[{"name":"question.close.duplicate.name","description":"question.close.duplicate.description","source":"question","type":1,"have_content":false,"content_type":""},{"name":"question.close.guideline.name","description":"question.close.guideline.description","source":"question","type":2,"have_content":false,"content_type":""},{"name":"question.close.multiple.name","description":"question.close.multiple.description","source":"question","type":3,"have_content":true,"content_type":"text"},{"name":"question.close.other.name","description":"question.close.other.description","source":"question","type":4,"have_content":true,"content_type":"textarea"}]`
|
||||
QuestionReportJSON = `[{"name":"report.spam.name","description":"report.spam.description","source":"question","type":1,"have_content":false,"content_type":""},{"name":"report.rude.name","description":"report.rude.description","source":"question","type":2,"have_content":false,"content_type":""},{"name":"report.duplicate.name","description":"report.duplicate.description","source":"question","type":3,"have_content":true,"content_type":"text"},{"name":"report.other.name","description":"report.other.description","source":"question","type":4,"have_content":true,"content_type":"textarea"}]`
|
||||
AnswerReportJSON = `[{"name":"report.spam.name","description":"report.spam.description","source":"answer","type":1,"have_content":false,"content_type":""},{"name":"report.rude.name","description":"report.rude.description","source":"answer","type":2,"have_content":false,"content_type":""},{"name":"report.not_answer.name","description":"report.not_answer.description","source":"answer","type":3,"have_content":false,"content_type":""},{"name":"report.other.name","description":"report.other.description","source":"answer","type":4,"have_content":true,"content_type":"textarea"}]`
|
||||
CommentReportJSON = `[{"name":"report.spam.name","description":"report.spam.description","source":"comment","type":1,"have_content":false,"content_type":""},{"name":"report.rude.name","description":"report.rude.description","source":"comment","type":2,"have_content":false,"content_type":""},{"name":"report.not_need.name","description":"report.not_need.description","source":"comment","type":3,"have_content":true,"content_type":"text"},{"name":"report.other.name","description":"report.other.description","source":"comment","type":4,"have_content":true,"content_type":"textarea"}]`
|
||||
)
|
|
@ -500,20 +500,6 @@ func (qc *QuestionController) UpdateQuestion(ctx *gin.Context) {
|
|||
handler.HandleResponse(ctx, nil, &schema.UpdateQuestionResp{WaitForReview: !req.NoNeedReview})
|
||||
}
|
||||
|
||||
// CloseMsgList close question msg list
|
||||
// @Summary close question msg list
|
||||
// @Description close question msg list
|
||||
// @Tags Question
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Success 200 {object} handler.RespBody
|
||||
// @Router /answer/api/v1/question/closemsglist [get]
|
||||
func (qc *QuestionController) CloseMsgList(ctx *gin.Context) {
|
||||
resp, err := qc.questionService.CloseMsgList(ctx, handler.GetLang(ctx))
|
||||
handler.HandleResponse(ctx, err, resp)
|
||||
}
|
||||
|
||||
// SearchByTitleLike add question title like
|
||||
// @Summary add question title like
|
||||
// @Description add question title like
|
||||
|
|
|
@ -55,21 +55,3 @@ func (rc *ReportController) AddReport(ctx *gin.Context) {
|
|||
err = rc.reportService.AddReport(ctx, req)
|
||||
handler.HandleResponse(ctx, err, nil)
|
||||
}
|
||||
|
||||
// GetReportTypeList get report type list
|
||||
// @Summary get report type list
|
||||
// @Description get report type list
|
||||
// @Tags Report
|
||||
// @Produce json
|
||||
// @Param source query string true "report source" Enums(question, answer, comment, user)
|
||||
// @Success 200 {object} handler.RespBody{data=[]schema.GetReportTypeResp}
|
||||
// @Router /answer/api/v1/report/type/list [get]
|
||||
func (rc *ReportController) GetReportTypeList(ctx *gin.Context) {
|
||||
req := &schema.GetReportListReq{}
|
||||
if handler.BindAndCheck(ctx, req) {
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := rc.reportService.GetReportTypeList(ctx, handler.GetLang(ctx), req)
|
||||
handler.HandleResponse(ctx, err, resp)
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ func (rr *reasonRepo) ListReasons(ctx context.Context, objectType, action string
|
|||
log.Error(err)
|
||||
continue
|
||||
}
|
||||
reason.Translate(reasonKey+".", lang)
|
||||
reason.Translate(reasonKey, lang)
|
||||
|
||||
reason.ReasonType, err = rr.configRepo.GetConfigType(reasonKey)
|
||||
if err != nil {
|
||||
|
|
|
@ -26,14 +26,14 @@ func (r *ReasonItem) Translate(keyPrefix string, lang i18n.Language) {
|
|||
if len(fieldData) == 0 {
|
||||
return fieldData
|
||||
}
|
||||
key := keyPrefix + fieldName
|
||||
key := keyPrefix + "." + fieldName
|
||||
fieldTr := translator.Tr(lang, key)
|
||||
if fieldTr != key {
|
||||
// If i18n key exists, return i18n value
|
||||
return fieldTr
|
||||
}
|
||||
// If i18n key not exists, return fieldData original value
|
||||
return fieldData
|
||||
return fieldData + "没翻译"
|
||||
}
|
||||
|
||||
r.Name = trField("name", r.Name)
|
||||
|
|
|
@ -30,7 +30,6 @@ import (
|
|||
"github.com/answerdev/answer/pkg/uid"
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/segmentfault/pacman/errors"
|
||||
"github.com/segmentfault/pacman/i18n"
|
||||
"github.com/segmentfault/pacman/log"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
@ -132,22 +131,6 @@ func (qs *QuestionService) ReopenQuestion(ctx context.Context, req *schema.Reope
|
|||
return nil
|
||||
}
|
||||
|
||||
// CloseMsgList list close question condition
|
||||
func (qs *QuestionService) CloseMsgList(ctx context.Context, lang i18n.Language) (
|
||||
resp []*schema.GetCloseTypeResp, err error,
|
||||
) {
|
||||
resp = make([]*schema.GetCloseTypeResp, 0)
|
||||
err = json.Unmarshal([]byte(constant.QuestionCloseJSON), &resp)
|
||||
if err != nil {
|
||||
return nil, errors.InternalServer(reason.UnknownError).WithError(err).WithStack()
|
||||
}
|
||||
for _, t := range resp {
|
||||
t.Name = translator.Tr(lang, t.Name)
|
||||
t.Description = translator.Tr(lang, t.Description)
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (qs *QuestionService) AddQuestionCheckTags(ctx context.Context, Tags []*entity.Tag) ([]string, error) {
|
||||
list := make([]string, 0)
|
||||
for _, tag := range Tags {
|
||||
|
|
|
@ -1,18 +1,11 @@
|
|||
package report
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/answerdev/answer/internal/base/constant"
|
||||
"github.com/answerdev/answer/internal/base/reason"
|
||||
"github.com/answerdev/answer/internal/base/translator"
|
||||
"github.com/answerdev/answer/internal/entity"
|
||||
"github.com/answerdev/answer/internal/schema"
|
||||
"github.com/answerdev/answer/internal/service/object_info"
|
||||
"github.com/answerdev/answer/internal/service/report_common"
|
||||
"github.com/answerdev/answer/pkg/obj"
|
||||
"github.com/segmentfault/pacman/errors"
|
||||
"github.com/segmentfault/pacman/i18n"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
|
@ -56,26 +49,3 @@ func (rs *ReportService) AddReport(ctx context.Context, req *schema.AddReportReq
|
|||
}
|
||||
return rs.reportRepo.AddReport(ctx, report)
|
||||
}
|
||||
|
||||
// GetReportTypeList get report list all
|
||||
func (rs *ReportService) GetReportTypeList(ctx context.Context, lang i18n.Language, req *schema.GetReportListReq) (
|
||||
resp []*schema.GetReportTypeResp, err error,
|
||||
) {
|
||||
resp = make([]*schema.GetReportTypeResp, 0)
|
||||
switch req.Source {
|
||||
case constant.QuestionObjectType:
|
||||
err = json.Unmarshal([]byte(constant.QuestionReportJSON), &resp)
|
||||
case constant.AnswerObjectType:
|
||||
err = json.Unmarshal([]byte(constant.AnswerReportJSON), &resp)
|
||||
case constant.CommentObjectType:
|
||||
err = json.Unmarshal([]byte(constant.CommentReportJSON), &resp)
|
||||
}
|
||||
if err != nil {
|
||||
err = errors.BadRequest(reason.UnknownError)
|
||||
}
|
||||
for _, t := range resp {
|
||||
t.Name = translator.Tr(lang, t.Name)
|
||||
t.Description = translator.Tr(lang, t.Description)
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
|
|
@ -3,7 +3,9 @@ package report_admin
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/answerdev/answer/internal/service/config"
|
||||
"github.com/answerdev/answer/internal/base/handler"
|
||||
"github.com/answerdev/answer/internal/repo/config"
|
||||
configrepo "github.com/answerdev/answer/internal/service/config"
|
||||
"github.com/answerdev/answer/pkg/htmltext"
|
||||
"github.com/segmentfault/pacman/log"
|
||||
|
||||
|
@ -31,7 +33,7 @@ type ReportAdminService struct {
|
|||
questionRepo questioncommon.QuestionRepo
|
||||
commentCommonRepo comment_common.CommentCommonRepo
|
||||
reportHandle *report_handle_admin.ReportHandle
|
||||
configRepo config.ConfigRepo
|
||||
configRepo configrepo.ConfigRepo
|
||||
}
|
||||
|
||||
// NewReportAdminService new report service
|
||||
|
@ -43,7 +45,7 @@ func NewReportAdminService(
|
|||
questionRepo questioncommon.QuestionRepo,
|
||||
commentCommonRepo comment_common.CommentCommonRepo,
|
||||
reportHandle *report_handle_admin.ReportHandle,
|
||||
configRepo config.ConfigRepo) *ReportAdminService {
|
||||
configRepo configrepo.ConfigRepo) *ReportAdminService {
|
||||
return &ReportAdminService{
|
||||
reportRepo: reportRepo,
|
||||
commonUser: commonUser,
|
||||
|
@ -70,8 +72,6 @@ func (rs *ReportAdminService) ListReportPage(ctx context.Context, dto schema.Get
|
|||
users map[string]*schema.UserBasicInfo
|
||||
)
|
||||
|
||||
pageModel = &pager.PageModel{}
|
||||
|
||||
flags, total, err = rs.reportRepo.GetReportListPage(ctx, dto)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -140,6 +140,7 @@ func (rs *ReportAdminService) HandleReported(ctx context.Context, req schema.Rep
|
|||
}
|
||||
|
||||
func (rs *ReportAdminService) parseObject(ctx context.Context, resp *[]*schema.GetReportListPageResp) {
|
||||
lang := handler.GetLangByCtx(ctx)
|
||||
var (
|
||||
res = *resp
|
||||
)
|
||||
|
@ -221,6 +222,7 @@ func (rs *ReportAdminService) parseObject(ctx context.Context, resp *[]*schema.G
|
|||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
r.Reason.Translate(config.ID2KeyMapping[r.ReportType], lang)
|
||||
}
|
||||
if r.FlaggedType > 0 {
|
||||
r.FlaggedReason = &schema.ReasonItem{
|
||||
|
@ -230,6 +232,7 @@ func (rs *ReportAdminService) parseObject(ctx context.Context, resp *[]*schema.G
|
|||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
r.Reason.Translate(config.ID2KeyMapping[r.ReportType], lang)
|
||||
}
|
||||
|
||||
res[i] = r
|
||||
|
|
Loading…
Reference in New Issue