-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathTimeController.java
More file actions
34 lines (26 loc) · 1009 Bytes
/
TimeController.java
File metadata and controls
34 lines (26 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package org.example.weeklab4.controller;
import org.example.weeklab4.service.TimeService;
import org.springframework.web.bind.annotation.*;
import java.util.LinkedHashMap;
import java.util.Map;
@RestController
public class TimeController {
private final TimeService timeService;
public TimeController(TimeService timeService) {
this.timeService = timeService;
}
@GetMapping("/time")
public String getTime() { return timeService.getCurrentTime(); }
@GetMapping("/date")
public String getDate() { return timeService.getCurrentDate(); }
@GetMapping("/day")
public String getDay() { return timeService.getDayOfWeek(); }
@GetMapping("/all")
public Map<String, String> getAllTime() {
Map<String, String> response = new LinkedHashMap<>();
response.put("time", timeService.getCurrentTime());
response.put("date", timeService.getCurrentDate());
response.put("day", timeService.getDayOfWeek());
return response;
}
}