- Timestamp:
- 01/04/23 02:56:41 (23 months ago)
- Branches:
- main
- Children:
- 7d43957
- Parents:
- ae042f4
- Location:
- src/main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/autopartz/config/WebSecurityConfig.java
rae042f4 rab952ab 29 29 .authorizeRequests() 30 30 .antMatchers("/", "/products", "/services", "/filtered", "/login", "/register").permitAll() 31 .antMatchers("/orders /*","/repairs/*","/reviews/*","/part/*").hasRole("CLIENT")31 .antMatchers("/orders","/repairs","/reviews","/part/*").hasRole("CLIENT") 32 32 .anyRequest() 33 33 .authenticated() -
src/main/java/com/example/autopartz/controller/UserController.java
rae042f4 rab952ab 4 4 import com.example.autopartz.repository.RepairsForUserRepository; 5 5 import com.example.autopartz.repository.ReviewsForUserRepository; 6 import com.example.autopartz.service.UserService; 6 7 import org.springframework.stereotype.Controller; 7 8 import org.springframework.ui.Model; … … 9 10 import org.springframework.web.bind.annotation.PathVariable; 10 11 import org.springframework.web.bind.annotation.RequestMapping; 12 13 import javax.servlet.http.HttpServletRequest; 11 14 12 15 @Controller … … 16 19 private final RepairsForUserRepository repairsForUserRepository; 17 20 private final ReviewsForUserRepository reviewsForUserRepository; 18 public UserController(OrdersForUserRepository ordersForUserRepository, RepairsForUserRepository repairsForUserRepository, ReviewsForUserRepository reviewsForUserRepository) { 21 private final UserService userService; 22 public UserController(OrdersForUserRepository ordersForUserRepository, RepairsForUserRepository repairsForUserRepository, ReviewsForUserRepository reviewsForUserRepository, UserService userService) { 19 23 this.ordersForUserRepository = ordersForUserRepository; 20 24 this.repairsForUserRepository = repairsForUserRepository; 21 25 this.reviewsForUserRepository = reviewsForUserRepository; 26 this.userService = userService; 22 27 } 23 @GetMapping("orders/{id}") 24 public String getOrdersForUser(@PathVariable Integer id, Model model){ 28 @GetMapping("orders") 29 public String getOrdersForUser(Model model, HttpServletRequest request){ 30 Integer id = userService.findByUsername(request.getRemoteUser()).getID_user(); 25 31 model.addAttribute("userOrders",ordersForUserRepository.findAllByUserid(id)); 26 32 model.addAttribute("bodyContent","ordersForUser"); 27 33 return "master-template"; 28 34 } 29 @GetMapping("repairs/{id}") 30 public String getRepairsForUser(@PathVariable Integer id,Model model){ 35 @GetMapping("repairs") 36 public String getRepairsForUser(Model model, HttpServletRequest request){ 37 Integer id = userService.findByUsername(request.getRemoteUser()).getID_user(); 31 38 model.addAttribute("userRepairs",repairsForUserRepository.findAllByUserid(id)); 32 39 model.addAttribute("bodyContent","repairsForUser"); 33 40 return "master-template"; 34 41 } 35 @GetMapping("reviews/{id}") 36 public String getReviewsForUser(@PathVariable Integer id, Model model){ 42 @GetMapping("reviews") 43 public String getReviewsForUser(Model model,HttpServletRequest request){ 44 Integer id = userService.findByUsername(request.getRemoteUser()).getID_user(); 37 45 model.addAttribute("userReviews",reviewsForUserRepository.findAllByUserid(id)); 38 46 model.addAttribute("bodyContent","reviewsForUser"); -
src/main/resources/templates/products.html
rae042f4 rab952ab 1 1 <div> 2 2 <header> 3 <a th:href="${'/orders /4'}">Мои нарачки</a>4 <a th:href="${'/repairs /4'}">Мои поправки</a>5 <a th:href="${'/reviews /4'}">Мои критики</a>3 <a th:href="${'/orders'}">Мои нарачки</a> 4 <a th:href="${'/repairs'}">Мои поправки</a> 5 <a th:href="${'/reviews'}">Мои критики</a> 6 6 </header> 7 7 <main>
Note:
See TracChangeset
for help on using the changeset viewer.