|
| 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