connexion done
This commit is contained in:
@@ -3,6 +3,7 @@ package fr.eni.enchere.dal;
|
||||
import fr.eni.enchere.bo.UserProfil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
@@ -43,26 +44,30 @@ public class UserRepositoryImpl implements UserRepository {
|
||||
|
||||
@Override
|
||||
public UserProfil findByUsername(String username) {
|
||||
String sql = "SELECT * FROM UTILISATEURS WHERE pseudo = :username OR email = :username";
|
||||
String sql = "SELECT * FROM UTILISATEURS WHERE pseudo = :username";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("username", username);
|
||||
UserProfil user = namedParameterJdbcTemplate.queryForObject(sql, params, (rs, rowNum) -> {
|
||||
UserProfil userProfile = new UserProfil();
|
||||
userProfile.setId(rs.getInt("no_utilisateur"));
|
||||
userProfile.setPrenom(rs.getString("prenom"));
|
||||
userProfile.setNom(rs.getString("nom"));
|
||||
userProfile.setPseudo(rs.getString("pseudo"));
|
||||
userProfile.setEmail(rs.getString("email"));
|
||||
userProfile.setTelephone(rs.getString("telephone"));
|
||||
userProfile.setRue(rs.getString("rue"));
|
||||
userProfile.setCode_postal(rs.getString("code_postal"));
|
||||
userProfile.setVille(rs.getString("ville"));
|
||||
userProfile.setPassword(rs.getString("mot_de_passe"));
|
||||
userProfile.setCredit(rs.getFloat("credit"));
|
||||
userProfile.setAdmin(rs.getBoolean("administrateur"));
|
||||
return userProfile;
|
||||
});
|
||||
return user;
|
||||
try {
|
||||
UserProfil user = namedParameterJdbcTemplate.queryForObject(sql, params, (rs, rowNum) -> {
|
||||
UserProfil userProfile = new UserProfil();
|
||||
userProfile.setId(rs.getInt("no_utilisateur"));
|
||||
userProfile.setPrenom(rs.getString("prenom"));
|
||||
userProfile.setNom(rs.getString("nom"));
|
||||
userProfile.setPseudo(rs.getString("pseudo"));
|
||||
userProfile.setEmail(rs.getString("email"));
|
||||
userProfile.setTelephone(rs.getString("telephone"));
|
||||
userProfile.setRue(rs.getString("rue"));
|
||||
userProfile.setCode_postal(rs.getString("code_postal"));
|
||||
userProfile.setVille(rs.getString("ville"));
|
||||
userProfile.setPassword(rs.getString("mot_de_passe"));
|
||||
userProfile.setCredit(rs.getFloat("credit"));
|
||||
userProfile.setAdmin(rs.getBoolean("administrateur"));
|
||||
return userProfile;
|
||||
});
|
||||
return user;
|
||||
} catch (EmptyResultDataAccessException err) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user