cicd + tool
This commit is contained in:
@@ -1,4 +1,40 @@
|
||||
package ru.ldeloff.aitools.datetime.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import reactor.core.publisher.Mono;
|
||||
import java.time.ZoneId;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class TimeController {
|
||||
|
||||
@GetMapping("/time/moscow")
|
||||
@Operation(summary = "Get current Moscow time", description = "Returns current date and time in Moscow timezone (Europe/Moscow) as ISO 8601 string. Used as a tool for LLMs to get accurate local time.")
|
||||
@ApiResponses({
|
||||
@ApiResponse(responseCode = "200", description = "Current time in Moscow in format yyyy-MM-dd HH:mm:ss"),
|
||||
@ApiResponse(responseCode = "500", description = "Internal server error")
|
||||
})
|
||||
public Mono<TimeResponse> getMoscowTime() {
|
||||
log.info("getMoscowTime");
|
||||
return Mono.fromSupplier(() -> {
|
||||
LocalDateTime moscowTime = LocalDateTime.now(ZoneId.of("Europe/Moscow"));
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
return new TimeResponse(moscowTime.format(formatter));
|
||||
});
|
||||
}
|
||||
|
||||
public static class TimeResponse {
|
||||
public final String time;
|
||||
|
||||
public TimeResponse(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
spring.application.name=aitools
|
||||
|
||||
springdoc.api-docs.path=/api-docs
|
||||
|
||||
Reference in New Issue
Block a user