|
|
@ -40,6 +40,15 @@ func GetMenu(c *gin.Context) { |
|
|
|
func GetMenuList(c *gin.Context) { |
|
|
|
var pageInfo request.PageInfo |
|
|
|
_ = c.ShouldBindJSON(&pageInfo) |
|
|
|
PageVerify := utils.Rules{ |
|
|
|
"Page": {utils.NotEmpty()}, |
|
|
|
"PageSize": {utils.NotEmpty()}, |
|
|
|
} |
|
|
|
PageVerifyErr := utils.Verify(pageInfo, PageVerify) |
|
|
|
if PageVerifyErr!=nil{ |
|
|
|
response.FailWithMessage(PageVerifyErr.Error(), c) |
|
|
|
return |
|
|
|
} |
|
|
|
err, menuList, total := service.GetInfoList() |
|
|
|
if err != nil { |
|
|
|
response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c) |
|
|
@ -65,11 +74,11 @@ func AddBaseMenu(c *gin.Context) { |
|
|
|
var menu model.SysBaseMenu |
|
|
|
_ = c.ShouldBindJSON(&menu) |
|
|
|
MenuVerify := utils.Rules{ |
|
|
|
"Path": {utils.NotEmpty()}, |
|
|
|
"Path": {"notEmpty"}, |
|
|
|
"ParentId": {utils.NotEmpty()}, |
|
|
|
"Name": {utils.NotEmpty()}, |
|
|
|
"Component": {utils.NotEmpty()}, |
|
|
|
"Sort": {utils.Ge("0")}, |
|
|
|
"Sort": {utils.Ge("0"),"ge=0"}, |
|
|
|
} |
|
|
|
MenuVerifyErr := utils.Verify(menu, MenuVerify) |
|
|
|
if MenuVerifyErr != nil { |
|
|
@ -119,7 +128,14 @@ func GetBaseMenuTree(c *gin.Context) { |
|
|
|
func AddMenuAuthority(c *gin.Context) { |
|
|
|
var addMenuAuthorityInfo request.AddMenuAuthorityInfo |
|
|
|
_ = c.ShouldBindJSON(&addMenuAuthorityInfo) |
|
|
|
|
|
|
|
MenuVerify := utils.Rules{ |
|
|
|
"AuthorityId": {"notEmpty"}, |
|
|
|
} |
|
|
|
MenuVerifyErr := utils.Verify(addMenuAuthorityInfo, MenuVerify) |
|
|
|
if MenuVerifyErr != nil { |
|
|
|
response.FailWithMessage(MenuVerifyErr.Error(), c) |
|
|
|
return |
|
|
|
} |
|
|
|
err := service.AddMenuAuthority(addMenuAuthorityInfo.Menus, addMenuAuthorityInfo.AuthorityId) |
|
|
|
if err != nil { |
|
|
|
response.FailWithMessage(fmt.Sprintf("添加失败,%v", err), c) |
|
|
@ -139,6 +155,14 @@ func AddMenuAuthority(c *gin.Context) { |
|
|
|
func GetMenuAuthority(c *gin.Context) { |
|
|
|
var authorityIdInfo request.AuthorityIdInfo |
|
|
|
_ = c.ShouldBindJSON(&authorityIdInfo) |
|
|
|
MenuVerify := utils.Rules{ |
|
|
|
"AuthorityId": {"notEmpty"}, |
|
|
|
} |
|
|
|
MenuVerifyErr := utils.Verify(authorityIdInfo, MenuVerify) |
|
|
|
if MenuVerifyErr != nil { |
|
|
|
response.FailWithMessage(MenuVerifyErr.Error(), c) |
|
|
|
return |
|
|
|
} |
|
|
|
err, menus := service.GetMenuAuthority(authorityIdInfo.AuthorityId) |
|
|
|
if err != nil { |
|
|
|
response.FailWithDetailed(response.ERROR, resp.SysMenusResponse{Menus: menus}, fmt.Sprintf("添加失败,%v", err), c) |
|
|
@ -158,6 +182,14 @@ func GetMenuAuthority(c *gin.Context) { |
|
|
|
func DeleteBaseMenu(c *gin.Context) { |
|
|
|
var idInfo request.GetById |
|
|
|
_ = c.ShouldBindJSON(&idInfo) |
|
|
|
MenuVerify := utils.Rules{ |
|
|
|
"Id": {"notEmpty"}, |
|
|
|
} |
|
|
|
MenuVerifyErr := utils.Verify(idInfo, MenuVerify) |
|
|
|
if MenuVerifyErr != nil { |
|
|
|
response.FailWithMessage(MenuVerifyErr.Error(), c) |
|
|
|
return |
|
|
|
} |
|
|
|
err := service.DeleteBaseMenu(idInfo.Id) |
|
|
|
if err != nil { |
|
|
|
response.FailWithMessage(fmt.Sprintf("删除失败:%v", err), c) |
|
|
@ -178,6 +210,26 @@ func DeleteBaseMenu(c *gin.Context) { |
|
|
|
func UpdateBaseMenu(c *gin.Context) { |
|
|
|
var menu model.SysBaseMenu |
|
|
|
_ = c.ShouldBindJSON(&menu) |
|
|
|
MenuVerify := utils.Rules{ |
|
|
|
"Path": {"notEmpty"}, |
|
|
|
"ParentId": {utils.NotEmpty()}, |
|
|
|
"Name": {utils.NotEmpty()}, |
|
|
|
"Component": {utils.NotEmpty()}, |
|
|
|
"Sort": {utils.Ge("0"),"ge=0"}, |
|
|
|
} |
|
|
|
MenuVerifyErr := utils.Verify(menu, MenuVerify) |
|
|
|
if MenuVerifyErr != nil { |
|
|
|
response.FailWithMessage(MenuVerifyErr.Error(), c) |
|
|
|
return |
|
|
|
} |
|
|
|
MetaVerify := utils.Rules{ |
|
|
|
"Title": {utils.NotEmpty()}, |
|
|
|
} |
|
|
|
MetaVerifyErr := utils.Verify(menu.Meta, MetaVerify) |
|
|
|
if MetaVerifyErr != nil { |
|
|
|
response.FailWithMessage(MetaVerifyErr.Error(), c) |
|
|
|
return |
|
|
|
} |
|
|
|
err := service.UpdateBaseMenu(menu) |
|
|
|
if err != nil { |
|
|
|
response.FailWithMessage(fmt.Sprintf("修改失败:%v", err), c) |
|
|
@ -197,6 +249,14 @@ func UpdateBaseMenu(c *gin.Context) { |
|
|
|
func GetBaseMenuById(c *gin.Context) { |
|
|
|
var idInfo request.GetById |
|
|
|
_ = c.ShouldBindJSON(&idInfo) |
|
|
|
MenuVerify := utils.Rules{ |
|
|
|
"Id": {"notEmpty"}, |
|
|
|
} |
|
|
|
MenuVerifyErr := utils.Verify(idInfo, MenuVerify) |
|
|
|
if MenuVerifyErr != nil { |
|
|
|
response.FailWithMessage(MenuVerifyErr.Error(), c) |
|
|
|
return |
|
|
|
} |
|
|
|
err, menu := service.GetBaseMenuById(idInfo.Id) |
|
|
|
if err != nil { |
|
|
|
response.FailWithMessage(fmt.Sprintf("查询失败:%v", err), c) |
|
|
|