- Timestamp:
- 12/26/23 18:50:43 (10 months ago)
- Branches:
- master
- Children:
- 1413ee2
- Parents:
- 950fa0d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/edu/gjoko/schedlr/services/BusinessService.java
-
Property mode
changed from
100644
to100755
r950fa0d r77205be 2 2 3 3 import edu.gjoko.schedlr.entity.*; 4 import edu.gjoko.schedlr.repositories.BusinessRepository; 5 import edu.gjoko.schedlr.repositories.ServiceRepository; 6 import edu.gjoko.schedlr.repositories.ServiceTypeRepository; 7 import edu.gjoko.schedlr.repositories.StakeholderRepository; 4 import edu.gjoko.schedlr.repositories.*; 8 5 import lombok.AllArgsConstructor; 9 6 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 10 7 import org.springframework.stereotype.Service; 8 import org.springframework.util.CollectionUtils; 11 9 12 10 import java.util.List; … … 22 20 private final ServiceTypeRepository serviceTypeRepository; 23 21 private final ServiceRepository serviceRepository; 22 private final StakeholderService stakeholderService; 24 23 25 24 private final StakeholderRepository stakeholderRepository; … … 54 53 .stream() 55 54 .forEach(business -> { 56 stakeholder Repository.save(business.getOwner());57 s erviceRepository.saveAll(business.getServices());58 businessRepository.save(business);55 stakeholderService.saveOrUpdateStakeholder(business.getOwner()); 56 saveOrUpdateServices(business.getServices()); 57 saveOrUpdateBusiness(business); 59 58 }); 60 59 } … … 66 65 } 67 66 68 public List<Business> findByBusinessTypeAndActiveStatus(BusinessType businessType) { 69 return businessRepository.findBusinessesByBusinessTypeAndBusinessStatus(businessType, ACTIVE); 67 public List<Business> findByBusinessTypeAndActiveStatus(Long businessTypeId) { 68 return businessRepository.findBusinessesByBusinessStatusAndBusinessType_Id(ACTIVE, businessTypeId); 69 } 70 71 72 73 private void saveOrUpdateBusiness(Business business) { 74 if (business.getId() != null) { 75 var foundBusinessEntity = businessRepository.findById(business.getId()); 76 business.setCreated(foundBusinessEntity.get().getCreated()); 77 } 78 businessRepository.save(business); 79 } 80 81 private void saveOrUpdateServices(List<edu.gjoko.schedlr.entity.Service> serviceList) { 82 if (!CollectionUtils.isEmpty(serviceList)) { 83 serviceList.forEach( service -> { 84 if (service.getId() != null) { 85 var found = serviceRepository.findById(service.getId()); 86 service.setCreated(found.get().getCreated()); 87 } 88 }); 89 serviceRepository.saveAll(serviceList); 90 } 70 91 } 71 92 } -
Property mode
changed from
Note:
See TracChangeset
for help on using the changeset viewer.