// Path: src/main/java/mobi/qubits/ex/library/domain/events/BorrowEvent.java
// public class BorrowEvent implements LibraryEvent{
// 
// 	private final String libraryId;
// 	
// 	private final String borrowerId;//reader
// 	
// 	private final String bookId;
// 
// 	public BorrowEvent(String libraryId, String bookId, String borrowerId) {
// 		super();
// 		this.libraryId = libraryId;
// 		this.borrowerId = borrowerId;
// 		this.bookId = bookId;
// 	}
// 
// 
// 	public String getLibraryId() {
// 		return libraryId;
// 	}
// 
// 
// 	public String getBorrowerId() {
// 		return borrowerId;
// 	}
// 
// 
// 	public String getBookId() {
// 		return bookId;
// 	}
// 	
// }
// 
// Path: src/main/java/mobi/qubits/ex/library/domain/events/NewReaderRegisteredEvent.java
// public class NewReaderRegisteredEvent implements LibraryEvent{
// 
// 	private final String libraryId;
// 	
// 	private final String readerId;
// 	
// 	private String name;
// 
// 	public NewReaderRegisteredEvent(String libraryId, String readerId,
// 			String name) {
// 		super();
// 		this.libraryId = libraryId;
// 		this.readerId = readerId;
// 		this.name = name;
// 	}
// 
// 	public String getLibraryId() {
// 		return libraryId;
// 	}
// 
// 	public String getReaderId() {
// 		return readerId;
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 
// 	
// }
// 
// Path: src/main/java/mobi/qubits/ex/library/domain/events/ReturnEvent.java
// public class ReturnEvent implements LibraryEvent{
// 
// 	private final String libraryId;
// 	
// 	
// 	private final String bookId;
// 	
// 	private final String borrowerId;
// 
// 	public ReturnEvent(String libraryId, String bookId, String borrowerId) {
// 		super();
// 		this.libraryId = libraryId;
// 		this.bookId = bookId;
// 		this.borrowerId = borrowerId;
// 	}
// 
// 	public String getLibraryId() {
// 		return libraryId;
// 	}
// 
// 	public String getBookId() {
// 		return bookId;
// 	}
// 
// 	public String getBorrowerId() {
// 		return borrowerId;
// 	}
// 	
// 
// 
// }


import mobi.qubits.ex.library.domain.events.BorrowEvent;
import mobi.qubits.ex.library.domain.events.NewReaderRegisteredEvent;
import mobi.qubits.ex.library.domain.events.ReturnEvent;
import org.axonframework.eventhandling.annotation.EventHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

package mobi.qubits.ex.library.query;



/**
 * 
 * @author yizhuan
 *
 */
@Component
public class ReaderEventListener {
	
	@Autowired
	private ReaderEntryRepository readerRepository;

	@EventHandler
	void on(NewReaderRegisteredEvent event) {
		
		ReaderEntry reader = new ReaderEntry();
		reader.setId(event.getReaderId());

// Path: src/main/java/mobi/qubits/ex/library/domain/events/BorrowEvent.java
// public class BorrowEvent implements LibraryEvent{
// 
// 	private final String libraryId;
// 	
// 	private final String borrowerId;//reader
// 	
// 	private final String bookId;
// 
// 	public BorrowEvent(String libraryId, String bookId, String borrowerId) {
// 		super();
// 		this.libraryId = libraryId;
// 		this.borrowerId = borrowerId;
// 		this.bookId = bookId;
// 	}
// 
// 
// 	public String getLibraryId() {
// 		return libraryId;
// 	}
// 
// 
// 	public String getBorrowerId() {
// 		return borrowerId;
// 	}
// 
// 
// 	public String getBookId() {
// 		return bookId;
// 	}
// 	
// }
// 
// Path: src/main/java/mobi/qubits/ex/library/domain/events/NewReaderRegisteredEvent.java
// public class NewReaderRegisteredEvent implements LibraryEvent{
// 
// 	private final String libraryId;
// 	
// 	private final String readerId;
// 	
// 	private String name;
// 
// 	public NewReaderRegisteredEvent(String libraryId, String readerId,
// 			String name) {
// 		super();
// 		this.libraryId = libraryId;
// 		this.readerId = readerId;
// 		this.name = name;
// 	}
// 
// 	public String getLibraryId() {
// 		return libraryId;
// 	}
// 
// 	public String getReaderId() {
// 		return readerId;
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 
// 	
// }
// 
// Path: src/main/java/mobi/qubits/ex/library/domain/events/ReturnEvent.java
// public class ReturnEvent implements LibraryEvent{
// 
// 	private final String libraryId;
// 	
// 	
// 	private final String bookId;
// 	
// 	private final String borrowerId;
// 
// 	public ReturnEvent(String libraryId, String bookId, String borrowerId) {
// 		super();
// 		this.libraryId = libraryId;
// 		this.bookId = bookId;
// 		this.borrowerId = borrowerId;
// 	}
// 
// 	public String getLibraryId() {
// 		return libraryId;
// 	}
// 
// 	public String getBookId() {
// 		return bookId;
// 	}
// 
// 	public String getBorrowerId() {
// 		return borrowerId;
// 	}
// 	
// 
// 
// }


// Path: src/main/java/mobi/qubits/ex/library/query/ReaderEventListener.java
import mobi.qubits.ex.library.domain.events.BorrowEvent;
import mobi.qubits.ex.library.domain.events.NewReaderRegisteredEvent;
import mobi.qubits.ex.library.domain.events.ReturnEvent;
import org.axonframework.eventhandling.annotation.EventHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

package mobi.qubits.ex.library.query;



/**
 * 
 * @author yizhuan
 *
 */
@Component
public class ReaderEventListener {
	
	@Autowired
	private ReaderEntryRepository readerRepository;

	@EventHandler
	void on(NewReaderRegisteredEvent event) {
		
		ReaderEntry reader = new ReaderEntry();
		reader.setId(event.getReaderId());

		reader.setLibraryId(event.getLibraryId());
