This commit is contained in:
parent
9666419ed2
commit
be3f70f14c
@ -1,23 +0,0 @@
|
||||
package ru.ulstu.fc.project.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import org.springframework.security.access.annotation.Secured;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import ru.ulstu.fc.project.model.Project;
|
||||
import ru.ulstu.fc.project.model.ProjectForm;
|
||||
import ru.ulstu.fc.project.service.ProjectRulesService;
|
||||
import ru.ulstu.fc.project.service.ProjectService;
|
||||
import ru.ulstu.fc.user.model.UserRoleConstants;
|
||||
|
||||
@Controller
|
||||
@Hidden
|
||||
@RequestMapping("projectRules")
|
||||
@Secured({UserRoleConstants.ADMIN})
|
||||
public class ProjecRulesController {
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package ru.ulstu.fc.rule.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import ru.ulstu.fc.project.model.Project;
|
||||
import ru.ulstu.fc.project.model.ProjectForm;
|
||||
import ru.ulstu.fc.rule.model.Rule;
|
||||
import ru.ulstu.fc.rule.model.RuleForm;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("rule")
|
||||
public class RuleController {
|
||||
private final RuleService ruleService;
|
||||
|
||||
public RuleController(RuleService ruleService) {
|
||||
this.ruleService = ruleService;
|
||||
}
|
||||
|
||||
@GetMapping("/edit/{ruleId}")
|
||||
public String edit(@PathVariable(value = "ruleId") Integer id, Model model) {
|
||||
model.addAttribute("rule",
|
||||
new RuleForm((id != null && id != 0)
|
||||
? ruleService.getById(id)
|
||||
: new Rule()));
|
||||
|
||||
return "rule/edit";
|
||||
}
|
||||
|
||||
@PostMapping(value = "save", params = "save")
|
||||
public String save(RuleForm ruleForm, Model model) {
|
||||
model.addAttribute("rule", ruleService.save(ruleForm));
|
||||
return "redirect:/project/edit/"+ruleForm.getProjectId();
|
||||
}
|
||||
|
||||
@PostMapping(value = "save", params = "delete")
|
||||
public String delete(RuleForm ruleForm) {
|
||||
if (ruleForm != null && ruleForm.getId() != null) {
|
||||
ruleService.delete(ruleForm);
|
||||
}
|
||||
return "redirect:/project/edit/"+ruleForm.getProjectId();
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package ru.ulstu.fc.rule.controller;
|
||||
|
||||
public class RuleService {
|
||||
|
||||
}
|
10
src/main/java/ru/ulstu/fc/rule/model/RuleForm.java
Normal file
10
src/main/java/ru/ulstu/fc/rule/model/RuleForm.java
Normal file
@ -0,0 +1,10 @@
|
||||
package ru.ulstu.fc.rule.model;
|
||||
|
||||
public class RuleForm {
|
||||
private final Integer projectId;
|
||||
|
||||
public Integer getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user