From 3fd34db3c1d0c93419e5d04f3c317b70c42e462d Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Tue, 29 Jun 2021 16:30:47 +0800 Subject: [PATCH] =?UTF-8?q?docs=F0=9F=93=9D:=20=E4=BF=AE=E6=94=B9=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/apis/sys_dict_type.go | 1 + app/admin/apis/sys_login_log.go | 5 +- app/admin/apis/sys_menu.go | 11 +- app/admin/apis/sys_user.go | 16 +- app/other/apis/file.go | 1 + app/other/apis/sys_server_monitor.go | 1 + app/other/apis/tools/db_columns.go | 6 +- app/other/apis/tools/db_tables.go | 6 +- app/other/apis/tools/sys_tables.go | 25 ++- common/ip.go | 7 +- config/settings.yml | 1 + docs/docs.go | 278 ++++++++++++++++++--------- docs/swagger.json | 278 ++++++++++++++++++--------- docs/swagger.yaml | 175 +++++++++++------ template/v4/dto.go.template | 2 +- template/v4/vue.go.template | 17 +- 16 files changed, 541 insertions(+), 289 deletions(-) diff --git a/app/admin/apis/sys_dict_type.go b/app/admin/apis/sys_dict_type.go index 767b5ab..b611a77 100644 --- a/app/admin/apis/sys_dict_type.go +++ b/app/admin/apis/sys_dict_type.go @@ -157,6 +157,7 @@ func (e SysDictType) Update(c *gin.Context) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": -1, "message": "删除失败"}" // @Router /api/v1/dict/type [delete] +// @Security Bearer func (e SysDictType) Delete(c *gin.Context) { s := service.SysDictType{} req := dto.SysDictTypeById{} diff --git a/app/admin/apis/sys_login_log.go b/app/admin/apis/sys_login_log.go index ee32b21..a90de72 100644 --- a/app/admin/apis/sys_login_log.go +++ b/app/admin/apis/sys_login_log.go @@ -51,7 +51,7 @@ func (e SysLoginLog) GetPage(c *gin.Context) { e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") } -// GetSysLoginLog 登录日志通过id获取 +// Get 登录日志通过id获取 // @Summary 登录日志通过id获取 // @Description 获取JSON // @Tags 登录日志 @@ -81,13 +81,14 @@ func (e SysLoginLog) Get(c *gin.Context) { e.OK(object, "查询成功") } -// DeleteSysLoginLog 登录日志删除 +// Delete 登录日志删除 // @Summary 登录日志删除 // @Description 登录日志删除 // @Tags 登录日志 // @Param data body dto.SysLoginLogById true "body" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Router /api/v1/sys-login-log [delete] +// @Security Bearer func (e SysLoginLog) Delete(c *gin.Context) { s := service.SysLoginLog{} req := dto.SysLoginLogById{} diff --git a/app/admin/apis/sys_menu.go b/app/admin/apis/sys_menu.go index 6fe7bd8..5e74489 100644 --- a/app/admin/apis/sys_menu.go +++ b/app/admin/apis/sys_menu.go @@ -1,13 +1,11 @@ package apis import ( - "github.com/gin-gonic/gin/binding" - "go-admin/app/admin/models" - "net/http" - "github.com/gin-gonic/gin" + "github.com/gin-gonic/gin/binding" "github.com/go-admin-team/go-admin-core/sdk/api" "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" + "go-admin/app/admin/models" "go-admin/app/admin/service" "go-admin/app/admin/service/dto" @@ -153,6 +151,7 @@ func (e SysMenu) Update(c *gin.Context) { // @Param data body dto.SysMenuById true "body" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Router /api/v1/menu [delete] +// @Security Bearer func (e SysMenu) Delete(c *gin.Context) { control := new(dto.SysMenuById) s := new(service.SysMenu) @@ -169,7 +168,7 @@ func (e SysMenu) Delete(c *gin.Context) { err = s.Remove(control).Error if err != nil { e.Logger.Errorf("RemoveSysMenu error, %s", err) - e.Error(http.StatusInternalServerError, err, "删除失败") + e.Error(500, err, "删除失败") return } e.OK(control.GetId(), "删除成功") @@ -197,7 +196,7 @@ func (e SysMenu) GetMenuRole(c *gin.Context) { result, err := s.SetMenuRole(user.GetRoleName(c)) if err != nil { - e.Error(http.StatusInternalServerError, err, "查询失败") + e.Error(500, err, "查询失败") return } diff --git a/app/admin/apis/sys_user.go b/app/admin/apis/sys_user.go index 747d8eb..b5c149a 100644 --- a/app/admin/apis/sys_user.go +++ b/app/admin/apis/sys_user.go @@ -30,10 +30,10 @@ type SysUser struct { // @Security Bearer func (e SysUser) GetPage(c *gin.Context) { s := service.SysUser{} - req := dto.SysUserSearch{} + req := dto.SysUserGetPageReq{} err := e.MakeContext(c). MakeOrm(). - Bind(&req, binding.Form). + Bind(&req). MakeService(&s.Service). Errors if err != nil { @@ -63,7 +63,7 @@ func (e SysUser) GetPage(c *gin.Context) { // @Tags 用户 // @Param userId path int true "用户编码" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" -// @Router /api/v1/sysUser/{userId} [get] +// @Router /api/v1/sys-user/{userId} [get] // @Security Bearer func (e SysUser) Get(c *gin.Context) { s := service.SysUser{} @@ -97,7 +97,8 @@ func (e SysUser) Get(c *gin.Context) { // @Product application/json // @Param data body dto.SysUserControl true "用户数据" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" -// @Router /api/v1/sysUser [post] +// @Router /api/v1/sys-user [post] +// @Security Bearer func (e SysUser) Insert(c *gin.Context) { s := service.SysUser{} req := dto.SysUserControl{} @@ -132,12 +133,13 @@ func (e SysUser) Insert(c *gin.Context) { // @Param data body dto.SysUserControl true "body" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Router /api/v1/sys-user/{userId} [put] +// @Security Bearer func (e SysUser) Update(c *gin.Context) { s := service.SysUser{} req := dto.SysUserControl{} err := e.MakeContext(c). MakeOrm(). - Bind(&req, binding.JSON, nil). + Bind(&req). MakeService(&s.Service). Errors if err != nil { @@ -166,6 +168,7 @@ func (e SysUser) Update(c *gin.Context) { // @Param userId path int true "userId" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Router /api/v1/sys-user/{userId} [delete] +// @Security Bearer func (e SysUser) Delete(c *gin.Context) { s := service.SysUser{} req := dto.SysUserById{} @@ -202,6 +205,7 @@ func (e SysUser) Delete(c *gin.Context) { // @Param file formData file true "file" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Router /api/v1/user/avatar [post] +// @Security Bearer func (e SysUser) InsetAvatar(c *gin.Context) { s := service.SysUser{} req := dto.SysUserControl{} @@ -250,6 +254,7 @@ func (e SysUser) InsetAvatar(c *gin.Context) { // @Param data body dto.UpdateSysUserStatusReq true "body" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Router /api/v1/user/status [put] +// @Security Bearer func (e SysUser) UpdateStatus(c *gin.Context) { s := service.SysUser{} req := dto.UpdateSysUserStatusReq{} @@ -286,6 +291,7 @@ func (e SysUser) UpdateStatus(c *gin.Context) { // @Param data body dto.ResetSysUserPwdReq true "body" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Router /api/v1/user/pwd/reset [put] +// @Security Bearer func (e SysUser) ResetPwd(c *gin.Context) { s := service.SysUser{} req := dto.ResetSysUserPwdReq{} diff --git a/app/other/apis/file.go b/app/other/apis/file.go index 0aadb12..4548edd 100644 --- a/app/other/apis/file.go +++ b/app/other/apis/file.go @@ -40,6 +40,7 @@ type File struct { // @Success 200 {string} string "{"code": 200, "message": "添加成功"}" // @Success 200 {string} string "{"code": -1, "message": "添加失败"}" // @Router /api/v1/public/uploadFile [post] +// @Security Bearer func (e File) UploadFile(c *gin.Context) { e.MakeContext(c) tag, _ := c.GetPostForm("type") diff --git a/app/other/apis/sys_server_monitor.go b/app/other/apis/sys_server_monitor.go index c821ffe..4841e7e 100644 --- a/app/other/apis/sys_server_monitor.go +++ b/app/other/apis/sys_server_monitor.go @@ -29,6 +29,7 @@ type ServerMonitor struct { // @Tags 系统信息 // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Router /api/v1/server-monitor [get] +// @Security Bearer func (e ServerMonitor) ServerInfo(c *gin.Context) { e.Context = c diff --git a/app/other/apis/tools/db_columns.go b/app/other/apis/tools/db_columns.go index 1fa940d..51786f9 100644 --- a/app/other/apis/tools/db_columns.go +++ b/app/other/apis/tools/db_columns.go @@ -1,8 +1,6 @@ package tools import ( - "net/http" - "github.com/gin-gonic/gin" "github.com/go-admin-team/go-admin-core/sdk/pkg" _ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" @@ -13,7 +11,7 @@ import ( // GetDBColumnList 分页列表数据 // @Summary 分页列表数据 / page list data // @Description 数据库表列分页列表 / database table column page list -// @Tags 工具 / Tools +// @Tags 工具 / 生成工具 // @Param tableName query string false "tableName / 数据表名称" // @Param pageSize query int false "pageSize / 页条数" // @Param pageIndex query int false "pageIndex / 页码" @@ -38,7 +36,7 @@ func (e *Gen) GetDBColumnList(c *gin.Context) { db, err := pkg.GetOrm(c) if err != nil { log.Errorf("get db connection error, %s", err.Error()) - e.Error(http.StatusInternalServerError, err, "数据库连接获取失败") + e.Error(500, err, "数据库连接获取失败") return } diff --git a/app/other/apis/tools/db_tables.go b/app/other/apis/tools/db_tables.go index d202c3f..7076700 100644 --- a/app/other/apis/tools/db_tables.go +++ b/app/other/apis/tools/db_tables.go @@ -2,8 +2,6 @@ package tools import ( "errors" - "net/http" - "github.com/gin-gonic/gin" "github.com/go-admin-team/go-admin-core/sdk/config" "github.com/go-admin-team/go-admin-core/sdk/pkg" @@ -15,7 +13,7 @@ import ( // GetDBTableList 分页列表数据 // @Summary 分页列表数据 / page list data // @Description 数据库表分页列表 / database table page list -// @Tags 工具 / Tools +// @Tags 工具 / 生成工具 // @Param tableName query string false "tableName / 数据表名称" // @Param pageSize query int false "pageSize / 页条数" // @Param pageIndex query int false "pageIndex / 页码" @@ -47,7 +45,7 @@ func (e *Gen) GetDBTableList(c *gin.Context) { db, err := pkg.GetOrm(c) if err != nil { log.Errorf("get db connection error, %s", err.Error()) - e.Error(http.StatusInternalServerError, err, "数据库连接获取失败") + e.Error(500, err, "数据库连接获取失败") return } diff --git a/app/other/apis/tools/sys_tables.go b/app/other/apis/tools/sys_tables.go index 5f6cf87..03a5d95 100644 --- a/app/other/apis/tools/sys_tables.go +++ b/app/other/apis/tools/sys_tables.go @@ -1,7 +1,6 @@ package tools import ( - "net/http" "strings" "github.com/gin-gonic/gin" @@ -20,7 +19,7 @@ type SysTable struct { // GetPage 分页列表数据 // @Summary 分页列表数据 // @Description 生成表分页列表 -// @Tags 工具 - 生成表 +// @Tags 工具 / 生成工具 // @Param tableName query string false "tableName / 数据表名称" // @Param pageSize query int false "pageSize / 页条数" // @Param pageIndex query int false "pageIndex / 页码" @@ -45,7 +44,7 @@ func (e SysTable) GetPage(c *gin.Context) { db, err := e.GetOrm() if err != nil { log.Errorf("get db connection error, %s", err.Error()) - e.Error(http.StatusInternalServerError, err, "数据库连接获取失败") + e.Error(500, err, "数据库连接获取失败") return } @@ -63,7 +62,7 @@ func (e SysTable) GetPage(c *gin.Context) { // Get // @Summary 获取配置 // @Description 获取JSON -// @Tags 工具 - 生成表 +// @Tags 工具 / 生成工具 // @Param configKey path int true "configKey" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Router /api/v1/sys/tables/info/{tableId} [get] @@ -74,7 +73,7 @@ func (e SysTable) Get(c *gin.Context) { db, err := e.GetOrm() if err != nil { log.Errorf("get db connection error, %s", err.Error()) - e.Error(http.StatusInternalServerError, err, "数据库连接获取失败") + e.Error(500, err, "数据库连接获取失败") return } @@ -99,7 +98,7 @@ func (e SysTable) GetSysTablesInfo(c *gin.Context) { db, err := e.GetOrm() if err != nil { log.Errorf("get db connection error, %s", err.Error()) - e.Error(http.StatusInternalServerError, err, "数据库连接获取失败") + e.Error(500, err, "数据库连接获取失败") return } @@ -128,7 +127,7 @@ func (e SysTable) GetSysTablesTree(c *gin.Context) { db, err := e.GetOrm() if err != nil { log.Errorf("get db connection error, %s", err.Error()) - e.Error(http.StatusInternalServerError, err, "数据库连接获取失败") + e.Error(500, err, "数据库连接获取失败") return } @@ -146,7 +145,7 @@ func (e SysTable) GetSysTablesTree(c *gin.Context) { // Insert // @Summary 添加表结构 // @Description 添加表结构 -// @Tags 工具 - 生成表 +// @Tags 工具 / 生成工具 // @Accept application/json // @Product application/json // @Param tables query string false "tableName / 数据表名称" @@ -160,7 +159,7 @@ func (e SysTable) Insert(c *gin.Context) { db, err := e.GetOrm() if err != nil { log.Errorf("get db connection error, %s", err.Error()) - e.Error(http.StatusInternalServerError, err, "数据库连接获取失败") + e.Error(500, err, "数据库连接获取失败") return } @@ -292,7 +291,7 @@ func genTableInit(tx *gorm.DB, tablesList []string, i int, c *gin.Context) (tool // Update // @Summary 修改表结构 // @Description 修改表结构 -// @Tags 工具 - 生成表 +// @Tags 工具 / 生成工具 // @Accept application/json // @Product application/json // @Param data body tools.SysTables true "body" @@ -310,7 +309,7 @@ func (e SysTable) Update(c *gin.Context) { db, err := e.GetOrm() if err != nil { log.Errorf("get db connection error, %s", err.Error()) - e.Error(http.StatusInternalServerError, err, "数据库连接获取失败") + e.Error(500, err, "数据库连接获取失败") return } @@ -327,7 +326,7 @@ func (e SysTable) Update(c *gin.Context) { // Delete // @Summary 删除表结构 // @Description 删除表结构 -// @Tags 工具 - 生成表 +// @Tags 工具 / 生成工具 // @Param tableId path int true "tableId" // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": -1, "message": "删除失败"}" @@ -338,7 +337,7 @@ func (e SysTable) Delete(c *gin.Context) { db, err := e.GetOrm() if err != nil { log.Errorf("get db connection error, %s", err.Error()) - e.Error(http.StatusInternalServerError, err, "数据库连接获取失败") + e.Error(500, err, "数据库连接获取失败") return } diff --git a/common/ip.go b/common/ip.go index 7822f25..e06b9bb 100644 --- a/common/ip.go +++ b/common/ip.go @@ -1,16 +1,15 @@ package common import ( - "fmt" "github.com/gin-gonic/gin" "strings" ) func GetClientIP(c *gin.Context) string { ClientIP := c.ClientIP() - fmt.Println("ClientIP:", ClientIP) + //fmt.Println("ClientIP:", ClientIP) RemoteIP, _ := c.RemoteIP() - fmt.Println("RemoteIP:", RemoteIP) + //fmt.Println("RemoteIP:", RemoteIP) ip := c.Request.Header.Get("X-Forwarded-For") if strings.Contains(ip, "127.0.0.1") || ip == "" { ip = c.Request.Header.Get("X-real-ip") @@ -24,6 +23,6 @@ func GetClientIP(c *gin.Context) string { if ClientIP != "127.0.0.1" { ip = ClientIP } - fmt.Println("ip:", ip) + //fmt.Println("ip:", ip) return ip } diff --git a/config/settings.yml b/config/settings.yml index 2e0ccad..63dde7a 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -52,6 +52,7 @@ settings: addr: 127.0.0.1:6379 password: xxxxxx db: 2 +# memory: '' key存在即可 queue: memory: poolSize: 100 diff --git a/docs/docs.go b/docs/docs.go index 6e936fd..7f5bd26 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -30,16 +30,11 @@ var doc = `{ "paths": { "/api/v1/app-config": { "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "获取系统配置信息,主要注意这里不在验证数据权限", + "description": "获取系统配置信息,主要注意这里不在验证权限", "tags": [ "配置管理" ], - "summary": "获取系统前台配置信息,主要注意这里不在验证数据权限", + "summary": "获取系统前台配置信息,主要注意这里不在验证权限", "responses": { "200": { "description": "{\"code\": 200, \"data\": [...]}", @@ -67,11 +62,6 @@ var doc = `{ }, "/api/v1/captcha": { "get": { - "security": [ - { - "Bearer": [] - } - ], "description": "获取验证码", "tags": [ "登陆" @@ -109,7 +99,7 @@ var doc = `{ "get": { "description": "数据库表列分页列表 / database table column page list", "tags": [ - "工具 / Tools" + "工具 / 生成工具" ], "summary": "分页列表数据 / page list data", "parameters": [ @@ -146,7 +136,7 @@ var doc = `{ "get": { "description": "数据库表分页列表 / database table page list", "tags": [ - "工具 / Tools" + "工具 / 生成工具" ], "summary": "分页列表数据 / page list data", "parameters": [ @@ -255,6 +245,11 @@ var doc = `{ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "description": "删除数据", "tags": [ "部门" @@ -661,6 +656,11 @@ var doc = `{ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "description": "删除数据", "tags": [ "字典类型" @@ -915,6 +915,11 @@ var doc = `{ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "description": "删除数据", "tags": [ "菜单" @@ -1136,7 +1141,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dto.SysPostControl" + "$ref": "#/definitions/dto.SysPostInsertReq" } } ], @@ -1150,6 +1155,11 @@ var doc = `{ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "description": "删除数据", "tags": [ "岗位" @@ -1157,11 +1167,13 @@ var doc = `{ "summary": "删除岗位", "parameters": [ { - "type": "integer", - "description": "id", + "description": "请求参数", "name": "id", - "in": "path", - "required": true + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.SysPostDeleteReq" + } } ], "responses": { @@ -1180,7 +1192,7 @@ var doc = `{ } } }, - "/api/v1/post/": { + "/api/v1/post/{id}": { "put": { "security": [ { @@ -1202,7 +1214,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dto.SysPostControl" + "$ref": "#/definitions/dto.SysPostUpdateReq" } } ], @@ -1231,8 +1243,8 @@ var doc = `{ "parameters": [ { "type": "integer", - "description": "postId", - "name": "postId", + "description": "编码", + "name": "id", "in": "path", "required": true } @@ -1249,6 +1261,11 @@ var doc = `{ }, "/api/v1/public/uploadFile": { "post": { + "security": [ + { + "Bearer": [] + } + ], "description": "获取JSON", "consumes": [ "multipart/form-data" @@ -1504,6 +1521,11 @@ var doc = `{ }, "/api/v1/server-monitor": { "get": { + "security": [ + { + "Bearer": [] + } + ], "description": "获取JSON", "tags": [ "系统信息" @@ -2080,6 +2102,11 @@ var doc = `{ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "description": "登录日志删除", "tags": [ "登录日志" @@ -2208,6 +2235,11 @@ var doc = `{ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "description": "删除数据", "tags": [ "操作日志" @@ -2292,10 +2324,78 @@ var doc = `{ } } } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取JSON", + "consumes": [ + "application/json" + ], + "tags": [ + "用户" + ], + "summary": "创建用户", + "parameters": [ + { + "description": "用户数据", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.SysUserControl" + } + } + ], + "responses": { + "200": { + "description": "{\"code\": 200, \"data\": [...]}", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } } }, "/api/v1/sys-user/{userId}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取JSON", + "tags": [ + "用户" + ], + "summary": "获取用户", + "parameters": [ + { + "type": "integer", + "description": "用户编码", + "name": "userId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "{\"code\": 200, \"data\": [...]}", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + }, "put": { + "security": [ + { + "Bearer": [] + } + ], "description": "获取JSON", "consumes": [ "application/json" @@ -2325,6 +2425,11 @@ var doc = `{ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "description": "删除数据", "tags": [ "用户" @@ -2361,7 +2466,7 @@ var doc = `{ "application/json" ], "tags": [ - "工具 - 生成表" + "工具 / 生成工具" ], "summary": "修改表结构", "parameters": [ @@ -2395,7 +2500,7 @@ var doc = `{ "application/json" ], "tags": [ - "工具 - 生成表" + "工具 / 生成工具" ], "summary": "添加表结构", "parameters": [ @@ -2425,7 +2530,7 @@ var doc = `{ ], "description": "获取JSON", "tags": [ - "工具 - 生成表" + "工具 / 生成工具" ], "summary": "获取配置", "parameters": [ @@ -2449,7 +2554,7 @@ var doc = `{ "delete": { "description": "删除表结构", "tags": [ - "工具 - 生成表" + "工具 / 生成工具" ], "summary": "删除表结构", "parameters": [ @@ -2475,7 +2580,7 @@ var doc = `{ "get": { "description": "生成表分页列表", "tags": [ - "工具 - 生成表" + "工具 / 生成工具" ], "summary": "分页列表数据", "parameters": [ @@ -2508,70 +2613,13 @@ var doc = `{ } } }, - "/api/v1/sysUser": { + "/api/v1/user/avatar": { "post": { - "description": "获取JSON", - "consumes": [ - "application/json" - ], - "tags": [ - "用户" - ], - "summary": "创建用户", - "parameters": [ - { - "description": "用户数据", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dto.SysUserControl" - } - } - ], - "responses": { - "200": { - "description": "{\"code\": 200, \"data\": [...]}", - "schema": { - "$ref": "#/definitions/response.Response" - } - } - } - } - }, - "/api/v1/sysUser/{userId}": { - "get": { "security": [ { "Bearer": [] } ], - "description": "获取JSON", - "tags": [ - "用户" - ], - "summary": "获取用户", - "parameters": [ - { - "type": "integer", - "description": "用户编码", - "name": "userId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "{\"code\": 200, \"data\": [...]}", - "schema": { - "$ref": "#/definitions/response.Response" - } - } - } - } - }, - "/api/v1/user/avatar": { - "post": { "description": "获取JSON", "consumes": [ "multipart/form-data" @@ -2623,6 +2671,11 @@ var doc = `{ }, "/api/v1/user/pwd/reset": { "put": { + "security": [ + { + "Bearer": [] + } + ], "description": "获取JSON", "consumes": [ "application/json" @@ -2690,6 +2743,11 @@ var doc = `{ }, "/api/v1/user/status": { "put": { + "security": [ + { + "Bearer": [] + } + ], "description": "获取JSON", "consumes": [ "application/json" @@ -3175,7 +3233,53 @@ var doc = `{ } } }, - "dto.SysPostControl": { + "dto.SysPostDeleteReq": { + "type": "object", + "properties": { + "createBy": { + "type": "integer" + }, + "ids": { + "type": "array", + "items": { + "type": "integer" + } + }, + "updateBy": { + "type": "integer" + } + } + }, + "dto.SysPostInsertReq": { + "type": "object", + "properties": { + "createBy": { + "type": "integer" + }, + "postCode": { + "type": "string" + }, + "postId": { + "type": "integer" + }, + "postName": { + "type": "string" + }, + "remark": { + "type": "string" + }, + "sort": { + "type": "integer" + }, + "status": { + "type": "integer" + }, + "updateBy": { + "type": "integer" + } + } + }, + "dto.SysPostUpdateReq": { "type": "object", "properties": { "createBy": { diff --git a/docs/swagger.json b/docs/swagger.json index 11d8063..fbee1c0 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -13,16 +13,11 @@ "paths": { "/api/v1/app-config": { "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "获取系统配置信息,主要注意这里不在验证数据权限", + "description": "获取系统配置信息,主要注意这里不在验证权限", "tags": [ "配置管理" ], - "summary": "获取系统前台配置信息,主要注意这里不在验证数据权限", + "summary": "获取系统前台配置信息,主要注意这里不在验证权限", "responses": { "200": { "description": "{\"code\": 200, \"data\": [...]}", @@ -50,11 +45,6 @@ }, "/api/v1/captcha": { "get": { - "security": [ - { - "Bearer": [] - } - ], "description": "获取验证码", "tags": [ "登陆" @@ -92,7 +82,7 @@ "get": { "description": "数据库表列分页列表 / database table column page list", "tags": [ - "工具 / Tools" + "工具 / 生成工具" ], "summary": "分页列表数据 / page list data", "parameters": [ @@ -129,7 +119,7 @@ "get": { "description": "数据库表分页列表 / database table page list", "tags": [ - "工具 / Tools" + "工具 / 生成工具" ], "summary": "分页列表数据 / page list data", "parameters": [ @@ -238,6 +228,11 @@ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "description": "删除数据", "tags": [ "部门" @@ -644,6 +639,11 @@ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "description": "删除数据", "tags": [ "字典类型" @@ -898,6 +898,11 @@ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "description": "删除数据", "tags": [ "菜单" @@ -1119,7 +1124,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dto.SysPostControl" + "$ref": "#/definitions/dto.SysPostInsertReq" } } ], @@ -1133,6 +1138,11 @@ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "description": "删除数据", "tags": [ "岗位" @@ -1140,11 +1150,13 @@ "summary": "删除岗位", "parameters": [ { - "type": "integer", - "description": "id", + "description": "请求参数", "name": "id", - "in": "path", - "required": true + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.SysPostDeleteReq" + } } ], "responses": { @@ -1163,7 +1175,7 @@ } } }, - "/api/v1/post/": { + "/api/v1/post/{id}": { "put": { "security": [ { @@ -1185,7 +1197,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dto.SysPostControl" + "$ref": "#/definitions/dto.SysPostUpdateReq" } } ], @@ -1214,8 +1226,8 @@ "parameters": [ { "type": "integer", - "description": "postId", - "name": "postId", + "description": "编码", + "name": "id", "in": "path", "required": true } @@ -1232,6 +1244,11 @@ }, "/api/v1/public/uploadFile": { "post": { + "security": [ + { + "Bearer": [] + } + ], "description": "获取JSON", "consumes": [ "multipart/form-data" @@ -1487,6 +1504,11 @@ }, "/api/v1/server-monitor": { "get": { + "security": [ + { + "Bearer": [] + } + ], "description": "获取JSON", "tags": [ "系统信息" @@ -2063,6 +2085,11 @@ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "description": "登录日志删除", "tags": [ "登录日志" @@ -2191,6 +2218,11 @@ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "description": "删除数据", "tags": [ "操作日志" @@ -2275,10 +2307,78 @@ } } } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取JSON", + "consumes": [ + "application/json" + ], + "tags": [ + "用户" + ], + "summary": "创建用户", + "parameters": [ + { + "description": "用户数据", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.SysUserControl" + } + } + ], + "responses": { + "200": { + "description": "{\"code\": 200, \"data\": [...]}", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } } }, "/api/v1/sys-user/{userId}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取JSON", + "tags": [ + "用户" + ], + "summary": "获取用户", + "parameters": [ + { + "type": "integer", + "description": "用户编码", + "name": "userId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "{\"code\": 200, \"data\": [...]}", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + }, "put": { + "security": [ + { + "Bearer": [] + } + ], "description": "获取JSON", "consumes": [ "application/json" @@ -2308,6 +2408,11 @@ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "description": "删除数据", "tags": [ "用户" @@ -2344,7 +2449,7 @@ "application/json" ], "tags": [ - "工具 - 生成表" + "工具 / 生成工具" ], "summary": "修改表结构", "parameters": [ @@ -2378,7 +2483,7 @@ "application/json" ], "tags": [ - "工具 - 生成表" + "工具 / 生成工具" ], "summary": "添加表结构", "parameters": [ @@ -2408,7 +2513,7 @@ ], "description": "获取JSON", "tags": [ - "工具 - 生成表" + "工具 / 生成工具" ], "summary": "获取配置", "parameters": [ @@ -2432,7 +2537,7 @@ "delete": { "description": "删除表结构", "tags": [ - "工具 - 生成表" + "工具 / 生成工具" ], "summary": "删除表结构", "parameters": [ @@ -2458,7 +2563,7 @@ "get": { "description": "生成表分页列表", "tags": [ - "工具 - 生成表" + "工具 / 生成工具" ], "summary": "分页列表数据", "parameters": [ @@ -2491,70 +2596,13 @@ } } }, - "/api/v1/sysUser": { + "/api/v1/user/avatar": { "post": { - "description": "获取JSON", - "consumes": [ - "application/json" - ], - "tags": [ - "用户" - ], - "summary": "创建用户", - "parameters": [ - { - "description": "用户数据", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dto.SysUserControl" - } - } - ], - "responses": { - "200": { - "description": "{\"code\": 200, \"data\": [...]}", - "schema": { - "$ref": "#/definitions/response.Response" - } - } - } - } - }, - "/api/v1/sysUser/{userId}": { - "get": { "security": [ { "Bearer": [] } ], - "description": "获取JSON", - "tags": [ - "用户" - ], - "summary": "获取用户", - "parameters": [ - { - "type": "integer", - "description": "用户编码", - "name": "userId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "{\"code\": 200, \"data\": [...]}", - "schema": { - "$ref": "#/definitions/response.Response" - } - } - } - } - }, - "/api/v1/user/avatar": { - "post": { "description": "获取JSON", "consumes": [ "multipart/form-data" @@ -2606,6 +2654,11 @@ }, "/api/v1/user/pwd/reset": { "put": { + "security": [ + { + "Bearer": [] + } + ], "description": "获取JSON", "consumes": [ "application/json" @@ -2673,6 +2726,11 @@ }, "/api/v1/user/status": { "put": { + "security": [ + { + "Bearer": [] + } + ], "description": "获取JSON", "consumes": [ "application/json" @@ -3158,7 +3216,53 @@ } } }, - "dto.SysPostControl": { + "dto.SysPostDeleteReq": { + "type": "object", + "properties": { + "createBy": { + "type": "integer" + }, + "ids": { + "type": "array", + "items": { + "type": "integer" + } + }, + "updateBy": { + "type": "integer" + } + } + }, + "dto.SysPostInsertReq": { + "type": "object", + "properties": { + "createBy": { + "type": "integer" + }, + "postCode": { + "type": "string" + }, + "postId": { + "type": "integer" + }, + "postName": { + "type": "string" + }, + "remark": { + "type": "string" + }, + "sort": { + "type": "integer" + }, + "status": { + "type": "integer" + }, + "updateBy": { + "type": "integer" + } + } + }, + "dto.SysPostUpdateReq": { "type": "object", "properties": { "createBy": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index e241d28..69a667c 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -292,7 +292,37 @@ definitions: type: integer type: array type: object - dto.SysPostControl: + dto.SysPostDeleteReq: + properties: + createBy: + type: integer + ids: + items: + type: integer + type: array + updateBy: + type: integer + type: object + dto.SysPostInsertReq: + properties: + createBy: + type: integer + postCode: + type: string + postId: + type: integer + postName: + type: string + remark: + type: string + sort: + type: integer + status: + type: integer + updateBy: + type: integer + type: object + dto.SysPostUpdateReq: properties: createBy: type: integer @@ -822,7 +852,7 @@ info: paths: /api/v1/app-config: get: - description: 获取系统配置信息,主要注意这里不在验证数据权限 + description: 获取系统配置信息,主要注意这里不在验证权限 responses: "200": description: '{"code": 200, "data": [...]}' @@ -835,9 +865,7 @@ paths: type: string type: object type: object - security: - - Bearer: [] - summary: 获取系统前台配置信息,主要注意这里不在验证数据权限 + summary: 获取系统前台配置信息,主要注意这里不在验证权限 tags: - 配置管理 /api/v1/captcha: @@ -857,8 +885,6 @@ paths: msg: type: string type: object - security: - - Bearer: [] summary: 获取验证码 tags: - 登陆 @@ -885,7 +911,7 @@ paths: $ref: '#/definitions/response.Response' summary: 分页列表数据 / page list data tags: - - 工具 / Tools + - 工具 / 生成工具 /api/v1/db/tables/page: get: description: 数据库表分页列表 / database table page list @@ -909,7 +935,7 @@ paths: $ref: '#/definitions/response.Response' summary: 分页列表数据 / page list data tags: - - 工具 / Tools + - 工具 / 生成工具 /api/v1/dept: delete: description: 删除数据 @@ -925,6 +951,8 @@ paths: description: '{"code": -1, "message": "删除失败"}' schema: type: string + security: + - Bearer: [] summary: 删除部门 tags: - 部门 @@ -1169,6 +1197,8 @@ paths: description: '{"code": -1, "message": "删除失败"}' schema: type: string + security: + - Bearer: [] summary: 删除字典类型 tags: - 字典类型 @@ -1348,6 +1378,8 @@ paths: description: '{"code": 200, "data": [...]}' schema: $ref: '#/definitions/response.Response' + security: + - Bearer: [] summary: 删除菜单 tags: - 菜单 @@ -1475,11 +1507,12 @@ paths: delete: description: 删除数据 parameters: - - description: id - in: path + - description: 请求参数 + in: body name: id required: true - type: integer + schema: + $ref: '#/definitions/dto.SysPostDeleteReq' responses: "200": description: '{"code": 200, "message": "删除成功"}' @@ -1489,6 +1522,8 @@ paths: description: '{"code": 500, "message": "删除失败"}' schema: type: string + security: + - Bearer: [] summary: 删除岗位 tags: - 岗位 @@ -1531,7 +1566,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/dto.SysPostControl' + $ref: '#/definitions/dto.SysPostInsertReq' responses: "200": description: '{"code": -1, "message": "添加失败"}' @@ -1542,7 +1577,7 @@ paths: summary: 添加岗位 tags: - 岗位 - /api/v1/post/: + /api/v1/post/{id}: put: consumes: - application/json @@ -1553,7 +1588,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/dto.SysPostControl' + $ref: '#/definitions/dto.SysPostUpdateReq' responses: "200": description: '{"code": -1, "message": "添加失败"}' @@ -1568,9 +1603,9 @@ paths: get: description: 获取JSON parameters: - - description: postId + - description: 编码 in: path - name: postId + name: id required: true type: integer responses: @@ -1604,6 +1639,8 @@ paths: description: '{"code": -1, "message": "添加失败"}' schema: type: string + security: + - Bearer: [] summary: 上传图片 tags: - 公共接口 @@ -1750,6 +1787,8 @@ paths: description: '{"code": 200, "data": [...]}' schema: $ref: '#/definitions/response.Response' + security: + - Bearer: [] summary: 系统信息 tags: - 系统信息 @@ -2061,6 +2100,8 @@ paths: description: '{"code": 200, "data": [...]}' schema: $ref: '#/definitions/response.Response' + security: + - Bearer: [] summary: 登录日志删除 tags: - 登录日志 @@ -2134,6 +2175,8 @@ paths: description: '{"code": 200, "data": [...]}' schema: $ref: '#/definitions/response.Response' + security: + - Bearer: [] summary: 删除操作日志 tags: - 操作日志 @@ -2218,6 +2261,27 @@ paths: summary: 列表用户信息数据 tags: - 用户 + post: + consumes: + - application/json + description: 获取JSON + parameters: + - description: 用户数据 + in: body + name: data + required: true + schema: + $ref: '#/definitions/dto.SysUserControl' + responses: + "200": + description: '{"code": 200, "data": [...]}' + schema: + $ref: '#/definitions/response.Response' + security: + - Bearer: [] + summary: 创建用户 + tags: + - 用户 /api/v1/sys-user/{userId}: delete: description: 删除数据 @@ -2232,9 +2296,29 @@ paths: description: '{"code": 200, "data": [...]}' schema: $ref: '#/definitions/response.Response' + security: + - Bearer: [] summary: 删除用户数据 tags: - 用户 + get: + description: 获取JSON + parameters: + - description: 用户编码 + in: path + name: userId + required: true + type: integer + responses: + "200": + description: '{"code": 200, "data": [...]}' + schema: + $ref: '#/definitions/response.Response' + security: + - Bearer: [] + summary: 获取用户 + tags: + - 用户 put: consumes: - application/json @@ -2251,6 +2335,8 @@ paths: description: '{"code": 200, "data": [...]}' schema: $ref: '#/definitions/response.Response' + security: + - Bearer: [] summary: 修改用户数据 tags: - 用户 @@ -2273,7 +2359,7 @@ paths: - Bearer: [] summary: 添加表结构 tags: - - 工具 - 生成表 + - 工具 / 生成工具 put: consumes: - application/json @@ -2294,7 +2380,7 @@ paths: - Bearer: [] summary: 修改表结构 tags: - - 工具 - 生成表 + - 工具 / 生成工具 /api/v1/sys/tables/info/{tableId}: delete: description: 删除表结构 @@ -2311,7 +2397,7 @@ paths: type: string summary: 删除表结构 tags: - - 工具 - 生成表 + - 工具 / 生成工具 get: description: 获取JSON parameters: @@ -2329,7 +2415,7 @@ paths: - Bearer: [] summary: 获取配置 tags: - - 工具 - 生成表 + - 工具 / 生成工具 /api/v1/sys/tables/page: get: description: 生成表分页列表 @@ -2353,46 +2439,7 @@ paths: $ref: '#/definitions/response.Response' summary: 分页列表数据 tags: - - 工具 - 生成表 - /api/v1/sysUser: - post: - consumes: - - application/json - description: 获取JSON - parameters: - - description: 用户数据 - in: body - name: data - required: true - schema: - $ref: '#/definitions/dto.SysUserControl' - responses: - "200": - description: '{"code": 200, "data": [...]}' - schema: - $ref: '#/definitions/response.Response' - summary: 创建用户 - tags: - - 用户 - /api/v1/sysUser/{userId}: - get: - description: 获取JSON - parameters: - - description: 用户编码 - in: path - name: userId - required: true - type: integer - responses: - "200": - description: '{"code": 200, "data": [...]}' - schema: - $ref: '#/definitions/response.Response' - security: - - Bearer: [] - summary: 获取用户 - tags: - - 用户 + - 工具 / 生成工具 /api/v1/user/avatar: post: consumes: @@ -2409,6 +2456,8 @@ paths: description: '{"code": 200, "data": [...]}' schema: $ref: '#/definitions/response.Response' + security: + - Bearer: [] summary: 修改头像 tags: - 个人中心 @@ -2442,6 +2491,8 @@ paths: description: '{"code": 200, "data": [...]}' schema: $ref: '#/definitions/response.Response' + security: + - Bearer: [] summary: 重置用户密码 tags: - 用户 @@ -2484,6 +2535,8 @@ paths: description: '{"code": 200, "data": [...]}' schema: $ref: '#/definitions/response.Response' + security: + - Bearer: [] summary: 修改用户状态 tags: - 用户 diff --git a/template/v4/dto.go.template b/template/v4/dto.go.template index b62058d..872ee3e 100644 --- a/template/v4/dto.go.template +++ b/template/v4/dto.go.template @@ -54,7 +54,7 @@ func (s *{{.ClassName}}Control) Generate(model *models.SysConfig) { {{$x := .Pk}} {{- if ($x) }} if s.{{.GoField}} == 0 { - model.Model = common.Model{{{.GoField}}: s.{{.GoField}}} + model.Model = common.Model{ {{.GoField}}: s.{{.GoField}} } } {{- else if eq .GoField "CreatedAt" -}} {{- else if eq .GoField "UpdatedAt" -}} diff --git a/template/v4/vue.go.template b/template/v4/vue.go.template index 70c5de6..4f2b406 100644 --- a/template/v4/vue.go.template +++ b/template/v4/vue.go.template @@ -223,7 +223,6 @@ 取 消 - @@ -233,17 +232,13 @@ import {add{{.ClassName}}, del{{.ClassName}}, get{{.ClassName}}, list{{.ClassName}}, update{{.ClassName}}} from '@/api/{{ .BusinessName}}' {{range .Columns}} {{- if ne .FkTableName "" -}} - import {list{{.FkTableNameClass}} } from '@/api/{{ .FkTableNamePackage}}' - + import {list{{.FkTableNameClass}} } from '@/api/{{ .FkTableNamePackage}}' {{ end -}} {{- end -}} - import FileChoose from '@/components/FileChoose' - export default { name: '{{.ClassName}}', components: { - FileChoose }, data() { return { @@ -262,8 +257,6 @@ // 是否显示弹出层 open: false, isEdit: false, - fileOpen: false, - fileIndex: undefined, // 类型数据字典 typeOptions: [], {{.ModuleName}}List: [], @@ -296,10 +289,7 @@ {{- range .Columns -}} {{- $x := .IsQuery -}} {{- if (eq $x "1") -}} - {{.JsonField}}: - [ - {required: true, message: '{{.ColumnComment}}不能为空', trigger: 'blur'} - ], + {{.JsonField}}: [ {required: true, message: '{{.ColumnComment}}不能为空', trigger: 'blur'} ], {{ end }} {{- end -}} } @@ -309,15 +299,12 @@ this.getList() {{range .Columns}} {{- if ne .DictType "" -}} - this.getDicts('{{.DictType}}').then(response => { this.{{.JsonField}}Options = response.data }) - {{ end -}} {{- if ne .FkTableName "" -}} this.get{{.FkTableNameClass}}Items() - {{ end -}} {{- end -}} },