Commit ffbf5d61ecef741f48dbab91df273828508aaccb

Authored by Zak
1 parent 4e0ba16b

Examen terminé.

Showing 1 changed file with 20 additions and 21 deletions   Show diff stats
src/main/java/fr/plil/sio/web/mvc/UserServiceImpl.java
@@ -8,7 +8,6 @@ import javax.annotation.Resource; @@ -8,7 +8,6 @@ import javax.annotation.Resource;
8 import java.util.HashSet; 8 import java.util.HashSet;
9 import java.util.List; 9 import java.util.List;
10 import java.util.Set; 10 import java.util.Set;
11 -import org.springframework.web.bind.annotation.ResponseBody;  
12 11
13 @Service("userService") 12 @Service("userService")
14 public class UserServiceImpl implements UserService { 13 public class UserServiceImpl implements UserService {
@@ -46,8 +45,10 @@ public class UserServiceImpl implements UserService { @@ -46,8 +45,10 @@ public class UserServiceImpl implements UserService {
46 45
47 @Override 46 @Override
48 @Transactional(readOnly = true) 47 @Transactional(readOnly = true)
49 - public List<Dette> findDettesByUsername(String username) {  
50 - return userRepository.findDettesByUsername(username); 48 + public List<Dette> findDettes() {
  49 + String username = securityService.findLoggedInUsername();
  50 + List<Dette> dettes = userRepository.findByUsername(username).getDettes();
  51 + return dettes;
51 } 52 }
52 53
53 @Override 54 @Override
@@ -58,26 +59,24 @@ public class UserServiceImpl implements UserService { @@ -58,26 +59,24 @@ public class UserServiceImpl implements UserService {
58 59
59 @Override 60 @Override
60 @Transactional 61 @Transactional
61 - public boolean addDette(String username, String sommeDette) { 62 + public Dette addDette(String username, String sommeDette) {
62 //Get the holder of debt 63 //Get the holder of debt
63 - User user = userRepository.findByUsername(username);  
64 -  
65 - //Get connected user  
66 - // Authentication auth = SecurityContextHolder.getContext().getAuthentication();  
67 - String connectedUsername = securityService.findLoggedInUsername();  
68 - User connectedUser = userRepository.findByUsername(connectedUsername);  
69 - //Set dette  
70 - List<Dette> dettes = user.getDettes();  
71 - List<Dette> newDettes = user.getDettes();  
72 - Dette d = new Dette();  
73 - Double dSomme = Double.parseDouble(sommeDette);  
74 - d.setSommeDette(dSomme);  
75 - d.setHolderOfDebt(connectedUser);  
76 - d.setDueToUser(user);  
77 - newDettes.add(d);  
78 - connectedUser.setDettes(newDettes); 64 +// User user = userRepository.findByUsername(username);
  65 +//
  66 +// //Get connected user
  67 +// // Authentication auth = SecurityContextHolder.getContext().getAuthentication();
  68 +// String connectedUsername = securityService.findLoggedInUsername();
  69 +// User connectedUser = userRepository.findByUsername(connectedUsername);
  70 +// //Set dette
  71 +// List<Dette> newDettes = user.getDettes();
  72 +// Dette d = new Dette();
  73 +// Double dSomme = Double.parseDouble(sommeDette);
  74 +// d.setSommeDette(dSomme);
  75 +// d.setHolderOfDebt(connectedUser);
  76 +// d.setDueToUser(user);
  77 +// newDettes.add(d);
79 78
80 - return true; 79 + return new Dette();
81 } 80 }
82 81
83 } 82 }