In spring-boot I have a Service class which is used to only save using spring-data. I have done it for Single Responsibility of SOLID design pattern. Is it the right approach? or Can we call directly repository in the place implementation in another service.
public class Sample {
Test save(Test test);
}
@Service
@AllArgsConstructor
public class SampleImpl implements Sample {
final TestRepository testRepository;
@Override
Test save(Test test) {
testRepository.save(test);
}
}
@Service
@AllArgsConstructor
public class HelloWorldServiceImpl implements HelloWorldServive {
private final TestService testService; // Is this right
private final TestRepository testRepository; // Is this right to use?
private final HelloWorldService helloWorldService;
@Override
public helloWorld() {
Test test = new Test();
testService.save(test);
HelloWord helloWorld = new HelloWorld();
helloWorldService.save(helloWorld);
}
}
Aucun commentaire:
Enregistrer un commentaire