This commit is contained in:
aichy126 2022-11-23 11:10:15 +08:00
parent 5547b2fe91
commit ba46d08e04
6 changed files with 352 additions and 4 deletions

View File

@ -1005,6 +1005,69 @@ const docTemplate = `{
}
}
},
"/answer/api/v1/activity/timeline": {
"get": {
"description": "get object timeline",
"produces": [
"application/json"
],
"tags": [
"Comment"
],
"summary": "get object timeline",
"parameters": [
{
"type": "string",
"description": "object id",
"name": "object_id",
"in": "query"
},
{
"type": "string",
"description": "tag slug name",
"name": "tag_slug_name",
"in": "query"
},
{
"enum": [
"question",
"answer",
"tag"
],
"type": "string",
"description": "object type",
"name": "object_type",
"in": "query"
},
{
"type": "boolean",
"description": "is show vote",
"name": "show_vote",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/handler.RespBody"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/schema.GetObjectTimelineResp"
}
}
}
]
}
}
}
}
},
"/answer/api/v1/answer": {
"put": {
"security": [
@ -4468,6 +4531,61 @@ const docTemplate = `{
"list": {}
}
},
"schema.ActObjectInfo": {
"type": "object",
"properties": {
"answer_id": {
"type": "string"
},
"object_type": {
"type": "string"
},
"question_id": {
"type": "string"
},
"title": {
"type": "string"
}
}
},
"schema.ActObjectTimeline": {
"type": "object",
"properties": {
"activity_id": {
"type": "string"
},
"activity_type": {
"type": "string"
},
"cancelled": {
"type": "boolean"
},
"cancelled_at": {
"type": "integer"
},
"comment": {
"type": "string"
},
"created_at": {
"type": "integer"
},
"object_id": {
"type": "string"
},
"object_type": {
"type": "string"
},
"revision_id": {
"type": "string"
},
"user_display_name": {
"type": "string"
},
"username": {
"type": "string"
}
}
},
"schema.ActionRecordResp": {
"type": "object",
"properties": {
@ -4874,6 +4992,20 @@ const docTemplate = `{
}
}
},
"schema.GetObjectTimelineResp": {
"type": "object",
"properties": {
"object_info": {
"$ref": "#/definitions/schema.ActObjectInfo"
},
"timeline": {
"type": "array",
"items": {
"$ref": "#/definitions/schema.ActObjectTimeline"
}
}
}
},
"schema.GetOtherUserInfoByUsernameResp": {
"type": "object",
"properties": {

View File

@ -993,6 +993,69 @@
}
}
},
"/answer/api/v1/activity/timeline": {
"get": {
"description": "get object timeline",
"produces": [
"application/json"
],
"tags": [
"Comment"
],
"summary": "get object timeline",
"parameters": [
{
"type": "string",
"description": "object id",
"name": "object_id",
"in": "query"
},
{
"type": "string",
"description": "tag slug name",
"name": "tag_slug_name",
"in": "query"
},
{
"enum": [
"question",
"answer",
"tag"
],
"type": "string",
"description": "object type",
"name": "object_type",
"in": "query"
},
{
"type": "boolean",
"description": "is show vote",
"name": "show_vote",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/handler.RespBody"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/schema.GetObjectTimelineResp"
}
}
}
]
}
}
}
}
},
"/answer/api/v1/answer": {
"put": {
"security": [
@ -4456,6 +4519,61 @@
"list": {}
}
},
"schema.ActObjectInfo": {
"type": "object",
"properties": {
"answer_id": {
"type": "string"
},
"object_type": {
"type": "string"
},
"question_id": {
"type": "string"
},
"title": {
"type": "string"
}
}
},
"schema.ActObjectTimeline": {
"type": "object",
"properties": {
"activity_id": {
"type": "string"
},
"activity_type": {
"type": "string"
},
"cancelled": {
"type": "boolean"
},
"cancelled_at": {
"type": "integer"
},
"comment": {
"type": "string"
},
"created_at": {
"type": "integer"
},
"object_id": {
"type": "string"
},
"object_type": {
"type": "string"
},
"revision_id": {
"type": "string"
},
"user_display_name": {
"type": "string"
},
"username": {
"type": "string"
}
}
},
"schema.ActionRecordResp": {
"type": "object",
"properties": {
@ -4862,6 +4980,20 @@
}
}
},
"schema.GetObjectTimelineResp": {
"type": "object",
"properties": {
"object_info": {
"$ref": "#/definitions/schema.ActObjectInfo"
},
"timeline": {
"type": "array",
"items": {
"$ref": "#/definitions/schema.ActObjectTimeline"
}
}
}
},
"schema.GetOtherUserInfoByUsernameResp": {
"type": "object",
"properties": {

View File

@ -89,6 +89,42 @@ definitions:
type: integer
list: {}
type: object
schema.ActObjectInfo:
properties:
answer_id:
type: string
object_type:
type: string
question_id:
type: string
title:
type: string
type: object
schema.ActObjectTimeline:
properties:
activity_id:
type: string
activity_type:
type: string
cancelled:
type: boolean
cancelled_at:
type: integer
comment:
type: string
created_at:
type: integer
object_id:
type: string
object_type:
type: string
revision_id:
type: string
user_display_name:
type: string
username:
type: string
type: object
schema.ActionRecordResp:
properties:
captcha_id:
@ -379,6 +415,15 @@ definitions:
description: tag id
type: string
type: object
schema.GetObjectTimelineResp:
properties:
object_info:
$ref: '#/definitions/schema.ActObjectInfo'
timeline:
items:
$ref: '#/definitions/schema.ActObjectTimeline'
type: array
type: object
schema.GetOtherUserInfoByUsernameResp:
properties:
answer_count:
@ -2189,6 +2234,45 @@ paths:
summary: get user page
tags:
- admin
/answer/api/v1/activity/timeline:
get:
description: get object timeline
parameters:
- description: object id
in: query
name: object_id
type: string
- description: tag slug name
in: query
name: tag_slug_name
type: string
- description: object type
enum:
- question
- answer
- tag
in: query
name: object_type
type: string
- description: is show vote
in: query
name: show_vote
type: boolean
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/handler.RespBody'
- properties:
data:
$ref: '#/definitions/schema.GetObjectTimelineResp'
type: object
summary: get object timeline
tags:
- Comment
/answer/api/v1/answer:
delete:
consumes:

View File

@ -28,8 +28,8 @@ backend:
other: "Answer do not found."
cannot_deleted:
other: "No permission to delete."
cannot_update:
other: "No permission to update."
cannot_update:
other: "No permission to update."
comment:
edit_without_permission:
other: "Comment are not allowed to edit."

View File

@ -29,7 +29,7 @@ func NewActivityController(
// @Param object_id query string false "object id"
// @Param tag_slug_name query string false "tag slug name"
// @Param object_type query string false "object type" Enums(question, answer, tag)
// @Param show_vote bool false "is show vote"
// @Param show_vote query boolean false "is show vote"
// @Success 200 {object} handler.RespBody{data=schema.GetObjectTimelineResp}
// @Router /answer/api/v1/activity/timeline [get]
func (ac *ActivityController) GetObjectTimeline(ctx *gin.Context) {

View File

@ -79,7 +79,7 @@ func (qs *QuestionService) CloseQuestion(ctx context.Context, req *schema.CloseQ
return errors.BadRequest(reason.QuestionCannotClose)
}
}
questionInfo.Status = entity.QuestionStatusclosed
questionInfo.Status = entity.QuestionStatusClosed
err = qs.questionRepo.UpdateQuestionStatus(ctx, questionInfo)
if err != nil {
return err