Changeset 676144b for src/main/java
- Timestamp:
- 01/05/23 04:11:40 (23 months ago)
- Branches:
- main
- Children:
- 1bd8d1e
- Parents:
- 7d43957
- Location:
- src/main/java/com/example/autopartz
- Files:
-
- 2 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/autopartz/config/WebSecurityConfig.java
r7d43957 r676144b 28 28 http.csrf().disable() 29 29 .authorizeRequests() 30 .antMatchers("/", "/products", "/services", "/filtered", "/login", "/register","/registerWarehouseman","/finishRegister","/test/*" ).permitAll()30 .antMatchers("/", "/products", "/services", "/filtered", "/login", "/register","/registerWarehouseman","/finishRegister","/test/*","/viewUsers","/approve/*").permitAll() 31 31 .antMatchers("/orders","/repairs","/reviews","/part/*","/currentOrder").hasRole("CLIENT") 32 32 .anyRequest() -
src/main/java/com/example/autopartz/controller/HomeController.java
r7d43957 r676144b 102 102 public void handleLogin(@RequestParam String username, @RequestParam String password){ 103 103 User u = loginService.login(username,password); 104 System.out.println(u.getName _user());104 System.out.println(u.getName()); 105 105 } 106 106 @PostMapping("/register") -
src/main/java/com/example/autopartz/controller/PartController.java
r7d43957 r676144b 50 50 } 51 51 @PostMapping("/repairshopdelivery") 52 public void setRepairShopDelivery(@RequestParam String name, HttpServletResponse response ){52 public void setRepairShopDelivery(@RequestParam String name, HttpServletResponse response, HttpSession session){ 53 53 // insert into project.repair (vin, id_repair_shop, id_service_book) values (1111,3,1) 54 session.removeAttribute("order"); 54 55 try { 55 56 response.sendRedirect("/"); … … 59 60 } 60 61 @PostMapping("/homedelivery") 61 public void setHomeDelivery(@RequestParam String address, HttpServletResponse response ){62 public void setHomeDelivery(@RequestParam String address, HttpServletResponse response, HttpSession session){ 62 63 // insert into delivery (delivery_status, delivery_address,id_user,id_order) values ('in progress','Aerodrom',4,1) 64 session.removeAttribute("order"); 63 65 try { 64 66 response.sendRedirect("/"); -
src/main/java/com/example/autopartz/controller/UserController.java
r7d43957 r676144b 28 28 @GetMapping("orders") 29 29 public String getOrdersForUser(Model model, HttpServletRequest request){ 30 Integer id = userService.findByUsername(request.getRemoteUser()).getI D_user();30 Integer id = userService.findByUsername(request.getRemoteUser()).getId(); 31 31 model.addAttribute("userOrders",ordersForUserRepository.findAllByUserid(id)); 32 32 model.addAttribute("bodyContent","ordersForUser"); … … 35 35 @GetMapping("repairs") 36 36 public String getRepairsForUser(Model model, HttpServletRequest request){ 37 Integer id = userService.findByUsername(request.getRemoteUser()).getI D_user();37 Integer id = userService.findByUsername(request.getRemoteUser()).getId(); 38 38 model.addAttribute("userRepairs",repairsForUserRepository.findAllByUserid(id)); 39 39 model.addAttribute("bodyContent","repairsForUser"); … … 42 42 @GetMapping("reviews") 43 43 public String getReviewsForUser(Model model,HttpServletRequest request){ 44 Integer id = userService.findByUsername(request.getRemoteUser()).getI D_user();44 Integer id = userService.findByUsername(request.getRemoteUser()).getId(); 45 45 model.addAttribute("userReviews",reviewsForUserRepository.findAllByUserid(id)); 46 46 model.addAttribute("bodyContent","reviewsForUser"); -
src/main/java/com/example/autopartz/model/Administrator.java
r7d43957 r676144b 27 27 if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false; 28 28 Administrator that = (Administrator) o; 29 return ID_user != null && Objects.equals(ID_user, that.ID_user);29 return id != null && Objects.equals(id, that.id); 30 30 } 31 31 -
src/main/java/com/example/autopartz/model/Client.java
r7d43957 r676144b 28 28 if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false; 29 29 Client client = (Client) o; 30 return ID_user != null && Objects.equals(ID_user, client.ID_user);30 return id != null && Objects.equals(id, client.id); 31 31 } 32 32 -
src/main/java/com/example/autopartz/model/Deliveryman.java
r7d43957 r676144b 35 35 if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false; 36 36 Deliveryman that = (Deliveryman) o; 37 return ID_user != null && Objects.equals(ID_user, that.ID_user);37 return id != null && Objects.equals(id, that.id); 38 38 } 39 39 -
src/main/java/com/example/autopartz/model/User.java
r7d43957 r676144b 25 25 @Id 26 26 @GeneratedValue(strategy = GenerationType.IDENTITY) 27 Integer ID_user; 27 @Column(name = "ID_user") 28 Integer id; 28 29 String username; 29 30 String email; 30 String name_user; 31 @Column(name = "name_user") 32 String name; 31 33 @Column(name = "password_user") 32 34 String password; … … 39 41 public User(String username, String name, String email, String password, String number) { 40 42 this.username = username; 41 this.name _user= name;43 this.name = name; 42 44 this.email = email; 43 45 this.password = password; … … 51 53 if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false; 52 54 User user = (User) o; 53 return ID_user != null && Objects.equals(ID_user, user.ID_user);55 return id != null && Objects.equals(id, user.id); 54 56 } 55 57 -
src/main/java/com/example/autopartz/model/Warehouseman.java
r7d43957 r676144b 39 39 if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false; 40 40 Warehouseman that = (Warehouseman) o; 41 return ID_user != null && Objects.equals(ID_user, that.ID_user);41 return id != null && Objects.equals(id, that.id); 42 42 } 43 43 … … 48 48 @Override 49 49 public Collection<? extends GrantedAuthority> getAuthorities() { 50 if( employed_from==defaultEmployedFrom)50 if(Objects.equals(employed_from, defaultEmployedFrom)) 51 51 return Collections.singletonList(Role.ROLE_PENDING_WAREHOUSEMAN); 52 52 else -
src/main/java/com/example/autopartz/model/views/ReviewsForUser.java
r7d43957 r676144b 28 28 Integer userid; 29 29 Integer rating; 30 Integer orderid; 30 31 String rcomment; 31 32 String rsname; -
src/main/java/com/example/autopartz/repository/UserRepository.java
r7d43957 r676144b 3 3 import com.example.autopartz.model.User; 4 4 import org.springframework.data.jpa.repository.JpaRepository; 5 import org.springframework.security.core.GrantedAuthority; 5 6 import org.springframework.stereotype.Repository; 6 7 8 import java.util.Collection; 7 9 import java.util.List; 8 10 -
src/main/java/com/example/autopartz/service/UserService.java
r7d43957 r676144b 8 8 List<User> findAllUsers(); 9 9 User findByUsername(String username); 10 10 User findById(Integer id); 11 11 } -
src/main/java/com/example/autopartz/service/impl/UserServiceImpl.java
r7d43957 r676144b 1 1 package com.example.autopartz.service.impl; 2 2 3 import com.example.autopartz.model.Role; 3 4 import com.example.autopartz.model.User; 4 5 import com.example.autopartz.repository.UserRepository; … … 6 7 import org.springframework.stereotype.Service; 7 8 9 import java.util.Collections; 8 10 import java.util.List; 9 11 … … 25 27 return userRepository.findAllByUsername(username).stream().findFirst().orElseThrow(RuntimeException::new); 26 28 } 29 30 @Override 31 public User findById(Integer id) { 32 return userRepository.findById(id).get(); 33 } 27 34 }
Note:
See TracChangeset
for help on using the changeset viewer.