//package com.backendsys.service.System;
//
//import org.springframework.jdbc.core.JdbcTemplate;
//import org.springframework.stereotype.Service;
//
//import java.util.HashMap;
//import java.util.Map;
//
//@Service
//public class SysActuatorServiceImpl implements SysActuatorService{
//
//    //@Autowired
//    //private HttpActuatorService httpActuatorService;
//
//    //@Override
//    //public Map<String, Object> requestActuatorMetrics() {
//    //    Map<String, Object> map = new HashMap<>();
//    //    // [Get] [metrics.application.started.time] 应用启动时间
//    //    List<Map<String, Object>> applicationStartedTime = httpActuatorService.getMetricsApplicationStartedTime();
//    //    map.put("applicationStartedTime", applicationStartedTime);
//    //    return map;
//    //}
//    private final JdbcTemplate jdbcTemplate;
//
//    public SysActuatorServiceImpl(JdbcTemplate jdbcTemplate) {
//        this.jdbcTemplate = jdbcTemplate;
//    }
//
//    @Override
//    public Map<String, Object> querySystemInfo() {
//        Map<String, Object> map = new HashMap<>();
//        map.put("os_name", System.getProperty("os.name"));
//        map.put("os_version", System.getProperty("os.version"));
//
//        String sql = "SELECT VERSION()";
//        map.put("sql_version", jdbcTemplate.queryForObject(sql, String.class));
//
//        // 以后有空再来优化？
//
//
//        // 获取内存管理的 MXBean 对象
//        //MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
//
//        //// 获取堆内存使用情况
//        //MemoryUsage heapMemoryUsage = memoryMXBean.getHeapMemoryUsage();
//        //System.out.println("Heap Memory Usage:");
//        //System.out.println("  - Initial: " + heapMemoryUsage.getInit());
//        //System.out.println("  - Used: " + heapMemoryUsage.getUsed());
//        //System.out.println("  - Committed: " + heapMemoryUsage.getCommitted());
//        //System.out.println("  - Max: " + heapMemoryUsage.getMax());
//        //
//        //// 获取非堆内存使用情况
//        //MemoryUsage nonHeapMemoryUsage = memoryMXBean.getNonHeapMemoryUsage();
//        //System.out.println("Non-Heap Memory Usage:");
//        //System.out.println("  - Initial: " + nonHeapMemoryUsage.getInit());
//        //System.out.println("  - Used: " + nonHeapMemoryUsage.getUsed());
//        //System.out.println("  - Committed: " + nonHeapMemoryUsage.getCommitted());
//        //System.out.println("  - Max: " + nonHeapMemoryUsage.getMax());
//
//        return map;
//    }
//
//}
