package com.example.demo.controller;

import com.example.demo.model.ApiResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * 健康检查控制器。
 *
 * <p>提供应用存活性和基本状态检查接口，用于监控与运维。</p>
 */
@RestController
@RequestMapping("/api")
@Tag(name = "健康检查", description = "系统健康检查与状态查看")
public class HealthController {

    /**
     * 健康检查端点。
     *
     * @return 系统状态信息
     */
    @GetMapping("/health")
    @Operation(summary = "健康检查", description = "返回系统当前运行状态及时间")
    public ApiResult<Map<String, Object>> health() {
        Map<String, Object> status = Map.of(
                "status", "UP",
                "timestamp", LocalDateTime.now().toString(),
                "service", "IMS-Demo"
        );
        return ApiResult.success(status);
    }
}
