Changeset a436340 for src/main/java
- Timestamp:
- 02/05/23 19:55:10 (22 months ago)
- Branches:
- master
- Children:
- 2b0a4db
- Parents:
- cc52b09
- Location:
- src/main/java/edu/gjoko/schedlr
- Files:
-
- 5 added
- 2 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/edu/gjoko/schedlr/config/AppSecurityConfig.java
rcc52b09 ra436340 45 45 http.csrf() 46 46 .disable() 47 .authorizeRequests()48 .antMatchers("/login").permitAll()49 .antMatchers("/register_customer").permitAll()50 .antMatchers("/register_business").permitAll()51 .antMatchers("/homepage").permitAll()52 .antMatchers("/css/**").permitAll()53 .antMatchers("/js/**").permitAll()54 .antMatchers("/anonymous*").anonymous()55 .anyRequest()56 .fullyAuthenticated()57 .and()58 47 .httpBasic() 59 48 .authenticationEntryPoint(new AppAuthenticationEntryPoint()) … … 64 53 .loginProcessingUrl("/login") 65 54 .successHandler(authenticationSuccessHandler) 66 .defaultSuccessUrl("/homepage"); 55 .defaultSuccessUrl("/homepage") 56 .and() 57 .authorizeRequests() 58 .antMatchers("/login").permitAll() 59 .antMatchers("/register_customer").permitAll() 60 .antMatchers("/register_business").permitAll() 61 .antMatchers("/api/nomenclatures/*").permitAll() 62 .antMatchers("/homepage").permitAll() 63 .antMatchers("/css/**").permitAll() 64 .antMatchers("/js/**").permitAll() 65 .antMatchers("/anonymous*").anonymous() 66 .anyRequest() 67 .fullyAuthenticated(); 67 68 } 68 69 } -
src/main/java/edu/gjoko/schedlr/controllers/HomePageController.java
rcc52b09 ra436340 1 1 package edu.gjoko.schedlr.controllers; 2 2 3 import edu.gjoko.schedlr.entity.Search;4 3 import org.springframework.stereotype.Controller; 5 4 import org.springframework.ui.Model; 6 5 import org.springframework.web.bind.annotation.GetMapping; 7 import org.springframework.web.bind.annotation.ModelAttribute;8 6 import org.springframework.web.bind.annotation.PostMapping; 7 8 import java.security.Principal; 9 9 10 10 @Controller … … 12 12 13 13 @GetMapping(name = "/homepage") 14 public String getHomePageTemplate(Model model, @ModelAttribute("search")Search search) {15 model.addAttribute("search", search);14 public String getHomePageTemplate(Model model, Principal principal) { 15 System.out.println(principal); 16 16 return "homepage"; 17 17 } 18 18 19 19 @PostMapping(name = "/homepage") 20 public String postHomePageTemplate(Model model, @ModelAttribute("search")Search search) { 21 model.addAttribute("search", search); 20 public String postHomePageTemplate(Model model) { 22 21 return "homepage"; 23 22 } -
src/main/java/edu/gjoko/schedlr/controllers/LoginController.java
rcc52b09 ra436340 12 12 13 13 @GetMapping(path = "/login") 14 public String getMapping(Model model) { 15 model.addAttribute("stakeholder", new Stakeholder()); 14 public String getMapping(@ModelAttribute Stakeholder customer, Model model) { 16 15 return "login"; 17 16 } -
src/main/java/edu/gjoko/schedlr/controllers/RegisterController.java
rcc52b09 ra436340 29 29 public String registerCustomer(@ModelAttribute Stakeholder customer, Model model) { 30 30 Stakeholder user = stakeholderService.saveStakeholder(customer); 31 model.addAttribute("user", user); 32 return "redirect:homepage"; 31 return "redirect:login"; 33 32 } 34 33 -
src/main/java/edu/gjoko/schedlr/entity/Business.java
rcc52b09 ra436340 1 1 package edu.gjoko.schedlr.entity; 2 2 3 import com.fasterxml.jackson.annotation.JsonManagedReference; 3 4 import lombok.AllArgsConstructor; 4 5 import lombok.Getter; … … 25 26 private String name; 26 27 27 @ Column(name = "business_type")28 @ Enumerated(EnumType.STRING)28 @OneToOne 29 @JoinColumn(name = "business_type_id", referencedColumnName = "id") 29 30 private BusinessType businessType; 30 31 … … 39 40 private Stakeholder owner; 40 41 42 @OneToMany(mappedBy = "business") 43 @JsonManagedReference 44 private List<Service> services; 45 41 46 @Column(name = "created") 42 47 private LocalDateTime created; … … 45 50 private LocalDateTime modified; 46 51 47 @OneToMany(mappedBy = "business") 48 private List<Service> services; 52 49 53 } -
src/main/java/edu/gjoko/schedlr/entity/BusinessType.java
rcc52b09 ra436340 1 1 package edu.gjoko.schedlr.entity; 2 2 3 public enum BusinessType { 4 TAILOR, 5 NAIL_SALON, 6 MASSAGE_PARLOR, 7 MAKEUP_STUDIO, 8 HAIRDRESSER, 9 BARBER 3 import com.fasterxml.jackson.annotation.JsonIgnore; 4 import com.fasterxml.jackson.annotation.JsonManagedReference; 5 import com.fasterxml.jackson.annotation.JsonProperty; 6 import lombok.AllArgsConstructor; 7 import lombok.Getter; 8 import lombok.NoArgsConstructor; 9 import lombok.Setter; 10 import org.springframework.data.annotation.CreatedDate; 11 import org.springframework.data.annotation.LastModifiedDate; 12 import org.springframework.data.jpa.domain.support.AuditingEntityListener; 13 14 import javax.persistence.*; 15 import java.time.LocalDateTime; 16 import java.util.List; 17 18 @Entity 19 @EntityListeners(AuditingEntityListener.class) 20 @Table(name = "business_type") 21 @Getter 22 @Setter 23 @NoArgsConstructor 24 @AllArgsConstructor 25 public class BusinessType { 26 27 @Id 28 @GeneratedValue(strategy = GenerationType.SEQUENCE) 29 @JsonProperty("value") 30 private Long id; 31 32 @Column(name = "name") 33 @JsonProperty("text") 34 private String name; 35 36 @OneToMany(mappedBy="businessType") 37 @JsonManagedReference 38 private List<ServiceType> serviceTypes; 39 40 @Column(name = "created") 41 @CreatedDate 42 @JsonIgnore 43 private LocalDateTime created; 44 45 @Column(name = "modified") 46 @LastModifiedDate 47 @JsonIgnore 48 private LocalDateTime modified; 10 49 } -
src/main/java/edu/gjoko/schedlr/entity/Service.java
rcc52b09 ra436340 1 1 package edu.gjoko.schedlr.entity; 2 2 3 import com.fasterxml.jackson.annotation.JsonBackReference; 3 4 import lombok.AllArgsConstructor; 4 5 import lombok.Getter; … … 35 36 private Float price; 36 37 38 @OneToOne 39 @JoinColumn(name = "service_type_id", referencedColumnName = "id") 40 private ServiceType serviceType; 41 37 42 @ManyToOne 38 @JoinColumn(name = "business_id") 43 @JoinColumn(name="business_fk") 44 @JsonBackReference 39 45 private Business business; 40 46 -
src/main/java/edu/gjoko/schedlr/services/StakeholderService.java
rcc52b09 ra436340 4 4 import edu.gjoko.schedlr.entity.StakeholderType; 5 5 import edu.gjoko.schedlr.repositories.StakeholderRepository; 6 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 6 7 import org.springframework.stereotype.Service; 7 8 … … 10 11 11 12 private StakeholderRepository stakeholderRepository; 13 private BCryptPasswordEncoder bCryptPasswordEncoder; 12 14 13 public StakeholderService(StakeholderRepository stakeholderRepository) { 15 public StakeholderService(StakeholderRepository stakeholderRepository, 16 BCryptPasswordEncoder bCryptPasswordEncoder) { 14 17 this.stakeholderRepository = stakeholderRepository; 18 this.bCryptPasswordEncoder = bCryptPasswordEncoder; 15 19 } 16 20 17 21 public Stakeholder saveStakeholder(Stakeholder stakeholder) { 22 stakeholder.setPassword(bCryptPasswordEncoder.encode(stakeholder.getPassword())); 18 23 stakeholder.setStakeholderType(StakeholderType.CUSTOMER); 19 24 return stakeholderRepository.save(stakeholder);
Note:
See TracChangeset
for help on using the changeset viewer.