mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 10:13:01 +00:00
docs📝: 修改接口文档
This commit is contained in:
@@ -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{}
|
||||
|
||||
@@ -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{}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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{}
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user