mirror of
https://github.com/gmbrax/MediaManager-core.git
synced 2026-11-09 14:00:17 +00:00
Implement Album management with full CRUD operations
This commit introduces comprehensive Album entity management following the established repository pattern used for other entities like AlbumType and SamplingRate. The Album entity includes relationships with AlbumType and AlbumArt entities. Key components implemented: Model Layer: - Album entity with complete field set: * Basic fields: id, name, year, numberOfDiscs, code, isCompilation * Foreign key relationships: AlbumType and AlbumArt (ManyToOne) * Audit timestamps: createdAt, updatedAt with JPA lifecycle hooks - JPA annotations with @PrePersist and @PreUpdate for automatic timestamps - Complete getters and setters Repository Layer: - AlbumRepository with EntityManager-based operations - Full transaction management with proper rollback handling - Methods: save, findAll, findById, update, deleteById Service Layer: - AlbumService with business logic and validation - Constructor injection of AlbumRepository, AlbumTypeRepository, AlbumArtRepository - Relationship handling: validates and sets AlbumType and AlbumArt entities - Input validation for null/empty name field - ID validation for all operations requiring entity lookup - Comprehensive logging using Log4j2 Mapper Layer: - AlbumMapper for bidirectional entity/protobuf conversion - Timestamp conversion between LocalDateTime and epoch milliseconds - Foreign key mapping for AlbumType and AlbumArt relationships - Null safety checks and validation - Proper handling of optional fields Action Handlers: - CreateAlbumHandler (album.create) - GetAlbumHandler (album.getAll) - GetAlbumByIdHandler (album.getById) - UpdateAlbumHandler (album.update) - DeleteAlbumHandler (album.delete) - HTTP status code handling: 200 (success), 400 (validation), 404 (not found), 500 (server error) - Handles optional fields with proper default value checks Protocol Buffers: - Fixed proto definition with correct Album fields - CreateAlbumRequest and UpdateAlbumRequest with all entity fields - All CRUD message definitions (Create, Get, GetById, Update, Delete) - Support for foreign keys and timestamps Service Registration: - AlbumRepository initialized with EntityManagerFactory - AlbumService registered with ServiceLocator with required dependencies - Ensures all Album action handlers can resolve dependencies The implementation follows best practices with proper error handling, logging, validation, relationship management, and consistency with existing codebase patterns. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.5
parent
7446047b9d
commit
21f5b93f48
@@ -0,0 +1,77 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "com.mediamanager.protocol.messages";
|
||||
option java_outer_classname = "AlbumMessages";
|
||||
|
||||
package mediamanager.messages;
|
||||
|
||||
message Album {
|
||||
int32 id = 1;
|
||||
string name = 2;
|
||||
int32 year = 3;
|
||||
int32 number_of_discs = 4;
|
||||
string code = 5;
|
||||
bool is_compilation = 6;
|
||||
|
||||
|
||||
int32 fk_albumtype_id = 7;
|
||||
int32 fk_albumart_id = 8;
|
||||
|
||||
|
||||
int64 created_at = 9;
|
||||
int64 updated_at = 10;
|
||||
}
|
||||
|
||||
message CreateAlbumRequest {
|
||||
string name = 1;
|
||||
int32 year = 2;
|
||||
int32 number_of_discs = 3;
|
||||
string code = 4;
|
||||
bool is_compilation = 5;
|
||||
int32 fk_albumtype_id = 6;
|
||||
int32 fk_albumart_id = 7;
|
||||
}
|
||||
|
||||
message CreateAlbumResponse {
|
||||
Album album = 1;
|
||||
}
|
||||
|
||||
message GetAlbumsRequest {
|
||||
|
||||
}
|
||||
|
||||
message GetAlbumsResponse {
|
||||
repeated Album albums = 1;
|
||||
}
|
||||
|
||||
message GetAlbumByIdRequest {
|
||||
int32 id = 1;
|
||||
}
|
||||
|
||||
message GetAlbumByIdResponse {
|
||||
Album album = 1;
|
||||
}
|
||||
|
||||
message UpdateAlbumRequest {
|
||||
int32 id = 1;
|
||||
string name = 2;
|
||||
int32 year = 3;
|
||||
int32 number_of_discs = 4;
|
||||
string code = 5;
|
||||
bool is_compilation = 6;
|
||||
int32 fk_albumtype_id = 7;
|
||||
int32 fk_albumart_id = 8;
|
||||
}
|
||||
|
||||
message UpdateAlbumResponse {
|
||||
Album album = 1;
|
||||
}
|
||||
|
||||
message DeleteAlbumRequest {
|
||||
int32 id = 1;
|
||||
}
|
||||
|
||||
message DeleteAlbumResponse {
|
||||
bool success = 1;
|
||||
string message = 2;
|
||||
}
|
||||
Reference in New Issue
Block a user