diff --git a/QMPlusServer/controller/api/fileUploadAndDownload.go b/QMPlusServer/controller/api/fileUploadAndDownload.go new file mode 100644 index 0000000000000000000000000000000000000000..56cee1e2724a6e04c7f639968dd5ff08fc271e06 --- /dev/null +++ b/QMPlusServer/controller/api/fileUploadAndDownload.go @@ -0,0 +1,68 @@ +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, + }) + } +} diff --git a/QMPlusServer/docs/docs.go b/QMPlusServer/docs/docs.go index 4ec664b1a5a259457f922a6d9ba57f886e9d6f98..e79c7824d60e3517d99d56a4e1cf00246877427e 100644 --- a/QMPlusServer/docs/docs.go +++ b/QMPlusServer/docs/docs.go @@ -1,6 +1,6 @@ // 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" } diff --git a/QMPlusServer/docs/swagger.json b/QMPlusServer/docs/swagger.json index 6a355adf7f5fae0c0813c43075baec0a7568410f..42af59c3e12b33715f139abc4a39f053ddcb1ebe 100644 --- a/QMPlusServer/docs/swagger.json +++ b/QMPlusServer/docs/swagger.json @@ -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" } diff --git a/QMPlusServer/docs/swagger.yaml b/QMPlusServer/docs/swagger.yaml index 03dd077b5c4feeb534fb91e12317fa099b295e2e..10e3a88a72a873fef0269dc2fcfc605bd5ccc304 100644 --- a/QMPlusServer/docs/swagger.yaml +++ b/QMPlusServer/docs/swagger.yaml @@ -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: diff --git a/QMPlusServer/go.mod b/QMPlusServer/go.mod index a40b0cda1c8202b7fb6f492bcd690563f4c3551c..d43b20e552fbf89c7d11d0a0f9d856be3829053e 100644 --- a/QMPlusServer/go.mod +++ b/QMPlusServer/go.mod @@ -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 diff --git a/QMPlusServer/init/initRouter/initRouter.go b/QMPlusServer/init/initRouter/initRouter.go index e6d5731bb68c61c49c9f3976336e61226d330fc6..bac9e650ea89082e75f7f4374887471b024057fc 100644 --- a/QMPlusServer/init/initRouter/initRouter.go +++ b/QMPlusServer/init/initRouter/initRouter.go @@ -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 } diff --git a/QMPlusServer/init/registTable/registTable.go b/QMPlusServer/init/registTable/registTable.go index 84003f6f237ce55558e05aed78bf0c274c0b0377..e1d951a818468b4dcb703b7d26a4afb7e5d67cd7 100644 --- a/QMPlusServer/init/registTable/registTable.go +++ b/QMPlusServer/init/registTable/registTable.go @@ -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{}) } diff --git a/QMPlusServer/model/dbModel/fileUploadAndDown.go b/QMPlusServer/model/dbModel/fileUploadAndDown.go deleted file mode 100644 index 9a3a2dc2ded5ac66f880909a7643e592a414310b..0000000000000000000000000000000000000000 --- a/QMPlusServer/model/dbModel/fileUploadAndDown.go +++ /dev/null @@ -1 +0,0 @@ -package dbModel diff --git a/QMPlusServer/model/dbModel/fileUploadAndDownload.go b/QMPlusServer/model/dbModel/fileUploadAndDownload.go new file mode 100644 index 0000000000000000000000000000000000000000..22d1307b70e27509cd9ab7da1e6ee2b675324f0e --- /dev/null +++ b/QMPlusServer/model/dbModel/fileUploadAndDownload.go @@ -0,0 +1,33 @@ +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 + } +} diff --git a/QMPlusServer/router/fileUploadAndDownload.go b/QMPlusServer/router/fileUploadAndDownload.go new file mode 100644 index 0000000000000000000000000000000000000000..18a8dcaca748fe26c78ee0416087bd9c0c32857e --- /dev/null +++ b/QMPlusServer/router/fileUploadAndDownload.go @@ -0,0 +1,15 @@ +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) // 获取上传文件列表 + } +}