Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajustements divers pour imports eleves /professeurs #13

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
/.nb-gradle/

/src/main/resources/application.properties
/src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import fr.educ.devoirsfaits.model.Utilisateur;
import fr.educ.devoirsfaits.service.UtilisateurService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
Expand Down Expand Up @@ -46,7 +48,7 @@ private <T extends Utilisateur> T mapCsvToUtilisateur(String[] csvData, long eta
String nom = csvData[INDEX_COLONNE_NOM].toUpperCase();
String prenomMinuscule = csvData[INDEX_COLONNE_PRENOM].toLowerCase();
String email = csvData[INDEX_COLONNE_EMAIL];
String motDePasse = "123";
String motDePasse = null;

T utilisateur = null;
try {
Expand Down Expand Up @@ -93,9 +95,14 @@ private void uploadFileIntoUtlisateurs(long etablissementId, MultipartFile file,
reader.readLine(); // On évite la ligne d'en-tête
while (currentLine != null) {
currentLine = reader.readLine();

Utilisateur utilisateurCourant = mapCsvToUtilisateur.apply(currentLine, etablissementId);
utilisateurService.save(utilisateurCourant);
try {
Utilisateur utilisateurCourant = mapCsvToUtilisateur.apply(currentLine, etablissementId);
utilisateurService.save(utilisateurCourant);
}
catch (NullPointerException e){
// L'utilisateur existe déjà : nous l'ignorons donc
e.printStackTrace();
}
}
} catch (IOException e){
e.printStackTrace();
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
spring.datasource.url = jdbc:mysql://localhost:3306/devoirsfaits
spring.datasource.username = root
spring.datasource.password = root
spring.datasource.username = admin
spring.datasource.password = admin

# Show or not log for each sql query
spring.jpa.show-sql = true
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ [email protected]@

spring.datasource.driverClassName = com.mysql.jdbc.Driver
spring.datasource.url = jdbc:mysql://localhost:3306/devoirsfaits
spring.datasource.username = root
spring.datasource.password = root
spring.datasource.username = admin
spring.datasource.password = admin


# Show or not log for each sql query
Expand Down