RoleController.java
2.06 KB
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
package com.bsth.controller.sys;
import com.bsth.controller.BaseController;
import com.bsth.entity.sys.Role;
import com.bsth.service.sys.RoleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Map;
@RestController
@RequestMapping("role")
public class RoleController extends BaseController<Role, Integer> {
static Logger logger = LoggerFactory.getLogger(RoleController.class);
@Autowired
RoleService roleService;
/**
* menu 菜单json
*/
private static String authJson;
static {
loadAuthStrByFile();
}
private static void loadAuthStrByFile() {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(RoleController.class.getClassLoader().getResourceAsStream("auths.json")));
StringBuilder sb = new StringBuilder();
String lineStr;
while ((lineStr = br.readLine()) != null) {
sb.append(lineStr);
}
authJson = sb.toString();
} catch (Exception e) {
logger.error("", e);
}
}
@RequestMapping("auth_json")
public String authJsonStr() {
return authJson;
}
@RequestMapping("re_load")
public int reLoadByFile() {
loadAuthStrByFile();
return 1;
}
@RequestMapping(value = "saveAuthStr", method = RequestMethod.POST)
public Map<String, Object> saveAuthStr(@RequestParam String authStr, @RequestParam int id){
return roleService.saveAuthStr(authStr, id);
}
@RequestMapping(value = "add", method = RequestMethod.POST)
public Map<String, Object> add(@RequestParam String roleName){
return roleService.add(roleName);
}
}