做读者档案、联系方式、借阅资格功能
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.mzh.library.entity;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum ReaderStatus {
|
||||
ACTIVE("active", "Active"),
|
||||
SUSPENDED("suspended", "Suspended"),
|
||||
INACTIVE("inactive", "Inactive");
|
||||
|
||||
private final String code;
|
||||
private final String displayName;
|
||||
|
||||
ReaderStatus(String code, String displayName) {
|
||||
this.code = code;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public static ReaderStatus fromCode(String code) {
|
||||
if (code == null || code.trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("Reader status is required");
|
||||
}
|
||||
|
||||
String normalized = code.trim().toLowerCase(Locale.ROOT);
|
||||
for (ReaderStatus status : values()) {
|
||||
if (status.code.equals(normalized)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Unsupported reader status: " + code);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user