Changeset 46fd0c7 for src/main/java/edu
- Timestamp:
- 03/13/23 00:58:07 (20 months ago)
- Branches:
- master
- Children:
- 9050790
- Parents:
- 2b0a4db
- Location:
- src/main/java/edu/gjoko/schedlr
- Files:
-
- 5 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/edu/gjoko/schedlr/config/AppFilter.java
r2b0a4db r46fd0c7 4 4 import org.springframework.security.core.context.SecurityContextImpl; 5 5 import org.springframework.security.core.userdetails.UserDetails; 6 import org.springframework.util.StringUtils; 6 7 import org.springframework.web.filter.GenericFilterBean; 7 8 … … 23 24 HttpSession session = httpServletRequest.getSession(false); 24 25 26 if(httpServletRequest.getRequestURI().endsWith(".js") || httpServletRequest.getRequestURI().endsWith(".css")) { 27 filterChain.doFilter(servletRequest, servletResponse); 28 return; 29 } 25 30 if(session != null) { 26 31 Map<String, String> roleTargetUrlMap = new HashMap<>(); 27 roleTargetUrlMap.put("ADMIN", "/ date");28 roleTargetUrlMap.put("CUSTOMER", "/ number");29 roleTargetUrlMap.put("BUSINESS_OWNER", " ");32 roleTargetUrlMap.put("ADMIN", "/admin"); 33 roleTargetUrlMap.put("CUSTOMER", "/homepage"); 34 roleTargetUrlMap.put("BUSINESS_OWNER", "/business_homepage"); 30 35 SecurityContextImpl sci = (SecurityContextImpl) session.getAttribute("SPRING_SECURITY_CONTEXT"); 31 36 if(sci != null) { … … 34 39 for (final GrantedAuthority grantedAuthority : authorities) { 35 40 String authorityName = grantedAuthority.getAuthority(); 36 if("DATE".equalsIgnoreCase(authorityName)) { 37 servletRequest.getRequestDispatcher("date").forward(servletRequest, servletResponse); 38 return; 39 } else if("GUESS_NUMBER".equalsIgnoreCase(authorityName)) { 40 try { 41 servletRequest.getRequestDispatcher("number").forward(servletRequest, servletResponse); 42 } catch (Exception e) { 43 e.printStackTrace(); 44 } 45 41 String page = ""; 42 switch (authorityName) { 43 case "ADMIN": 44 page = "/admin"; 45 break; 46 case "CUSTOMER": 47 case "BUSINESS_OWNER": 48 page = "/homepage"; 49 break; 50 default: 51 break; 52 } 53 if(page != null && !page.trim().isEmpty()) { 54 servletRequest.getRequestDispatcher(page).forward(servletRequest, servletResponse); 46 55 return; 47 56 } -
src/main/java/edu/gjoko/schedlr/config/AppSecurityConfig.java
r2b0a4db r46fd0c7 60 60 .antMatchers("/register_business").permitAll() 61 61 .antMatchers("/api/nomenclatures/*").permitAll() 62 .antMatchers("/api/business").permitAll() 62 63 .antMatchers("/homepage").permitAll() 63 64 .antMatchers("/css/**").permitAll() -
src/main/java/edu/gjoko/schedlr/config/MvcConfig.java
r2b0a4db r46fd0c7 2 2 3 3 import org.springframework.context.annotation.Configuration; 4 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 4 5 import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; 5 6 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; … … 14 15 registry.addViewController("/register_business").setViewName("register_business"); 15 16 registry.addViewController("/homepage").setViewName("homepage"); 17 registry.addViewController("/admin").setViewName("admin"); 16 18 } 17 19 18 20 @Override 21 public void addResourceHandlers(ResourceHandlerRegistry registry) { 22 registry.addResourceHandler("/resources/**") 23 .addResourceLocations("/resources/"); 24 } 19 25 } -
src/main/java/edu/gjoko/schedlr/controllers/HomePageController.java
r2b0a4db r46fd0c7 11 11 public class HomePageController { 12 12 13 @GetMapping( name= "/homepage")13 @GetMapping(path = "/homepage") 14 14 public String getHomePageTemplate(Model model, Principal principal) { 15 15 System.out.println(principal); … … 17 17 } 18 18 19 @PostMapping( name= "/homepage")19 @PostMapping(path = "/homepage") 20 20 public String postHomePageTemplate(Model model) { 21 21 return "homepage"; -
src/main/java/edu/gjoko/schedlr/controllers/RegisterController.java
r2b0a4db r46fd0c7 20 20 } 21 21 22 @GetMapping( value="/register_customer")22 @GetMapping(path ="/register_customer") 23 23 public String getCustomerRegisterPage(Model model) { 24 24 model.addAttribute("stakeholder", new Stakeholder()); … … 26 26 } 27 27 28 @PostMapping( value= "/register_customer")28 @PostMapping(path = "/register_customer") 29 29 public String registerCustomer(@ModelAttribute Stakeholder customer, Model model) { 30 30 Stakeholder user = stakeholderService.saveStakeholder(customer); … … 32 32 } 33 33 34 @GetMapping( value= "/register_business")34 @GetMapping(path = "/register_business") 35 35 public String getBusinessRegisterPage(Model model) { 36 36 return "register_business"; … … 39 39 @PostMapping(value = "/register_business") 40 40 public String registerBusiness(Model model) { 41 return "re gister_business";41 return "redirect:login"; 42 42 } 43 43 } -
src/main/java/edu/gjoko/schedlr/entity/Appointment.java
r2b0a4db r46fd0c7 5 5 import lombok.NoArgsConstructor; 6 6 import lombok.Setter; 7 import org.springframework.data.annotation.LastModifiedDate; 8 import org.springframework.data.jpa.domain.support.AuditingEntityListener; 7 9 8 10 import javax.persistence.*; … … 10 12 11 13 @Entity 14 @EntityListeners(AuditingEntityListener.class) 12 15 @Table(name = "appointment") 13 16 @Getter … … 31 34 32 35 @Column(name = "created") 36 @LastModifiedDate 33 37 private LocalDateTime created; 34 38 35 39 @Column(name = "modified") 40 @LastModifiedDate 36 41 private LocalDateTime modified; 37 42 } -
src/main/java/edu/gjoko/schedlr/entity/Business.java
r2b0a4db r46fd0c7 2 2 3 3 import com.fasterxml.jackson.annotation.JsonManagedReference; 4 import com.fasterxml.jackson.annotation.JsonProperty; 4 5 import lombok.AllArgsConstructor; 5 6 import lombok.Getter; 6 7 import lombok.NoArgsConstructor; 7 8 import lombok.Setter; 9 import org.springframework.data.annotation.CreatedDate; 10 import org.springframework.data.annotation.LastModifiedDate; 11 import org.springframework.data.jpa.domain.support.AuditingEntityListener; 8 12 9 13 import javax.persistence.*; … … 12 16 13 17 @Entity 18 @EntityListeners(AuditingEntityListener.class) 14 19 @Table(name = "business") 15 20 @Getter … … 23 28 private Long id; 24 29 25 @Column(name = " name")26 private String name;30 @Column(name = "company_name") 31 private String companyName; 27 32 28 33 @OneToOne 29 34 @JoinColumn(name = "business_type_id", referencedColumnName = "id") 35 @JsonProperty("businessType") 30 36 private BusinessType businessType; 31 37 32 @Column(name = "opening_time") 33 private LocalDateTime openingTime; 34 35 @Column(name = "closing_time") 36 private LocalDateTime closingTime; 37 38 @ManyToOne 38 @ManyToOne(cascade = CascadeType.PERSIST) 39 39 @JoinColumn(name = "owner_id", referencedColumnName = "id", nullable = false) 40 @JsonProperty("owner") 40 41 private Stakeholder owner; 41 42 42 @OneToMany(mappedBy = "business" )43 @OneToMany(mappedBy = "business", cascade = CascadeType.PERSIST) 43 44 @JsonManagedReference 44 45 private List<Service> services; 45 46 47 @Column(name = "business_status") 48 @Enumerated(EnumType.STRING) 49 private BusinessStatus businessStatus; 50 46 51 @Column(name = "created") 52 @CreatedDate 47 53 private LocalDateTime created; 48 54 49 55 @Column(name = "modified") 56 @LastModifiedDate 50 57 private LocalDateTime modified; 51 58 -
src/main/java/edu/gjoko/schedlr/entity/Service.java
r2b0a4db r46fd0c7 11 11 12 12 import javax.persistence.*; 13 import java.sql.Timestamp;14 13 import java.time.LocalDateTime; 15 14 … … 27 26 private Long id; 28 27 29 @Column(name = "name")30 private String name;31 32 28 @Column(name = "duration") 33 29 private Integer duration; 34 30 35 @Column(name = "price") 36 private Float price; 37 38 @OneToOne 31 @OneToOne(cascade = CascadeType.MERGE) 39 32 @JoinColumn(name = "service_type_id", referencedColumnName = "id") 40 33 private ServiceType serviceType; 41 34 42 35 @ManyToOne 43 @JoinColumn(name ="business_fk")36 @JoinColumn(name = "business_fk") 44 37 @JsonBackReference 45 38 private Business business; -
src/main/java/edu/gjoko/schedlr/repositories/BusinessTypeRepository.java
r2b0a4db r46fd0c7 2 2 3 3 import edu.gjoko.schedlr.entity.BusinessType; 4 import edu.gjoko.schedlr.entity.Stakeholder;5 4 import org.springframework.data.jpa.repository.JpaRepository; 6 5 import org.springframework.stereotype.Repository;
Note:
See TracChangeset
for help on using the changeset viewer.