提交 4ebd90e0 编写于 作者: Mr.奇淼('s avatar Mr.奇淼(

图片上传示例 前端图片跨域下载示例 文档更新

上级 dd209669
package api
import (
"fmt"
"github.com/gin-gonic/gin"
"main/controller/servers"
"main/model/dbModel"
"main/model/modelInterface"
"strings"
)
// @Tags FileUploadAndDownload
// @Summary 上传文件示例
// @Security ApiKeyAuth
// @accept multipart/form-data
// @Produce application/json
// @Param file formData file true "上传文件示例"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"上传成功"}"
// @Router /fileUploadAndDownload/upload [post]
func UploadFile(c *gin.Context) {
_, header, err := c.Request.FormFile("file")
if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("上传文件失败,%v", err), gin.H{})
} else {
//文件上传后拿到文件路径
err, filePath := servers.Upload(header, USER_HEADER_BUCKET, USER_HEADER_IMG_PATH)
if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("接收返回值失败,%v", err), gin.H{})
} else {
//修改数据库后得到修改后的user并且返回供前端使用
var file dbModel.FileUploadAndDownload
file.Url = filePath
file.Name = header.Filename
s := strings.Split(file.Name, ".")
file.Tag = s[len(s)-1]
err := file.Upload()
if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("修改数据库链接失败,%v", err), gin.H{})
} else {
servers.ReportFormat(c, true, "上传成功", gin.H{"file": file})
}
}
}
}
// @Tags FileUploadAndDownload
// @Summary 分页文件列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body modelInterface.PageInfo true "分页获取文件户列表"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /fileUploadAndDownload/getFileList [post]
func GetFileList(c *gin.Context) {
var pageInfo modelInterface.PageInfo
_ = c.BindJSON(&pageInfo)
err, list, total := new(dbModel.FileUploadAndDownload).GetInfoList(pageInfo)
if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{})
} else {
servers.ReportFormat(c, true, "获取数据成功", gin.H{
"list": list,
"total": total,
"page": pageInfo.Page,
"pageSize": pageInfo.PageSize,
})
}
}
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at
// 2019-09-22 17:09:11.1201116 +0800 CST m=+0.066820301
// 2019-10-26 23:18:53.1133875 +0800 CST m=+0.203566501
package docs
......@@ -90,7 +90,7 @@ var doc = `{
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/api.DeleteApiParams"
"$ref": "#/definitions/dbModel.Api"
}
}
],
......@@ -104,7 +104,7 @@ var doc = `{
}
}
},
"/api/getApiList": {
"/api/getAllApis": {
"post": {
"security": [
{
......@@ -120,7 +120,34 @@ var doc = `{
"tags": [
"Api"
],
"summary": "分页获取角色列表",
"summary": "获取所有的Api 不分页",
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/api/getApiById": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Api"
],
"summary": "根据id获取api",
"parameters": [
{
"description": "分页获取用户列表",
......@@ -143,7 +170,46 @@ var doc = `{
}
}
},
"/api/setAuthAndPath": {
"/api/getApiList": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Api"
],
"summary": "分页获取API列表",
"parameters": [
{
"description": "分页获取API列表",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/modelInterface.PageInfo"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/api/setAuthAndApi": {
"post": {
"security": [
{
......@@ -182,6 +248,45 @@ var doc = `{
}
}
},
"/api/updataApi": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Api"
],
"summary": "创建基础api",
"parameters": [
{
"description": "创建api",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/api.CreateApiParams"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/authority/createAuthority": {
"post": {
"security": [
......@@ -260,6 +365,45 @@ var doc = `{
}
}
},
"/authority/getAuthAndApi": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"authority"
],
"summary": "获取本角色所有有权限的apiId",
"parameters": [
{
"description": "获取本角色所有有权限的apiId",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/api.GetAuthorityId"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/authority/getAuthorityList": {
"post": {
"security": [
......@@ -361,6 +505,81 @@ var doc = `{
}
}
},
"/fileUploadAndDownload/getFileList": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"FileUploadAndDownload"
],
"summary": "分页文件列表",
"parameters": [
{
"description": "分页获取文件户列表",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/modelInterface.PageInfo"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/fileUploadAndDownload/upload": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"tags": [
"FileUploadAndDownload"
],
"summary": "上传文件示例",
"parameters": [
{
"type": "file",
"description": "上传文件示例",
"name": "file",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"上传成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/menu/addBaseMenu": {
"post": {
"security": [
......@@ -377,16 +596,16 @@ var doc = `{
"tags": [
"menu"
],
"summary": "分页获取基础menu列表",
"summary": "新增菜单",
"parameters": [
{
"description": "分页获取基础menu列表",
"description": "新增菜单",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/modelInterface.PageInfo"
"$ref": "#/definitions/dbModel.BaseMenu"
}
}
],
......@@ -455,7 +674,7 @@ var doc = `{
"tags": [
"menu"
],
"summary": "获取指定角色menu",
"summary": "删除菜单",
"parameters": [
{
"description": "删除菜单",
......@@ -478,6 +697,45 @@ var doc = `{
}
}
},
"/menu/getBaseMenuById": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"menu"
],
"summary": "根据id获取菜单",
"parameters": [
{
"description": "根据id获取菜单",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/api.GetById"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/menu/getBaseMenuTree": {
"post": {
"security": [
......@@ -589,6 +847,45 @@ var doc = `{
}
}
},
"/menu/updataBaseMen": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"menu"
],
"summary": "更新菜单",
"parameters": [
{
"description": "更新菜单",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/dbModel.BaseMenu"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/user/changePassword": {
"post": {
"security": [
......@@ -625,7 +922,7 @@ var doc = `{
}
}
},
"/user/getInfoList": {
"/user/getUserList": {
"post": {
"security": [
{
......@@ -664,6 +961,45 @@ var doc = `{
}
}
},
"/user/setUserAuthority": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"User"
],
"summary": "设置用户权限",
"parameters": [
{
"description": "设置用户权限",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/api.SetUserAuth"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"修改成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/user/uploadHeaderImg": {
"post": {
"security": [
......@@ -726,10 +1062,10 @@ var doc = `{
"api.AuthAndPathIn": {
"type": "object",
"properties": {
"apis": {
"apiIds": {
"type": "array",
"items": {
"$ref": "#/definitions/dbModel.Api"
"type": "integer"
}
},
"authorityId": {
......@@ -781,19 +1117,27 @@ var doc = `{
}
}
},
"api.DeleteApiParams": {
"api.DeleteAuthorityPatams": {
"type": "object",
"properties": {
"path": {
"authorityId": {
"type": "integer"
}
}
},
"api.DeleteAuthorityPatams": {
"api.GetAuthorityId": {
"type": "object",
"properties": {
"authorityId": {
"type": "integer"
"type": "string"
}
}
},
"api.GetById": {
"type": "object",
"properties": {
"id": {
"type": "number"
}
}
},
......@@ -816,12 +1160,26 @@ var doc = `{
}
}
},
"api.SetUserAuth": {
"type": "object",
"properties": {
"authorityId": {
"type": "string"
},
"uuid": {
"type": "string"
}
}
},
"dbModel.Api": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"group": {
"type": "string"
},
"path": {
"type": "string"
}
......
......@@ -73,7 +73,7 @@
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/api.DeleteApiParams"
"$ref": "#/definitions/dbModel.Api"
}
}
],
......@@ -87,7 +87,7 @@
}
}
},
"/api/getApiList": {
"/api/getAllApis": {
"post": {
"security": [
{
......@@ -103,7 +103,34 @@
"tags": [
"Api"
],
"summary": "分页获取角色列表",
"summary": "获取所有的Api 不分页",
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/api/getApiById": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Api"
],
"summary": "根据id获取api",
"parameters": [
{
"description": "分页获取用户列表",
......@@ -126,7 +153,46 @@
}
}
},
"/api/setAuthAndPath": {
"/api/getApiList": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Api"
],
"summary": "分页获取API列表",
"parameters": [
{
"description": "分页获取API列表",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/modelInterface.PageInfo"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/api/setAuthAndApi": {
"post": {
"security": [
{
......@@ -165,6 +231,45 @@
}
}
},
"/api/updataApi": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Api"
],
"summary": "创建基础api",
"parameters": [
{
"description": "创建api",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/api.CreateApiParams"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/authority/createAuthority": {
"post": {
"security": [
......@@ -243,6 +348,45 @@
}
}
},
"/authority/getAuthAndApi": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"authority"
],
"summary": "获取本角色所有有权限的apiId",
"parameters": [
{
"description": "获取本角色所有有权限的apiId",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/api.GetAuthorityId"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/authority/getAuthorityList": {
"post": {
"security": [
......@@ -344,6 +488,81 @@
}
}
},
"/fileUploadAndDownload/getFileList": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"FileUploadAndDownload"
],
"summary": "分页文件列表",
"parameters": [
{
"description": "分页获取文件户列表",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/modelInterface.PageInfo"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/fileUploadAndDownload/upload": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"tags": [
"FileUploadAndDownload"
],
"summary": "上传文件示例",
"parameters": [
{
"type": "file",
"description": "上传文件示例",
"name": "file",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"上传成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/menu/addBaseMenu": {
"post": {
"security": [
......@@ -360,16 +579,16 @@
"tags": [
"menu"
],
"summary": "分页获取基础menu列表",
"summary": "新增菜单",
"parameters": [
{
"description": "分页获取基础menu列表",
"description": "新增菜单",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/modelInterface.PageInfo"
"$ref": "#/definitions/dbModel.BaseMenu"
}
}
],
......@@ -438,7 +657,7 @@
"tags": [
"menu"
],
"summary": "获取指定角色menu",
"summary": "删除菜单",
"parameters": [
{
"description": "删除菜单",
......@@ -461,6 +680,45 @@
}
}
},
"/menu/getBaseMenuById": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"menu"
],
"summary": "根据id获取菜单",
"parameters": [
{
"description": "根据id获取菜单",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/api.GetById"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/menu/getBaseMenuTree": {
"post": {
"security": [
......@@ -572,6 +830,45 @@
}
}
},
"/menu/updataBaseMen": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"menu"
],
"summary": "更新菜单",
"parameters": [
{
"description": "更新菜单",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/dbModel.BaseMenu"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/user/changePassword": {
"post": {
"security": [
......@@ -608,7 +905,7 @@
}
}
},
"/user/getInfoList": {
"/user/getUserList": {
"post": {
"security": [
{
......@@ -647,6 +944,45 @@
}
}
},
"/user/setUserAuthority": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"User"
],
"summary": "设置用户权限",
"parameters": [
{
"description": "设置用户权限",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/api.SetUserAuth"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"修改成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/user/uploadHeaderImg": {
"post": {
"security": [
......@@ -709,10 +1045,10 @@
"api.AuthAndPathIn": {
"type": "object",
"properties": {
"apis": {
"apiIds": {
"type": "array",
"items": {
"$ref": "#/definitions/dbModel.Api"
"type": "integer"
}
},
"authorityId": {
......@@ -764,19 +1100,27 @@
}
}
},
"api.DeleteApiParams": {
"api.DeleteAuthorityPatams": {
"type": "object",
"properties": {
"path": {
"authorityId": {
"type": "integer"
}
}
},
"api.DeleteAuthorityPatams": {
"api.GetAuthorityId": {
"type": "object",
"properties": {
"authorityId": {
"type": "integer"
"type": "string"
}
}
},
"api.GetById": {
"type": "object",
"properties": {
"id": {
"type": "number"
}
}
},
......@@ -799,12 +1143,26 @@
}
}
},
"api.SetUserAuth": {
"type": "object",
"properties": {
"authorityId": {
"type": "string"
},
"uuid": {
"type": "string"
}
}
},
"dbModel.Api": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"group": {
"type": "string"
},
"path": {
"type": "string"
}
......
......@@ -11,9 +11,9 @@ definitions:
type: object
api.AuthAndPathIn:
properties:
apis:
apiIds:
items:
$ref: '#/definitions/dbModel.Api'
type: integer
type: array
authorityId:
type: string
......@@ -46,15 +46,20 @@ definitions:
authorityName:
type: string
type: object
api.DeleteApiParams:
api.DeleteAuthorityPatams:
properties:
path:
authorityId:
type: integer
type: object
api.DeleteAuthorityPatams:
api.GetAuthorityId:
properties:
authorityId:
type: integer
type: string
type: object
api.GetById:
properties:
id:
type: number
type: object
api.IdInfo:
properties:
......@@ -68,10 +73,19 @@ definitions:
username:
type: string
type: object
api.SetUserAuth:
properties:
authorityId:
type: string
uuid:
type: string
type: object
dbModel.Api:
properties:
description:
type: string
group:
type: string
path:
type: string
type: object
......@@ -146,7 +160,7 @@ paths:
name: data
required: true
schema:
$ref: '#/definitions/api.DeleteApiParams'
$ref: '#/definitions/dbModel.Api'
type: object
produces:
- application/json
......@@ -160,7 +174,23 @@ paths:
summary: 删除指定api
tags:
- Api
/api/getApiList:
/api/getAllApis:
post:
consumes:
- application/json
produces:
- application/json
responses:
"200":
description: '{"success":true,"data":{},"msg":"获取成功"}'
schema:
type: string
security:
- ApiKeyAuth: []
summary: 获取所有的Api 不分页
tags:
- Api
/api/getApiById:
post:
consumes:
- application/json
......@@ -181,10 +211,34 @@ paths:
type: string
security:
- ApiKeyAuth: []
summary: 分页获取角色列表
summary: 根据id获取api
tags:
- Api
/api/setAuthAndPath:
/api/getApiList:
post:
consumes:
- application/json
parameters:
- description: 分页获取API列表
in: body
name: data
required: true
schema:
$ref: '#/definitions/modelInterface.PageInfo'
type: object
produces:
- application/json
responses:
"200":
description: '{"success":true,"data":{},"msg":"获取成功"}'
schema:
type: string
security:
- ApiKeyAuth: []
summary: 分页获取API列表
tags:
- Api
/api/setAuthAndApi:
post:
consumes:
- application/json
......@@ -208,6 +262,30 @@ paths:
summary: 创建api和角色关系
tags:
- Api
/api/updataApi:
post:
consumes:
- application/json
parameters:
- description: 创建api
in: body
name: data
required: true
schema:
$ref: '#/definitions/api.CreateApiParams'
type: object
produces:
- application/json
responses:
"200":
description: '{"success":true,"data":{},"msg":"获取成功"}'
schema:
type: string
security:
- ApiKeyAuth: []
summary: 创建基础api
tags:
- Api
/authority/createAuthority:
post:
consumes:
......@@ -256,6 +334,30 @@ paths:
summary: 删除角色
tags:
- authority
/authority/getAuthAndApi:
post:
consumes:
- application/json
parameters:
- description: 获取本角色所有有权限的apiId
in: body
name: data
required: true
schema:
$ref: '#/definitions/api.GetAuthorityId'
type: object
produces:
- application/json
responses:
"200":
description: '{"success":true,"data":{},"msg":"获取成功"}'
schema:
type: string
security:
- ApiKeyAuth: []
summary: 获取本角色所有有权限的apiId
tags:
- authority
/authority/getAuthorityList:
post:
consumes:
......@@ -320,12 +422,12 @@ paths:
summary: 用户注册账号
tags:
- Base
/menu/addBaseMenu:
/fileUploadAndDownload/getFileList:
post:
consumes:
- application/json
parameters:
- description: 分页获取基础menu列表
- description: 分页获取文件户列表
in: body
name: data
required: true
......@@ -341,7 +443,53 @@ paths:
type: string
security:
- ApiKeyAuth: []
summary: 分页获取基础menu列表
summary: 分页文件列表
tags:
- FileUploadAndDownload
/fileUploadAndDownload/upload:
post:
consumes:
- multipart/form-data
parameters:
- description: 上传文件示例
in: formData
name: file
required: true
type: file
produces:
- application/json
responses:
"200":
description: '{"success":true,"data":{},"msg":"上传成功"}'
schema:
type: string
security:
- ApiKeyAuth: []
summary: 上传文件示例
tags:
- FileUploadAndDownload
/menu/addBaseMenu:
post:
consumes:
- application/json
parameters:
- description: 新增菜单
in: body
name: data
required: true
schema:
$ref: '#/definitions/dbModel.BaseMenu'
type: object
produces:
- application/json
responses:
"200":
description: '{"success":true,"data":{},"msg":"获取成功"}'
schema:
type: string
security:
- ApiKeyAuth: []
summary: 新增菜单
tags:
- menu
/menu/addMenuAuthority:
......@@ -389,7 +537,31 @@ paths:
type: string
security:
- ApiKeyAuth: []
summary: 获取指定角色menu
summary: 删除菜单
tags:
- menu
/menu/getBaseMenuById:
post:
consumes:
- application/json
parameters:
- description: 根据id获取菜单
in: body
name: data
required: true
schema:
$ref: '#/definitions/api.GetById'
type: object
produces:
- application/json
responses:
"200":
description: '{"success":true,"data":{},"msg":"获取成功"}'
schema:
type: string
security:
- ApiKeyAuth: []
summary: 根据id获取菜单
tags:
- menu
/menu/getBaseMenuTree:
......@@ -460,6 +632,30 @@ paths:
summary: 分页获取基础menu列表
tags:
- menu
/menu/updataBaseMen:
post:
consumes:
- application/json
parameters:
- description: 更新菜单
in: body
name: data
required: true
schema:
$ref: '#/definitions/dbModel.BaseMenu'
type: object
produces:
- application/json
responses:
"200":
description: '{"success":true,"data":{},"msg":"获取成功"}'
schema:
type: string
security:
- ApiKeyAuth: []
summary: 更新菜单
tags:
- menu
/user/changePassword:
post:
parameters:
......@@ -482,7 +678,7 @@ paths:
summary: 用户修改密码
tags:
- User
/user/getInfoList:
/user/getUserList:
post:
consumes:
- application/json
......@@ -506,6 +702,30 @@ paths:
summary: 分页获取用户列表
tags:
- User
/user/setUserAuthority:
post:
consumes:
- application/json
parameters:
- description: 设置用户权限
in: body
name: data
required: true
schema:
$ref: '#/definitions/api.SetUserAuth'
type: object
produces:
- application/json
responses:
"200":
description: '{"success":true,"data":{},"msg":"修改成功"}'
schema:
type: string
security:
- ApiKeyAuth: []
summary: 设置用户权限
tags:
- User
/user/uploadHeaderImg:
post:
consumes:
......
......@@ -18,6 +18,8 @@ require (
github.com/qiniu/x v7.0.8+incompatible // indirect
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
github.com/satori/go.uuid v1.2.0
github.com/shamsher31/goimgext v1.0.0 // indirect
github.com/shamsher31/goimgtype v1.0.0
github.com/sirupsen/logrus v1.2.0
github.com/spf13/viper v1.4.0
github.com/swaggo/gin-swagger v1.2.0
......
......@@ -13,11 +13,11 @@ func InitRouter() *gin.Engine {
var Router = gin.Default()
Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
//Router.Use(middleware.Logger())
router.InitUserRouter(Router) // 注册用户路由
router.InitBaseRouter(Router) // 注册基础功能路由
router.InitMenuRouter(Router) // 注册menu路由
router.InitAuthorityRouter(Router) // 注册角色路由
router.InitApiRouter(Router) // 注册功能api路由
router.InitUserRouter(Router) // 注册用户路由
router.InitBaseRouter(Router) // 注册基础功能路由
router.InitMenuRouter(Router) // 注册menu路由
router.InitAuthorityRouter(Router) // 注册角色路由
router.InitApiRouter(Router) // 注册功能api路由
router.InitFileUploadAndDownloadRouter(Router) // 文件上传下载功能路由
return Router
}
......@@ -7,5 +7,5 @@ import (
//注册数据库表专用
func RegistTable(db *gorm.DB) {
db.AutoMigrate(dbModel.User{}, dbModel.Authority{}, dbModel.Menu{}, dbModel.Api{}, dbModel.ApiAuthority{}, dbModel.BaseMenu{})
db.AutoMigrate(dbModel.User{}, dbModel.Authority{}, dbModel.Menu{}, dbModel.Api{}, dbModel.ApiAuthority{}, dbModel.BaseMenu{}, dbModel.FileUploadAndDownload{})
}
package dbModel
import (
"github.com/jinzhu/gorm"
"main/controller/servers"
"main/init/qmsql"
"main/model/modelInterface"
)
type FileUploadAndDownload struct {
gorm.Model
Name string `json:"name"`
Url string `json:"url"`
Tag string `json:"tag"`
}
func (f *FileUploadAndDownload) Upload() error {
err := qmsql.DEFAULTDB.Create(f).Error
return err
}
// 分页获取数据 需要分页实现这个接口即可
func (f *FileUploadAndDownload) GetInfoList(info modelInterface.PageInfo) (err error, list interface{}, total int) {
// 封装分页方法 调用即可 传入 当前的结构体和分页信息
err, db, total := servers.PagingServer(f, info)
if err != nil {
return
} else {
var fileLists []FileUploadAndDownload
err = db.Order("updated_at desc").Find(&fileLists).Error
return err, fileLists, total
}
}
package router
import (
"github.com/gin-gonic/gin"
"main/controller/api"
"main/middleware"
)
func InitFileUploadAndDownloadRouter(Router *gin.Engine) {
FileUploadAndDownloadGroup := Router.Group("fileUploadAndDownload").Use(middleware.JWTAuth())
{
FileUploadAndDownloadGroup.POST("/upload", api.UploadFile) // 上传文件
FileUploadAndDownloadGroup.POST("/getFileList", api.GetFileList) // 获取上传文件列表
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册