【更新】更新restful

This commit is contained in:
PandaGoAdmin
2022-08-03 17:21:07 +08:00
parent 249ddd80b2
commit 518a3de903
18 changed files with 68 additions and 892 deletions

View File

@@ -16,39 +16,17 @@ type MenuApi struct {
RoleApp services.SysRoleModel
}
// @Summary 获取菜单树
// @Description 获取JSON
// @Tags 菜单
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
// @Router /system/menu/menuTreSelect [get]
// @Security X-TOKEN
func (m *MenuApi) GetMenuTreeSelect(rc *restfulx.ReqCtx) {
lable := m.MenuApp.SelectMenuLable(entity.SysMenu{})
rc.ResData = lable
}
// @Summary 登陆成功获取的路由,根据角色名称获取菜单列表数据(左菜单使用)
// @Description 获取JSON
// @Tags 菜单
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Success 200 {string} string "{"code": 400, "message": "抱歉未找到相关信息"}"
// @Router /system/menu/menuRole [get]
// @Security X-TOKEN
func (m *MenuApi) GetMenuRole(rc *restfulx.ReqCtx) {
roleKey := restfulx.QueryParam(rc, "roleKey")
biz.IsTrue(roleKey != "", "请传入角色Key")
rc.ResData = Build(*m.MenuApp.SelectMenuRole(roleKey))
}
// @Summary 获取角色的菜单树
// @Description 获取JSON
// @Tags 菜单
// @Param roleId path int false "roleId"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Success 200 {string} string "{"code": 400, "message": "抱歉未找到相关信息"}"
// @Router /system/menu/menuTreRoleSelect/{roleId} [get]
// @Security X-TOKEN
func (m *MenuApi) GetMenuTreeRoleSelect(rc *restfulx.ReqCtx) {
roleId := restfulx.PathParamInt(rc, "roleId")
@@ -63,30 +41,12 @@ func (m *MenuApi) GetMenuTreeRoleSelect(rc *restfulx.ReqCtx) {
}
}
// @Summary 获取角色对应的菜单路径数组
// @Description 获取JSON
// @Tags 菜单
// @Param roleKey query string true "roleKey"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Success 200 {string} string "{"code": 400, "message": "抱歉未找到相关信息"}"
// @Router /system/menu/menuPaths [get]
// @Security X-TOKEN
func (m *MenuApi) GetMenuPaths(rc *restfulx.ReqCtx) {
roleKey := restfulx.QueryParam(rc, "roleKey")
biz.IsTrue(roleKey != "", "请传入角色Key")
rc.ResData = m.RoleMenuApp.GetMenuPaths(entity.SysRoleMenu{RoleName: roleKey})
}
// @Summary Menu列表数据
// @Description 获取JSON
// @Tags 菜单
// @Param menuName query string false "menuName"
// @Param IsHide query string false "IsHide"
// @Param title query string false "title"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Success 200 {string} string "{"code": 400, "message": "抱歉未找到相关信息"}"
// @Router /system/menu/menuList [get]
// @Security Bearer
func (m *MenuApi) GetMenuList(rc *restfulx.ReqCtx) {
menuName := restfulx.QueryParam(rc, "menuName")
status := restfulx.QueryParam(rc, "status")
@@ -99,28 +59,12 @@ func (m *MenuApi) GetMenuList(rc *restfulx.ReqCtx) {
}
}
// @Summary Menu列表数据
// @Description 获取JSON
// @Tags 菜单
// @Param menuId path string true "menuId"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Success 200 {string} string "{"code": 400, "message": "抱歉未找到相关信息"}"
// @Router /system/menu/{menuId} [get]
// @Security Bearer
func (m *MenuApi) GetMenu(rc *restfulx.ReqCtx) {
menuId := restfulx.PathParamInt(rc, "menuId")
rc.ResData = m.MenuApp.FindOne(int64(menuId))
}
// @Summary 创建菜单
// @Description 获取JSON
// @Tags 菜单
// @Param data body entity.SysMenu true "data"
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
// @Router /system/menu [post]
// @Security X-TOKEN
func (m *MenuApi) InsertMenu(rc *restfulx.ReqCtx) {
var menu entity.SysMenu
restfulx.BindQuery(rc, &menu)
@@ -134,14 +78,6 @@ func (m *MenuApi) InsertMenu(rc *restfulx.ReqCtx) {
}
}
// @Summary 修改菜单
// @Description 获取JSON
// @Tags 菜单
// @Param data body entity.SysMenu true "body"
// @Success 200 {string} string "{"code": 200, "message": "修改成功"}"
// @Success 200 {string} string "{"code": -1, "message": "修改失败"}"
// @Router /system/menu [put]
// @Security X-TOKEN
func (m *MenuApi) UpdateMenu(rc *restfulx.ReqCtx) {
var menu entity.SysMenu
restfulx.BindQuery(rc, &menu)
@@ -155,13 +91,6 @@ func (m *MenuApi) UpdateMenu(rc *restfulx.ReqCtx) {
}
}
// @Summary 删除菜单
// @Description 删除数据
// @Tags 菜单
// @Param menuId path int true "menuId"
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /system/menu/{menuId} [delete]
func (m *MenuApi) DeleteMenu(rc *restfulx.ReqCtx) {
menuId := restfulx.PathParam(rc, "menuId")
m.MenuApp.Delete(utils.IdsStrToIdsIntGroup(menuId))