Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void create(DistrictsJSONImportDto model) {
- if (!ValidationUtil.isValid(model)){
- throw new IllegalArgumentException();
- }
- Town town = townRepository.findByName(model.getTownName());
- District district = districtRepository.findByName(model.getName());
- if (district != null){
- throw new IllegalStateException("duplicate data");
- }
- district = mapper.convert(model, District.class);
- district.setTown(town);
- districtRepository.save(district);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement