2
13693261870
2022-09-16 653761a31dfeb50dd3d007e892d69c90bf0cdafc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
//package com.landtool.lanbase.modules.sys.controller;
//
//import org.apache.commons.lang.StringUtils;
//import org.apache.shiro.authz.annotation.RequiresPermissions;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RestController;
//
//import com.landtool.lanbase.common.Constant.MenuType;
//import com.landtool.lanbase.common.annotation.LogAction;
//import com.landtool.lanbase.common.annotation.LogLogininfo;
//import com.landtool.lanbase.common.annotation.SysLog;
//import com.landtool.lanbase.common.exception.LanbaseException;
//import com.landtool.lanbase.common.utils.Result;
//import com.landtool.lanbase.modules.sys.entity.SysMenu;
//import com.landtool.lanbase.modules.sys.service.SysMenuService;
//import com.landtool.lanbase.modules.sys.service.SysUserService;
//
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//
//import java.util.HashMap;
//import java.util.List;
//import java.util.Set;
//
///**
// * @author lanbase
// * @Description: TODO(系统菜单)
// * @date 2017-6-23 15:07
// */
//@RestController
//@RequestMapping("/sys/menu")
//@Api(value = "", tags = {"系统菜单"})
//public class SysMenuController extends AbstractController {
//
//    @Autowired
//    private SysUserService sysUserService;
//
//    @Autowired
//    private SysMenuService sysMenuService;
//
//    /**
//     * 导航菜单
//     */
//    @RequestMapping(value ="/nav", method ={RequestMethod.POST, RequestMethod.GET})
//    @ApiOperation(
//            value = "导航菜单",
//            notes = "返回导航菜单,带有权限,用于首页",
//            response = Result.class
//            )
//    public Result nav(){
//        List<SysMenu> menuList = sysMenuService.getUserMenuList(getUserId());
//        Set<String> permissions = sysUserService.getUserPermissions(getUserId());
//        return Result.ok().put("menuList", menuList).put("permissions", permissions);
//    }
//
//    /**
//     * 所有菜单列表
//     */
//    @RequestMapping(value ="/list", method ={RequestMethod.POST, RequestMethod.GET})
//    @RequiresPermissions("sys:menu:list")
//    @ApiOperation(
//            value = "菜单列表",
//            notes = "所有菜单列表"
//            )
//    public List<SysMenu> list(){
//        List<SysMenu> menuList = sysMenuService.queryList(new HashMap<String, Object>());
//
//        return menuList;
//    }
//    
//    /**
//     * 选择菜单(添加、修改菜单)
//     */
//    @GetMapping("/select")
//    @RequiresPermissions("sys:menu:select")
//    @ApiOperation(
//            value = "选择菜单",
//            notes = "选择菜单(添加、修改菜单)"
//            )
//    public Result select(){
//        //查询列表数据
//        List<SysMenu> menuList = sysMenuService.queryNotButtonList();
//        
//        //添加顶级菜单
//        SysMenu root = new SysMenu();
//        root.setId(0L);
//        root.setName("一级菜单");
//        root.setParentId(-1L);
//        root.setOpen(true);
//        menuList.add(root);
//        
//        return Result.ok().put("menuList", menuList);
//    }
//    
//    /**
//     * 菜单信息
//     */
//    @GetMapping("/info/{menuId}")
//    @RequiresPermissions("sys:menu:info")
//    @ApiOperation(
//            value = "菜单信息",
//            notes = ""
//            )
//    public Result info(@ApiParam(name="menuId",value="菜单id",required=true)@PathVariable("menuId") Long menuId){
//        SysMenu menu = sysMenuService.queryObject(menuId);
//        return Result.ok().put("menu", menu);
//    }
//    
//    /**
//     * 保存
//     */
//    //@LogAction("保存菜单")
//    @PostMapping("/save")
//    @RequiresPermissions("sys:menu:save")
//    @ApiOperation(
//            value = "保存菜单",
//            notes = ""
//            )
//    public Result save(@ApiParam(name="菜单对象",value="传入json格式",required=true)@RequestBody SysMenu menu){
//        //数据校验
//        verifyForm(menu);
//        
//        sysMenuService.save(menu);
//        
//        return Result.ok();
//    }
//    
//    /**
//     * 修改
//     */
//    //@LogLogininfo("修改")
//    @PostMapping("/update")
//    @RequiresPermissions("sys:menu:update")
//    @ApiOperation(
//            value = "修改菜单",
//            notes = ""
//            )
//    public Result update(@ApiParam(name="菜单对象",value="传入json格式",required=true)@RequestBody SysMenu menu){
//        //数据校验
//        verifyForm(menu);
//                
//        sysMenuService.update(menu);
//        
//        return Result.ok();
//    }
//    
//    /**
//     * 删除
//     */
//    @SysLog("删除菜单")
//    @PostMapping("/delete")
//    @RequiresPermissions("sys:menu:delete")
//    @ApiOperation(
//            value = "删除菜单",
//            notes = ""
//            )
//    public Result delete(@ApiParam(name="menuId",value="菜单id",required=true)long menuId){
//        //判断是否有子菜单或按钮
//        List<SysMenu> menuList = sysMenuService.queryListByParentId(menuId);
//        SysMenu menu = sysMenuService.queryObject(menuId); //当前菜单
//        SysMenu rootMenu = sysMenuService.queryObject(menuId); //一级菜单
//        while (rootMenu.getParentId() != 0) {
//            rootMenu = sysMenuService.queryObject(rootMenu.getParentId());
//        }
//            
//        if (!rootMenu.getName().equals("内容管理") && menuList.size() > 0) {
//                return Result.error("请先删除子菜单或按钮");
//        }        
//
//        sysMenuService.deleteBatch(new Long[]{menuId});
//        return Result.ok();
//    }
//    
//    /**
//     * 验证参数是否正确
//     */
//    private void verifyForm(SysMenu menu){
//        if(StringUtils.isBlank(menu.getName())){
//            throw new LanbaseException("菜单名称不能为空");
//        }
//        
//        if(menu.getParentId() == null){
//            throw new LanbaseException("上级菜单不能为空");
//        }
//        
//        //菜单
//        if(menu.getType() == MenuType.MENU.getValue()){
//            if(StringUtils.isBlank(menu.getUrl())){
//                throw new LanbaseException("菜单URL不能为空");
//            }
//        }
//        
//        //上级菜单类型
//        int parentType = MenuType.CATALOG.getValue();
//        if(menu.getParentId() != 0){
//            SysMenu parentMenu = sysMenuService.queryObject(menu.getParentId());
//            parentType = parentMenu.getType();
//        }
//        
//        //目录、菜单
//        if(menu.getType() == MenuType.CATALOG.getValue() ||
//                menu.getType() == MenuType.MENU.getValue()){
//            if(parentType != MenuType.CATALOG.getValue()){
//                throw new LanbaseException("上级菜单只能为目录类型");
//            }
//            return ;
//        }
//        
//        //按钮
//        if(menu.getType() == MenuType.BUTTON.getValue()){
//            if(parentType != MenuType.MENU.getValue()){
//                throw new LanbaseException("上级菜单只能为菜单类型");
//            }
//            return ;
//        }
//    }
//}