新增书籍表、列表/搜索、管理员/馆员维护入口
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
package com.mzh.library.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class Book {
|
||||
private long id;
|
||||
private String identifier;
|
||||
private String title;
|
||||
private String author;
|
||||
private long categoryId;
|
||||
private String categoryName;
|
||||
private int totalCopies;
|
||||
private int availableCopies;
|
||||
private BookStatus status;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public void setIdentifier(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public long getCategoryId() {
|
||||
return categoryId;
|
||||
}
|
||||
|
||||
public void setCategoryId(long categoryId) {
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
public String getCategoryName() {
|
||||
return categoryName;
|
||||
}
|
||||
|
||||
public void setCategoryName(String categoryName) {
|
||||
this.categoryName = categoryName;
|
||||
}
|
||||
|
||||
public int getTotalCopies() {
|
||||
return totalCopies;
|
||||
}
|
||||
|
||||
public void setTotalCopies(int totalCopies) {
|
||||
this.totalCopies = totalCopies;
|
||||
}
|
||||
|
||||
public int getAvailableCopies() {
|
||||
return availableCopies;
|
||||
}
|
||||
|
||||
public void setAvailableCopies(int availableCopies) {
|
||||
this.availableCopies = availableCopies;
|
||||
}
|
||||
|
||||
public BookStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(BookStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.mzh.library.entity;
|
||||
|
||||
public class BookCategory {
|
||||
private long id;
|
||||
private String name;
|
||||
private String description;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.mzh.library.entity;
|
||||
|
||||
public class BookSearchCriteria {
|
||||
private String identifier;
|
||||
private String title;
|
||||
private String author;
|
||||
private Long categoryId;
|
||||
|
||||
public BookSearchCriteria() {
|
||||
}
|
||||
|
||||
public BookSearchCriteria(String identifier, String title, String author, Long categoryId) {
|
||||
this.identifier = trim(identifier);
|
||||
this.title = trim(title);
|
||||
this.author = trim(author);
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public void setIdentifier(String identifier) {
|
||||
this.identifier = trim(identifier);
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = trim(title);
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = trim(author);
|
||||
}
|
||||
|
||||
public Long getCategoryId() {
|
||||
return categoryId;
|
||||
}
|
||||
|
||||
public void setCategoryId(Long categoryId) {
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
private String trim(String value) {
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.mzh.library.entity;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum BookStatus {
|
||||
AVAILABLE("available", "Available"),
|
||||
UNAVAILABLE("unavailable", "Unavailable"),
|
||||
ARCHIVED("archived", "Archived");
|
||||
|
||||
private final String code;
|
||||
private final String displayName;
|
||||
|
||||
BookStatus(String code, String displayName) {
|
||||
this.code = code;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public static BookStatus fromCode(String code) {
|
||||
if (code == null || code.trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("Book status is required");
|
||||
}
|
||||
|
||||
String normalized = code.trim().toLowerCase(Locale.ROOT);
|
||||
for (BookStatus status : values()) {
|
||||
if (status.code.equals(normalized)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Unsupported book status: " + code);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user