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.
add question status
aichy26f605a649de
diff --git a/docs/docs.go b/docs/docs.goindex b9b29980..b114aa17 100644--- a/docs/docs.go+++ b/docs/docs.go@@ -1380,7 +1380,7 @@ const docTemplate = `{"ApiKeyAuth": []}],- "description": "GetRedDot",+ "description": "get notification list","consumes": ["application/json"],@@ -1390,7 +1390,7 @@ const docTemplate = `{"tags": ["Notification"],- "summary": "GetRedDot",+ "summary": "get notification list","parameters": [{"type": "integer",@@ -1412,7 +1412,8 @@ const docTemplate = `{"type": "string","description": "type","name": "type",- "in": "query"+ "in": "query",+ "required": true}],"responses": {@@ -3256,7 +3257,7 @@ const docTemplate = `{"ApiKeyAuth": []}],- "description": "UserUpdateInfo",+ "description": "UserUpdateInfo update user info","consumes": ["application/json"],@@ -3266,7 +3267,7 @@ const docTemplate = `{"tags": ["User"],- "summary": "UserUpdateInfo",+ "summary": "UserUpdateInfo update user info","parameters": [{"type": "string",@@ -4922,7 +4923,7 @@ const docTemplate = `{"title": {"description": "question title","type": "string",- "maxLength": 64,+ "maxLength": 150,"minLength": 6}}@@ -4995,7 +4996,7 @@ const docTemplate = `{"title": {"description": "question title","type": "string",- "maxLength": 64,+ "maxLength": 150,"minLength": 6}}@@ -5250,7 +5251,7 @@ const docTemplate = `{"display_name": {"description": "display_name","type": "string",- "maxLength": 50+ "maxLength": 35},"original_text": {"description": "original text",@@ -5263,7 +5264,7 @@ const docTemplate = `{"slug_name": {"description": "slug_name","type": "string",- "maxLength": 50+ "maxLength": 35}}},@@ -5345,32 +5346,39 @@ const docTemplate = `{},"schema.UpdateInfoRequest": {"type": "object",+ "required": [+ "display_name"+ ],"properties": {"avatar": {"description": "avatar",- "type": "string"+ "type": "string",+ "maxLength": 500},"bio": {- "type": "string"+ "description": "bio",+ "type": "string",+ "maxLength": 4096},"bio_html": {- "type": "string"+ "description": "bio",+ "type": "string",+ "maxLength": 4096},"display_name": {"description": "display_name",- "type": "string"+ "type": "string",+ "maxLength": 30},"location": {"description": "location",- "type": "string"- },- "username": {- "description": "name",- "type": "string"+ "type": "string",+ "maxLength": 100},"website": {"description": "website",- "type": "string"+ "type": "string",+ "maxLength": 500}}},@@ -5407,7 +5415,7 @@ const docTemplate = `{"display_name": {"description": "display_name","type": "string",- "maxLength": 50+ "maxLength": 35},"edit_summary": {"description": "edit summary",@@ -5424,7 +5432,7 @@ const docTemplate = `{"slug_name": {"description": "slug_name","type": "string",- "maxLength": 50+ "maxLength": 35},"tag_id": {"description": "tag_id",diff --git a/docs/swagger.json b/docs/swagger.jsonindex f76df152..5e186a46 100644--- a/docs/swagger.json+++ b/docs/swagger.json@@ -1368,7 +1368,7 @@"ApiKeyAuth": []}],- "description": "GetRedDot",+ "description": "get notification list","consumes": ["application/json"],@@ -1378,7 +1378,7 @@"tags": ["Notification"],- "summary": "GetRedDot",+ "summary": "get notification list","parameters": [{"type": "integer",@@ -1400,7 +1400,8 @@"type": "string","description": "type","name": "type",- "in": "query"+ "in": "query",+ "required": true}],"responses": {@@ -3244,7 +3245,7 @@"ApiKeyAuth": []}],- "description": "UserUpdateInfo",+ "description": "UserUpdateInfo update user info","consumes": ["application/json"],@@ -3254,7 +3255,7 @@"tags": ["User"],- "summary": "UserUpdateInfo",+ "summary": "UserUpdateInfo update user info","parameters": [{"type": "string",@@ -4910,7 +4911,7 @@"title": {"description": "question title","type": "string",- "maxLength": 64,+ "maxLength": 150,"minLength": 6}}@@ -4983,7 +4984,7 @@"title": {"description": "question title","type": "string",- "maxLength": 64,+ "maxLength": 150,"minLength": 6}}@@ -5238,7 +5239,7 @@"display_name": {"description": "display_name","type": "string",- "maxLength": 50+ "maxLength": 35},"original_text": {"description": "original text",@@ -5251,7 +5252,7 @@"slug_name": {"description": "slug_name","type": "string",- "maxLength": 50+ "maxLength": 35}}},@@ -5333,32 +5334,39 @@},"schema.UpdateInfoRequest": {"type": "object",+ "required": [+ "display_name"+ ],"properties": {"avatar": {"description": "avatar",- "type": "string"+ "type": "string",+ "maxLength": 500},"bio": {- "type": "string"+ "description": "bio",+ "type": "string",+ "maxLength": 4096},"bio_html": {- "type": "string"+ "description": "bio",+ "type": "string",+ "maxLength": 4096},"display_name": {"description": "display_name",- "type": "string"+ "type": "string",+ "maxLength": 30},"location": {"description": "location",- "type": "string"- },- "username": {- "description": "name",- "type": "string"+ "type": "string",+ "maxLength": 100},"website": {"description": "website",- "type": "string"+ "type": "string",+ "maxLength": 500}}},@@ -5395,7 +5403,7 @@"display_name": {"description": "display_name","type": "string",- "maxLength": 50+ "maxLength": 35},"edit_summary": {"description": "edit summary",@@ -5412,7 +5420,7 @@"slug_name": {"description": "slug_name","type": "string",- "maxLength": 50+ "maxLength": 35},"tag_id": {"description": "tag_id",diff --git a/docs/swagger.yaml b/docs/swagger.yamlindex 3800c298..3d116152 100644--- a/docs/swagger.yaml+++ b/docs/swagger.yaml@@ -791,7 +791,7 @@ definitions:type: arraytitle:description: question title- maxLength: 64+ maxLength: 150minLength: 6type: stringrequired:@@ -845,7 +845,7 @@ definitions:type: arraytitle:description: question title- maxLength: 64+ maxLength: 150minLength: 6type: stringrequired:@@ -1027,7 +1027,7 @@ definitions:properties:display_name:description: display_name- maxLength: 50+ maxLength: 35type: stringoriginal_text:description: original text@@ -1037,7 +1037,7 @@ definitions:type: stringslug_name:description: slug_name- maxLength: 50+ maxLength: 35type: stringtype: objectschema.TagResp:@@ -1097,23 +1097,30 @@ definitions:properties:avatar:description: avatar+ maxLength: 500type: stringbio:+ description: bio+ maxLength: 4096type: stringbio_html:+ description: bio+ maxLength: 4096type: stringdisplay_name:description: display_name+ maxLength: 30type: stringlocation:description: location- type: string- username:- description: name+ maxLength: 100type: stringwebsite:description: website+ maxLength: 500type: string+ required:+ - display_nametype: objectschema.UpdateNotificationReadReq:properties:@@ -1136,7 +1143,7 @@ definitions:properties:display_name:description: display_name- maxLength: 50+ maxLength: 35type: stringedit_summary:description: edit summary@@ -1149,7 +1156,7 @@ definitions:type: stringslug_name:description: slug_name- maxLength: 50+ maxLength: 35type: stringtag_id:description: tag_id@@ -2176,7 +2183,7 @@ paths:get:consumes:- application/json- description: GetRedDot+ description: get notification listparameters:- description: page sizein: query@@ -2192,6 +2199,7 @@ paths:- achievementin: queryname: type+ required: truetype: stringproduces:- application/json@@ -2202,7 +2210,7 @@ paths:$ref: '#/definitions/handler.RespBody'security:- ApiKeyAuth: []- summary: GetRedDot+ summary: get notification listtags:- Notification/answer/api/v1/notification/read/state:@@ -3318,7 +3326,7 @@ paths:put:consumes:- application/json- description: UserUpdateInfo+ description: UserUpdateInfo update user infoparameters:- description: access-tokenin: header@@ -3340,7 +3348,7 @@ paths:$ref: '#/definitions/handler.RespBody'security:- ApiKeyAuth: []- summary: UserUpdateInfo+ summary: UserUpdateInfo update user infotags:- User/answer/api/v1/user/login/email:diff --git a/internal/entity/question_entity.go b/internal/entity/question_entity.goindex 4fc47440..0a02c50d 100644--- a/internal/entity/question_entity.go+++ b/internal/entity/question_entity.go@@ -16,6 +16,12 @@ var CmsQuestionSearchStatus = map[string]int{"deleted": QuestionStatusDeleted,}+var CmsQuestionSearchStatusIntToString = map[int]string{+ QuestionStatusAvailable: "available",+ QuestionStatusclosed: "closed",+ QuestionStatusDeleted: "deleted",+}+type QuestionTag struct {Question `xorm:"extends"`TagRel `xorm:"extends"`diff --git a/internal/schema/question_schema.go b/internal/schema/question_schema.goindex e80af221..202aeaa2 100644--- a/internal/schema/question_schema.go+++ b/internal/schema/question_schema.go@@ -57,6 +57,7 @@ type QuestionBaseInfo struct {AnswerCount int `json:"answer_count" xorm:"answer_count"` // 回复总数CollectionCount int `json:"collection_count" xorm:"collection_count"` // 收藏总数FollowCount int `json:"follow_count" xorm:"follow_count"` // 关注数+ Status string `json:"status"`AcceptedAnswer bool `json:"accepted_answer"`}@@ -150,6 +151,7 @@ type UserQuestionInfo struct {CollectionCount int `json:"collection_count"`CreateTime int `json:"create_time"`AcceptedAnswerId string `json:"accepted_answer_id"`+ Status string `json:"status"`}type QuestionSearch struct {diff --git a/internal/service/question_service.go b/internal/service/question_service.goindex eb6284b6..f2273a1f 100644--- a/internal/service/question_service.go+++ b/internal/service/question_service.go@@ -273,6 +273,10 @@ func (qs *QuestionService) SearchUserList(ctx context.Context, userName, order sfor _, item := range questionlist {info := &schema.UserQuestionInfo{}_ = copier.Copy(info, item)+ status, ok := entity.CmsQuestionSearchStatusIntToString[item.Status]+ if ok {+ info.Status = status+ }userlist = append(userlist, info)}return userlist, count, nil@@ -446,6 +450,10 @@ func (qs *QuestionService) SearchByTitleLike(ctx context.Context, title string,item.AnswerCount = question.AnswerCountitem.CollectionCount = question.CollectionCountitem.FollowCount = question.FollowCount+ status, ok := entity.CmsQuestionSearchStatusIntToString[question.Status]+ if ok {+ item.Status = status+ }if question.AcceptedAnswerID != "0" {item.AcceptedAnswer = true}