Create Service, Entity and Repository for Client and Location. Client add test to BDD done
This commit is contained in:
25
src/main/java/fr/eni/demo/bll/ClientService.java
Normal file
25
src/main/java/fr/eni/demo/bll/ClientService.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package fr.eni.demo.bll;
|
||||
|
||||
import fr.eni.demo.bo.Client;
|
||||
import fr.eni.demo.dal.ClientRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ClientService {
|
||||
|
||||
@Autowired
|
||||
private ClientRepository clientRepository;
|
||||
|
||||
public void add(Client client) {
|
||||
if (client.getPrenom() == null) {
|
||||
Client clientTest = new Client();
|
||||
clientTest.setPrenom("Olivier");
|
||||
clientTest.setNom("Parpaillon");
|
||||
clientTest.setEmail("olivier@test.fr");
|
||||
clientRepository.save(clientTest);
|
||||
} else {
|
||||
clientRepository.save(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,14 @@ package fr.eni.demo.bll;
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Service;
|
||||
import fr.eni.demo.bo.Employe;
|
||||
import fr.eni.demo.dal.EmployeDAO;
|
||||
import fr.eni.demo.dal.EmployeRepository;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
//Permet de faire injecter la couche DAL associée
|
||||
@AllArgsConstructor
|
||||
@Service
|
||||
public class EmployeServiceImpl implements EmployeService {
|
||||
private EmployeDAO employeRepository;
|
||||
private EmployeRepository employeRepository;
|
||||
|
||||
@Override
|
||||
public void ajouter(Employe employe) {
|
||||
|
||||
25
src/main/java/fr/eni/demo/bll/LocationService.java
Normal file
25
src/main/java/fr/eni/demo/bll/LocationService.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package fr.eni.demo.bll;
|
||||
|
||||
import fr.eni.demo.bo.Location;
|
||||
import fr.eni.demo.dal.LocationRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class LocationService {
|
||||
|
||||
@Autowired
|
||||
LocationRepository locationRepository;
|
||||
|
||||
public void add(Location location) {
|
||||
if (location.getRue() == null || location.getCodePostal() == null || location.getVille() == null) {
|
||||
Location locationTest = new Location();
|
||||
locationTest.setRue("18 Rue de la Paix");
|
||||
locationTest.setCodePostal("75000");
|
||||
locationTest.setVille("Paris");
|
||||
locationRepository.save(locationTest);
|
||||
} else {
|
||||
locationRepository.save(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package fr.eni.demo.bll;
|
||||
|
||||
class TestEmployeService {
|
||||
}
|
||||
Reference in New Issue
Block a user