Developer 역할 Spring 골격 smoke (runtime-role-matrix-live-20260714112301-v11-developer-001)
This commit is contained in:
parent
944ebc2c27
commit
0e753bfabf
1 changed files with 24 additions and 0 deletions
24
src/main/java/com/example/demo/RoleService.java
Normal file
24
src/main/java/com/example/demo/RoleService.java
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.example.demo;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class RoleService {
|
||||||
|
|
||||||
|
public String getRoleName(String roleId) {
|
||||||
|
if (roleId == null || roleId.isBlank()) {
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
return switch (roleId.toUpperCase()) {
|
||||||
|
case "ADMIN" -> "Administrator";
|
||||||
|
case "DEVELOPER" -> "Developer";
|
||||||
|
case "VIEWER" -> "Viewer";
|
||||||
|
default -> "Role: " + roleId;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValidRole(String roleId) {
|
||||||
|
return roleId != null && !roleId.isBlank() &&
|
||||||
|
roleId.matches("^[A-Z_]+$");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue