Ignore:
Timestamp:
01/05/23 12:40:07 (23 months ago)
Author:
andrejtodorovski <82031894+andrejtodorovski@…>
Branches:
main
Children:
f484b14
Parents:
676144b
Message:

Added views and functionalities for deliveryman, warehouseman and admin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/autopartz/controller/HomeController.java

    r676144b r1bd8d1e  
    11package com.example.autopartz.controller;
    22
    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;
     3import com.example.autopartz.model.*;
     4import com.example.autopartz.model.manytomany.PartIsInStockInWarehouse;
     5import com.example.autopartz.repository.*;
    106import com.example.autopartz.service.*;
    117import org.springframework.stereotype.Controller;
     
    2016import javax.servlet.http.HttpSession;
    2117import java.io.IOException;
     18import java.util.List;
    2219import java.util.Objects;
    2320
     
    3431    private final OrderContainsPartRepository orderContainsPartRepository;
    3532    private final OrderService orderService;
    36 
     33    private final UserService userService;
     34    private final DeliveryService deliveryService;
     35    private final PartIsInStockInWarehouseRepository partIsInStockInWarehouseRepository;
    3736    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) {
    3938        this.loginService = loginService;
    4039        this.partService = partService;
     
    4645        this.orderContainsPartRepository = orderContainsPartRepository;
    4746        this.orderService = orderService;
     47        this.userService = userService;
     48        this.deliveryService = deliveryService;
     49        this.partIsInStockInWarehouseRepository = partIsInStockInWarehouseRepository;
    4850    }
    4951
     
    7880            model.addAttribute("hasError",false);
    7981            model.addAttribute("order",o);
    80             model.addAttribute("parts",orderService.findById(o.getID_order()).getPartList());
     82            model.addAttribute("parts",orderService.findById(o.getOrderid()).getPartList());
    8183        }
    8284        model.addAttribute("bodyContent","currentOrder");
     
    154156        }
    155157    }
     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    }
    156181}
Note: See TracChangeset for help on using the changeset viewer.