2
2
3
3
import com .github .pagehelper .PageInfo ;
4
4
import com .study .model .Role ;
5
+ import com .study .model .RoleResources ;
5
6
import com .study .model .User ;
7
+ import com .study .service .RoleResourcesService ;
6
8
import com .study .service .RoleService ;
9
+ import org .springframework .util .StringUtils ;
10
+ import org .springframework .web .bind .annotation .PathVariable ;
7
11
import org .springframework .web .bind .annotation .RequestMapping ;
8
12
import org .springframework .web .bind .annotation .RequestParam ;
9
13
import org .springframework .web .bind .annotation .RestController ;
21
25
public class RoleController {
22
26
@ Resource
23
27
private RoleService roleService ;
28
+ @ Resource
29
+ private RoleResourcesService roleResourcesService ;
24
30
25
31
@ RequestMapping
26
32
public Map <String ,Object > getAll (Role role , String draw ,
@@ -29,7 +35,6 @@ public Map<String,Object> getAll(Role role, String draw,
29
35
30
36
Map <String ,Object > map = new HashMap <>();
31
37
PageInfo <Role > pageInfo = roleService .selectByPage (role , start , length );
32
- System .out .println ("pageInfo.getTotal():" +pageInfo .getTotal ());
33
38
map .put ("draw" ,draw );
34
39
map .put ("recordsTotal" ,pageInfo .getTotal ());
35
40
map .put ("recordsFiltered" ,pageInfo .getTotal ());
@@ -42,4 +47,39 @@ public List<Role> rolesWithSelected(Integer uid){
42
47
return roleService .queryRoleListWithSelected (uid );
43
48
}
44
49
50
+ @ RequestMapping ("/saveRoleResources" )
51
+ public String saveRoleResources (RoleResources roleResources ){
52
+ if (StringUtils .isEmpty (roleResources .getRoleid ()))
53
+ return "error" ;
54
+ try {
55
+ roleResourcesService .addRoleResources (roleResources );
56
+ return "success" ;
57
+ } catch (Exception e ) {
58
+ e .printStackTrace ();
59
+ return "fail" ;
60
+ }
61
+ }
62
+
63
+ @ RequestMapping (value = "/add" )
64
+ public String add (Role role ) {
65
+ try {
66
+ roleService .save (role );
67
+ return "success" ;
68
+ } catch (Exception e ) {
69
+ e .printStackTrace ();
70
+ return "fail" ;
71
+ }
72
+ }
73
+
74
+ @ RequestMapping (value = "/delete/{id}" )
75
+ public String delete (@ PathVariable Integer id ){
76
+ try {
77
+ roleService .delete (id );
78
+ return "success" ;
79
+ }catch (Exception e ){
80
+ e .printStackTrace ();
81
+ return "fail" ;
82
+ }
83
+ }
84
+
45
85
}
0 commit comments