优化
This commit is contained in:
@@ -18,8 +18,8 @@ func NewPermission(service *service.PermissionService) *Permission {
|
||||
|
||||
func (h *Permission) Buttons(c *gin.Context) {
|
||||
var req dto.GetAuthorityButtonsRequest
|
||||
if c.ShouldBindJSON(&req) != nil {
|
||||
httpx.Fail(c, "参数错误")
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
httpx.Fail(c, err.Error())
|
||||
return
|
||||
}
|
||||
selected, err := h.service.SelectedButtons(c.Request.Context(), req.AuthorityID, req.MenuID)
|
||||
@@ -32,8 +32,8 @@ func (h *Permission) Buttons(c *gin.Context) {
|
||||
|
||||
func (h *Permission) SetButtons(c *gin.Context) {
|
||||
var req dto.SetAuthorityButtonsRequest
|
||||
if c.ShouldBindJSON(&req) != nil {
|
||||
httpx.Fail(c, "参数错误")
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
httpx.Fail(c, err.Error())
|
||||
return
|
||||
}
|
||||
if err := h.service.SetSelectedButtons(c.Request.Context(), req.AuthorityID, req.MenuID, req.Selected); err != nil {
|
||||
@@ -47,7 +47,7 @@ func (h *Permission) CanRemoveButton(c *gin.Context) {
|
||||
id, _ := strconv.ParseUint(c.Query("id"), 10, 64)
|
||||
allowed, err := h.service.CanRemoveButton(c.Request.Context(), uint(id))
|
||||
if err != nil {
|
||||
httpx.Fail(c, "检查失败")
|
||||
httpx.Fail(c, err.Error())
|
||||
return
|
||||
}
|
||||
if !allowed {
|
||||
|
||||
Reference in New Issue
Block a user