增加生成访客文档

pull/30/head
taoshihan1991 4 years ago
parent 3b9aa02be2
commit 0ace37765c

@ -9,10 +9,11 @@ import (
// @Summary 登陆验证接口
// @Produce json
// @Accept multipart/form-data
// @Param username formData string true "username"
// @Param password formData string true "password"
// @Param type formData string true "type"
// @Success 200 {string} string "{"code":200,"result":{},"msg":"ok"}"
// @Param username formData string true "用户名"
// @Param password formData string true "密码"
// @Param type formData string true "类型"
// @Success 200 {object} controller.Response
// @Failure 200 {object} controller.Response
// @Router /check [post]
//验证接口
func LoginCheckPass(c *gin.Context) {

@ -0,0 +1,6 @@
package controller
type Response struct {
Code int `json:"code"`
Msg string `json:"msg"`
result interface{} `json:"result"`
}

@ -16,6 +16,14 @@ func GetVisitor(c *gin.Context) {
"result":vistor,
})
}
// @Summary 获取访客列表接口
// @Produce json
// @Accept multipart/form-data
// @Param page query string true "分页"
// @Param token header string true "认证token"
// @Success 200 {object} controller.Response
// @Failure 200 {object} controller.Response
// @Router /visitors [get]
func GetVisitors(c *gin.Context) {
page,_:=strconv.Atoi(c.Query("page"))
kefuId,_:=c.Get("kefu_name")

@ -1,20 +1,17 @@
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at
// 2020-07-10 22:43:52.8548363 +0800 CST m=+0.306823701
// 2020-07-13 15:09:32.8830515 +0800 CST m=+0.102005901
package docs
import (
"bytes"
"encoding/json"
"strings"
"github.com/alecthomas/template"
"github.com/swaggo/swag"
)
var doc = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{.Description}}",
@ -38,21 +35,21 @@ var doc = `{
"parameters": [
{
"type": "string",
"description": "username",
"description": "用户名",
"name": "username",
"in": "formData",
"required": true
},
{
"type": "string",
"description": "password",
"description": "密码",
"name": "password",
"in": "formData",
"required": true
},
{
"type": "string",
"description": "type",
"description": "类型",
"name": "type",
"in": "formData",
"required": true
@ -60,14 +57,67 @@ var doc = `{
],
"responses": {
"200": {
"description": "{\"code\":200,\"result\":{},\"msg\":\"ok\"}",
"description": "OK",
"schema": {
"type": "string"
"type": "object",
"$ref": "#/definitions/controller.Response"
}
}
}
}
},
"/visitors": {
"get": {
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"summary": "获取访客列表接口",
"parameters": [
{
"type": "string",
"description": "分页",
"name": "page",
"in": "query",
"required": true
},
{
"type": "string",
"description": "认证token",
"name": "token",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"$ref": "#/definitions/controller.Response"
}
}
}
}
}
},
"definitions": {
"controller.Response": {
"type": "object",
"properties": {
"code": {
"type": "integer"
},
"msg": {
"type": "string"
},
"result": {
"type": "object"
}
}
}
}
}`
@ -75,39 +125,23 @@ type swaggerInfo struct {
Version string
Host string
BasePath string
Schemes []string
Title string
Description string
}
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = swaggerInfo{
Version: "",
Host: "",
BasePath: "",
Schemes: []string{},
Title: "",
Description: "",
}
var SwaggerInfo swaggerInfo
type s struct{}
func (s *s) ReadDoc() string {
sInfo := SwaggerInfo
sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1)
t, err := template.New("swagger_info").Funcs(template.FuncMap{
"marshal": func(v interface{}) string {
a, _ := json.Marshal(v)
return string(a)
},
}).Parse(doc)
t, err := template.New("swagger_info").Parse(doc)
if err != nil {
return doc
}
var tpl bytes.Buffer
if err := t.Execute(&tpl, sInfo); err != nil {
if err := t.Execute(&tpl, SwaggerInfo); err != nil {
return doc
}

@ -1,9 +1,14 @@
{
"swagger": "2.0",
"info": {
"description": "{{.Description}}",
"title": "{{.Title}}",
"contact": {},
"license": {}
"license": {},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/check": {
"post": {
@ -17,21 +22,21 @@
"parameters": [
{
"type": "string",
"description": "username",
"description": "用户名",
"name": "username",
"in": "formData",
"required": true
},
{
"type": "string",
"description": "password",
"description": "密码",
"name": "password",
"in": "formData",
"required": true
},
{
"type": "string",
"description": "type",
"description": "类型",
"name": "type",
"in": "formData",
"required": true
@ -39,13 +44,66 @@
],
"responses": {
"200": {
"description": "{\"code\":200,\"result\":{},\"msg\":\"ok\"}",
"description": "OK",
"schema": {
"type": "string"
"type": "object",
"$ref": "#/definitions/controller.Response"
}
}
}
}
},
"/visitors": {
"get": {
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"summary": "获取访客列表接口",
"parameters": [
{
"type": "string",
"description": "分页",
"name": "page",
"in": "query",
"required": true
},
{
"type": "string",
"description": "认证token",
"name": "token",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"$ref": "#/definitions/controller.Response"
}
}
}
}
}
},
"definitions": {
"controller.Response": {
"type": "object",
"properties": {
"code": {
"type": "integer"
},
"msg": {
"type": "string"
},
"result": {
"type": "object"
}
}
}
}
}

@ -1,23 +1,38 @@
basePath: '{{.BasePath}}'
definitions:
controller.Response:
properties:
code:
type: integer
msg:
type: string
result:
type: object
type: object
host: '{{.Host}}'
info:
contact: {}
description: '{{.Description}}'
license: {}
title: '{{.Title}}'
version: '{{.Version}}'
paths:
/check:
post:
consumes:
- multipart/form-data
parameters:
- description: username
- description: 用户名
in: formData
name: username
required: true
type: string
- description: password
- description: 密码
in: formData
name: password
required: true
type: string
- description: type
- description: 类型
in: formData
name: type
required: true
@ -26,8 +41,33 @@ paths:
- application/json
responses:
"200":
description: '{"code":200,"result":{},"msg":"ok"}'
description: OK
schema:
type: string
$ref: '#/definitions/controller.Response'
type: object
summary: 登陆验证接口
/visitors:
get:
consumes:
- multipart/form-data
parameters:
- description: 分页
in: query
name: page
required: true
type: string
- description: 认证token
in: header
name: token
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/controller.Response'
type: object
summary: 获取访客列表接口
swagger: "2.0"

@ -74,10 +74,10 @@ func main() {
//文档服务
docs.SwaggerInfo.Title = "GO-FLY接口文档"
docs.SwaggerInfo.Description = "go-fly即时通讯web客服管理系统"
docs.SwaggerInfo.Version = "0.0.5"
docs.SwaggerInfo.Version = "0.0.6"
docs.SwaggerInfo.Host = "127.0.0.1:"+port
docs.SwaggerInfo.BasePath = "/"
docs.SwaggerInfo.Schemes = []string{"http"}
engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
//docs.SwaggerInfo.Schemes = []string{"http"}
engine.GET("/docs/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
engine.Run(baseServer)
}

@ -2,7 +2,7 @@
<el-menu
default-active="3"
mode="horizontal">
<el-menu-item class="mainLogo" v-on:click="openUrl('/login')">GO-FLY<span class="version">V0.0.5</span></el-menu-item>
<el-menu-item class="mainLogo" v-on:click="openUrl('/login')">GO-FLY<span class="version">V0.0.6</span></el-menu-item>
<el-menu-item style="display:none" index="2" v-on:click="openIframeUrl('/list')">邮箱<el-badge class="mark" :value="mailTotal" style="margin-bottom: 20px;"/>
</el-menu-item>
<el-menu-item index="3" v-on:click="openIframeUrl('/chat_main')">聊天</el-menu-item>

Loading…
Cancel
Save