package com.starry.admin.modules.system.controller;

import com.starry.common.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Health Check Controller
 *
 * @author admin
 * @since 2025/08/30
 */
@Api(tags = "健康检查", description = "服务健康状态检查接口")
@RestController
@RequestMapping("/health")
public class HealthController {

    @ApiOperation(value = "健康检查", notes = "检查服务是否正常运行")
    @ApiResponses({@ApiResponse(code = 200, message = "服务正常运行")})
    @GetMapping
    public R health() {
        Map<String, Object> data = new HashMap<>();
        data.put("status", "UP");
        data.put("message", "Hello, I'm alive!");
        data.put("timestamp", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        data.put("service", "peipei-backend");
        return R.ok(data);
    }

    @ApiOperation(value = "简单检查", notes = "最简单的存活检查")
    @ApiResponses({@ApiResponse(code = 200, message = "服务正常")})
    @GetMapping("/ping")
    public R ping() {
        return R.ok("pong");
    }
}
