add sample roles, get roles for mobile door
This commit is contained in:
1 parent
78aaebc8bb
commit
2eaa2a7020
4 files changed
+48
-18
No files matched your search
@@ -28,6 +28,16 @@ public class RoleController {
|
||||
roleRepository.save(role);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/addSampleRoles")
|
||||
@ResponseBody
|
||||
public String addSampleRoles() {
|
||||
roleRepository.save(new Role("CLEANER", "shityJob"));
|
||||
roleRepository.save(new Role("BOSS", "fuckYea"));
|
||||
roleRepository.save(new Role("SECURITY", "ochroniarzPatryk"));
|
||||
|
||||
return "roles added";
|
||||
}
|
||||
|
||||
@RequestMapping("/{roleId}")
|
||||
@ResponseBody
|
||||
public String getRole(@PathVariable("roleId") Long roleId) throws JSONException{
|
||||
@@ -49,7 +59,6 @@ public class RoleController {
|
||||
JSONArray roleArray = new JSONArray();
|
||||
for (Role role : roleRepository.findAll()) {
|
||||
JSONObject roleJSON = new JSONObject();
|
||||
roleJSON.put("id", role.getRoleId());
|
||||
roleJSON.put("role", role.getRoleName());
|
||||
roleJSON.put("password", role.getPassword());
|
||||
roleArray.put(roleJSON);
|
||||
@@ -57,6 +66,25 @@ public class RoleController {
|
||||
return roleArray.toString();
|
||||
}
|
||||
|
||||
@RequestMapping("/getRoles")
|
||||
public
|
||||
@ResponseBody
|
||||
String getRoles() throws JSONException {
|
||||
JSONObject accessCodes = new JSONObject();
|
||||
accessCodes.put("success",true);
|
||||
|
||||
JSONArray roleArray = new JSONArray();
|
||||
for (Role role : roleRepository.findAll()) {
|
||||
JSONObject roleJSON = new JSONObject();
|
||||
roleJSON.put("role", role.getRoleName());
|
||||
roleJSON.put("password", role.getPassword());
|
||||
roleArray.put(roleJSON);
|
||||
}
|
||||
accessCodes.put("accessCodes", roleArray);
|
||||
|
||||
return accessCodes.toString();
|
||||
}
|
||||
|
||||
@RequestMapping("/remove/{roleId}")
|
||||
public String removeRole(@PathVariable("roleId") Long roleId) {
|
||||
roleRepository.delete(roleId);
|
||||
|
||||
Reference in new issue
Block a user