Changeset e278ff8


Ignore:
Timestamp:
01/06/23 19:28:09 (23 months ago)
Author:
Bojan <bojantrpeski123@…>
Branches:
main
Children:
497d129
Parents:
154b74c
Message:

Articles by location and details views added

Location:
FullyStocked/src/main
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • FullyStocked/src/main/java/com/bazi/fullystocked/Controller/WorkerController.java

    r154b74c re278ff8  
    11package com.bazi.fullystocked.Controller;
    22
     3import com.bazi.fullystocked.Models.SqlViews.ArticlesReport;
     4import com.bazi.fullystocked.Models.StoredArticles;
     5import com.bazi.fullystocked.Models.User;
    36import com.bazi.fullystocked.Models.Workers;
     7import com.bazi.fullystocked.Services.StoredArticlesService;
    48import org.springframework.stereotype.Controller;
    59import org.springframework.ui.Model;
    610import org.springframework.web.bind.annotation.GetMapping;
     11import org.springframework.web.bind.annotation.PathVariable;
    712import org.springframework.web.bind.annotation.RequestMapping;
    813
    914import javax.servlet.http.HttpServletRequest;
     15import java.util.List;
     16import java.util.Optional;
    1017
    1118@Controller
    1219@RequestMapping(value ="/worker")
    1320public class WorkerController {
     21   private final StoredArticlesService storedArticlesService;
     22
     23    public WorkerController(StoredArticlesService storedArticlesService) {
     24        this.storedArticlesService = storedArticlesService;
     25    }
     26
    1427    @GetMapping
    1528    public String getWorkerPage()
     
    1831        return "homeWorker";
    1932    }
     33    @GetMapping("/articles")
     34    public String getArticles(HttpServletRequest request, Model model)
     35    {
     36        Workers u= (Workers) request.getSession().getAttribute("user");
     37        List<ArticlesReport> articlesReport=storedArticlesService.findByLocation(u.getLocation().getLocationid());
     38        model.addAttribute("articles",articlesReport);
     39        return "articles";
     40    }
     41    @GetMapping("/articles/details/{id}")
     42    public String getDetails(@PathVariable Integer id,Model model)
     43    {
     44        if(this.storedArticlesService.findById(id).isPresent())
     45        {
     46            ArticlesReport articlesReport=this.storedArticlesService.findById(id).get();
     47            model.addAttribute("article",articlesReport);
     48            return "detailsArticle";
     49        }
     50        return "redirect:/articles?error=ArticleNotFound";
     51    }
    2052}
  • FullyStocked/src/main/java/com/bazi/fullystocked/Models/SqlViews/ArticlesReport.java

    r154b74c re278ff8  
    2020    private String locationname;
    2121    private Integer locationid;
     22
     23    public Integer getSarticleid() {
     24        return sarticleid;
     25    }
     26
     27    public Integer getArticleid() {
     28        return articleid;
     29    }
     30
     31    public String getArticlename() {
     32        return articlename;
     33    }
     34
     35    public String getDescription() {
     36        return description;
     37    }
     38
     39    public String getImageurl() {
     40        return imageurl;
     41    }
     42
     43    public int getQuantity() {
     44        return quantity;
     45    }
     46
     47    public String getLocationname() {
     48        return locationname;
     49    }
     50
     51    public Integer getLocationid() {
     52        return locationid;
     53    }
    2254}
  • FullyStocked/src/main/java/com/bazi/fullystocked/Services/Implementations/StoredArticlesServiceImpl.java

    r154b74c re278ff8  
    6262        return articlesReportRepository.findAllByLocationid(locationId);
    6363    }
     64    public Optional<ArticlesReport> findById(Integer id)
     65    {
     66        return articlesReportRepository.findById(id);
     67    }
    6468}
  • FullyStocked/src/main/java/com/bazi/fullystocked/Services/StoredArticlesService.java

    r154b74c re278ff8  
    1212    Optional<StoredArticles> updateFromOrder(Integer oarticleid);
    1313    List<ArticlesReport> findByLocation(Integer locationId);
     14    Optional<ArticlesReport> findById(Integer id);
     15
    1416}
  • FullyStocked/src/main/resources/templates/homeManager.html

    r154b74c re278ff8  
    1111<nav class="navbar navbar-expand-md navbar-dark bg-dark">
    1212  <div class="container">
    13     <a class="navbar-brand" href="/">FULLYSTOCKED</a>
     13    <a class="navbar-brand" href="/homeManager">FULLYSTOCKED</a>
    1414    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault"
    1515            aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
  • FullyStocked/src/main/resources/templates/homeSupplier.html

    r154b74c re278ff8  
    1111<nav class="navbar navbar-expand-md navbar-dark bg-dark">
    1212  <div class="container">
    13     <a class="navbar-brand" href="/">FULLYSTOCKED</a>
     13    <a class="navbar-brand" href="/homeSupplier">FULLYSTOCKED</a>
    1414    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault"
    1515            aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
  • FullyStocked/src/main/resources/templates/homeWorker.html

    r154b74c re278ff8  
    1111<nav class="navbar navbar-expand-md navbar-dark bg-dark">
    1212  <div class="container">
    13     <a class="navbar-brand" href="/">FULLYSTOCKED</a>
     13    <a class="navbar-brand" href="/homeWorker">FULLYSTOCKED</a>
    1414    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault"
    1515            aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
     
    2020      <ul class="navbar-nav m-auto">
    2121        <li class="nav-item m-auto">
    22           <a class="nav-link active" href="#">Преглед на магацинот</a>
     22          <a class="nav-link active" href="/worker/articles">Преглед на магацинот</a>
    2323        </li>
    2424        <li class="nav-item m-auto">
Note: See TracChangeset for help on using the changeset viewer.