package springmvc.models.repository;

import org.springframework.stereotype.Component;

import springmvc.models.Spitter;

@Component
public class SpitterRepositoryImp implements ISpitterRepository {

	@Override
	public Spitter save(Spitter spitter) {
		System.out.println("save " + spitter.getUsername());
		return null;
	}

	@Override
	public Spitter findByUsername(String username) {
		return new Spitter(1L, "aaaa", "123456", "asassss", "bbbbbb");
	}

}

@@ -29,24 +29,107 @@
 ository;%0D%0A%0D%0A
+import java.util.ArrayList;%0D%0Aimport java.util.List;%0D%0Aimport java.util.Optional;%0D%0A%0D%0A
 import org.s
@@ -282,16 +282,77 @@
 itory %7B%0D
+%0A%09private List%3CSpitter%3E spitters = new ArrayList%3CSpitter%3E();%0D
 %0A%0D%0A%09@Ove
@@ -405,58 +405,28 @@
 %0D%0A%09%09
-System.out.println(%22save %22 + spitter.getUsername()
+spitters.add(spitter
 );%0D%0A
@@ -438,12 +438,15 @@
 urn 
-null
+spitter
 ;%0D%0A%09
@@ -519,69 +519,196 @@
 %0D%0A%09%09
-return new Spitter(1L, %22aaaa%22, %22123456%22, %22asassss%22, %22bbbbbb%22)
+// tim trong db%0D%0A%09%09Optional%3CSpitter%3E findFirst = spitters.stream()%0D%0A%09%09%09%09.filter(e -%3E e.getUsername().equals(username)).findFirst();%0D%0A%09%09return findFirst.isPresent() ? findFirst.get() : null
 ;%0D%0A%09

Update Save and FindByUser funtion in SpitterRepositoryImp