Changeset 1bd8d1e for src/main/java/com
- Timestamp:
- 01/05/23 12:40:07 (23 months ago)
- Branches:
- main
- Children:
- f484b14
- Parents:
- 676144b
- Location:
- src/main/java/com/example/autopartz
- Files:
-
- 6 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/autopartz/config/WebSecurityConfig.java
r676144b r1bd8d1e 28 28 http.csrf().disable() 29 29 .authorizeRequests() 30 .antMatchers("/", "/products", "/services", "/filtered", "/login", "/register","/registerWarehouseman","/finishRegister","/test/*","/ viewUsers","/approve/*").permitAll()30 .antMatchers("/", "/products", "/services", "/filtered", "/login", "/register","/registerWarehouseman","/finishRegister","/test/*","/access_denied").permitAll() 31 31 .antMatchers("/orders","/repairs","/reviews","/part/*","/currentOrder").hasRole("CLIENT") 32 .antMatchers("/viewUsers","/approve/*").hasRole("ADMIN") 32 33 .anyRequest() 33 34 .authenticated() -
src/main/java/com/example/autopartz/controller/AdminController.java
r676144b r1bd8d1e 13 13 import org.springframework.web.bind.annotation.RequestMapping; 14 14 15 import javax.annotation.security.RolesAllowed; 15 16 import javax.servlet.http.HttpServletResponse; 16 17 import java.io.IOException; -
src/main/java/com/example/autopartz/controller/HomeController.java
r676144b r1bd8d1e 1 1 package com.example.autopartz.controller; 2 2 3 import com.example.autopartz.model.Order; 4 import com.example.autopartz.model.User; 5 import com.example.autopartz.model.Warehouse; 6 import com.example.autopartz.repository.OrderContainsPartRepository; 7 import com.example.autopartz.repository.PartsForCarTypeAndCategoryRepository; 8 import com.example.autopartz.repository.RepairShopReviewSummaryRepository; 9 import com.example.autopartz.repository.WarehouseRepository; 3 import com.example.autopartz.model.*; 4 import com.example.autopartz.model.manytomany.PartIsInStockInWarehouse; 5 import com.example.autopartz.repository.*; 10 6 import com.example.autopartz.service.*; 11 7 import org.springframework.stereotype.Controller; … … 20 16 import javax.servlet.http.HttpSession; 21 17 import java.io.IOException; 18 import java.util.List; 22 19 import java.util.Objects; 23 20 … … 34 31 private final OrderContainsPartRepository orderContainsPartRepository; 35 32 private final OrderService orderService; 36 33 private final UserService userService; 34 private final DeliveryService deliveryService; 35 private final PartIsInStockInWarehouseRepository partIsInStockInWarehouseRepository; 37 36 public HomeController(LoginService loginService, PartService partService, PartsForCarTypeAndCategoryRepository partsForCarTypeAndCategoryRepository, CarService carService, CategoryService categoryService, RepairShopReviewSummaryRepository repairShopReviewSummaryRepository, WarehouseRepository warehouseRepository, 38 OrderContainsPartRepository orderContainsPartRepository, OrderService orderService ) {37 OrderContainsPartRepository orderContainsPartRepository, OrderService orderService, UserService userService, DeliveryService deliveryService, PartIsInStockInWarehouseRepository partIsInStockInWarehouseRepository) { 39 38 this.loginService = loginService; 40 39 this.partService = partService; … … 46 45 this.orderContainsPartRepository = orderContainsPartRepository; 47 46 this.orderService = orderService; 47 this.userService = userService; 48 this.deliveryService = deliveryService; 49 this.partIsInStockInWarehouseRepository = partIsInStockInWarehouseRepository; 48 50 } 49 51 … … 78 80 model.addAttribute("hasError",false); 79 81 model.addAttribute("order",o); 80 model.addAttribute("parts",orderService.findById(o.get ID_order()).getPartList());82 model.addAttribute("parts",orderService.findById(o.getOrderid()).getPartList()); 81 83 } 82 84 model.addAttribute("bodyContent","currentOrder"); … … 154 156 } 155 157 } 158 @GetMapping("/access_denied") 159 public String accessDenied(Model model){ 160 model.addAttribute("bodyContent","access_denied"); 161 return "master-template"; 162 } 163 @GetMapping("/myWarehouse") 164 public String myWarehouse(Model model, HttpServletRequest request){ 165 Warehouseman whm = (Warehouseman) userService.findByUsername(request.getRemoteUser()); 166 Warehouse warehouse = whm.getWarehouse(); 167 List<PartIsInStockInWarehouse> partIsInStockInWarehouseList = partIsInStockInWarehouseRepository.findAllByWarehouseid(warehouse.getID_warehouse()); 168 model.addAttribute("bodyContent","myWarehouse"); 169 model.addAttribute("warehouse",warehouse); 170 model.addAttribute("parts", partIsInStockInWarehouseList); 171 return "master-template"; 172 } 173 @GetMapping("myDeliveries") 174 public String myDeliveries(Model model, HttpServletRequest request){ 175 Deliveryman dm = (Deliveryman) userService.findByUsername(request.getRemoteUser()); 176 List<Delivery> deliveries = deliveryService.findAllByDeliverer(dm); 177 model.addAttribute("bodyContent","myDeliveries"); 178 model.addAttribute("deliveries",deliveries); 179 return "master-template"; 180 } 156 181 } -
src/main/java/com/example/autopartz/controller/PartController.java
r676144b r1bd8d1e 77 77 } 78 78 Order order = (Order) session.getAttribute("order"); 79 orderContainsPartRepository.save(new OrderContainsPart(id,order.get ID_order(),quantity));79 orderContainsPartRepository.save(new OrderContainsPart(id,order.getOrderid(),quantity)); 80 80 try { 81 81 response.sendRedirect("/products"); -
src/main/java/com/example/autopartz/controller/TestController.java
r676144b r1bd8d1e 36 36 User u = userService.findByUsername("client13"); 37 37 Order o = orderService.create((Client) u); 38 orderContainsPartRepository.save(new OrderContainsPart(5,o.get ID_order(),2));39 orderContainsPartRepository.save(new OrderContainsPart(7,o.get ID_order(),1));38 orderContainsPartRepository.save(new OrderContainsPart(5,o.getOrderid(),2)); 39 orderContainsPartRepository.save(new OrderContainsPart(7,o.getOrderid(),1)); 40 40 } 41 41 @GetMapping("/t") -
src/main/java/com/example/autopartz/model/Delivery.java
r676144b r1bd8d1e 18 18 @Id 19 19 Integer ID_delivery; 20 String delivery_status; 21 String delivery_address; 20 @Column(name = "delivery_status") 21 String status; 22 @Column(name = "delivery_address") 23 String address; 22 24 @ManyToOne 23 25 @JoinColumn(name = "id_user") -
src/main/java/com/example/autopartz/model/Order.java
r676144b r1bd8d1e 21 21 @Id 22 22 @GeneratedValue(strategy = GenerationType.IDENTITY) 23 Integer ID_order; 23 @Column(name = "ID_order") 24 Integer orderid; 24 25 String order_status; 25 LocalDateTime order_date; 26 @Column(name = "order_date") 27 LocalDateTime date; 26 28 @JoinColumn(name = "id_user") 27 29 @ManyToOne … … 37 39 this.order_status = "created"; 38 40 this.user = user; 39 this. order_date = LocalDateTime.now();41 this.date = LocalDateTime.now(); 40 42 } 41 43 … … 45 47 if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false; 46 48 Order order = (Order) o; 47 return ID_order != null && Objects.equals(ID_order, order.ID_order);49 return orderid != null && Objects.equals(orderid, order.orderid); 48 50 } 49 51
Note:
See TracChangeset
for help on using the changeset viewer.