Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.findwork.findwork.Entities.Users.UserPerson;
import com.findwork.findwork.Enums.Category;
import com.findwork.findwork.Enums.JobLevel;
import com.findwork.findwork.Repositories.JobApplicationRepository;
import com.findwork.findwork.Requests.CreateJobOfferRequest;
import com.findwork.findwork.Requests.EditJobOfferRequest;
import com.findwork.findwork.Services.OfferService;
Expand All @@ -17,21 +18,22 @@
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import java.util.List;
import java.util.UUID;
import java.util.*;

@Controller
@AllArgsConstructor
@RequestMapping("/offers")
public class JobOfferController {
private final ValidationService validationService;
private final OfferService offerService;
private final JobApplicationRepository applicationRepo;

@GetMapping("/")
public String getAllOffers(Model model,
@RequestParam(required = false) String search,
@RequestParam(required = false) String jobCategory,
@RequestParam(required = false) String jobLevel) {
@RequestParam(required = false) String jobLevel){

List<JobOffer> offers;

if (jobCategory != null && jobCategory.equals("--Any--"))
Expand All @@ -42,7 +44,12 @@ public String getAllOffers(Model model,

offers = offerService.getOffers(search, jobCategory, jobLevel);

model.addAttribute("offers", offers);
HashMap<JobOffer, Integer> offerRating = new HashMap<JobOffer, Integer>();
for(JobOffer offer:offers){
offerRating.put(offer,applicationRepo.countAllByOffer(offer));
}

model.addAttribute("offers", offerRating);
model.addAttribute("levels", JobLevel.values());
model.addAttribute("categories", Category.values());
return "offers";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ public interface JobApplicationRepository extends JpaRepository<JobApplication,
JobApplication findJobApplicationByUserAndOffer(UserPerson user, JobOffer offer);

List<JobApplication> findAllByOffer(JobOffer offer);
Integer countAllByOffer(JobOffer offer);
}
18 changes: 11 additions & 7 deletions src/main/resources/templates/offers.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,34 @@ <h1 class="dashboard-title">Offers</h1>
<th:block th:each="offer: ${offers}">
<div class="offers-board">
<div class="card-body">
<h5 th:text="${offer.title}" class="card-title"></h5>
<h5 th:text="${offer.key.title}" class="card-title"></h5>
<div class="divStyle">
<label class="lebStyle">Company: </label>
<a th:href="@{/company/{id}(id=${offer.company.id})}" th:text="${offer.company.name}"
<a th:href="@{/company/{id}(id=${offer.key.company.id})}" th:text="${offer.key.company.name}"
class="companyName"></a>
</div>
<div class="divStyle">
<label class="lebStyle">Location: </label>
<a th:text="${offer.location}" class="aStyle"></a>
<a th:text="${offer.key.location}" class="aStyle"></a>
</div>
<div class="divStyle">
<label class="lebStyle">Salary: </label>
<a th:text="${offer.salary}" class="aStyle"></a>
<a th:text="${offer.key.salary}" class="aStyle"></a>
</div>
<div class="divStyle">
<label class="lebStyle">Level: </label>
<a th:text="${offer.jobLevel}" class="aStyle"></a>
<a th:text="${offer.key.jobLevel}" class="aStyle"></a>
</div>
<div class="divStyle">
<label class="lebStyle">Category: </label>
<a th:text="${offer.jobCategory}" class="aStyle"></a>
<a th:text="${offer.key.jobCategory}" class="aStyle"></a>
</div>
<div class="divStyle">
<label class="lebStyle">Rating: </label>
<a th:text="${offer.value}" class="aStyle"></a>
</div>
<div class="divBtn">
<a th:href="@{/offers/{id}(id=${offer.id})}" class="styleButton">See more</a>
<a th:href="@{/offers/{id}(id=${offer.key.id})}" class="styleButton">See more</a>
</div>
</div>
</div>
Expand Down