Changeset 9050790 for src/main/java/edu


Ignore:
Timestamp:
03/13/23 23:30:41 (21 months ago)
Author:
Gjoko Kostadinov <gjoko.kostadinov@…>
Branches:
master
Children:
8bcd64c
Parents:
46fd0c7
Message:

Add admin functionality for activating or deactivating companies

Location:
src/main/java/edu/gjoko/schedlr
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/edu/gjoko/schedlr/config/AppFilter.java

    r46fd0c7 r9050790  
    2424        HttpSession session = httpServletRequest.getSession(false);
    2525
    26         if(httpServletRequest.getRequestURI().endsWith(".js") || httpServletRequest.getRequestURI().endsWith(".css")) {
     26        if(httpServletRequest.getRequestURI().endsWith(".js")
     27                || httpServletRequest.getRequestURI().endsWith(".css")
     28                || httpServletRequest.getRequestURI().startsWith("/api")) {
    2729            filterChain.doFilter(servletRequest, servletResponse);
    2830            return;
  • src/main/java/edu/gjoko/schedlr/controllers/rest/BusinessController.java

    r46fd0c7 r9050790  
    2121
    2222    @GetMapping
    23     public List<Business> getNewBusinesses() {
    24         return businessService.getNewBusiness();
     23    public List<Business> findAll() {
     24        return businessService.findAll();
    2525    }
    2626
    2727    @PatchMapping
    28     public void activateBusinesses(@RequestBody List<Business> businessList) {
    29         businessService.activateBusinesses(businessList);
     28    public void updateBusinesses(@RequestBody List<Business> businessList) {
     29        businessService.updateBusinesses(businessList);
    3030    }
    3131}
  • src/main/java/edu/gjoko/schedlr/entity/BusinessStatus.java

    r46fd0c7 r9050790  
    44    NEW,
    55    ACTIVE,
    6     BLOCKED
     6    DEACTIVATED
    77}
  • src/main/java/edu/gjoko/schedlr/services/BusinessService.java

    r46fd0c7 r9050790  
    22
    33import edu.gjoko.schedlr.entity.Business;
    4 import edu.gjoko.schedlr.entity.BusinessStatus;
    54import edu.gjoko.schedlr.entity.ServiceType;
    65import edu.gjoko.schedlr.entity.StakeholderType;
     
    1110
    1211import java.util.List;
    13 import java.util.stream.Collectors;
    1412
    1513import static edu.gjoko.schedlr.entity.BusinessStatus.ACTIVE;
     
    3230    public void saveNewServiceTypes(Business business) {
    3331        business.getServices()
    34             .stream()
    35             .forEach(service -> {
    36                 if(service.getServiceType().getId() == null) {
    37                     ServiceType serviceType = service.getServiceType();
    38                     serviceType.setBusinessType(business.getBusinessType());
    39                     service.setServiceType(serviceTypeRepository.save(serviceType));
    40                 }
    41             });
     32                .stream()
     33                .forEach(service -> {
     34                    if (service.getServiceType().getId() == null) {
     35                        ServiceType serviceType = service.getServiceType();
     36                        serviceType.setBusinessType(business.getBusinessType());
     37                        service.setServiceType(serviceTypeRepository.save(serviceType));
     38                    }
     39                });
    4240    }
    4341
    44     public List<Business> getNewBusiness() {
    45         return businessRepository.findBusinessesByBusinessStatus(NEW);
     42    public List<Business> findAll() {
     43        return businessRepository.findAll();
    4644    }
    4745
    48     public void activateBusinesses(List<Business> businessList) {
     46    public void updateBusinesses(List<Business> businessList) {
    4947        businessList
    5048                .stream()
    5149                .forEach(business -> {
    52                     business.setBusinessStatus(ACTIVE);
    5350                    businessRepository.save(business);
    5451                });
Note: See TracChangeset for help on using the changeset viewer.