Skip to content

Commit d9f1392

Browse files
奇淼(piexlmaxhelight
andauthored
新增按钮权限,增加redis可独立配置 (flipped-aurora#923)
* fix jwt to golang-jwt, gin to 1.7.0 * 增加按钮权限功能 * 增加redis可独立配置 Co-authored-by: helight <helight@helight.info>
1 parent e2d9cfc commit d9f1392

File tree

33 files changed

+5026
-544
lines changed

33 files changed

+5026
-544
lines changed

server/api/v1/system/enter.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type ApiGroup struct {
1616
OperationRecordApi
1717
AutoCodeHistoryApi
1818
DictionaryDetailApi
19+
AuthorityBtnApi
1920
}
2021

2122
var (
@@ -33,4 +34,5 @@ var (
3334
operationRecordService = service.ServiceGroupApp.SystemServiceGroup.OperationRecordService
3435
autoCodeHistoryService = service.ServiceGroupApp.SystemServiceGroup.AutoCodeHistoryService
3536
dictionaryDetailService = service.ServiceGroupApp.SystemServiceGroup.DictionaryDetailService
37+
authorityBtnService = service.ServiceGroupApp.SystemServiceGroup.AuthorityBtnService
3638
)
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package system
2+
3+
import (
4+
"github.com/flipped-aurora/gin-vue-admin/server/global"
5+
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
6+
"github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
7+
"github.com/gin-gonic/gin"
8+
"go.uber.org/zap"
9+
)
10+
11+
type AuthorityBtnApi struct{}
12+
13+
// @Tags AuthorityBtn
14+
// @Summary 获取权限按钮
15+
// @Security ApiKeyAuth
16+
// @accept application/json
17+
// @Produce application/json
18+
// @Param data body request.SysAuthorityBtnReq true "菜单id, 角色id, 选中的按钮id"
19+
// @Success 200 {object} response.Response{data=response.SysAuthorityBtnRes,msg=string} "返回列表成功"
20+
// @Router /authorityBtn/getAuthorityBtn [post]
21+
func (a *AuthorityBtnApi) GetAuthorityBtn(c *gin.Context) {
22+
var req request.SysAuthorityBtnReq
23+
_ = c.ShouldBindJSON(&req)
24+
if err, res := authorityBtnService.GetAuthorityBtn(req); err != nil {
25+
global.GVA_LOG.Error("查询失败!", zap.Error(err))
26+
response.FailWithMessage("查询失败", c)
27+
} else {
28+
response.OkWithDetailed(res, "查询成功", c)
29+
}
30+
}
31+
32+
// @Tags AuthorityBtn
33+
// @Summary 设置权限按钮
34+
// @Security ApiKeyAuth
35+
// @accept application/json
36+
// @Produce application/json
37+
// @Param data body request.SysAuthorityBtnReq true "菜单id, 角色id, 选中的按钮id"
38+
// @Success 200 {object} response.Response{msg=string} "返回列表成功"
39+
// @Router /authorityBtn/getAuthorityBtn [post]
40+
func (a *AuthorityBtnApi) SetAuthorityBtn(c *gin.Context) {
41+
var req request.SysAuthorityBtnReq
42+
_ = c.ShouldBindJSON(&req)
43+
if err := authorityBtnService.SetAuthorityBtn(req); err != nil {
44+
global.GVA_LOG.Error("分配失败!", zap.Error(err))
45+
response.FailWithMessage("分配失败", c)
46+
} else {
47+
response.OkWithMessage("分配成功", c)
48+
}
49+
}
50+
51+
// @Tags AuthorityBtn
52+
// @Summary 设置权限按钮
53+
// @Security ApiKeyAuth
54+
// @accept application/json
55+
// @Produce application/json
56+
// @Success 200 {object} response.Response{msg=string} "删除成功"
57+
// @Router /authorityBtn/canRemoveAuthorityBtn [post]
58+
func (a *AuthorityBtnApi) CanRemoveAuthorityBtn(c *gin.Context) {
59+
id := c.Query("id")
60+
if err := authorityBtnService.CanRemoveAuthorityBtn(id); err != nil {
61+
global.GVA_LOG.Error("删除失败!", zap.Error(err))
62+
response.FailWithMessage(err.Error(), c)
63+
} else {
64+
response.OkWithMessage("删除成功", c)
65+
}
66+
}

0 commit comments

Comments
 (0)