Commit cfec11b1 authored by szh's avatar szh

up

parent ddd99b81
// 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
// 2019-02-02 17:46:50.428407 +0800 CST m=+0.087414608
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": "An example of gin", "description": "{{.Description}}",
"title": "Golang Gin API", "title": "{{.Title}}",
"termsOfService": "https://chain33-pai", "termsOfService": "https://chain33-pai",
"contact": {}, "contact": {},
"license": { "license": {
"name": "MIT", "name": "MIT",
"url": "https://chain33-pai/blob/master/LICENSE" "url": "https://chain33-pai/blob/master/LICENSE"
}, },
"version": "1.0" "version": "{{.Version}}"
}, },
"host": "{{.Host}}", "host": "{{.Host}}",
"basePath": "{{.BasePath}}", "basePath": "{{.BasePath}}",
"paths": { "paths": {
"/api/v1/articles": { "/api/v1/tags/import": {
"get": {
"produces": [
"application/json"
],
"summary": "Get multiple articles",
"parameters": [
{
"description": "TagID",
"name": "tag_id",
"in": "body",
"schema": {
"type": "object"
}
},
{
"description": "State",
"name": "state",
"in": "body",
"schema": {
"type": "object"
}
},
{
"description": "CreatedBy",
"name": "created_by",
"in": "body",
"schema": {
"type": "object"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"$ref": "#/definitions/app.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"$ref": "#/definitions/app.Response"
}
}
}
},
"post": { "post": {
"produces": [ "produces": [
"application/json" "application/json"
], ],
"summary": "Add article", "summary": "Import Image",
"parameters": [ "parameters": [
{ {
"description": "TagID", "type": "file",
"name": "tag_id", "description": "Image File",
"in": "body", "name": "image",
"required": true, "in": "formData",
"schema": {
"type": "object"
}
},
{
"description": "Title",
"name": "title",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
},
{
"description": "Desc",
"name": "desc",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
},
{
"description": "Content",
"name": "content",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
},
{
"description": "CreatedBy",
"name": "created_by",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
},
{
"description": "State",
"name": "state",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"$ref": "#/definitions/app.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"$ref": "#/definitions/app.Response"
}
}
}
}
},
"/api/v1/articles/{id}": {
"get": {
"produces": [
"application/json"
],
"summary": "Get a single article",
"parameters": [
{
"type": "integer",
"description": "ID",
"name": "id",
"in": "path",
"required": true "required": true
} }
], ],
...@@ -174,379 +48,173 @@ var doc = `{ ...@@ -174,379 +48,173 @@ var doc = `{
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "object",
"$ref": "#/definitions/app.Response" "$ref": "#/definitions/app.Response"
} }
}, },
"500": { "500": {
"description": "Internal Server Error", "description": "Internal Server Error",
"schema": { "schema": {
"type": "object",
"$ref": "#/definitions/app.Response"
}
}
}
},
"put": {
"produces": [
"application/json"
],
"summary": "Update article",
"parameters": [
{
"type": "integer",
"description": "ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "TagID",
"name": "tag_id",
"in": "body",
"schema": {
"type": "object"
}
},
{
"description": "Title",
"name": "title",
"in": "body",
"schema": {
"type": "object"
}
},
{
"description": "Desc",
"name": "desc",
"in": "body",
"schema": {
"type": "object"
}
},
{
"description": "Content",
"name": "content",
"in": "body",
"schema": {
"type": "object"
}
},
{
"description": "ModifiedBy",
"name": "modified_by",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
},
{
"description": "State",
"name": "state",
"in": "body",
"schema": {
"type": "object"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"$ref": "#/definitions/app.Response" "$ref": "#/definitions/app.Response"
} }
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"$ref": "#/definitions/app.Response"
} }
} }
} }
}, },
"delete": { "/pai/closenode": {
"produces": [ "post": {
"description": "关闭节点",
"consumes": [
"application/json" "application/json"
], ],
"summary": "Delete article", "summary": "关闭节点",
"parameters": [
{
"type": "integer",
"description": "ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "object",
"$ref": "#/definitions/app.Response" "$ref": "#/definitions/app.Response"
} }
}, },
"500": { "500": {
"description": "Internal Server Error", "description": "Internal Server Error",
"schema": { "schema": {
"type": "object",
"$ref": "#/definitions/app.Response" "$ref": "#/definitions/app.Response"
} }
} }
} }
} }
}, },
"/api/v1/tags": { "/pai/nodeinfo": {
"get": { "post": {
"produces": [ "description": "获取节点运行状态",
"consumes": [
"application/json" "application/json"
], ],
"summary": "Get multiple article tags", "summary": "获取节点运行状态",
"parameters": [
{
"type": "string",
"description": "Name",
"name": "name",
"in": "query"
},
{
"type": "integer",
"description": "State",
"name": "state",
"in": "query"
}
],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "object",
"$ref": "#/definitions/app.Response" "$ref": "#/definitions/app.Response"
} }
}, },
"500": { "500": {
"description": "Internal Server Error", "description": "Internal Server Error",
"schema": { "schema": {
"type": "object",
"$ref": "#/definitions/app.Response" "$ref": "#/definitions/app.Response"
} }
} }
} }
}
}, },
"/pai/reset": {
"post": { "post": {
"produces": [ "description": "重置节点 慎用(同步时间长 1周以上)",
"consumes": [
"application/json" "application/json"
], ],
"summary": "Add article tag", "summary": "重置节点",
"parameters": [
{
"description": "Name",
"name": "name",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
},
{
"description": "State",
"name": "state",
"in": "body",
"schema": {
"type": "object"
}
},
{
"description": "CreatedBy",
"name": "created_by",
"in": "body",
"schema": {
"type": "object"
}
}
],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "object",
"$ref": "#/definitions/app.Response" "$ref": "#/definitions/app.Response"
} }
}, },
"500": { "500": {
"description": "Internal Server Error", "description": "Internal Server Error",
"schema": { "schema": {
"type": "object",
"$ref": "#/definitions/app.Response" "$ref": "#/definitions/app.Response"
} }
} }
} }
} }
}, },
"/api/v1/tags/export": { "/pai/resetwallet": {
"post": { "post": {
"produces": [ "description": "重置节点钱包 无参",
"consumes": [
"application/json" "application/json"
], ],
"summary": "Export article tag", "summary": "重置节点钱包",
"parameters": [
{
"description": "Name",
"name": "name",
"in": "body",
"schema": {
"type": "object"
}
},
{
"description": "State",
"name": "state",
"in": "body",
"schema": {
"type": "object"
}
}
],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "object",
"$ref": "#/definitions/app.Response" "$ref": "#/definitions/app.Response"
} }
}, },
"500": { "500": {
"description": "Internal Server Error", "description": "Internal Server Error",
"schema": { "schema": {
"type": "object",
"$ref": "#/definitions/app.Response" "$ref": "#/definitions/app.Response"
} }
} }
} }
} }
}, },
"/api/v1/tags/import": { "/pai/restartnode": {
"post": { "post": {
"produces": [ "description": "重启节点",
"consumes": [
"application/json" "application/json"
], ],
"summary": "Import article tag", "summary": "重启节点",
"parameters": [
{
"description": "Excel File",
"name": "file",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
}
],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "object",
"$ref": "#/definitions/app.Response" "$ref": "#/definitions/app.Response"
} }
}, },
"500": { "500": {
"description": "Internal Server Error", "description": "Internal Server Error",
"schema": { "schema": {
"type": "object",
"$ref": "#/definitions/app.Response" "$ref": "#/definitions/app.Response"
} }
} }
} }
} }
}, },
"/api/v1/tags/{id}": { "/pai/updatenode": {
"put": { "post": {
"produces": [ "description": "节点手动更新 无参",
"consumes": [
"application/json" "application/json"
], ],
"summary": "Update article tag", "summary": "节点手动更新",
"parameters": [
{
"type": "integer",
"description": "ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "ID",
"name": "name",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
},
{
"description": "State",
"name": "state",
"in": "body",
"schema": {
"type": "object"
}
},
{
"description": "ModifiedBy",
"name": "modified_by",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
}
],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "object",
"$ref": "#/definitions/app.Response" "$ref": "#/definitions/app.Response"
} }
}, },
"500": { "500": {
"description": "Internal Server Error", "description": "Internal Server Error",
"schema": { "schema": {
"type": "object",
"$ref": "#/definitions/app.Response" "$ref": "#/definitions/app.Response"
} }
} }
} }
}
}, },
"delete": { "/pai/version": {
"produces": [ "post": {
"description": "获取当前版本和最新版本",
"consumes": [
"application/json" "application/json"
], ],
"summary": "Delete article tag", "summary": "获取当前版本和最新版本",
"parameters": [
{
"type": "integer",
"description": "ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "object",
"$ref": "#/definitions/app.Response" "$ref": "#/definitions/app.Response"
} }
}, },
"500": { "500": {
"description": "Internal Server Error", "description": "Internal Server Error",
"schema": { "schema": {
"type": "object",
"$ref": "#/definitions/app.Response" "$ref": "#/definitions/app.Response"
} }
} }
...@@ -576,23 +244,39 @@ type swaggerInfo struct { ...@@ -576,23 +244,39 @@ 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: "1.0",
Host: "",
BasePath: "",
Schemes: []string{},
Title: "Golang Gin API",
Description: "An example of gin",
}
type s struct{} type s struct{}
func (s *s) ReadDoc() string { func (s *s) ReadDoc() string {
t, err := template.New("swagger_info").Parse(doc) 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)
if err != nil { if err != nil {
return doc return doc
} }
var tpl bytes.Buffer var tpl bytes.Buffer
if err := t.Execute(&tpl, SwaggerInfo); err != nil { if err := t.Execute(&tpl, sInfo); err != nil {
return doc return doc
} }
......
...@@ -22,6 +22,13 @@ import ( ...@@ -22,6 +22,13 @@ import (
"chain33-pai/pkg/util" "chain33-pai/pkg/util"
) )
// @Summary 重置节点钱包
// @Description 重置节点钱包 无参
// @Accept json
// @Success 200 {object} app.Response
// @Failure 500 {object} app.Response
// @Router /pai/resetwallet [post]
func ResetWallet(c *gin.Context) { func ResetWallet(c *gin.Context) {
appG := app.Gin{C: c} appG := app.Gin{C: c}
util.AddValue(&app.JobID,1) util.AddValue(&app.JobID,1)
...@@ -29,9 +36,12 @@ func ResetWallet(c *gin.Context) { ...@@ -29,9 +36,12 @@ func ResetWallet(c *gin.Context) {
appG.Response(http.StatusOK, e.SUCCESS, app.JobID) appG.Response(http.StatusOK, e.SUCCESS, app.JobID)
} }
//钱包更新,只替换执行文件和配置文件 // @Summary 节点手动更新
//具体更新逻辑不再代码实现 // @Description 节点手动更新 无参
//oss下载包打包要保持执行权限 // @Accept json
// @Success 200 {object} app.Response
// @Failure 500 {object} app.Response
// @Router /pai/updatenode [post]
func UpdateNodeNew(c *gin.Context) { func UpdateNodeNew(c *gin.Context) {
appG := app.Gin{C: c} appG := app.Gin{C: c}
app.BityuanFlag.Lock.Lock() app.BityuanFlag.Lock.Lock()
...@@ -152,7 +162,12 @@ func UpdateNodeNew(c *gin.Context) { ...@@ -152,7 +162,12 @@ func UpdateNodeNew(c *gin.Context) {
appG.Response(http.StatusOK, e.SUCCESS, "update job ok") appG.Response(http.StatusOK, e.SUCCESS, "update job ok")
} }
//重置节点只需要删除datadir 然后重启节点 // @Summary 重置节点
// @Description 重置节点 慎用(同步时间长 1周以上)
// @Accept json
// @Success 200 {object} app.Response
// @Failure 500 {object} app.Response
// @Router /pai/reset [post]
func ResetNode(c *gin.Context) { func ResetNode(c *gin.Context) {
appG := app.Gin{C: c} appG := app.Gin{C: c}
util.AddValue(&app.JobID,1) util.AddValue(&app.JobID,1)
...@@ -168,7 +183,12 @@ func UpdateDetail(c *gin.Context) { ...@@ -168,7 +183,12 @@ func UpdateDetail(c *gin.Context) {
}) })
} }
//get current version and latest version // @Summary 获取当前版本和最新版本
// @Description 获取当前版本和最新版本
// @Accept json
// @Success 200 {object} app.Response
// @Failure 500 {object} app.Response
// @Router /pai/version [post]
func Version(c *gin.Context) { func Version(c *gin.Context) {
appG := app.Gin{C: c} appG := app.Gin{C: c}
setting.FreshVersion() setting.FreshVersion()
...@@ -187,6 +207,12 @@ func Version(c *gin.Context) { ...@@ -187,6 +207,12 @@ func Version(c *gin.Context) {
}) })
} }
// @Summary 获取节点运行状态
// @Description 获取节点运行状态
// @Accept json
// @Success 200 {object} app.Response
// @Failure 500 {object} app.Response
// @Router /pai/nodeinfo [post]
func NodeInfo(c *gin.Context) { func NodeInfo(c *gin.Context) {
appG := app.Gin{C: c} appG := app.Gin{C: c}
var client chain33.PaiClient var client chain33.PaiClient
...@@ -198,6 +224,12 @@ func NodeInfo(c *gin.Context) { ...@@ -198,6 +224,12 @@ func NodeInfo(c *gin.Context) {
appG.Response(http.StatusOK, e.SUCCESS, "node is running") appG.Response(http.StatusOK, e.SUCCESS, "node is running")
} }
// @Summary 重启节点
// @Description 重启节点
// @Accept json
// @Success 200 {object} app.Response
// @Failure 500 {object} app.Response
// @Router /pai/restartnode [post]
func RestartNode(c *gin.Context) { func RestartNode(c *gin.Context) {
appG := app.Gin{C: c} appG := app.Gin{C: c}
util.AddValue(&app.JobID,1) util.AddValue(&app.JobID,1)
...@@ -205,6 +237,12 @@ func RestartNode(c *gin.Context) { ...@@ -205,6 +237,12 @@ func RestartNode(c *gin.Context) {
appG.Response(http.StatusOK, e.SUCCESS, app.JobID) appG.Response(http.StatusOK, e.SUCCESS, app.JobID)
} }
// @Summary 关闭节点
// @Description 关闭节点
// @Accept json
// @Success 200 {object} app.Response
// @Failure 500 {object} app.Response
// @Router /pai/closenode [post]
func CloseNode(c *gin.Context) { func CloseNode(c *gin.Context) {
appG := app.Gin{C: c} appG := app.Gin{C: c}
util.AddValue(&app.JobID,1) util.AddValue(&app.JobID,1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment