Changeset 53765dd
- Timestamp:
- 01/04/24 09:07:47 (11 months ago)
- Branches:
- master
- Children:
- e8999eb
- Parents:
- 1413ee2
- Location:
- src/main
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/edu/gjoko/schedlr/config/AppSecurityConfig.java
r1413ee2 r53765dd 68 68 .antMatchers("/register_customer").permitAll() 69 69 .antMatchers("/register_business").permitAll() 70 .antMatchers("/api/nomenclature s/*").permitAll()70 .antMatchers("/api/nomenclature/*").permitAll() 71 71 .antMatchers("/api/user/me").permitAll() 72 72 .antMatchers("/api/business").permitAll() -
src/main/java/edu/gjoko/schedlr/controllers/LoginController.java
r1413ee2 r53765dd 22 22 @PostMapping(path = "/login") 23 23 public String loginCustomer(@ModelAttribute Stakeholder customer, Model model) { 24 return "redirect: homepage";24 return "redirect:login"; 25 25 } 26 26 } -
src/main/java/edu/gjoko/schedlr/controllers/rest/NomenclatureApi.java
r1413ee2 r53765dd 2 2 3 3 import edu.gjoko.schedlr.entity.BusinessType; 4 import edu.gjoko.schedlr.entity.ServiceType; 4 5 import edu.gjoko.schedlr.services.NomenclaturesService; 5 6 import lombok.AllArgsConstructor; 6 7 import org.springframework.web.bind.annotation.GetMapping; 8 import org.springframework.web.bind.annotation.PathVariable; 7 9 import org.springframework.web.bind.annotation.RequestMapping; 8 10 import org.springframework.web.bind.annotation.RestController; 9 11 12 import javax.servlet.http.HttpServletRequest; 10 13 import java.util.List; 11 14 12 15 @RestController 13 @RequestMapping("api/nomenclature s")16 @RequestMapping("api/nomenclature") 14 17 @AllArgsConstructor 15 18 public class NomenclatureApi { … … 20 23 return nomenclaturesService.getBusinessTypes(); 21 24 } 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 } 22 31 } -
src/main/java/edu/gjoko/schedlr/entity/Service.java
r1413ee2 r53765dd 56 56 @Column(name = "service_status") 57 57 @Enumerated(EnumType.STRING) 58 private ServiceStatus serviceStatus ;58 private ServiceStatus serviceStatus = ServiceStatus.ACTIVE; 59 59 60 60 @Column(name = "created") -
src/main/java/edu/gjoko/schedlr/repositories/ServiceTypeRepository.java
r1413ee2 r53765dd 1 1 package edu.gjoko.schedlr.repositories; 2 2 3 import edu.gjoko.schedlr.entity. BusinessType;3 import edu.gjoko.schedlr.entity.Service; 4 4 import edu.gjoko.schedlr.entity.ServiceType; 5 5 import org.springframework.data.jpa.repository.JpaRepository; 6 import org.springframework.data.jpa.repository.Modifying;7 6 import org.springframework.data.jpa.repository.Query; 8 7 import org.springframework.stereotype.Repository; 9 8 9 import java.util.List; 10 10 11 @Repository 11 12 public 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); 12 19 } -
src/main/java/edu/gjoko/schedlr/services/NomenclaturesService.java
r1413ee2 r53765dd 2 2 3 3 import edu.gjoko.schedlr.entity.BusinessType; 4 import edu.gjoko.schedlr.entity.ServiceType; 4 5 import edu.gjoko.schedlr.repositories.BusinessTypeRepository; 5 6 import edu.gjoko.schedlr.repositories.ServiceTypeRepository; … … 20 21 return businessTypeRepository.findAll(); 21 22 } 23 24 public List<ServiceType> findAppropriateBusinessTypesForBusinessByOwnerId(Long ownerId) { 25 return serviceTypeRepository.findAppropriateBusinessTypesForBusinessByOwnerId(ownerId); 26 } 22 27 } -
src/main/resources/data.sql
r1413ee2 r53765dd 13 13 (nextval('hibernate_sequence'), current_timestamp, current_timestamp, 'waxing', 6), 14 14 (nextval('hibernate_sequence'), current_timestamp, current_timestamp, 'nail extensions', 2), 15 (nextval('hibernate_sequence'), current_timestamp, current_timestamp, 'dress s hortening', 1),16 (nextval('hibernate_sequence'), current_timestamp, current_timestamp, ' holes fixing', 1);15 (nextval('hibernate_sequence'), current_timestamp, current_timestamp, 'dress sewing', 1), 16 (nextval('hibernate_sequence'), current_timestamp, current_timestamp, 'pants shortening', 1); 17 17 18 18 insert into stakeholder (id, created, phone_number, email, first_name, last_name, modified, password, stakeholder_type, username) -
src/main/resources/static/js/business_admin.js
r1413ee2 r53765dd 1 1 $(document).ready(function() { 2 2 var business = {}; 3 4 getBusinessInfo().then(function (data) { 5 business = data; 6 }); 3 var serviceTypeList = {}; 4 5 getServiceTypes().then(function (serviceTypes) { 6 serviceTypeList = serviceTypes; 7 getBusinessInfo(serviceTypes).then(function (data) { 8 business = data; 9 }); 10 }); 11 12 7 13 8 14 getAppointments(); … … 71 77 72 78 updateServices(servicesObj).then(function (response) { 73 getBusinessInfo( ).then(function (data) {79 getBusinessInfo(serviceTypeList).then(function (data) { 74 80 business = data; 75 81 }); … … 78 84 if (servicesForDelete.length > 0) { 79 85 deleteServices(servicesForDelete).then(function (response) { 80 getBusinessInfo( ).then(function (data) {86 getBusinessInfo(serviceTypeList).then(function (data) { 81 87 business = data; 82 88 }); … … 101 107 102 108 updateBusinessInfo(businesses).then(function() { 103 getBusinessInfo( ).then(function (found) {109 getBusinessInfo(serviceTypeList).then(function (found) { 104 110 business = found; 105 111 }); … … 205 211 } 206 212 207 function getBusinessInfo() { 213 function getServiceTypes() { 214 return $.ajax({ 215 url: "http://localhost:8080/api/nomenclature/serviceTypes/me" 216 }).then(function (serviceTypes) { 217 return serviceTypes; 218 }); 219 } 220 221 function getBusinessInfo(serviceTypeList) { 208 222 return $.ajax({ 209 223 url: "http://localhost:8080/api/business/me" … … 231 245 var $el = $("#predefined_services_admin_panel"); 232 246 $el.empty(); 247 const existingServiceTypeIds = business['services'].map(service => service['serviceType']['id']); 248 const missingAddedServiceTypes = serviceTypeList.filter(serviceType => existingServiceTypeIds.indexOf(serviceType['id']) === -1); 249 //console.log(missingAddedServiceTypes); 233 250 234 251 $.each(business['services'], function (index, obj) { -
src/main/resources/static/js/customer_admin.js
r1413ee2 r53765dd 1 1 $(document).ready(function() { 2 3 getCustomerInfo(); 2 var customer = {}; 3 4 getCustomerInfo().then(function (customerData) { 5 customer = customerData; 6 }); 4 7 5 8 getFutureAppointments(); … … 70 73 71 74 function getCustomerInfo() { 72 $.ajax({75 return $.ajax({ 73 76 url: "http://localhost:8080/api/customer/me" 74 77 }).success(function (customer) { … … 82 85 $('#email').val(customer['email']); 83 86 $('#username').val(customer['username']); 87 return customer; 84 88 }).error(function (error) { 85 89 console.log(JSON.stringify(error)); -
src/main/resources/static/js/homepage.js
r1413ee2 r53765dd 59 59 60 60 $.ajax({ 61 url: "http://localhost:8080/api/nomenclature s/businessTypes"61 url: "http://localhost:8080/api/nomenclature/businessTypes" 62 62 }).then(function (data) { 63 63 businessTypes = data; … … 338 338 }).then(function (data) { 339 339 var $el = $("#reviewsModalBody"); 340 $('#reviews-ul').append($('< td class="form-outline mb-4"><button type="button" id="reviews-li" class="btn btn-primary btn-block" data-bs-toggle="modal" data-bs-target="#showReviewsModal">Checkout reviews</button></td>'));340 $('#reviews-ul').append($('<button type="button" id="reviews-li" class="btn btn-primary btn-block" data-bs-toggle="modal" data-bs-target="#showReviewsModal">Checkout reviews</button>')); 341 341 $el.empty(); 342 342 -
src/main/resources/static/js/register_business.js
r1413ee2 r53765dd 2 2 var enumerations = {}; 3 3 $.ajax({ 4 url: "http://localhost:8080/api/nomenclature s/businessTypes"4 url: "http://localhost:8080/api/nomenclature/businessTypes" 5 5 }).then(function (data) { 6 6 enumerations = data; 7 7 var $el = $("#companyType"); 8 //$el.empty(); // remove old options9 8 10 9 $.each(data, function (index, obj) { … … 103 102 }); 104 103 businessObj['services'] = servicesObj; 105 console.log(businessObj);106 104 $.ajax({ 107 105 url: "http://localhost:8080/api/business", … … 113 111 alert( "Well done! You have finished the registration process. " + 114 112 "Please check periodically to see if the company has been approved." ); 115 window.location.href = "/ homepage";113 window.location.href = "/login"; 116 114 }, 117 115 error: function(err) {
Note:
See TracChangeset
for help on using the changeset viewer.