Merge branch 'ai_work' into 'main'

add question status

See merge request opensource/answer!26
This commit is contained in:
linkinstar 2022-09-30 02:29:27 +00:00
commit 69c6b22b41
6 changed files with 95 additions and 55 deletions

View File

@ -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",

View File

@ -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",

View File

@ -791,7 +791,7 @@ definitions:
type: array
title:
description: question title
maxLength: 64
maxLength: 150
minLength: 6
type: string
required:
@ -845,7 +845,7 @@ definitions:
type: array
title:
description: question title
maxLength: 64
maxLength: 150
minLength: 6
type: string
required:
@ -1027,7 +1027,7 @@ definitions:
properties:
display_name:
description: display_name
maxLength: 50
maxLength: 35
type: string
original_text:
description: original text
@ -1037,7 +1037,7 @@ definitions:
type: string
slug_name:
description: slug_name
maxLength: 50
maxLength: 35
type: string
type: object
schema.TagResp:
@ -1097,23 +1097,30 @@ definitions:
properties:
avatar:
description: avatar
maxLength: 500
type: string
bio:
description: bio
maxLength: 4096
type: string
bio_html:
description: bio
maxLength: 4096
type: string
display_name:
description: display_name
maxLength: 30
type: string
location:
description: location
type: string
username:
description: name
maxLength: 100
type: string
website:
description: website
maxLength: 500
type: string
required:
- display_name
type: object
schema.UpdateNotificationReadReq:
properties:
@ -1136,7 +1143,7 @@ definitions:
properties:
display_name:
description: display_name
maxLength: 50
maxLength: 35
type: string
edit_summary:
description: edit summary
@ -1149,7 +1156,7 @@ definitions:
type: string
slug_name:
description: slug_name
maxLength: 50
maxLength: 35
type: string
tag_id:
description: tag_id
@ -2176,7 +2183,7 @@ paths:
get:
consumes:
- application/json
description: GetRedDot
description: get notification list
parameters:
- description: page size
in: query
@ -2192,6 +2199,7 @@ paths:
- achievement
in: query
name: type
required: true
type: string
produces:
- application/json
@ -2202,7 +2210,7 @@ paths:
$ref: '#/definitions/handler.RespBody'
security:
- ApiKeyAuth: []
summary: GetRedDot
summary: get notification list
tags:
- Notification
/answer/api/v1/notification/read/state:
@ -3318,7 +3326,7 @@ paths:
put:
consumes:
- application/json
description: UserUpdateInfo
description: UserUpdateInfo update user info
parameters:
- description: access-token
in: header
@ -3340,7 +3348,7 @@ paths:
$ref: '#/definitions/handler.RespBody'
security:
- ApiKeyAuth: []
summary: UserUpdateInfo
summary: UserUpdateInfo update user info
tags:
- User
/answer/api/v1/user/login/email:

View File

@ -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"`

View File

@ -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 {

View File

@ -273,6 +273,10 @@ func (qs *QuestionService) SearchUserList(ctx context.Context, userName, order s
for _, 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.AnswerCount
item.CollectionCount = question.CollectionCount
item.FollowCount = question.FollowCount
status, ok := entity.CmsQuestionSearchStatusIntToString[question.Status]
if ok {
item.Status = status
}
if question.AcceptedAnswerID != "0" {
item.AcceptedAnswer = true
}