|
@@ -0,0 +1,70 @@
|
|
1
|
+package com.huiju.estateagents.cleancode;
|
|
2
|
+
|
|
3
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
4
|
+import com.huiju.estateagents.base.ResponseBean;
|
|
5
|
+import com.huiju.estateagents.entity.*;
|
|
6
|
+import com.huiju.estateagents.service.*;
|
|
7
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
8
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
9
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
10
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
11
|
+import org.springframework.web.bind.annotation.RestController;
|
|
12
|
+
|
|
13
|
+import javax.servlet.http.HttpServletRequest;
|
|
14
|
+import java.util.List;
|
|
15
|
+
|
|
16
|
+@RestController
|
|
17
|
+@RequestMapping("/")
|
|
18
|
+public class CleanCode {
|
|
19
|
+
|
|
20
|
+ @Autowired
|
|
21
|
+ private ISysMenuService sysMenuService;
|
|
22
|
+
|
|
23
|
+ @Autowired
|
|
24
|
+ private ITaRoleService taRoleService;
|
|
25
|
+
|
|
26
|
+ @Autowired
|
|
27
|
+ private ITaRoleMenuService taRoleMenuService;
|
|
28
|
+
|
|
29
|
+ @Autowired
|
|
30
|
+ private ITaRoleButtonService taRoleButtonService;
|
|
31
|
+
|
|
32
|
+ @Autowired
|
|
33
|
+ private ISysButtonInMenuService sysButtonInMenuService;
|
|
34
|
+
|
|
35
|
+ @RequestMapping(value = "/clean/menurole", method = RequestMethod.GET)
|
|
36
|
+ public void cleanMenu() {
|
|
37
|
+ List<SysMenu> sysMenuList = sysMenuService.list();
|
|
38
|
+
|
|
39
|
+ QueryWrapper<TaRole> roleQueryWrapper = new QueryWrapper<>();
|
|
40
|
+ roleQueryWrapper.eq("is_admin",1);
|
|
41
|
+ List<TaRole> roleList = taRoleService.list(roleQueryWrapper);
|
|
42
|
+
|
|
43
|
+ roleList.forEach(e -> {
|
|
44
|
+ sysMenuList.forEach(s -> {
|
|
45
|
+ TaRoleMenu taRoleMenu = new TaRoleMenu();
|
|
46
|
+ taRoleMenu.setRoleId(e.getRoleId());
|
|
47
|
+ taRoleMenu.setMenuId(s.getMenuId());
|
|
48
|
+ taRoleMenuService.save(taRoleMenu);
|
|
49
|
+ });
|
|
50
|
+ });
|
|
51
|
+ }
|
|
52
|
+
|
|
53
|
+ @RequestMapping(value = "/clean/buttonrole", method = RequestMethod.GET)
|
|
54
|
+ public void cleanButton() {
|
|
55
|
+ List<SysButtonInMenu> buttlist = sysButtonInMenuService.list();
|
|
56
|
+
|
|
57
|
+ QueryWrapper<TaRole> roleQueryWrapper = new QueryWrapper<>();
|
|
58
|
+ roleQueryWrapper.eq("is_admin",1);
|
|
59
|
+ List<TaRole> roleList = taRoleService.list(roleQueryWrapper);
|
|
60
|
+
|
|
61
|
+ roleList.forEach(e -> {
|
|
62
|
+ buttlist.forEach(s -> {
|
|
63
|
+ TaRoleButton taRoleButton = new TaRoleButton();
|
|
64
|
+ taRoleButton.setBtnId(s.getBtnId());
|
|
65
|
+ taRoleButton.setRoleId(e.getRoleId());
|
|
66
|
+ taRoleButtonService.save(taRoleButton);
|
|
67
|
+ });
|
|
68
|
+ });
|
|
69
|
+ }
|
|
70
|
+}
|