Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion database/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func ConnectDatabase() {
log.Fatalf("Failed to connect to database: %v", err)
}

err = DB.AutoMigrate(&models.User{}, &models.Question{}, &models.Answer{}, &models.Comment{}, &models.Tag{}, &models.Log{})
err = DB.AutoMigrate(&models.User{}, &models.Question{}, &models.Answer{}, &models.Comment{}, &models.Tag{}, &models.Log{}, &models.Report{})
if err != nil {
log.Fatalf("Migration failed: %v", err)
}
Expand Down
118 changes: 104 additions & 14 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const docTemplate = `{
}
}
},
"/api/answer_handler/add": {
"/api/answer/add": {
"post": {
"consumes": [
"application/json"
Expand All @@ -88,7 +88,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
"answer_handler"
"answer"
],
"parameters": [
{
Expand All @@ -100,7 +100,7 @@ const docTemplate = `{
},
{
"description": "Answer object",
"name": "answer_handler",
"name": "answer",
"in": "body",
"required": true,
"schema": {
Expand All @@ -118,7 +118,7 @@ const docTemplate = `{
}
}
},
"/api/answer_handler/correctAnswer/{id}": {
"/api/answer/correctAnswer/{id}": {
"get": {
"consumes": [
"application/json"
Expand All @@ -127,7 +127,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
"answer_handler"
"answer"
],
"parameters": [
{
Expand All @@ -148,7 +148,7 @@ const docTemplate = `{
}
}
},
"/api/answer_handler/delete": {
"/api/answer/delete": {
"delete": {
"consumes": [
"application/json"
Expand All @@ -157,7 +157,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
"answer_handler"
"answer"
],
"parameters": [
{
Expand All @@ -178,7 +178,7 @@ const docTemplate = `{
}
}
},
"/api/answer_handler/voteDown/{id}": {
"/api/answer/voteDown/{id}": {
"get": {
"consumes": [
"application/json"
Expand All @@ -187,7 +187,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
"answer_handler"
"answer"
],
"parameters": [
{
Expand Down Expand Up @@ -215,7 +215,7 @@ const docTemplate = `{
}
}
},
"/api/answer_handler/voteUp/{id}": {
"/api/answer/voteUp/{id}": {
"get": {
"consumes": [
"application/json"
Expand All @@ -224,7 +224,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
"answer_handler"
"answer"
],
"parameters": [
{
Expand Down Expand Up @@ -351,7 +351,7 @@ const docTemplate = `{
},
{
"description": "Question Data",
"name": "question_handler",
"name": "question",
"in": "body",
"required": true,
"schema": {
Expand Down Expand Up @@ -417,7 +417,7 @@ const docTemplate = `{
},
{
"description": "Question object",
"name": "question_handler",
"name": "question",
"in": "body",
"required": true,
"schema": {
Expand Down Expand Up @@ -465,7 +465,7 @@ const docTemplate = `{
}
}
},
"/api/questions/my/{id}": {
"/api/questions/voteDown/{id}": {
"get": {
"consumes": [
"application/json"
Expand Down Expand Up @@ -539,6 +539,82 @@ const docTemplate = `{
}
}
},
"/api/questions/{id}": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"questions"
],
"parameters": [
{
"type": "string",
"description": "Bearer Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/models.Question"
}
}
}
}
},
"/api/report": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"report"
],
"parameters": [
{
"type": "string",
"description": "Bearer Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "Report object",
"name": "report",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.Report"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/models.Report"
}
}
}
}
},
"/api/tag/add": {
"post": {
"consumes": [
Expand Down Expand Up @@ -785,6 +861,20 @@ const docTemplate = `{
}
}
},
"models.Report": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"report_id": {
"type": "string"
},
"report_type": {
"type": "string"
}
}
},
"models.Tag": {
"type": "object",
"properties": {
Expand Down
98 changes: 94 additions & 4 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@
}
}
},
"/api/questions/my/{id}": {
"/api/questions/voteDown/{id}": {
"get": {
"consumes": [
"application/json"
Expand Down Expand Up @@ -528,6 +528,82 @@
}
}
},
"/api/questions/{id}": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"questions"
],
"parameters": [
{
"type": "string",
"description": "Bearer Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/models.Question"
}
}
}
}
},
"/api/report": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"report"
],
"parameters": [
{
"type": "string",
"description": "Bearer Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "Report object",
"name": "report",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.Report"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/models.Report"
}
}
}
}
},
"/api/tag/add": {
"post": {
"consumes": [
Expand Down Expand Up @@ -611,7 +687,7 @@
"parameters": [
{
"description": "User object",
"name": "answer",
"name": "answer_handler",
"in": "body",
"required": true,
"schema": {
Expand Down Expand Up @@ -673,7 +749,7 @@
"parameters": [
{
"description": "User object",
"name": "answer",
"name": "answer_handler",
"in": "body",
"required": true,
"schema": {
Expand Down Expand Up @@ -736,7 +812,7 @@
"type": "integer"
},
"parent_type": {
"description": "\"question\" or \"answer\"",
"description": "\"question_handler\" or \"answer_handler\"",
"type": "string"
},
"user_id": {
Expand Down Expand Up @@ -774,6 +850,20 @@
}
}
},
"models.Report": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"report_id": {
"type": "string"
},
"report_type": {
"type": "string"
}
}
},
"models.Tag": {
"type": "object",
"properties": {
Expand Down
Loading
Loading