Initial commit

This commit is contained in:
Zzzz
2026-04-27 18:40:30 +08:00
commit 2120774b05
112 changed files with 12308 additions and 0 deletions
@@ -0,0 +1,40 @@
package com.mzh.library.entity;
import java.util.Locale;
public enum Role {
ADMINISTRATOR("administrator", "Administrator"),
LIBRARIAN("librarian", "Librarian"),
READER("reader", "Reader");
private final String code;
private final String displayName;
Role(String code, String displayName) {
this.code = code;
this.displayName = displayName;
}
public String getCode() {
return code;
}
public String getDisplayName() {
return displayName;
}
public static Role fromCode(String code) {
if (code == null || code.trim().isEmpty()) {
throw new IllegalArgumentException("Role code is required");
}
String normalized = code.trim().toLowerCase(Locale.ROOT);
for (Role role : values()) {
if (role.code.equals(normalized)) {
return role;
}
}
throw new IllegalArgumentException("Unsupported role code: " + code);
}
}