This is an exercise of Domain Driven Design and Spring Boot techniques.
The program manages books and readers of a library. Each reader can borrow up to three books, and one book can only be borrowed by one reader a time. When a book has been borrowed five times, it is marked as a 'hot' book. The admin can register new books and new readers. The admin can check who is holding a book and what books a reader has currently borrowed.
This application uses:
- Domain Driven Design
- CQRS
- Event Sourcing
- Spring Boot
- Axon Framework
- RESTful service
$ mvn package
net start MongoDB
java -jar target/library-0.1.0.jar
curl -X POST -d '{"name":"Bantian District Library"}' -H "Content-Type:application/json" http://localhost:8080/api/libraries
curl -X POST -d '{"name":"John Smith"}' -H "Content-Type:application/json" http://localhost:8080/api/libraries/{libraryId}/readers
curl -X POST -d '{"title":"Lord of the Rings", "author": "J. R. R. Tolkien"}' -H "Content-Type:application/json" http://localhost:8080/api/libraries/{libraryId}/books
curl http://localhost:8080/api/libraries
curl http://localhost:8080/api/libraries/{libraryId}/readers
curl http://localhost:8080/api/libraries/{libraryId}/books
curl -X POST -d '{"bookId":"3f7bf042-489a-4d5a-b0cb-ba62bf71ae32"}' -H "Content-Type:application/json" http://localhost:8080/api/libraries/{libraryId}/readers/{readerId}/borrow
curl http://localhost:8080/api/libraries/{libraryId}/readers/{readerId}/return
> mongo
> show dbs > use axonframework switched to db axonframework
> show collections
domainevents system.indexes
> db.domainevents.find()
This version is just a rough sketch. Still lots to do.