Skip to content
Open

q #33

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
65 changes: 65 additions & 0 deletions log/output.log
Original file line number Diff line number Diff line change
@@ -1 +1,66 @@
2018-12-03 | 20:53:40 | INFO | MlHhApplication:30 | Start method |
2018-12-08 | 14:10:19 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-08 | 14:10:20 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-14 | 15:42:16 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-14 | 15:42:17 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-14 | 16:08:44 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-14 | 16:08:44 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-14 | 16:12:38 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-14 | 16:12:38 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 15:01:07 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 15:01:08 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 15:06:31 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 15:06:32 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 15:09:30 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 15:12:08 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 15:12:09 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 15:17:59 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 15:18:00 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 15:21:20 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 15:21:20 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 15:25:51 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 15:25:51 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 15:27:10 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 15:27:11 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 15:30:48 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 15:30:48 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 15:41:47 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 15:41:48 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 15:55:46 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 15:55:46 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 16:06:35 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 16:06:35 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 16:12:43 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 16:12:44 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 16:19:05 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 16:19:06 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 16:21:36 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 16:21:37 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 16:27:47 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 16:27:47 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 16:29:09 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 16:29:10 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 16:34:05 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 16:34:06 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 16:45:14 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 16:45:15 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 16:46:38 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 16:46:38 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 16:48:23 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 16:48:24 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 16:51:24 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 16:51:25 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 16:52:37 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 16:52:38 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 16:55:57 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 16:55:59 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 18:30:33 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 18:30:34 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 18:34:59 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 18:35:00 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 18:38:08 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 18:38:09 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 18:38:33 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 18:38:34 | INFO | MlHhApplication:39 | Add new candidates |
2018-12-17 | 18:39:03 | INFO | WebSecurityConfig:40 | user has successfully logged in |
2018-12-17 | 18:39:04 | INFO | MlHhApplication:39 | Add new candidates |
34 changes: 34 additions & 0 deletions src/main/java/learn/epam/mlhh/MlHhApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,40 @@ private void testJpaMethods(){
candidate.setKeyWord("Spring");
candidateService.createCandidate(candidate);

Candidate candidate1 = new Candidate();
candidate1.setName("John");
candidate1.setAge(30);
candidate1.setGender("М");
candidate1.setRegion("Gorky");
candidate1.setSalary(500.000);
candidate1.setDeveloper("Java Developer");
candidate1.setExperience(3);
candidate1.setKeyWord("Spring");
candidateService.createCandidate(candidate1);

Candidate candidate2 = new Candidate();
candidate2.setName("Poul");
candidate2.setAge(40);
candidate2.setGender("М");
candidate2.setRegion("Gorky");
candidate2.setSalary(1000.000);
candidate2.setDeveloper("Java Developer");
candidate2.setExperience(5);
candidate2.setKeyWord("Spring");
candidateService.createCandidate(candidate2);


Candidate candidate3 = new Candidate();
candidate3.setName("Anna");
candidate3.setAge(25);
candidate3.setGender("Ж");
candidate3.setRegion("Mos");
candidate3.setSalary(500.000);
candidate3.setDeveloper("Java Developer");
candidate3.setExperience(3);
candidate3.setKeyWord("Spring");
candidateService.createCandidate(candidate3);

Candidate newCandidate = new Candidate();
newCandidate.setName("FIO");
newCandidate.setAge(20);
Expand Down
59 changes: 59 additions & 0 deletions src/main/java/learn/epam/mlhh/controllers/SearchController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package learn.epam.mlhh.controllers;


import learn.epam.mlhh.entity.Candidate;
import learn.epam.mlhh.entity.Search;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*;
import learn.epam.mlhh.service.CandidateService;

import javax.validation.Valid;
import java.util.*;

@Controller
public class SearchController {

@Autowired
private CandidateService candidateService;


@GetMapping("/search")
public String searchForm(Model model) {
model.addAttribute("search", new Search());
return "search";
}

@PostMapping("/search")
public String searchSubmit(Search search, Map<String, Object> model) {

double dSearchMin = search.getSalaryMin().doubleValue();
double dSearchMax = search.getSalaryMax().doubleValue();

List<Candidate> forsearch = candidateService.findAll();

Iterator<Candidate> i = forsearch.iterator();
while (i.hasNext()) {
Candidate c = i.next(); // must be called before you can call i.remove()

if (
c.getAge() < search.getAgeMin() || c.getAge() > search.getAgeMax()
|| !(c.getGender().equals(search.getGender()))
|| !(c.getRegion().equals(search.getRegion()))
|| c.getSalary().compareTo(dSearchMin) < 0 || c.getSalary().compareTo(dSearchMax) > 0
|| !(c.getDeveloper().equals(search.getDeveloper()))
|| c.getExperience() < search.getExperienceMin() || c.getExperience() > search.getExperienceMax()
|| !(c.getKeyWord().equals(search.getKeywords()))) {
i.remove();
}
}
model.put("searchPut", forsearch);

return "searchresult";
}
}



129 changes: 129 additions & 0 deletions src/main/java/learn/epam/mlhh/entity/Search.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
package learn.epam.mlhh.entity;


import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

import java.math.BigDecimal;

//@Data
public class Search {

// @NotBlank(message="ageMin is required")
private Integer ageMin;

// @NotBlank(message="ageMax is required")
private Integer ageMax;

// @NotBlank(message="gender is required")
// @Size(max=1, message="You can select only one character")
private String gender;

// @NotBlank(message="region is required")
private String region;

// @NotBlank(message="salaryMin is required")
private BigDecimal salaryMin;

// @NotBlank(message="salaryMax is required")
private BigDecimal salaryMax;

// @NotBlank(message="developer is required")
private String developer;

// @NotBlank(message="experienceMin is required")
private Integer experienceMin;

// @NotBlank(message="experienceMax is required")
private Integer experienceMax;

// @NotBlank(message="keywords is required")
private String keywords;

public Search() {
}

public Integer getAgeMin() {
return ageMin;
}

public void setAgeMin(Integer ageMin) {
this.ageMin = ageMin;
}

public Integer getAgeMax() {
return ageMax;
}

public void setAgeMax(Integer ageMax) {
this.ageMax = ageMax;
}

public String getGender() {
return gender;
}

public void setGender(String gender) {
this.gender = gender;
}

public String getRegion() {
return region;
}

public void setRegion(String region) {
this.region = region;
}

public BigDecimal getSalaryMin() {
return salaryMin;
}

public void setSalaryMin(BigDecimal salaryMin) {
this.salaryMin = salaryMin;
}

public BigDecimal getSalaryMax() {
return salaryMax;
}

public void setSalaryMax(BigDecimal salaryMax) {
this.salaryMax = salaryMax;
}

public String getDeveloper() {
return developer;
}

public void setDeveloper(String developer) {
this.developer = developer;
}

public Integer getExperienceMin() {
return experienceMin;
}

public void setExperienceMin(Integer experienceMin) {
this.experienceMin = experienceMin;
}

public Integer getExperienceMax() {
return experienceMax;
}

public void setExperienceMax(Integer experienceMax) {
this.experienceMax = experienceMax;
}

public String getKeywords() {
return keywords;
}

public void setKeywords(String keywords) {
this.keywords = keywords;
}




}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public interface CandidateRepository extends JpaRepository<Candidate, Long> {

/*@Query("SELECT u FROM Candidate u WHERE developer like 'Java'") //собственный запрос
List<Candidate> findWhereDevelop();*/

}
2 changes: 2 additions & 0 deletions src/main/java/learn/epam/mlhh/service/CandidateService.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class CandidateService {
private final CandidateRepository candidateRepository;

public CandidateService(CandidateRepository candidateRepository){

this.candidateRepository = candidateRepository;
}

Expand All @@ -32,4 +33,5 @@ public Candidate findById(Long candidateId){
public List<Candidate> findAllByName(String name){
return candidateRepository.findAllByName(name);
}

}
4 changes: 4 additions & 0 deletions src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ <h1 th:text="${message}"></h1>
<form action="/table" method="POST">
<input type="submit" value="table">
</form>
<br>
<form action="http://localhost:8080/search">
<button>На страницу поиска</button>
</form>
</div>
</div>
</div>
Expand Down
47 changes: 47 additions & 0 deletions src/main/resources/templates/result.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Table</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12">
<h1 th:text="${messageSearch}"></h1><form action="/" method="GET">
<input type="submit" value="back">
</form>
</div>
</div>
<table class="table">
<thead>
<tr>
<th >ID</th>
<th>Name</th>
<th>Age</th>
<th>gender</th>
<th>region</th>
<th>salary</th>
<th>developer</th>
<th>experience</th>
<th>keyword</th>
</tr>
</thead>
<tbody>
<tr th:each="candidate: ${candidats}">
<td th:text="${candidate.getCandidateId()}"></td>
<td th:text="${candidate.getName()}"></td>
<td th:text="${candidate.getAge()}"></td>
<td th:text="${candidate.getGender()}"></td>
<td th:text="${candidate.getRegion()}"></td>
<td th:text="${candidate.getSalary()}"></td>
<td th:text="${candidate.getDeveloper()}"></td>
<td th:text="${candidate.getExperience()}"></td>
<td th:text="${candidate.getKeyWord()}"></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Loading