|
|
package BaseMenuController
|
|
|
|
|
|
import (
|
|
|
"dsBaseWeb/Business/BaseMenu/BaseMenuService"
|
|
|
"dsBaseWeb/Model"
|
|
|
"dsBaseWeb/Utils/CommonUtil"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"net/http"
|
|
|
)
|
|
|
|
|
|
func Routers(r *gin.RouterGroup) {
|
|
|
rr := r.Group("/menu")
|
|
|
|
|
|
rr.GET("/PageMenuInfo", PageMenuInfo)
|
|
|
rr.GET("/GetMenuInfo", GetMenuInfo)
|
|
|
rr.POST("/AddMenuInfo", AddMenuInfo)
|
|
|
rr.POST("/DeleteMenuInfo", DeleteMenuInfo)
|
|
|
rr.POST("/UpdateMenuInfo", UpdateMenuInfo)
|
|
|
rr.POST("/SetMenuSortInfo", SetMenuSortInfo)
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// @Summary 根据系统ID和身份ID获取菜单信息
|
|
|
// @Description 根据系统ID和身份ID获取菜单信息
|
|
|
// @Tags 菜单信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param appId query string true "系统ID"
|
|
|
// @Param identityId query int true "身份ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/menu/PageMenuInfo [get]
|
|
|
// @X-EmptyLimit ["appId","identityId"]
|
|
|
// @X-LengthLimit [{"appId":"36,36"}]
|
|
|
// @X-IntRangeLimit [{"identityId":"1,4"}]
|
|
|
// @X-RoleLimit ["1"]
|
|
|
// @X-TableName ["t_base_menu"]
|
|
|
// @X-Sort [1]
|
|
|
func PageMenuInfo(c *gin.Context) {
|
|
|
//系统ID
|
|
|
appId := c.Query("appId")
|
|
|
//身份ID
|
|
|
identityId := CommonUtil.ConvertStringToInt32(c.Query("identityId"))
|
|
|
r, err := BaseMenuService.PageBaseMenuInfo(appId, identityId)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "调用RPC服务失败!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: r.Success,
|
|
|
Message: r.Message,
|
|
|
List: CommonUtil.ConvertJsonStringToMapArray("[" + r.List + "]"),
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// @Summary 根据菜单ID获取该菜单信息
|
|
|
// @Description 根据菜单ID获取该菜单信息
|
|
|
// @Tags 菜单信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param menuId query string true "菜单ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/menu/GetMenuInfo [get]
|
|
|
// @X-EmptyLimit ["menuId"]
|
|
|
// @X-LengthLimit [{"menuId":"36,36"}]
|
|
|
// @X-RoleLimit ["1"]
|
|
|
// @X-TableName ["t_base_menu"]
|
|
|
// @X-Sort [2]
|
|
|
func GetMenuInfo(c *gin.Context) {
|
|
|
//菜单ID
|
|
|
menuId := c.Query("menuId")
|
|
|
r, err := BaseMenuService.GetBaseMenuInfo(menuId)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "调用RPC服务失败!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: r.Success,
|
|
|
Message: r.Message,
|
|
|
List: CommonUtil.ConvertJsonStringToMapArray(r.List),
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// @Summary 增加菜单信息
|
|
|
// @Description 增加菜单信息
|
|
|
// @Tags 菜单信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param appId formData string true "系统ID"
|
|
|
// @Param parentId formData string true "父节点ID"
|
|
|
// @Param identityId formData int true "身份ID"
|
|
|
// @Param menuName formData string true "菜单名称"
|
|
|
// @Param menuCode formData string true "菜单编码"
|
|
|
// @Param menuUrl formData string true "菜单的URL"
|
|
|
// @Param menuIcon formData string true "菜单图标"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/menu/AddMenuInfo [post]
|
|
|
// @X-EmptyLimit ["appId","parentId","menuName","menuCode","menuUrl","menuIcon"]
|
|
|
// @X-IntRangeLimit [{"identityId":"1,4"}]
|
|
|
// @X-LengthLimit [{"appId":"36,36"},{"parentId":"36,36"},{"menuName":"2,50"},{"menuCode":"1,6"},{"menuUrl":"1,500"}]
|
|
|
// @X-RoleLimit ["1"]
|
|
|
// @X-Sort [3]
|
|
|
func AddMenuInfo(c *gin.Context) {
|
|
|
//系统ID
|
|
|
appId := c.PostForm("appId")
|
|
|
//父节点ID
|
|
|
parentId := c.PostForm("parentId")
|
|
|
//身份ID
|
|
|
identityId := CommonUtil.ConvertStringToInt32(c.PostForm("identityId"))
|
|
|
//菜单名称
|
|
|
menuName := c.PostForm("menuName")
|
|
|
//菜单编码
|
|
|
menuCode := c.PostForm("menuCode")
|
|
|
//菜单的URL
|
|
|
menuUrl := c.PostForm("menuUrl")
|
|
|
//菜单图标
|
|
|
menuIcon := c.PostForm("menuIcon")
|
|
|
|
|
|
r, err := BaseMenuService.AddBaseMenuInfo(appId, parentId, identityId, menuName, menuCode, menuUrl, menuIcon)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "调用RPC服务失败!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: r.Success,
|
|
|
Message: r.Message,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// @Summary 删除菜单信息
|
|
|
// @Description 删除菜单信息
|
|
|
// @Tags 菜单信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param menuIds formData string true "菜单ID,多个用逗号分隔"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/menu/DeleteMenuInfo [post]
|
|
|
// @X-EmptyLimit ["menuIds"]
|
|
|
// @X-LengthLimit [{"menuIds":"36,1800"}]
|
|
|
// @X-RoleLimit ["1"]
|
|
|
// @X-Sort [4]
|
|
|
func DeleteMenuInfo(c *gin.Context) {
|
|
|
//菜单ID
|
|
|
menuIds := c.PostForm("menuIds")
|
|
|
r, err := BaseMenuService.DeleteBaseMenuInfo(menuIds)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "调用RPC服务失败!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: r.Success,
|
|
|
Message: r.Message,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// @Summary 修改菜单信息
|
|
|
// @Description 修改菜单信息
|
|
|
// @Tags 菜单信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param menuId formData string true "菜单ID"
|
|
|
// @Param menuName formData string true "菜单名称"
|
|
|
// @Param menuCode formData string true "菜单编码"
|
|
|
// @Param menuUrl formData string true "菜单的URL"
|
|
|
// @Param menuIcon formData string true "菜单图标"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/menu/UpdateMenuInfo [post]
|
|
|
// @X-EmptyLimit ["menuId","menuName","menuCode","menuUrl","menuIcon"]
|
|
|
// @X-LengthLimit [{"menuId":"36,36"},{"menuName":"36,36"},{"menuName":"2,50"},{"menuCode":"2,20"},{"menuUrl":"1,500"}]
|
|
|
// @X-RoleLimit ["1"]
|
|
|
// @X-Sort [5]
|
|
|
func UpdateMenuInfo(c *gin.Context) {
|
|
|
//菜单ID
|
|
|
menuId := c.PostForm("menuId")
|
|
|
//菜单名称
|
|
|
menuName := c.PostForm("menuName")
|
|
|
//菜单编码
|
|
|
menuCode := c.PostForm("menuCode")
|
|
|
//菜单的URL
|
|
|
menuUrl := c.PostForm("menuUrl")
|
|
|
//菜单图标
|
|
|
menuIcon := c.PostForm("menuIcon")
|
|
|
|
|
|
r, err := BaseMenuService.UpdateBaseMenuInfo(menuId, menuName, menuCode, menuUrl, menuIcon)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "调用RPC服务失败!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: r.Success,
|
|
|
Message: r.Message,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// @Summary 设置菜单排序
|
|
|
// @Description 设置菜单排序
|
|
|
// @Tags 菜单信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param menuId formData string true "菜单ID"
|
|
|
// @Param direction formData int true "调整顺序的方向 1:向上 2:向下"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/menu/SetMenuSortInfo [post]
|
|
|
// @X-EmptyLimit ["menuId","direction"]
|
|
|
// @X-LengthLimit [{"menuId":"36,36"}]
|
|
|
// @X-IntRangeLimit [{"direction":"1,2"}]
|
|
|
// @X-RoleLimit ["1"]
|
|
|
// @X-Sort [6]
|
|
|
func SetMenuSortInfo(c *gin.Context) {
|
|
|
//菜单ID
|
|
|
menuId := c.PostForm("menuId")
|
|
|
//调整顺序的方向
|
|
|
direction := CommonUtil.ConvertStringToInt32(c.PostForm("direction"))
|
|
|
r, err := BaseMenuService.SetMenuSortInfo(menuId, direction)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "调用RPC服务失败!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: r.Success,
|
|
|
Message: r.Message,
|
|
|
})
|
|
|
}
|