55
55
import ru .mystamps .web .service .dto .EntityInfoDto ;
56
56
import ru .mystamps .web .support .spring .security .SecurityContextUtils ;
57
57
import ru .mystamps .web .util .CatalogUtils ;
58
+ import ru .mystamps .web .validation .ValidationRules ;
58
59
59
60
@ Controller
60
61
@ RequiredArgsConstructor
@@ -63,13 +64,27 @@ public class SeriesController {
63
64
private static final Integer SINCE_YEAR = 1840 ;
64
65
private static final Integer CURRENT_YEAR = new GregorianCalendar ().get (Calendar .YEAR );
65
66
67
+ private static final Map <Integer , Integer > DAYS ;
68
+ private static final Map <Integer , Integer > MONTHS ;
66
69
private static final Map <Integer , Integer > YEARS ;
67
70
68
71
private final CategoryService categoryService ;
69
72
private final CountryService countryService ;
70
73
private final SeriesService seriesService ;
71
74
72
75
static {
76
+ DAYS = new LinkedHashMap <>(ValidationRules .MAX_DAYS_IN_MONTH );
77
+ for (int i = 1 ; i <= ValidationRules .MAX_DAYS_IN_MONTH ; i ++) {
78
+ Integer day = Integer .valueOf (i );
79
+ DAYS .put (day , day );
80
+ }
81
+
82
+ MONTHS = new LinkedHashMap <>(ValidationRules .MAX_MONTHS_IN_YEAR );
83
+ for (int i = 1 ; i <= ValidationRules .MAX_MONTHS_IN_YEAR ; i ++) {
84
+ Integer month = Integer .valueOf (i );
85
+ MONTHS .put (month , month );
86
+ }
87
+
73
88
YEARS = new LinkedHashMap <>();
74
89
for (Integer i = CURRENT_YEAR ; i >= SINCE_YEAR ; i --) {
75
90
YEARS .put (i , i );
@@ -86,6 +101,16 @@ protected void initBinder(WebDataBinder binder) {
86
101
binder .registerCustomEditor (String .class , "comment" , new StringTrimmerEditor (true ));
87
102
}
88
103
104
+ @ ModelAttribute ("days" )
105
+ public Map <Integer , Integer > getDays () {
106
+ return DAYS ;
107
+ }
108
+
109
+ @ ModelAttribute ("months" )
110
+ public Map <Integer , Integer > getMonths () {
111
+ return MONTHS ;
112
+ }
113
+
89
114
@ ModelAttribute ("years" )
90
115
public Map <Integer , Integer > getYears () {
91
116
return YEARS ;
0 commit comments