Merge branch 'doc/0.3.0/github' of git.backyard.segmentfault.com:opensource/answer into doc/0.3.0/github

This commit is contained in:
aichy126 2022-11-11 15:21:42 +08:00
commit 80b0f79540
5 changed files with 949 additions and 134 deletions

View File

@ -9,7 +9,7 @@
docker run -d -p 9080:80 -v answer-data:/data --name answer answerdev/answer:latest
```
### Step 2: Access the installation path for project installation
### Step 2: Visit the installation url
[http://127.0.0.1:9080/install](http://127.0.0.1:9080/install)
After selecting the language click next to select the appropriate database, if you just want to experience it currently, it is recommended to select sqlite as the database directly, as shown below
@ -35,12 +35,12 @@ wget https://raw.githubusercontent.com/answerdev/answer/main/docker-compose.yaml
docker-compose up
```
### Step 2: Access the installation path for project installation
### Step 2: Visit the installation url
[http://127.0.0.1:9080/install](http://127.0.0.1:9080/install)
The exact configuration is the same as for docker use
### Step 3: After installation, access the project path to start using
### Step 3: After installation, visit home page
[http://127.0.0.1:9080/](http://127.0.0.1:9080/)
## Install with binary

View File

@ -62,6 +62,12 @@ const docTemplate = `{
"description": "answer id or question title",
"name": "query",
"in": "query"
},
{
"type": "string",
"description": "question id",
"name": "question_id",
"in": "query"
}
],
"responses": {
@ -143,11 +149,6 @@ const docTemplate = `{
},
"/answer/admin/api/language/options": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Get language options",
"produces": [
"application/json"
@ -1443,11 +1444,6 @@ const docTemplate = `{
},
"/answer/api/v1/language/options": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Get language options",
"produces": [
"application/json"
@ -3402,6 +3398,52 @@ const docTemplate = `{
}
}
},
"/answer/api/v1/user/interface": {
"put": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "UserUpdateInterface update user interface config",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"User"
],
"summary": "UserUpdateInterface update user interface config",
"parameters": [
{
"type": "string",
"description": "access-token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "UpdateInfoRequest",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/schema.UpdateUserInterfaceRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handler.RespBody"
}
}
}
}
},
"/answer/api/v1/user/login/email": {
"post": {
"description": "UserEmailLogin",
@ -3721,46 +3763,6 @@ const docTemplate = `{
}
}
},
"/answer/api/v1/user/status": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "get user status info",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"User"
],
"summary": "get user status info",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/handler.RespBody"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/schema.GetUserResp"
}
}
}
]
}
}
}
}
},
"/answer/api/v1/vote/down": {
"post": {
"security": [
@ -3863,6 +3865,190 @@ const docTemplate = `{
}
}
},
"/installation/base-info": {
"post": {
"description": "init base info",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"installation"
],
"summary": "init base info",
"parameters": [
{
"description": "InitBaseInfoReq",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/install.InitBaseInfoReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handler.RespBody"
}
}
}
}
},
"/installation/config-file/check": {
"post": {
"description": "check config file if exist when installation",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"installation"
],
"summary": "check config file if exist when installation",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/handler.RespBody"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/install.CheckConfigFileResp"
}
}
}
]
}
}
}
}
},
"/installation/db/check": {
"post": {
"description": "check database if exist when installation",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"installation"
],
"summary": "check database if exist when installation",
"parameters": [
{
"description": "CheckDatabaseReq",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/install.CheckDatabaseReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/handler.RespBody"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/install.CheckConfigFileResp"
}
}
}
]
}
}
}
}
},
"/installation/init": {
"post": {
"description": "init environment",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"installation"
],
"summary": "init environment",
"parameters": [
{
"description": "CheckDatabaseReq",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/install.CheckDatabaseReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handler.RespBody"
}
}
}
}
},
"/installation/language/options": {
"get": {
"description": "get installation language options",
"produces": [
"application/json"
],
"tags": [
"Lang"
],
"summary": "get installation language options",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/handler.RespBody"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/translator.LangOption"
}
}
}
}
]
}
}
}
}
},
"/personal/question/page": {
"get": {
"security": [
@ -3961,6 +4147,94 @@ const docTemplate = `{
}
}
},
"install.CheckConfigFileResp": {
"type": "object",
"properties": {
"config_file_exist": {
"type": "boolean"
},
"db_connection_success": {
"type": "boolean"
},
"db_table_exist": {
"type": "boolean"
}
}
},
"install.CheckDatabaseReq": {
"type": "object",
"required": [
"db_type"
],
"properties": {
"db_file": {
"type": "string"
},
"db_host": {
"type": "string"
},
"db_name": {
"type": "string"
},
"db_password": {
"type": "string"
},
"db_type": {
"type": "string",
"enum": [
"postgres",
"sqlite3",
"mysql"
]
},
"db_username": {
"type": "string"
}
}
},
"install.InitBaseInfoReq": {
"type": "object",
"required": [
"contact_email",
"email",
"lang",
"name",
"password",
"site_name",
"site_url"
],
"properties": {
"contact_email": {
"type": "string",
"maxLength": 500
},
"email": {
"type": "string",
"maxLength": 500
},
"lang": {
"type": "string",
"maxLength": 30
},
"name": {
"type": "string",
"maxLength": 30
},
"password": {
"type": "string",
"maxLength": 32,
"minLength": 8
},
"site_name": {
"type": "string",
"maxLength": 30
},
"site_url": {
"type": "string",
"maxLength": 512
}
}
},
"pager.PageModel": {
"type": "object",
"properties": {
@ -4833,6 +5107,10 @@ const docTemplate = `{
"description": "is admin",
"type": "boolean"
},
"language": {
"description": "language",
"type": "string"
},
"last_login_date": {
"description": "last login date",
"type": "integer"
@ -4929,6 +5207,10 @@ const docTemplate = `{
"description": "is admin",
"type": "boolean"
},
"language": {
"description": "language",
"type": "string"
},
"last_login_date": {
"description": "last login date",
"type": "integer"
@ -5614,6 +5896,19 @@ const docTemplate = `{
}
}
},
"schema.UpdateUserInterfaceRequest": {
"type": "object",
"required": [
"language"
],
"properties": {
"language": {
"description": "language",
"type": "string",
"maxLength": 100
}
}
},
"schema.UpdateUserStatusReq": {
"type": "object",
"required": [
@ -5854,6 +6149,17 @@ const docTemplate = `{
"type": "integer"
}
}
},
"translator.LangOption": {
"type": "object",
"properties": {
"label": {
"type": "string"
},
"value": {
"type": "string"
}
}
}
},
"securityDefinitions": {

View File

@ -50,6 +50,12 @@
"description": "answer id or question title",
"name": "query",
"in": "query"
},
{
"type": "string",
"description": "question id",
"name": "question_id",
"in": "query"
}
],
"responses": {
@ -131,11 +137,6 @@
},
"/answer/admin/api/language/options": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Get language options",
"produces": [
"application/json"
@ -1431,11 +1432,6 @@
},
"/answer/api/v1/language/options": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Get language options",
"produces": [
"application/json"
@ -3390,6 +3386,52 @@
}
}
},
"/answer/api/v1/user/interface": {
"put": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "UserUpdateInterface update user interface config",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"User"
],
"summary": "UserUpdateInterface update user interface config",
"parameters": [
{
"type": "string",
"description": "access-token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "UpdateInfoRequest",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/schema.UpdateUserInterfaceRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handler.RespBody"
}
}
}
}
},
"/answer/api/v1/user/login/email": {
"post": {
"description": "UserEmailLogin",
@ -3709,46 +3751,6 @@
}
}
},
"/answer/api/v1/user/status": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "get user status info",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"User"
],
"summary": "get user status info",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/handler.RespBody"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/schema.GetUserResp"
}
}
}
]
}
}
}
}
},
"/answer/api/v1/vote/down": {
"post": {
"security": [
@ -3851,6 +3853,190 @@
}
}
},
"/installation/base-info": {
"post": {
"description": "init base info",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"installation"
],
"summary": "init base info",
"parameters": [
{
"description": "InitBaseInfoReq",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/install.InitBaseInfoReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handler.RespBody"
}
}
}
}
},
"/installation/config-file/check": {
"post": {
"description": "check config file if exist when installation",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"installation"
],
"summary": "check config file if exist when installation",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/handler.RespBody"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/install.CheckConfigFileResp"
}
}
}
]
}
}
}
}
},
"/installation/db/check": {
"post": {
"description": "check database if exist when installation",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"installation"
],
"summary": "check database if exist when installation",
"parameters": [
{
"description": "CheckDatabaseReq",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/install.CheckDatabaseReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/handler.RespBody"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/install.CheckConfigFileResp"
}
}
}
]
}
}
}
}
},
"/installation/init": {
"post": {
"description": "init environment",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"installation"
],
"summary": "init environment",
"parameters": [
{
"description": "CheckDatabaseReq",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/install.CheckDatabaseReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handler.RespBody"
}
}
}
}
},
"/installation/language/options": {
"get": {
"description": "get installation language options",
"produces": [
"application/json"
],
"tags": [
"Lang"
],
"summary": "get installation language options",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/handler.RespBody"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/translator.LangOption"
}
}
}
}
]
}
}
}
}
},
"/personal/question/page": {
"get": {
"security": [
@ -3949,6 +4135,94 @@
}
}
},
"install.CheckConfigFileResp": {
"type": "object",
"properties": {
"config_file_exist": {
"type": "boolean"
},
"db_connection_success": {
"type": "boolean"
},
"db_table_exist": {
"type": "boolean"
}
}
},
"install.CheckDatabaseReq": {
"type": "object",
"required": [
"db_type"
],
"properties": {
"db_file": {
"type": "string"
},
"db_host": {
"type": "string"
},
"db_name": {
"type": "string"
},
"db_password": {
"type": "string"
},
"db_type": {
"type": "string",
"enum": [
"postgres",
"sqlite3",
"mysql"
]
},
"db_username": {
"type": "string"
}
}
},
"install.InitBaseInfoReq": {
"type": "object",
"required": [
"contact_email",
"email",
"lang",
"name",
"password",
"site_name",
"site_url"
],
"properties": {
"contact_email": {
"type": "string",
"maxLength": 500
},
"email": {
"type": "string",
"maxLength": 500
},
"lang": {
"type": "string",
"maxLength": 30
},
"name": {
"type": "string",
"maxLength": 30
},
"password": {
"type": "string",
"maxLength": 32,
"minLength": 8
},
"site_name": {
"type": "string",
"maxLength": 30
},
"site_url": {
"type": "string",
"maxLength": 512
}
}
},
"pager.PageModel": {
"type": "object",
"properties": {
@ -4821,6 +5095,10 @@
"description": "is admin",
"type": "boolean"
},
"language": {
"description": "language",
"type": "string"
},
"last_login_date": {
"description": "last login date",
"type": "integer"
@ -4917,6 +5195,10 @@
"description": "is admin",
"type": "boolean"
},
"language": {
"description": "language",
"type": "string"
},
"last_login_date": {
"description": "last login date",
"type": "integer"
@ -5602,6 +5884,19 @@
}
}
},
"schema.UpdateUserInterfaceRequest": {
"type": "object",
"required": [
"language"
],
"properties": {
"language": {
"description": "language",
"type": "string",
"maxLength": 100
}
}
},
"schema.UpdateUserStatusReq": {
"type": "object",
"required": [
@ -5842,6 +6137,17 @@
"type": "integer"
}
}
},
"translator.LangOption": {
"type": "object",
"properties": {
"label": {
"type": "string"
},
"value": {
"type": "string"
}
}
}
},
"securityDefinitions": {

View File

@ -20,6 +20,69 @@ definitions:
description: reason key
type: string
type: object
install.CheckConfigFileResp:
properties:
config_file_exist:
type: boolean
db_connection_success:
type: boolean
db_table_exist:
type: boolean
type: object
install.CheckDatabaseReq:
properties:
db_file:
type: string
db_host:
type: string
db_name:
type: string
db_password:
type: string
db_type:
enum:
- postgres
- sqlite3
- mysql
type: string
db_username:
type: string
required:
- db_type
type: object
install.InitBaseInfoReq:
properties:
contact_email:
maxLength: 500
type: string
email:
maxLength: 500
type: string
lang:
maxLength: 30
type: string
name:
maxLength: 30
type: string
password:
maxLength: 32
minLength: 8
type: string
site_name:
maxLength: 30
type: string
site_url:
maxLength: 512
type: string
required:
- contact_email
- email
- lang
- name
- password
- site_name
- site_url
type: object
pager.PageModel:
properties:
count:
@ -652,6 +715,9 @@ definitions:
is_admin:
description: is admin
type: boolean
language:
description: language
type: string
last_login_date:
description: last login date
type: integer
@ -723,6 +789,9 @@ definitions:
is_admin:
description: is admin
type: boolean
language:
description: language
type: string
last_login_date:
description: last login date
type: integer
@ -1219,6 +1288,15 @@ definitions:
- synonym_tag_list
- tag_id
type: object
schema.UpdateUserInterfaceRequest:
properties:
language:
description: language
maxLength: 100
type: string
required:
- language
type: object
schema.UpdateUserStatusReq:
properties:
status:
@ -1390,6 +1468,13 @@ definitions:
votes:
type: integer
type: object
translator.LangOption:
properties:
label:
type: string
value:
type: string
type: object
info:
contact: {}
paths:
@ -1418,6 +1503,10 @@ paths:
in: query
name: query
type: string
- description: question id
in: query
name: question_id
type: string
produces:
- application/json
responses:
@ -1481,8 +1570,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/handler.RespBody'
security:
- ApiKeyAuth: []
summary: Get language options
tags:
- Lang
@ -2267,8 +2354,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/handler.RespBody'
security:
- ApiKeyAuth: []
summary: Get language options
tags:
- Lang
@ -3455,6 +3540,35 @@ paths:
summary: UserUpdateInfo update user info
tags:
- User
/answer/api/v1/user/interface:
put:
consumes:
- application/json
description: UserUpdateInterface update user interface config
parameters:
- description: access-token
in: header
name: Authorization
required: true
type: string
- description: UpdateInfoRequest
in: body
name: data
required: true
schema:
$ref: '#/definitions/schema.UpdateUserInterfaceRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handler.RespBody'
security:
- ApiKeyAuth: []
summary: UserUpdateInterface update user interface config
tags:
- User
/answer/api/v1/user/login/email:
post:
consumes:
@ -3647,28 +3761,6 @@ paths:
summary: UserRegisterByEmail
tags:
- User
/answer/api/v1/user/status:
get:
consumes:
- application/json
description: get user status info
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/handler.RespBody'
- properties:
data:
$ref: '#/definitions/schema.GetUserResp'
type: object
security:
- ApiKeyAuth: []
summary: get user status info
tags:
- User
/answer/api/v1/vote/down:
post:
consumes:
@ -3727,6 +3819,117 @@ paths:
summary: vote up
tags:
- Activity
/installation/base-info:
post:
consumes:
- application/json
description: init base info
parameters:
- description: InitBaseInfoReq
in: body
name: data
required: true
schema:
$ref: '#/definitions/install.InitBaseInfoReq'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handler.RespBody'
summary: init base info
tags:
- installation
/installation/config-file/check:
post:
consumes:
- application/json
description: check config file if exist when installation
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/handler.RespBody'
- properties:
data:
$ref: '#/definitions/install.CheckConfigFileResp'
type: object
summary: check config file if exist when installation
tags:
- installation
/installation/db/check:
post:
consumes:
- application/json
description: check database if exist when installation
parameters:
- description: CheckDatabaseReq
in: body
name: data
required: true
schema:
$ref: '#/definitions/install.CheckDatabaseReq'
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/handler.RespBody'
- properties:
data:
$ref: '#/definitions/install.CheckConfigFileResp'
type: object
summary: check database if exist when installation
tags:
- installation
/installation/init:
post:
consumes:
- application/json
description: init environment
parameters:
- description: CheckDatabaseReq
in: body
name: data
required: true
schema:
$ref: '#/definitions/install.CheckDatabaseReq'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handler.RespBody'
summary: init environment
tags:
- installation
/installation/language/options:
get:
description: get installation language options
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/handler.RespBody'
- properties:
data:
items:
$ref: '#/definitions/translator.LangOption'
type: array
type: object
summary: get installation language options
tags:
- Lang
/personal/question/page:
get:
consumes:

View File

@ -24,7 +24,7 @@ import (
// @Description get installation language options
// @Tags Lang
// @Produce json
// @Success 200 {object} handler.RespBody{data=[]*translator.LangOption}
// @Success 200 {object} handler.RespBody{data=[]translator.LangOption}
// @Router /installation/language/options [get]
func LangOptions(ctx *gin.Context) {
handler.HandleResponse(ctx, nil, translator.LanguageOptions)
@ -94,7 +94,7 @@ func CheckDatabase(ctx *gin.Context) {
// @Accept json
// @Produce json
// @Param data body install.CheckDatabaseReq true "CheckDatabaseReq"
// @Success 200 {object} handler.RespBody{data=install.CheckConfigFileResp{}}
// @Success 200 {object} handler.RespBody{}
// @Router /installation/init [post]
func InitEnvironment(ctx *gin.Context) {
req := &CheckDatabaseReq{}
@ -146,7 +146,7 @@ func InitEnvironment(ctx *gin.Context) {
// @Accept json
// @Produce json
// @Param data body install.InitBaseInfoReq true "InitBaseInfoReq"
// @Success 200 {object} handler.RespBody{data=install.CheckConfigFileResp{}}
// @Success 200 {object} handler.RespBody{}
// @Router /installation/base-info [post]
func InitBaseInfo(ctx *gin.Context) {
req := &InitBaseInfoReq{}