Several fixes
All checks were successful
Build, Push and Deploy / build-and-deploy (push) Successful in 55s
All checks were successful
Build, Push and Deploy / build-and-deploy (push) Successful in 55s
- added organizations - added industries - added logo in 2 colors for light and dark theme - improved authorization to allow multi tenancy - added Bruno configs
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
package de.iwomm.propify_api.service;
|
||||
|
||||
import de.iwomm.propify_api.dto.*;
|
||||
import de.iwomm.propify_api.entity.Industry;
|
||||
import de.iwomm.propify_api.entity.Organization;
|
||||
import de.iwomm.propify_api.entity.Project;
|
||||
import de.iwomm.propify_api.entity.Property;
|
||||
import de.iwomm.propify_api.mapper.IndustryMapper;
|
||||
import de.iwomm.propify_api.repository.IndustryRepository;
|
||||
import jakarta.persistence.EntityNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class IndustryService {
|
||||
private IndustryRepository industryRepository;
|
||||
private IndustryMapper industryMapper;
|
||||
|
||||
|
||||
public IndustryService(IndustryRepository industryRepository, IndustryMapper industryMapper) {
|
||||
this.industryRepository = industryRepository;
|
||||
this.industryMapper = industryMapper;
|
||||
}
|
||||
|
||||
public List<Industry> findAll() {
|
||||
return industryRepository.findAll();
|
||||
}
|
||||
|
||||
public Optional<Industry> findById(UUID id) {
|
||||
return industryRepository.findById(id);
|
||||
}
|
||||
|
||||
public Industry save(IndustryDTO dto) {
|
||||
return industryRepository.save(industryMapper.fromDto(dto));
|
||||
}
|
||||
|
||||
public void deleteByIds(BulkDeleteIdsDTO bulkDeleteIdsDTO) {
|
||||
industryRepository.deleteAllById(bulkDeleteIdsDTO.ids());
|
||||
}
|
||||
|
||||
public List<IndustryDTO> toDTOs(List<Industry> industries) {
|
||||
List<IndustryDTO> dtos = new ArrayList<>();
|
||||
|
||||
industries.forEach(industry -> {
|
||||
dtos.add(this.industryMapper.toDto(industry));
|
||||
});
|
||||
|
||||
return dtos;
|
||||
}
|
||||
|
||||
public Industry update(UUID id, IndustryDTO industryDTO) {
|
||||
Industry updated = industryRepository.findById(id).orElseThrow(EntityNotFoundException::new);
|
||||
|
||||
updated.setName(industryDTO.name());
|
||||
|
||||
industryRepository.save(updated);
|
||||
|
||||
return updated;
|
||||
}
|
||||
|
||||
public void deleteById(UUID id) {
|
||||
Industry industry = industryRepository.findById(id).orElseThrow(EntityNotFoundException::new);
|
||||
industryRepository.delete(industry);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user