Bläddra i källkod

update

master
dengbiao 2 månader sedan
förälder
incheckning
006d48ccf2
7 ändrade filer med 159 tillägg och 10 borttagningar
  1. +33
    -2
      app/hdl/hdl_comm.go
  2. +5
    -2
      app/router/router.go
  3. +45
    -2
      docs/docs.go
  4. +45
    -2
      docs/swagger.json
  5. +31
    -2
      docs/swagger.yaml
  6. Binär
     
  7. Binär
     

+ 33
- 2
app/hdl/hdl_comm.go Visa fil

@@ -110,8 +110,8 @@ func MenuList(c *gin.Context) {

// GetBaseInfo
// @Summary 获取系统信息
// @Tags 公共模块-获取系统信息
// @Description 获取系统信息
// @Tags 公共模块
// @Description 公共模块-获取系统信息
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
@@ -130,3 +130,34 @@ func GetBaseInfo(c *gin.Context) {
}, nil)
return
}

// UploadFile
// @Summary 上传文件
// @Tags 公共模块
// @Description 公共模块-上传文件
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept multipart/form-data
// @Produce multipart/form-data
// @Param file formData file true "上传的文件"
// @Success 200 {string} "success"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/comm/basicGet [POST]
func UploadFile(c *gin.Context) {
// 单文件上传
file, err := c.FormFile("file")
if err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err.Error())
return
}

dst := "./static/upload/" + file.Filename
if err = c.SaveUploadedFile(file, dst); err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}

e.OutSuc(c, map[string]string{
"url": c.Request.Host + "/api/comm/upload/" + file.Filename,
}, nil)
return
}

+ 5
- 2
app/router/router.go Visa fil

@@ -8,6 +8,7 @@ import (
"github.com/gin-gonic/gin"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
"net/http"
)

// 初始化路由
@@ -66,12 +67,12 @@ func route(r *gin.RouterGroup) {
}
r.Use(mw.CheckBody) // body参数转换
r.Use(mw.CheckSign) // 签名校验

r.Use(mw.Auth) // 以下接口需要JWT验证
r.GET("/loginInfo", hdl.LoginInfo)

rComm(r.Group("/comm"))

r.Use(mw.Auth) // 以下接口需要JWT验证

r.Use(mw.CheckPermission) // 检测权限
rRole(r.Group("/role")) // 权限管理
rDataCenter(r.Group("/dataCenter")) // 数据中心
@@ -80,6 +81,8 @@ func route(r *gin.RouterGroup) {
}

func rComm(r *gin.RouterGroup) {
r.StaticFS("/upload", http.Dir("./static/upload"))
r.POST("/uploadFile", hdl.UploadFile) // 上传文件
r.GET("/getBaseInfo", hdl.GetBaseInfo) // 获取系统信息
r.POST("/getMenuList", hdl.MenuList) // 获取菜单栏列表
}


+ 45
- 2
docs/docs.go Visa fil

@@ -27,7 +27,7 @@ const docTemplate = `{
"paths": {
"/api/comm/basicGet": {
"get": {
"description": "获取系统信息",
"description": "公共模块-获取系统信息",
"consumes": [
"application/json"
],
@@ -35,7 +35,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
"公共模块-获取系统信息"
"公共模块"
],
"summary": "获取系统信息",
"parameters": [
@@ -61,6 +61,49 @@ const docTemplate = `{
}
}
}
},
"post": {
"description": "公共模块-上传文件",
"consumes": [
"multipart/form-data"
],
"produces": [
"multipart/form-data"
],
"tags": [
"公共模块"
],
"summary": "上传文件",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "file",
"description": "上传的文件",
"name": "file",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "success",
"schema": {
"type": "string"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/dataCenter/generate/data/detail": {


+ 45
- 2
docs/swagger.json Visa fil

@@ -19,7 +19,7 @@
"paths": {
"/api/comm/basicGet": {
"get": {
"description": "获取系统信息",
"description": "公共模块-获取系统信息",
"consumes": [
"application/json"
],
@@ -27,7 +27,7 @@
"application/json"
],
"tags": [
"公共模块-获取系统信息"
"公共模块"
],
"summary": "获取系统信息",
"parameters": [
@@ -53,6 +53,49 @@
}
}
}
},
"post": {
"description": "公共模块-上传文件",
"consumes": [
"multipart/form-data"
],
"produces": [
"multipart/form-data"
],
"tags": [
"公共模块"
],
"summary": "上传文件",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "file",
"description": "上传的文件",
"name": "file",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "success",
"schema": {
"type": "string"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/dataCenter/generate/data/detail": {


+ 31
- 2
docs/swagger.yaml Visa fil

@@ -497,7 +497,7 @@ paths:
get:
consumes:
- application/json
description: 获取系统信息
description: 公共模块-获取系统信息
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
@@ -517,7 +517,36 @@ paths:
$ref: '#/definitions/md.Response'
summary: 获取系统信息
tags:
- 公共模块-获取系统信息
- 公共模块
post:
consumes:
- multipart/form-data
description: 公共模块-上传文件
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
name: Authorization
required: true
type: string
- description: 上传的文件
in: formData
name: file
required: true
type: file
produces:
- multipart/form-data
responses:
"200":
description: success
schema:
type: string
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 上传文件
tags:
- 公共模块
/api/dataCenter/generate/data/detail:
post:
consumes:


Binär
Visa fil


Binär
Visa fil


Laddar…
Avbryt
Spara