Merge branch 'doc/0.3.0/github' into 'main'

Doc/0.3.0/github

See merge request 
This commit is contained in:
linkinstar 2022-11-11 07:27:15 +00:00
commit cfcf4ba02f
10 changed files with 1018 additions and 242 deletions

View File

@ -17,6 +17,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64,linux/arm64
- name: Login to DockerHub
uses: docker/login-action@v1
@ -34,7 +38,8 @@ jobs:
# branch event
type=ref,enable=true,priority=600,prefix=,suffix=,event=branch
# tag event
type=ref,enable=true,priority=600,prefix=,suffix=,event=tag
#type=ref,enable=true,priority=600,prefix=,suffix=,event=tag
type=semver,pattern={{version}}
@ -42,6 +47,8 @@ jobs:
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@ -1,103 +1,69 @@
# How to build and install
# Answer installation guide
## Environment Preparation
- Memory >= 512M
- If using MySQL version >= 5.7
Before installing Answer, you need to install the base environment first.
- database
- [MySQL](http://dev.mysql.com) Version >= 5.7
You can then install Answer in several ways:
- [Deploy with Docker](#Docker-compose-for-Answer)
- [Binary installation](#Install-Answer-using-binary)
- [Source installation](#Compile-the-image)
## Docker-compose for Answer
## Installing with docker
### Step 1: Start the project with the docker command
```bash
$ mkdir answer && cd answer
$ wget https://raw.githubusercontent.com/answerdev/answer/main/docker-compose.yaml
$ docker-compose up
docker run -d -p 9080:80 -v answer-data:/data --name answer answerdev/answer:latest
```
In browser, open URL [http://127.0.0.1:9080/](http://127.0.0.1:9080/).
### Step 2: Visit the installation url
[http://127.0.0.1:9080/install](http://127.0.0.1:9080/install)
You can log in with the default administrator username (**`admin@admin.com`**) and password (**`admin`**).
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
## Docker for Answer
Visit [Docker Hub](https://hub.docker.com/r/answerdev/answer) or GitHub Container registry to see all available images and tags.
![install-database](docs/img/install-database.png)
### Usage
To persist data beyond the life of a Docker container, use a volume (/var/data -> /data). You can modify this based on your situation.
Then click next to create the configuration file, click next to enter the basic website information and administrator information, as shown below
```
# Pull image from Docker Hub.
$ docker pull answerdev/answer:latest
![install- site-info](docs/img/install-site-info.png)
# Create local directory for volume.
$ mkdir -p /var/data
Click Next to complete the installation
# Run the image first
$ docker run --name=answer -p 9080:80 -v /var/data:/data answerdev/answer
### Step 3: After installation, visit the project path to start using
[http://127.0.0.1:9080/](http://127.0.0.1:9080/)
# After successful first startup, a configuration file will be generated in the /var/data directory
# /var/data/conf/config.yaml
# Need to modify the Mysql database address in the configuration file
vim /var/data/conf/config.yaml
Login with the administrator username and password you just created.
# Modify database connection
# connection: [username]:[password]@tcp([host]:[port])/[DbName]
...
# After configuring the configuration file, you can start the container again to start the service
$ docker start answer
## Installing with docker-compose
### Step 1: Start the project with the docker-compose command
```bash
mkdir answer && cd answer
wget https://raw.githubusercontent.com/answerdev/answer/main/docker-compose.yaml
docker-compose up
```
## Install Answer using binary
### Step 2: Visit the installation url
[http://127.0.0.1:9080/install](http://127.0.0.1:9080/install)
1. Unzip the compressed package
2. Use the command `cd` to enter the directory you just created
3. Execute the command `./answer init`
4. Answer will generate a `./data` directory in the current directory
5. Enter the `data` directory and modify the `config.yaml` file
6. Modify the database connection identify your database connection information
`connection: [username]:[password]@tcp([host]:[port])/[DbName]`
7. Use `cd ..` to return the directory from step 2, and execute `./answer run -c ./data/conf/config.yaml`
The exact configuration is the same as for docker use
## Available Commands
Usage: `answer [command]`
### Step 3: After installation, visit home page
[http://127.0.0.1:9080/](http://127.0.0.1:9080/)
- `help`: Help about any command
- `init`: Init answer application
- `run`: Run answer application
- `check`: Check answer required environment
- `dump`: Backup answer data
## Install with binary
### Step 1: Download the binaries
[https://github.com/answerdev/answer/releases](https://github.com/answerdev/answer/releases)
Download the version you need for your current system
## config.yaml Description
Here is a sample/default config.yaml file, as would be created from `answer init`.
```
server:
http:
addr: 0.0.0.0:80 #Project access port number
data:
database:
connection: root:root@tcp(127.0.0.1:3306)/answer #MySQL database connection address
cache:
file_path: "/tmp/cache/cache.db" #Cache file storage path
i18n:
bundle_dir: "/data/i18n" #Internationalized file storage directory
swaggerui:
show: true #Whether to display the swaggerapi documentation, address /swagger/index.html
protocol: http #swagger protocol header
host: 127.0.0.1 #An accessible IP address or domain name
address: ':80' #accessible port number
service_config:
secret_key: "answer" #encryption key
web_host: "http://127.0.0.1" #Page access using domain name address
upload_path: "./uploads" #upload directory
### Step 2: Install using command line
> The following command -C specifies the data directory required for answer, you can modify it as you see fit
```bash
. /answer init -C . /answer-data/
```
## Compile the image
If you have modified the source files and want to repackage the image, you can use the following to repackage the image
Then visit: [http://127.0.0.1:9080/install](http://127.0.0.1:9080/install) to install, the configuration is the same as using docker installation
### Step 3: Start with command line
After the installation is complete, the program will exit, so use the command to start the project formally
```bash
. /answer run -C . /answer-data/
```
docker build -t answer:v1.0.0 .
```
## common problem
1. The project cannot be started: the main program startup depends on proper configuraiton of the configuration file, `config.yaml`, as well as the internationalization translation directory (`i18n`), and the upload file storage directory (`uploads`). Ensure that the configuration file is loaded when the project starts, such as when using `answer run -c config.yaml` and that the `config.yaml` correctly specifies the i18n and uploads directories.
After normal startup you can access [http://127.0.0.1:9080/](http://127.0.0.1:9080/) to log in using the administrator username password specified during installation
## Installation FAQ
- Having trouble reinstalling using docker? The default command we give is to use `answer-data` to name the volume, so if you don't need the original data again, please delete it voluntarily `docker volume rm answer-data`

View File

@ -1,4 +1,7 @@
# Answer 安装指引
## 环境准备
- 内存 >= 512M
- 如果使用 MySQL 版本 >= 5.7
## 使用 docker 安装
### 步骤 1: 使用 docker 命令启动项目
@ -50,31 +53,16 @@ docker-compose up
```bash
./answer init -C ./answer-data/
```
server:
http:
addr: 0.0.0.0:80 #项目访问端口号
data:
database:
connection: root:root@tcp(127.0.0.1:3306)/answer #mysql数据库连接地址
cache:
file_path: "/tmp/cache/cache.db" #缓存文件存放路径
i18n:
bundle_dir: "/data/i18n" #国际化文件存放目录
swaggerui:
show: true #是否显示swaggerapi文档,地址 /swagger/index.html
protocol: http #swagger 协议头
host: 127.0.0.1 #可被访问的ip地址或域名
address: ':80' #可被访问的端口号
service_config:
secret_key: "answer" #加密key
web_host: "http://127.0.0.1" #页面访问使用域名地址
upload_path: "./upfiles" #上传目录
然后访问:[http://127.0.0.1:9080/install](http://127.0.0.1:9080/install) 进行安装,具体配置与使用 docker 安装相同
### 步骤 3: 使用命令行启动
安装完成之后程序会退出,请使用命令正式启动项目
```bash
./answer run -C ./answer-data/
```
## 编译镜像
如果修改了源文件并且要重新打包镜像可以使用以下语句重新打包镜像
```
docker build -t answer:v1.0.0 .
```
## 常见问题
1. 项目无法启动answer 主程序启动依赖配置文件 config.yaml 、国际化翻译目录 /i18n 、上传文件存放目录 /upfiles需要确保项目启动时加载了配置文件 answer run -c config.yaml 以及在 config.yaml 正确的指定 i18n 和 upfiles 目录的配置项
正常启动后可以访问 [http://127.0.0.1:9080/](http://127.0.0.1:9080/) 使用安装时指定的管理员用户名密码进行登录
## 安装常见问题
- 使用 docker 重新安装遇到问题?默认我们给出的命令是使用 `answer-data` 命名卷,所以如果重新不需要原来的数据,请主动进行删除 `docker volume rm answer-data`

View File

@ -1,6 +1,6 @@
.PHONY: build clean ui
VERSION=0.0.1
VERSION=0.3.0
BIN=answer
DIR_SRC=./cmd/answer
DOCKER_CMD=docker
@ -40,6 +40,6 @@ install-ui-packages:
ui:
@npm config set registry https://repo.huaweicloud.com/repository/npm/
@cd ui && echo "REACT_APP_VERSION=$(VERSION)" >> .env && pnpm install && pnpm build && cd -
@cd ui && pnpm install && pnpm build && cd -
all: clean build

View File

@ -22,7 +22,7 @@ To learn more about the project, visit [answer.dev](https://answer.dev).
### Running with docker
```bash
docker run -d -p 9080:80 -v $PWD/answer-data:/data --name answer answerdev/answer:latest
docker run -d -p 9080:80 -v answer-data:/data --name answer answerdev/answer:latest
```
For more information, see [INSTALL.md](./INSTALL.md)

View File

@ -22,7 +22,7 @@
### 使用 docker 快速搭建
```bash
docker run -d -p 9080:80 -v $PWD/answer-data:/data --name answer answerdev/answer:latest
docker run -d -p 9080:80 -v answer-data:/data --name answer answerdev/answer:latest
```
其他安装配置细节请参考 [INSTALL.md](./INSTALL.md)

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