#76 -- fix part
parent
c39bc3c6ca
commit
8cb6fdf082
@ -0,0 +1,39 @@
|
||||
package ru.ulstu.extractor.recommendation.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import ru.ulstu.extractor.branch.service.BranchService;
|
||||
import ru.ulstu.extractor.recommendation.model.FilterBranchForm;
|
||||
import ru.ulstu.extractor.rule.service.FuzzyInferenceService;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static ru.ulstu.extractor.core.Route.RECOMMENDATIONS;
|
||||
|
||||
@Controller
|
||||
@ApiIgnore
|
||||
public class RecommendationController {
|
||||
private final FuzzyInferenceService fuzzyInferenceService;
|
||||
private final BranchService branchService;
|
||||
|
||||
public RecommendationController(FuzzyInferenceService fuzzyInferenceService,
|
||||
BranchService branchService) {
|
||||
this.fuzzyInferenceService = fuzzyInferenceService;
|
||||
this.branchService = branchService;
|
||||
}
|
||||
|
||||
@GetMapping(RECOMMENDATIONS)
|
||||
public String getRecommendations(Model model, @RequestParam Optional<Integer> branchId) {
|
||||
model.addAttribute("branches", branchService.findAll());
|
||||
if (branchId.isPresent()) {
|
||||
model.addAttribute("recommendations", fuzzyInferenceService.getRecommendations());
|
||||
model.addAttribute("filterBranchForm", new FilterBranchForm(branchId.get()));
|
||||
} else {
|
||||
model.addAttribute("filterBranchForm", new FilterBranchForm());
|
||||
}
|
||||
return RECOMMENDATIONS;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package ru.ulstu.extractor.recommendation.model;
|
||||
|
||||
public class FilterBranchForm {
|
||||
private Integer branchId;
|
||||
|
||||
public FilterBranchForm() {
|
||||
}
|
||||
|
||||
public FilterBranchForm(Integer branchId) {
|
||||
this.branchId = branchId;
|
||||
}
|
||||
|
||||
public Integer getBranchId() {
|
||||
return branchId;
|
||||
}
|
||||
|
||||
public void setBranchId(Integer branchId) {
|
||||
this.branchId = branchId;
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package ru.ulstu.extractor.rule.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import ru.ulstu.extractor.rule.service.FuzzyInferenceService;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import static ru.ulstu.extractor.core.Route.RECOMMENDATIONS;
|
||||
|
||||
@Controller
|
||||
@ApiIgnore
|
||||
public class RecommendationController {
|
||||
private final FuzzyInferenceService fuzzyInferenceService;
|
||||
|
||||
public RecommendationController(FuzzyInferenceService fuzzyInferenceService) {
|
||||
this.fuzzyInferenceService = fuzzyInferenceService;
|
||||
}
|
||||
|
||||
@GetMapping(RECOMMENDATIONS)
|
||||
public String getRecommendations(Model model) {
|
||||
model.addAttribute("recommendations", fuzzyInferenceService.run());
|
||||
return RECOMMENDATIONS;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue