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.
typo: rename flaged to flagged
LinkinStar76657ae3dc28
diff --git a/docs/docs.go b/docs/docs.goindex f4ac833c..6f984f79 100644--- a/docs/docs.go+++ b/docs/docs.go@@ -3596,12 +3596,12 @@ const docTemplate = `{"summary": "UserRegisterByEmail","parameters": [{- "description": "UserRegister",+ "description": "UserRegisterReq","name": "data","in": "body","required": true,"schema": {- "$ref": "#/definitions/schema.UserRegister"+ "$ref": "#/definitions/schema.UserRegisterReq"}}],@@ -5088,14 +5088,14 @@ const docTemplate = `{"schema.ReportHandleReq": {"type": "object","required": [- "flaged_type",+ "flagged_type","id"],"properties": {- "flaged_content": {+ "flagged_content": {"type": "string"},- "flaged_type": {+ "flagged_type": {"type": "integer"},"id": {@@ -5391,6 +5391,11 @@ const docTemplate = `{"type": "string","maxLength": 100},+ "username": {+ "description": "username",+ "type": "string",+ "maxLength": 30+ },"website": {"description": "website","type": "string",@@ -5641,7 +5646,7 @@ const docTemplate = `{}}},- "schema.UserRegister": {+ "schema.UserRegisterReq": {"type": "object","required": ["e_mail",@@ -5657,7 +5662,7 @@ const docTemplate = `{"name": {"description": "name","type": "string",- "maxLength": 50+ "maxLength": 30},"pass": {"description": "password",diff --git a/docs/swagger.json b/docs/swagger.jsonindex 11c99f4d..7f031f94 100644--- a/docs/swagger.json+++ b/docs/swagger.json@@ -3584,12 +3584,12 @@"summary": "UserRegisterByEmail","parameters": [{- "description": "UserRegister",+ "description": "UserRegisterReq","name": "data","in": "body","required": true,"schema": {- "$ref": "#/definitions/schema.UserRegister"+ "$ref": "#/definitions/schema.UserRegisterReq"}}],@@ -5076,14 +5076,14 @@"schema.ReportHandleReq": {"type": "object","required": [- "flaged_type",+ "flagged_type","id"],"properties": {- "flaged_content": {+ "flagged_content": {"type": "string"},- "flaged_type": {+ "flagged_type": {"type": "integer"},"id": {@@ -5379,6 +5379,11 @@"type": "string","maxLength": 100},+ "username": {+ "description": "username",+ "type": "string",+ "maxLength": 30+ },"website": {"description": "website","type": "string",@@ -5629,7 +5634,7 @@}}},- "schema.UserRegister": {+ "schema.UserRegisterReq": {"type": "object","required": ["e_mail",@@ -5645,7 +5650,7 @@"name": {"description": "name","type": "string",- "maxLength": 50+ "maxLength": 30},"pass": {"description": "password",diff --git a/docs/swagger.yaml b/docs/swagger.yamlindex a88b3ca6..7ecf9fc1 100644--- a/docs/swagger.yaml+++ b/docs/swagger.yaml@@ -905,14 +905,14 @@ definitions:type: objectschema.ReportHandleReq:properties:- flaged_content:+ flagged_content:type: string- flaged_type:+ flagged_type:type: integerid:type: stringrequired:- - flaged_type+ - flagged_type- idtype: objectschema.SearchListResp:@@ -1118,6 +1118,10 @@ definitions:description: locationmaxLength: 100type: string+ username:+ description: username+ maxLength: 30+ type: stringwebsite:description: websitemaxLength: 500@@ -1297,7 +1301,7 @@ definitions:- code- passtype: object- schema.UserRegister:+ schema.UserRegisterReq:properties:e_mail:description: email@@ -1305,7 +1309,7 @@ definitions:type: stringname:description: name- maxLength: 50+ maxLength: 30type: stringpass:description: password@@ -3534,12 +3538,12 @@ paths:- application/jsondescription: UserRegisterByEmailparameters:- - description: UserRegister+ - description: UserRegisterReqin: bodyname: datarequired: trueschema:- $ref: '#/definitions/schema.UserRegister'+ $ref: '#/definitions/schema.UserRegisterReq'produces:- application/jsonresponses:diff --git a/internal/entity/report_entity.go b/internal/entity/report_entity.goindex 53a0d510..e50ef260 100644--- a/internal/entity/report_entity.go+++ b/internal/entity/report_entity.go@@ -27,8 +27,8 @@ type Report struct {ObjectType int `xorm:"not null default 0 comment('revision type') INT(11) object_type"`ReportType int `xorm:"not null default 0 comment('report type') INT(11) report_type"`Content string `xorm:"not null comment('report content') TEXT content"`- FlagedType int `xorm:"not null default 0 comment('flaged type') INT(11) flaged_type"`- FlagedContent string `xorm:"not null comment('flaged content') TEXT flaged_content"`+ FlaggedType int `xorm:"not null default 0 comment('flaged type') INT(11) flaged_type"`+ FlaggedContent string `xorm:"not null comment('flaged content') TEXT flaged_content"`Status int `xorm:"not null default 1 comment('status(normal: 1; delete 2)') INT(11) status"`}diff --git a/internal/schema/report_schema.go b/internal/schema/report_schema.goindex d3766558..5dc19945 100644--- a/internal/schema/report_schema.go+++ b/internal/schema/report_schema.go@@ -1,8 +1,9 @@package schemaimport (- "github.com/segmentfault/answer/internal/base/constant""time"++ "github.com/segmentfault/answer/internal/base/constant")// AddReportReq add report request@@ -41,9 +42,9 @@ type GetReportTypeResp struct {// ReportHandleReq request handle requesttype ReportHandleReq struct {- ID string `validate:"required" comment:"report id" form:"id" json:"id"`- FlagedType int `validate:"required" comment:"flaged type" form:"flaged_type" json:"flaged_type"`- FlagedContent string `validate:"omitempty" comment:"flaged content" form:"flaged_content" json:"flaged_content"`+ ID string `validate:"required" comment:"report id" form:"id" json:"id"`+ FlaggedType int `validate:"required" comment:"flagged type" form:"flagged_type" json:"flagged_type"`+ FlaggedContent string `validate:"omitempty" comment:"flagged content" form:"flagged_content" json:"flagged_content"`}// GetReportListPageDTO report list data transfer object@@ -60,9 +61,9 @@ type GetReportListPageResp struct {ReportedUser *UserBasicInfo `json:"reported_user"`ReportUser *UserBasicInfo `json:"report_user"`- Content string `json:"content"`- FlagedContent string `json:"flaged_content"`- OType string `json:"object_type"`+ Content string `json:"content"`+ FlaggedContent string `json:"flagged_content"`+ OType string `json:"object_type"`ObjectID string `json:"-"`QuestionID string `json:"question_id"`@@ -79,15 +80,15 @@ type GetReportListPageResp struct {UpdatedAt time.Time `json:"_"`UpdatedAtParsed int64 `json:"updated_at"`- Reason *ReasonItem `json:"reason"`- FlagedReason *ReasonItem `json:"flaged_reason"`+ Reason *ReasonItem `json:"reason"`+ FlaggedReason *ReasonItem `json:"flagged_reason"`UserID string `json:"-"`ReportedUserID string `json:"-"`Status int `json:"-"`ObjectType int `json:"-"`ReportType int `json:"-"`- FlagedType int `json:"-"`+ FlaggedType int `json:"-"`}// Format format resultdiff --git a/internal/service/report_backyard/report_backyard.go b/internal/service/report_backyard/report_backyard.goindex 3aaa1db6..029c4382 100644--- a/internal/service/report_backyard/report_backyard.go+++ b/internal/service/report_backyard/report_backyard.go@@ -62,10 +62,10 @@ func (rs *ReportBackyardService) ListReportPage(ctx context.Context, dto schema.flags []entity.Reporttotal int64- flagedUserIds,+ flaggedUserIds,userIds []string- flagedUsers,+ flaggedUsers,users map[string]*schema.UserBasicInfo)@@ -78,18 +78,18 @@ func (rs *ReportBackyardService) ListReportPage(ctx context.Context, dto schema._ = copier.Copy(&resp, flags)for _, r := range resp {- flagedUserIds = append(flagedUserIds, r.ReportedUserID)+ flaggedUserIds = append(flaggedUserIds, r.ReportedUserID)userIds = append(userIds, r.UserID)r.Format()}- // flaged users- flagedUsers, err = rs.commonUser.BatchUserBasicInfoByID(ctx, flagedUserIds)+ // flagged users+ flaggedUsers, err = rs.commonUser.BatchUserBasicInfoByID(ctx, flaggedUserIds)// flag usersusers, err = rs.commonUser.BatchUserBasicInfoByID(ctx, userIds)for _, r := range resp {- r.ReportedUser = flagedUsers[r.ReportedUserID]+ r.ReportedUser = flaggedUsers[r.ReportedUserID]r.ReportUser = users[r.UserID]}@@ -102,9 +102,9 @@ func (rs *ReportBackyardService) HandleReported(ctx context.Context, req schema.var (reported = entity.Report{}handleData = entity.Report{- FlagedContent: req.FlagedContent,- FlagedType: req.FlagedType,- Status: entity.ReportStatusCompleted,+ FlaggedContent: req.FlaggedContent,+ FlaggedType: req.FlaggedType,+ Status: entity.ReportStatusCompleted,}exist = false)@@ -203,11 +203,11 @@ func (rs *ReportBackyardService) parseObject(ctx context.Context, resp *[]*schem}err = rs.configRepo.GetConfigById(r.ReportType, r.Reason)}- if r.FlagedType > 0 {- r.FlagedReason = &schema.ReasonItem{- ReasonType: r.FlagedType,+ if r.FlaggedType > 0 {+ r.FlaggedReason = &schema.ReasonItem{+ ReasonType: r.FlaggedType,}- _ = rs.configRepo.GetConfigById(r.FlagedType, r.FlagedReason)+ _ = rs.configRepo.GetConfigById(r.FlaggedType, r.FlaggedReason)}res[i] = rdiff --git a/internal/service/report_handle_backyard/report_handle.go b/internal/service/report_handle_backyard/report_handle.goindex e774aefe..5c24ac8f 100644--- a/internal/service/report_handle_backyard/report_handle.go+++ b/internal/service/report_handle_backyard/report_handle.go@@ -2,6 +2,7 @@ package report_handle_backyardimport ("context"+"github.com/segmentfault/answer/internal/service/config""github.com/segmentfault/answer/internal/base/constant"@@ -46,23 +47,23 @@ func (rh *ReportHandle) HandleObject(ctx context.Context, reported entity.Report}switch objectKey {case "question":- switch req.FlagedType {+ switch req.FlaggedType {case reasonDelete:err = rh.questionCommon.RemoveQuestion(ctx, &schema.RemoveQuestionReq{ID: objectID})case reasonClose:err = rh.questionCommon.CloseQuestion(ctx, &schema.CloseQuestionReq{ID: objectID,- CloseType: req.FlagedType,- CloseMsg: req.FlagedContent,+ CloseType: req.FlaggedType,+ CloseMsg: req.FlaggedContent,})}case "answer":- switch req.FlagedType {+ switch req.FlaggedType {case reasonDelete:err = rh.questionCommon.RemoveAnswer(ctx, objectID)}case "comment":- switch req.FlagedType {+ switch req.FlaggedType {case reasonDelete:err = rh.commentRepo.RemoveComment(ctx, objectID)rh.sendNotification(ctx, reportedUserID, objectID, constant.YourCommentWasDeleted)