Changeset f29cd58 for src/main/java
- Timestamp:
- 01/15/24 00:11:01 (10 months ago)
- Branches:
- master
- Children:
- 943857c
- Parents:
- e8999eb
- Location:
- src/main/java/edu/gjoko/schedlr
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/edu/gjoko/schedlr/controllers/rest/ServiceApi.java
re8999eb rf29cd58 1 1 package edu.gjoko.schedlr.controllers.rest; 2 2 3 import edu.gjoko.schedlr.dto.ServiceDto; 3 4 import edu.gjoko.schedlr.entity.Service; 5 import edu.gjoko.schedlr.mappers.ServiceDtoMapper; 4 6 import edu.gjoko.schedlr.services.ServicesService; 5 7 import lombok.AllArgsConstructor; … … 18 20 19 21 private ServicesService service; 22 private ServiceDtoMapper serviceDtoMapper; 20 23 @PostMapping(path="/delete") 21 24 public void saveBusiness(@RequestBody List<Service> serviceList) { … … 34 37 service.saveOrUpdateServices(serviceList, ownerId); 35 38 } 39 40 @GetMapping 41 public List<ServiceDto> searchServicesByKeyWord(@RequestParam(value = "searchKeyword", required = false) String searchKeyWord) { 42 return service.getServicesByKeyword(searchKeyWord) 43 .stream() 44 .map(serviceDtoMapper::serviceToServiceDto) 45 .toList(); 46 } 36 47 } -
src/main/java/edu/gjoko/schedlr/entity/Service.java
re8999eb rf29cd58 50 50 private Business business; 51 51 52 @Column(name = "description") 53 private String description; 54 52 55 @OneToMany(mappedBy="service") 53 56 @JsonManagedReference(value = "serviceAppointments") -
src/main/java/edu/gjoko/schedlr/repositories/ServiceRepository.java
re8999eb rf29cd58 11 11 @Repository 12 12 public interface ServiceRepository extends JpaRepository<Service, Long> { 13 14 @Query(value = "select s from Service as s " + 15 " where (s.serviceType.name like CONCAT('%', :keyword, '%') " + 16 " or s.description like CONCAT('%', :keyword, '%'))" + 17 " and s.serviceStatus = 'ACTIVE'") 18 List<Service> getServicesByKeyword(String keyword); 13 19 } -
src/main/java/edu/gjoko/schedlr/services/ServicesService.java
re8999eb rf29cd58 5 5 import edu.gjoko.schedlr.entity.ServiceType; 6 6 import edu.gjoko.schedlr.repositories.BusinessRepository; 7 import edu.gjoko.schedlr.repositories.BusinessTypeRepository;8 7 import edu.gjoko.schedlr.repositories.ServiceRepository; 9 8 import edu.gjoko.schedlr.repositories.ServiceTypeRepository; … … 29 28 } 30 29 30 public List<edu.gjoko.schedlr.entity.Service> getServicesByKeyword(String keyword) { 31 return serviceRepository.getServicesByKeyword(keyword); 32 } 33 31 34 public void saveOrUpdateServices(List<edu.gjoko.schedlr.entity.Service> serviceList, Long ownerId) { 32 35 if (!CollectionUtils.isEmpty(serviceList)) { … … 38 41 found.setPrice(service.getPrice()); 39 42 found.setServiceStatus(ServiceStatus.ACTIVE); 43 found.setDescription(service.getDescription()); 40 44 serviceRepository.save(found); 41 45 } else {
Note:
See TracChangeset
for help on using the changeset viewer.