Add indicator max value
This commit is contained in:
parent
8b8d64bd00
commit
bf57c20b96
@ -5,6 +5,8 @@ public class IndicatorForm {
|
|||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
private int max;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@ -20,4 +22,12 @@ public class IndicatorForm {
|
|||||||
public void setId(Integer id) {
|
public void setId(Integer id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMax() {
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMax(int max) {
|
||||||
|
this.max = max;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,10 @@ public class AdminService {
|
|||||||
|
|
||||||
public void saveIndicator(IndicatorForm indicatorForm) {
|
public void saveIndicator(IndicatorForm indicatorForm) {
|
||||||
Indicator indicator = indicatorForm.getId() == null
|
Indicator indicator = indicatorForm.getId() == null
|
||||||
? new Indicator(indicatorForm.getName())
|
? new Indicator(indicatorForm)
|
||||||
: indicatorService.getIndicatorById(indicatorForm.getId());
|
: indicatorService.getIndicatorById(indicatorForm.getId());
|
||||||
indicator.setName(indicatorForm.getName());
|
indicator.setName(indicatorForm.getName());
|
||||||
|
indicator.setMax(indicatorForm.getMax());
|
||||||
indicatorService.save(indicator);
|
indicatorService.save(indicator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package ru.ulstu.indicator.model;
|
package ru.ulstu.indicator.model;
|
||||||
|
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.validation.constraints.Max;
|
||||||
|
import jakarta.validation.constraints.Min;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import ru.ulstu.admin.model.IndicatorForm;
|
||||||
import ru.ulstu.model.BaseEntity;
|
import ru.ulstu.model.BaseEntity;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@ -10,11 +13,16 @@ public class Indicator extends BaseEntity {
|
|||||||
@NotBlank
|
@NotBlank
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@Min(0)
|
||||||
|
@Max(30)
|
||||||
|
private int max;
|
||||||
|
|
||||||
public Indicator() {
|
public Indicator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Indicator(String name) {
|
public Indicator(IndicatorForm indicatorForm) {
|
||||||
this.name = name;
|
this.name = indicatorForm.getName();
|
||||||
|
this.max = indicatorForm.getMax();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -24,4 +32,12 @@ public class Indicator extends BaseEntity {
|
|||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMax() {
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMax(int max) {
|
||||||
|
this.max = max;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,17 +4,24 @@
|
|||||||
layout:decorate="~{default}">
|
layout:decorate="~{default}">
|
||||||
<div class="container" layout:fragment="content">
|
<div class="container" layout:fragment="content">
|
||||||
<h3>Редактирование показателя:</h3>
|
<h3>Редактирование показателя:</h3>
|
||||||
<form action="#" th:action="@{/admin/saveIndicator}" th:object="${indicator}" method="post"
|
<form action="#" th:action="@{/admin/saveIndicator}"
|
||||||
|
th:object="${indicator}"
|
||||||
|
method="post"
|
||||||
enctype="multipart/form-data">
|
enctype="multipart/form-data">
|
||||||
<input type="hidden" th:field="*{id}">
|
<input type="hidden" th:field="*{id}">
|
||||||
<input type="hidden" th:field="*{version}">
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="name">Название</label>
|
<label for="name">Название</label>
|
||||||
<input type="text" class="form-control" id="name" th:field="*{name}" placeholder="Название показателя">
|
<input type="text" required class="form-control" id="name" th:field="*{name}"
|
||||||
|
placeholder="Название показателя">
|
||||||
<p th:if="${#fields.hasErrors('name')}" th:class="${#fields.hasErrors('name')}? error">
|
<p th:if="${#fields.hasErrors('name')}" th:class="${#fields.hasErrors('name')}? error">
|
||||||
Не может быть пустым</p>
|
Не может быть пустым</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">Максимальная сумма баллов</label>
|
||||||
|
<input type="number" required class="form-control" id="max" min="0" , max="30" th:field="*{max}">
|
||||||
|
</div>
|
||||||
|
|
||||||
<button name="save" type="submit" class="btn btn-outline-dark">Сохранить</button>
|
<button name="save" type="submit" class="btn btn-outline-dark">Сохранить</button>
|
||||||
<button name="delete"
|
<button name="delete"
|
||||||
type="submit"
|
type="submit"
|
||||||
|
Loading…
Reference in New Issue
Block a user