Revize 159626c0
Přidáno uživatelem Lukas Cerny před téměř 6 roky(ů)
server/src/main/java/cz/zcu/yamanager/dto/CalendarItem.java | ||
---|---|---|
9 | 9 |
private LocalTime from; |
10 | 10 |
private LocalTime to; |
11 | 11 |
private VacationType type; |
12 |
private RequestStatus status; |
|
12 | 13 |
|
13 | 14 |
public LocalDate getDate() { |
14 | 15 |
return date; |
... | ... | |
41 | 42 |
public void setType(VacationType type) { |
42 | 43 |
this.type = type; |
43 | 44 |
} |
45 |
|
|
46 |
public RequestStatus getStatus() { |
|
47 |
return status; |
|
48 |
} |
|
49 |
|
|
50 |
public void setStatus(RequestStatus status) { |
|
51 |
this.status = status; |
|
52 |
} |
|
44 | 53 |
} |
server/src/main/java/cz/zcu/yamanager/dto/CalendarView.java | ||
---|---|---|
1 |
package cz.zcu.yamanager.dto; |
|
2 |
|
|
3 |
import java.time.LocalDate; |
|
4 |
import java.time.LocalTime; |
|
5 |
|
|
6 |
public class CalendarView { |
|
7 |
|
|
8 |
private LocalDate date; |
|
9 |
private LocalTime from; |
|
10 |
private LocalTime to; |
|
11 |
private VacationType type; |
|
12 |
private RequestStatus status; |
|
13 |
|
|
14 |
public LocalDate getDate() { |
|
15 |
return date; |
|
16 |
} |
|
17 |
|
|
18 |
public void setDate(LocalDate date) { |
|
19 |
this.date = date; |
|
20 |
} |
|
21 |
|
|
22 |
public LocalTime getFrom() { |
|
23 |
return from; |
|
24 |
} |
|
25 |
|
|
26 |
public void setFrom(LocalTime from) { |
|
27 |
this.from = from; |
|
28 |
} |
|
29 |
|
|
30 |
public LocalTime getTo() { |
|
31 |
return to; |
|
32 |
} |
|
33 |
|
|
34 |
public void setTo(LocalTime to) { |
|
35 |
this.to = to; |
|
36 |
} |
|
37 |
|
|
38 |
public VacationType getType() { |
|
39 |
return type; |
|
40 |
} |
|
41 |
|
|
42 |
public void setType(VacationType type) { |
|
43 |
this.type = type; |
|
44 |
} |
|
45 |
|
|
46 |
public RequestStatus getStatus() { |
|
47 |
return status; |
|
48 |
} |
|
49 |
|
|
50 |
public void setStatus(RequestStatus status) { |
|
51 |
this.status = status; |
|
52 |
} |
|
53 |
} |
server/src/main/java/cz/zcu/yamanager/dto/DefaultSettings.java | ||
---|---|---|
3 | 3 |
import java.time.LocalDateTime; |
4 | 4 |
|
5 | 5 |
public class DefaultSettings { |
6 |
|
|
6 | 7 |
private VacationInfo sickDay; |
7 | 8 |
private LocalDateTime notification; |
8 | 9 |
|
server/src/main/java/cz/zcu/yamanager/dto/RequestType.java | ||
---|---|---|
1 | 1 |
package cz.zcu.yamanager.dto; |
2 | 2 |
|
3 | 3 |
public enum RequestType { |
4 |
VACATION, AUTHORIZATION |
|
4 |
VACATION, SICK_DAY, AUTHORIZATION
|
|
5 | 5 |
} |
server/src/main/java/cz/zcu/yamanager/ws/rest/ApiController.java | ||
---|---|---|
38 | 38 |
|
39 | 39 |
CalendarItem calendarItem = new CalendarItem(); |
40 | 40 |
calendarItem.setType(VacationType.SICKDAY); |
41 |
calendarItem.setStatus(RequestStatus.ACCEPTED); |
|
41 | 42 |
calendarItem.setDate(LocalDate.now()); |
42 | 43 |
calendarItem.setFrom(LocalTime.now()); |
43 | 44 |
calendarItem.setTo(LocalTime.now()); |
... | ... | |
75 | 76 |
} |
76 | 77 |
|
77 | 78 |
@RequestMapping(value = "/users/requests", method=GET) |
78 |
public UserRequest userRequests(@RequestParam("type") String type) {
|
|
79 |
public UserRequest userRequests(@RequestParam(value = "type", required = false) String type) {
|
|
79 | 80 |
RequestType requestType = RequestType.valueOf(type); |
80 | 81 |
|
81 | 82 |
UserName userName = new UserName(); |
... | ... | |
111 | 112 |
|
112 | 113 |
|
113 | 114 |
@RequestMapping(value = "/user/calendar", method=GET) |
114 |
public List<CalendarView> personalCalendarView(@RequestParam("viewType") String viewType, @RequestParam("value") String value) {
|
|
115 |
public List<CalendarItem> personalCalendarView(@RequestParam("viewType") String viewType, @RequestParam("value") String value) {
|
|
115 | 116 |
CalendarViewType calendarViewType = CalendarViewType.valueOf(viewType); |
116 | 117 |
int numberOfView = Integer.valueOf(value); |
117 | 118 |
|
118 |
List<CalendarView> calendarViews = new ArrayList<>();
|
|
119 |
List<CalendarItem> calendarItems = new ArrayList<>();
|
|
119 | 120 |
|
120 |
CalendarView view = new CalendarView();
|
|
121 |
CalendarItem view = new CalendarItem();
|
|
121 | 122 |
view.setStatus(RequestStatus.PENDING); |
122 | 123 |
view.setType(VacationType.SICKDAY); |
123 | 124 |
view.setDate(LocalDate.now()); |
124 | 125 |
view.setFrom(LocalTime.of(9, 30)); |
125 | 126 |
view.setTo(LocalTime.of(18, 30)); |
126 | 127 |
|
127 |
calendarViews.add(view);
|
|
128 |
calendarItems.add(view);
|
|
128 | 129 |
|
129 |
return calendarViews;
|
|
130 |
return calendarItems;
|
|
130 | 131 |
} |
131 | 132 |
|
132 | 133 |
@RequestMapping(value = "/user/{id}/calendar", method=GET) |
133 |
public List<CalendarView> userCalendarView(@PathVariable("id") String id, @RequestParam("viewType") String viewType, @RequestParam("value") String value) {
|
|
134 |
public List<CalendarItem> userCalendarView(@PathVariable("id") String id, @RequestParam("viewType") String viewType, @RequestParam("value") String value) {
|
|
134 | 135 |
CalendarViewType calendarViewType = CalendarViewType.valueOf(viewType); |
135 | 136 |
int numberOfView = Integer.valueOf(value); |
136 | 137 |
long userId = Long.valueOf(id); |
137 | 138 |
|
138 |
List<CalendarView> calendarViews = new ArrayList<>();
|
|
139 |
List<CalendarItem> calendarItems = new ArrayList<>();
|
|
139 | 140 |
|
140 |
CalendarView view = new CalendarView();
|
|
141 |
CalendarItem view = new CalendarItem();
|
|
141 | 142 |
view.setStatus(RequestStatus.PENDING); |
142 | 143 |
view.setType(VacationType.SICKDAY); |
143 | 144 |
view.setDate(LocalDate.now()); |
144 | 145 |
view.setFrom(LocalTime.of(9, 30)); |
145 | 146 |
view.setTo(LocalTime.of(18, 30)); |
146 | 147 |
|
147 |
calendarViews.add(view);
|
|
148 |
calendarItems.add(view);
|
|
148 | 149 |
|
149 |
return calendarViews;
|
|
150 |
return calendarItems;
|
|
150 | 151 |
} |
151 | 152 |
|
152 | 153 |
@RequestMapping(value = "/settings/default", method=GET) |
... | ... | |
166 | 167 |
// *********************** POST **************************** |
167 | 168 |
|
168 | 169 |
@RequestMapping(value = "/user/calendar", method=POST) |
169 |
public ResponseEntity personalCalendarView(@RequestBody CalendarView calendarView) {
|
|
170 |
public ResponseEntity personalCalendarView(@RequestBody CalendarItem calendarItem) {
|
|
170 | 171 |
|
171 |
if (calendarView == null) {
|
|
172 |
if (calendarItem == null) {
|
|
172 | 173 |
return ResponseEntity.badRequest().build(); |
173 | 174 |
} |
174 | 175 |
|
Také k dispozici: Unified diff
Re #7471 edited design of APIs based on consultation