增加生成访客文档

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

@ -9,10 +9,11 @@ import (
// @Summary 登陆验证接口 // @Summary 登陆验证接口
// @Produce json // @Produce json
// @Accept multipart/form-data // @Accept multipart/form-data
// @Param username formData string true "username" // @Param username formData string true "用户名"
// @Param password formData string true "password" // @Param password formData string true "密码"
// @Param type formData string true "type" // @Param type formData string true "类型"
// @Success 200 {string} string "{"code":200,"result":{},"msg":"ok"}" // @Success 200 {object} controller.Response
// @Failure 200 {object} controller.Response
// @Router /check [post] // @Router /check [post]
//验证接口 //验证接口
func LoginCheckPass(c *gin.Context) { 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, "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) { func GetVisitors(c *gin.Context) {
page,_:=strconv.Atoi(c.Query("page")) page,_:=strconv.Atoi(c.Query("page"))
kefuId,_:=c.Get("kefu_name") kefuId,_:=c.Get("kefu_name")

@ -1,20 +1,17 @@
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at // 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 package docs
import ( import (
"bytes" "bytes"
"encoding/json"
"strings"
"github.com/alecthomas/template" "github.com/alecthomas/template"
"github.com/swaggo/swag" "github.com/swaggo/swag"
) )
var doc = `{ var doc = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0", "swagger": "2.0",
"info": { "info": {
"description": "{{.Description}}", "description": "{{.Description}}",
@ -38,21 +35,21 @@ var doc = `{
"parameters": [ "parameters": [
{ {
"type": "string", "type": "string",
"description": "username", "description": "用户名",
"name": "username", "name": "username",
"in": "formData", "in": "formData",
"required": true "required": true
}, },
{ {
"type": "string", "type": "string",
"description": "password", "description": "密码",
"name": "password", "name": "password",
"in": "formData", "in": "formData",
"required": true "required": true
}, },
{ {
"type": "string", "type": "string",
"description": "type", "description": "类型",
"name": "type", "name": "type",
"in": "formData", "in": "formData",
"required": true "required": true
@ -60,14 +57,67 @@ var doc = `{
], ],
"responses": { "responses": {
"200": { "200": {
"description": "{\"code\":200,\"result\":{},\"msg\":\"ok\"}", "description": "OK",
"schema": { "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 Version string
Host string Host string
BasePath string BasePath string
Schemes []string
Title string Title string
Description string Description string
} }
// SwaggerInfo holds exported Swagger Info so clients can modify it // SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = swaggerInfo{ var SwaggerInfo swaggerInfo
Version: "",
Host: "",
BasePath: "",
Schemes: []string{},
Title: "",
Description: "",
}
type s struct{} type s struct{}
func (s *s) ReadDoc() string { func (s *s) ReadDoc() string {
sInfo := SwaggerInfo t, err := template.New("swagger_info").Parse(doc)
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)
if err != nil { if err != nil {
return doc return doc
} }
var tpl bytes.Buffer var tpl bytes.Buffer
if err := t.Execute(&tpl, sInfo); err != nil { if err := t.Execute(&tpl, SwaggerInfo); err != nil {
return doc return doc
} }

@ -1,9 +1,14 @@
{ {
"swagger": "2.0", "swagger": "2.0",
"info": { "info": {
"description": "{{.Description}}",
"title": "{{.Title}}",
"contact": {}, "contact": {},
"license": {} "license": {},
"version": "{{.Version}}"
}, },
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": { "paths": {
"/check": { "/check": {
"post": { "post": {
@ -17,21 +22,21 @@
"parameters": [ "parameters": [
{ {
"type": "string", "type": "string",
"description": "username", "description": "用户名",
"name": "username", "name": "username",
"in": "formData", "in": "formData",
"required": true "required": true
}, },
{ {
"type": "string", "type": "string",
"description": "password", "description": "密码",
"name": "password", "name": "password",
"in": "formData", "in": "formData",
"required": true "required": true
}, },
{ {
"type": "string", "type": "string",
"description": "type", "description": "类型",
"name": "type", "name": "type",
"in": "formData", "in": "formData",
"required": true "required": true
@ -39,13 +44,66 @@
], ],
"responses": { "responses": {
"200": { "200": {
"description": "{\"code\":200,\"result\":{},\"msg\":\"ok\"}", "description": "OK",
"schema": { "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: info:
contact: {} contact: {}
description: '{{.Description}}'
license: {} license: {}
title: '{{.Title}}'
version: '{{.Version}}'
paths: paths:
/check: /check:
post: post:
consumes: consumes:
- multipart/form-data - multipart/form-data
parameters: parameters:
- description: username - description: 用户名
in: formData in: formData
name: username name: username
required: true required: true
type: string type: string
- description: password - description: 密码
in: formData in: formData
name: password name: password
required: true required: true
type: string type: string
- description: type - description: 类型
in: formData in: formData
name: type name: type
required: true required: true
@ -26,8 +41,33 @@ paths:
- application/json - application/json
responses: responses:
"200": "200":
description: '{"code":200,"result":{},"msg":"ok"}' description: OK
schema: schema:
type: string $ref: '#/definitions/controller.Response'
type: object
summary: 登陆验证接口 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" swagger: "2.0"

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

@ -2,7 +2,7 @@
<el-menu <el-menu
default-active="3" default-active="3"
mode="horizontal"> 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 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>
<el-menu-item index="3" v-on:click="openIframeUrl('/chat_main')">聊天</el-menu-item> <el-menu-item index="3" v-on:click="openIframeUrl('/chat_main')">聊天</el-menu-item>

Loading…
Cancel
Save