refactoring
This commit is contained in:
1 parent
abbac0b416
commit
2df87040ed
11 files changed
+129
-256
No files matched your search
@@ -23,22 +23,26 @@ public class RoleController {
|
||||
private RoleRepository roleRepository;
|
||||
|
||||
@RequestMapping(value = "/add")
|
||||
@ResponseBody
|
||||
public String addRole(@RequestParam String rolename,@RequestParam String password) {
|
||||
public void addRole(@RequestParam String rolename,@RequestParam String password) {
|
||||
Role role = new Role(rolename,password);
|
||||
roleRepository.save(role);
|
||||
return "saved role: "+role.getRoleId();
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/{roleId}")
|
||||
@ResponseBody
|
||||
public String getRole(@PathVariable("roleId") Long roleId) {
|
||||
public String getRole(@PathVariable("roleId") Long roleId) throws JSONException{
|
||||
Role role = roleRepository.findOne(roleId);
|
||||
return "role: "+role.toString();
|
||||
JSONArray roleArray = new JSONArray();
|
||||
JSONObject roleJSON = new JSONObject();
|
||||
roleJSON.put("id", role.getRoleId());
|
||||
roleJSON.put("name", role.getRoleName());
|
||||
roleJSON.put("password", role.getPassword());
|
||||
roleArray.put(roleJSON);
|
||||
|
||||
return roleArray.toString();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/all")
|
||||
@RequestMapping
|
||||
public
|
||||
@ResponseBody
|
||||
String listRolesJson(ModelMap model) throws JSONException {
|
||||
|
||||
Reference in new issue
Block a user