feat: 代码生成

This commit is contained in:
Blizzard
2026-04-28 10:29:02 +08:00
parent 7e282b36d7
commit b343856b58
38 changed files with 2199 additions and 51 deletions
+17 -11
View File
@@ -32,24 +32,30 @@ func (a *AuthApi) Login(c *gin.Context) {
response.FailWithMsg(err.Error(), c)
return
}
if l.CaptchaId != "" && l.Captcha != "" && store.Verify(l.CaptchaId, l.Captcha, true) {
u := &system.User{Account: l.Account, Password: l.Password}
user, err := userService.Login(u)
if err != nil {
global.Logger.Error("登录失败! 用户名不存在或者密码错误!", zap.Error(err))
response.FailWithMsg("用户名不存在或者密码错误", c)
return
}
a.GetToken(c, *user)
// 验证码校验:enable-captcha=0 时跳过
captchaOk := global.Config.System.EnableCaptcha == 0 ||
(l.CaptchaId != "" && l.Captcha != "" && store.Verify(l.CaptchaId, l.Captcha, true))
if !captchaOk {
response.FailWithMsg("验证码错误", c)
return
}
response.FailWithMsg("验证码错误", c)
u := &system.User{Account: l.Account, Password: l.Password}
user, err := userService.Login(u)
if err != nil {
global.Logger.Error("登录失败! 用户名不存在或者密码错误!", zap.Error(err))
response.FailWithMsg("用户名不存在或者密码错误", c)
return
}
a.GetToken(c, *user)
}
// Logout
// @Tags 登录相关
// @Summary pc登出
// @Security ApiKeyAuth
// @Security BasicAuth
// @Produce application/json
// @Success 200 {object} response.Response{msg=string} "登出成功"
// @Router /api/auth/logout [get]
+4 -4
View File
@@ -18,7 +18,7 @@ type OssApi struct {
// UploadFile
// @tags 文件相关
// @Summary 文件上传
// @Security ApiKeyAuth
// @Security BasicAuth
// @accept multipart/form-data
// @Produce application/json
// @Param file formData file true "上传文件"
@@ -44,7 +44,7 @@ func (o *OssApi) UploadFile(c *gin.Context) {
// DeleteFile
// @tags 文件相关
// @Summary 删除文件
// @Security ApiKeyAuth
// @Security BasicAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "批量删除文件"
@@ -69,7 +69,7 @@ func (o *OssApi) DeleteFile(c *gin.Context) {
// GetFileList
// @tags 文件相关
// @Summary 文件列表
// @Security ApiKeyAuth
// @Security BasicAuth
// @Accept application/json
// @Produce application/json
// @Param data body sysReq.GetOssFileList true "文件列表"
@@ -99,7 +99,7 @@ func (o *OssApi) GetFileList(c *gin.Context) {
// Detail
// @tags 文件相关
// @Summary 文件详情
// @Security ApiKeyAuth
// @Security BasicAuth
// @Produce application/json
// @Param id query string true "文件id"
// @Success 200 {object} response.Response{data=string} "文件详情"
+5 -5
View File
@@ -17,7 +17,7 @@ type ClientApi struct {
// SaveClient
// @Tags 客户端管理
// @Summary 创建client
// @Security ApiKeyAuth
// @Security BasicAuth
// @accept application/json
// @Produce application/json
// @Param data body system.Client true "client"
@@ -42,7 +42,7 @@ func (s *ClientApi) SaveClient(c *gin.Context) {
// UpdateClient
// @Tags 客户端管理
// @Summary 更新client
// @Security ApiKeyAuth
// @Security BasicAuth
// @accept application/json
// @Produce application/json
// @Param data body system.Client true "client"
@@ -67,7 +67,7 @@ func (s *ClientApi) UpdateClient(c *gin.Context) {
// GetClientList
// @Tags 客户端管理
// @Summary 获取client列表
// @Security ApiKeyAuth
// @Security BasicAuth
// @accept application/json
// @Produce application/json
// @Param data body systemReq.GetClientList true "client"
@@ -97,7 +97,7 @@ func (s *ClientApi) GetClientList(c *gin.Context) {
// Delete
// @Tags 客户端管理
// @Summary 删除client
// @Security ApiKeyAuth
// @Security BasicAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "ids"
@@ -123,7 +123,7 @@ func (s *ClientApi) Delete(c *gin.Context) {
// @Tags 客户端管理
// @Summary 获取client详情
// @Description id获取详情
// @Security ApiKeyAuth
// @Security BasicAuth
// @Produce application/json
// @Param id query string true "id"
// @Success 200 {object} response.Response{data=system.Client,msg=string} "获取client详情"
+7 -7
View File
@@ -17,7 +17,7 @@ type MenuApi struct {
// SaveMenu
// @Tags 菜单管理
// @Summary 新增菜单
// @Security ApiKeyAuth
// @Security BasicAuth
// @accept application/json
// @Produce application/json
// @Param data body system.Menu false "menu"
@@ -42,7 +42,7 @@ func (m *MenuApi) SaveMenu(c *gin.Context) {
// UpdateMenu
// @Tags 菜单管理
// @Summary 更新菜单
// @Security ApiKeyAuth
// @Security BasicAuth
// @accept application/json
// @Produce application/json
// @Param data body system.Menu false "menu"
@@ -68,7 +68,7 @@ func (m *MenuApi) UpdateMenu(c *gin.Context) {
// @Tags 菜单管理
// @Summary 删除menu
// @Description 删除menu
// @Security ApiKeyAuth
// @Security BasicAuth
// @Produce application/json
// @Param id query string true "id"
// @Success 200 {object} response.Response{msg=string} "详情"
@@ -88,7 +88,7 @@ func (m *MenuApi) DeleteMenu(c *gin.Context) {
// @Tags 菜单管理
// @Summary 获取menu详情
// @Description id获取详情
// @Security ApiKeyAuth
// @Security BasicAuth
// @Produce application/json
// @Param id query string true "id"
// @Success 200 {object} response.Response{data=system.Menu,msg=string} "详情"
@@ -107,7 +107,7 @@ func (m *MenuApi) Detail(c *gin.Context) {
// GetAllMenuTree
// @Tags 菜单管理
// @Summary 获取所有菜单树
// @Security ApiKeyAuth
// @Security BasicAuth
// @Accept json
// @Produce json
// @Param data body systemReq.GetMenuTree true "菜单信息"
@@ -132,7 +132,7 @@ func (m *MenuApi) GetAllMenuTree(c *gin.Context) {
// GetUserMenuTree
// @Tags 菜单管理
// @Summary 用户菜单数据
// @Security ApiKeyAuth
// @Security BasicAuth
// @Produce json
// @Success 200 {object} response.Response{data=[]system.Menu,msg=string} "用户菜单数据"
// @Router /api/menu/getUserMenuTree [get]
@@ -143,7 +143,7 @@ func (m *MenuApi) GetUserMenuTree(c *gin.Context) {
// Route
// @Tags 菜单管理
// @Summary 用户路由
// @Security ApiKeyAuth
// @Security BasicAuth
// @Produce json
// @Success 200 {object} response.Response{data=[]system.Menu,msg=string} "用户route"
// @Router /api/menu/route [get]
+4 -4
View File
@@ -17,7 +17,7 @@ type RoleApi struct {
// SaveRole
// @tags 角色管理
// @Summary 创建角色
// @Security ApiKeyAuth
// @Security BasicAuth
// @accept json
// @Produce json
// @Param data body system.Role true "角色信息"
@@ -42,7 +42,7 @@ func (a *RoleApi) SaveRole(context *gin.Context) {
// UpdateRole
// @tags 角色管理
// @Summary 修改角色
// @Security ApiKeyAuth
// @Security BasicAuth
// @accept application/json
// @Produce application/json
// @Param data body system.Role true "角色ID"
@@ -121,7 +121,7 @@ func (a *RoleApi) Delete(context *gin.Context) {
// Detail
// @Tags 角色管理
// @Summary 角色详情
// @Security ApiKeyAuth
// @Security BasicAuth
// @Produce application/json
// @Param id query string true "id"
// @Success 200 {object} response.Response{data=system.Role} "角色详情"
@@ -140,7 +140,7 @@ func (a *RoleApi) Detail(context *gin.Context) {
// GrantMenu
// @tags 角色管理
// @Summary 授权菜单给角色
// @Security ApiKeyAuth
// @Security BasicAuth
// @accept application/json
// @Produce application/json
// @Param data body systemreq.GrantMenu true "授权菜单给角色"
+7 -7
View File
@@ -17,7 +17,7 @@ type UserApi struct {
// SaveUser
// @tags 用户管理
// @Summary 新增用户
// @Security ApiKeyAuth
// @Security BasicAuth
// @accept json
// @Produce json
// @Param data body system.User true "用户信息"
@@ -41,7 +41,7 @@ func (u *UserApi) SaveUser(c *gin.Context) {
// UpdateUser
// @tags 用户管理
// @Summary 更新用户
// @Security ApiKeyAuth
// @Security BasicAuth
// @accept application/json
// @Produce application/json
// @Param data body system.User true "用户ID,用户信息"
@@ -65,7 +65,7 @@ func (u *UserApi) UpdateUser(c *gin.Context) {
// GetUserList
// @tags 用户管理
// @Summary 获取用户列表
// @Security ApiKeyAuth
// @Security BasicAuth
// @accept application/json
// @Produce application/json
// @Param data body systemReq.GetUserList true "页码, 每页大小, 搜索条件"
@@ -95,7 +95,7 @@ func (u *UserApi) GetUserList(c *gin.Context) {
// Delete
// @Tags 用户管理
// @Summary 删除用户
// @Security ApiKeyAuth
// @Security BasicAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "批量删除用户"
@@ -120,7 +120,7 @@ func (u *UserApi) Delete(c *gin.Context) {
// Detail
// @Tags 用户管理
// @Summary 获取用户详情
// @Security ApiKeyAuth
// @Security BasicAuth
// @Produce application/json
// @Param id query string true "id"
// @Success 200 {object} response.Response{data=system.User} "获取用户详情成功"
@@ -139,7 +139,7 @@ func (u *UserApi) Detail(c *gin.Context) {
// ChangePassword
// @Tags 用户管理
// @Summary 修改密码
// @Security ApiKeyAuth
// @Security BasicAuth
// @Description 修改密码
// @accept json
// @Produce application/json
@@ -165,7 +165,7 @@ func (u *UserApi) ChangePassword(c *gin.Context) {
// GrantRole
// @Tags 用户管理
// @Summary 给用户分配角色
// @Security ApiKeyAuth
// @Security BasicAuth
// @accept application/json
// @Produce application/json
// @Param data body systemReq.GrantRole true "用户ID, 角色ID"