package com.fufan.mtsaas.modules.emoon.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/index")
public class MessageController {
    @PostMapping("/checkMessage")
    public ResponseEntity<Map<String, Object>> checkMessage(
            @RequestParam(required = false) String info,
            @RequestParam(required = false) String token) {
        if (info != null && !info.isEmpty()) {
            Map<String, Object> map = new HashMap<>();
            map.put("id", "AI");
            map.put("ghId", "exampleGhId");
            map.put("info", info);
            map.put("url", "https://example.com");
            map.put("time", LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
            return ResponseEntity.ok(map);
        }
        Map<String, Object> map = new HashMap<>();
        map.put("status", 0);
        return ResponseEntity.ok(map);
    }
}
