Changeset 53765dd for src/main/java/edu


Ignore:
Timestamp:
01/04/24 09:07:47 (11 months ago)
Author:
gjoko kostadinov <gjokokostadinov@…>
Branches:
master
Children:
e8999eb
Parents:
1413ee2
Message:

Fix bugs.

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

Legend:

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

    r1413ee2 r53765dd  
    6868                .antMatchers("/register_customer").permitAll()
    6969                .antMatchers("/register_business").permitAll()
    70                 .antMatchers("/api/nomenclatures/*").permitAll()
     70                .antMatchers("/api/nomenclature/*").permitAll()
    7171                .antMatchers("/api/user/me").permitAll()
    7272                .antMatchers("/api/business").permitAll()
  • src/main/java/edu/gjoko/schedlr/controllers/LoginController.java

    r1413ee2 r53765dd  
    2222    @PostMapping(path = "/login")
    2323    public String loginCustomer(@ModelAttribute Stakeholder customer, Model model) {
    24         return "redirect:homepage";
     24        return "redirect:login";
    2525    }
    2626}
  • src/main/java/edu/gjoko/schedlr/controllers/rest/NomenclatureApi.java

    r1413ee2 r53765dd  
    22
    33import edu.gjoko.schedlr.entity.BusinessType;
     4import edu.gjoko.schedlr.entity.ServiceType;
    45import edu.gjoko.schedlr.services.NomenclaturesService;
    56import lombok.AllArgsConstructor;
    67import org.springframework.web.bind.annotation.GetMapping;
     8import org.springframework.web.bind.annotation.PathVariable;
    79import org.springframework.web.bind.annotation.RequestMapping;
    810import org.springframework.web.bind.annotation.RestController;
    911
     12import javax.servlet.http.HttpServletRequest;
    1013import java.util.List;
    1114
    1215@RestController
    13 @RequestMapping("api/nomenclatures")
     16@RequestMapping("api/nomenclature")
    1417@AllArgsConstructor
    1518public class NomenclatureApi {
     
    2023        return nomenclaturesService.getBusinessTypes();
    2124    }
     25
     26    @GetMapping( "/serviceTypes/me")
     27    public List<ServiceType> getServiceTypesForBusinessType( HttpServletRequest request) {
     28        Long ownerId = (long) request.getSession(true).getAttribute("stakeholderId");
     29        return nomenclaturesService.findAppropriateBusinessTypesForBusinessByOwnerId(ownerId);
     30    }
    2231}
  • src/main/java/edu/gjoko/schedlr/entity/Service.java

    r1413ee2 r53765dd  
    5656    @Column(name = "service_status")
    5757    @Enumerated(EnumType.STRING)
    58     private ServiceStatus serviceStatus;
     58    private ServiceStatus serviceStatus = ServiceStatus.ACTIVE;
    5959
    6060    @Column(name = "created")
  • src/main/java/edu/gjoko/schedlr/repositories/ServiceTypeRepository.java

    r1413ee2 r53765dd  
    11package edu.gjoko.schedlr.repositories;
    22
    3 import edu.gjoko.schedlr.entity.BusinessType;
     3import edu.gjoko.schedlr.entity.Service;
    44import edu.gjoko.schedlr.entity.ServiceType;
    55import org.springframework.data.jpa.repository.JpaRepository;
    6 import org.springframework.data.jpa.repository.Modifying;
    76import org.springframework.data.jpa.repository.Query;
    87import org.springframework.stereotype.Repository;
    98
     9import java.util.List;
     10
    1011@Repository
    1112public interface ServiceTypeRepository extends JpaRepository<ServiceType, Long> {
     13
     14    List<ServiceType> findAllByBusinessType_Id(Long businessTypeId);
     15
     16    @Query(value = "select b.businessType.serviceTypes from Business as b " +
     17            " where b.owner.id = :ownerId")
     18    List<ServiceType> findAppropriateBusinessTypesForBusinessByOwnerId(Long ownerId);
    1219}
  • src/main/java/edu/gjoko/schedlr/services/NomenclaturesService.java

    r1413ee2 r53765dd  
    22
    33import edu.gjoko.schedlr.entity.BusinessType;
     4import edu.gjoko.schedlr.entity.ServiceType;
    45import edu.gjoko.schedlr.repositories.BusinessTypeRepository;
    56import edu.gjoko.schedlr.repositories.ServiceTypeRepository;
     
    2021        return businessTypeRepository.findAll();
    2122    }
     23
     24    public List<ServiceType> findAppropriateBusinessTypesForBusinessByOwnerId(Long ownerId) {
     25        return serviceTypeRepository.findAppropriateBusinessTypesForBusinessByOwnerId(ownerId);
     26    }
    2227}
Note: See TracChangeset for help on using the changeset viewer.