Skip to content

Commit 4ccf526

Browse files
committed
add a form for holding values
1 parent 3cc13dc commit 4ccf526

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (C) 2009-2025 Slava Semushin <slava.semushin@gmail.com>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*/
18+
19+
package ru.mystamps.web.feature.series;
20+
21+
import lombok.Getter;
22+
import lombok.Setter;
23+
24+
import javax.validation.constraints.NotNull;
25+
import java.math.BigDecimal;
26+
27+
@Getter
28+
@Setter
29+
public class AddCatalogPriceForm {
30+
@NotNull
31+
private StampsCatalog catalogName;
32+
33+
// @todo #1340 Update series: add validation for a price
34+
@NotNull
35+
private BigDecimal price;
36+
}

src/main/java/ru/mystamps/web/feature/series/HtmxSeriesController.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ public String addCatalogNumbers(
140140
)
141141
public String addCatalogPrice(
142142
@PathVariable("id") Integer seriesId,
143+
@Valid AddCatalogPriceForm form,
144+
BindingResult result,
143145
@AuthenticationPrincipal CustomUserDetails currentUser,
144146
HttpServletResponse response
145147
) throws IOException {
@@ -154,14 +156,20 @@ public String addCatalogPrice(
154156
return null;
155157
}
156158

159+
if (result.hasErrors()) {
160+
response.setStatus(HttpStatus.UNPROCESSABLE_ENTITY.value());
161+
// XXX: implement
162+
return null;
163+
}
164+
157165
// XXX: implement
158166
System.out.println("PATCH add catalog price");
159167

160168
Integer currentUserId = currentUser.getUserId();
161169
seriesService.addCatalogPrice(
162-
StampsCatalog.MICHEL, // XXX
170+
form.getCatalogName(),
163171
seriesId,
164-
BigDecimal.TEN, // XXX
172+
form.getPrice(),
165173
currentUserId
166174
);
167175

src/main/java/ru/mystamps/web/feature/series/RestSeriesController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class RestSeriesController {
4444
private final SeriesService seriesService;
4545
private final SeriesImageService seriesImageService;
4646

47-
// @todo #1340 Update series: add validation for a price
4847
// @todo #1343 Update series: add validation for a release year
4948
@PatchMapping(SeriesUrl.INFO_SERIES_PAGE)
5049
public ResponseEntity<Void> updateSeries(

0 commit comments

Comments
 (0)