package com.gameplatform.server.controller;

import com.gameplatform.server.mapper.log.ScriptOperationLogMapper;
import com.gameplatform.server.model.entity.log.ScriptOperationLog;
import com.gameplatform.server.model.enums.ScriptOperationType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 脚本操作日志查询接口
 */
@RestController
@RequestMapping("/api/admin/script-operation-log")
@Slf4j
public class ScriptOperationLogController {

    @Autowired
    private ScriptOperationLogMapper logMapper;

    /**
     * 根据设备ID查询操作记录
     */
    // @GetMapping("/machine/{machineId}")
    // public List<ScriptOperationLog> getByMachineId(@PathVariable String machineId,
    //                                               @RequestParam(defaultValue = "10") Integer limit) {
    //     return logMapper.findByMachineId(machineId, limit);
    // }

    // /**
    //  * 根据操作类型查询记录
    //  */
    // @GetMapping("/type/{operationType}")
    // public List<ScriptOperationLog> getByOperationType(@PathVariable ScriptOperationType operationType,
    //                                                   @RequestParam(defaultValue = "10") Integer limit) {
    //     return logMapper.findByOperationType(operationType, limit);
    // }

    // /**
    //  * 查询失败的操作记录
    //  */
    // @GetMapping("/failed")
    // public List<ScriptOperationLog> getFailedOperations(@RequestParam(defaultValue = "10") Integer limit) {
    //     LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
    //     LocalDateTime now = LocalDateTime.now();
    //     return logMapper.findFailedOperations(yesterday, now, limit);
    // }

    // /**
    //  * 获取操作统计信息
    //  */
    // @GetMapping("/statistics")
    // public List<Map<String, Object>> getStatistics(@RequestParam(defaultValue = "1") Integer days) {
    //     LocalDateTime startTime = LocalDateTime.now().minusDays(days);
    //     LocalDateTime endTime = LocalDateTime.now();
    //     return logMapper.getOperationStatistics(startTime, endTime);
    // }

    // /**
    //  * 查询最近的操作记录
    //  */
    // @GetMapping("/recent")
    // public List<ScriptOperationLog> getRecentOperations(@RequestParam(defaultValue = "20") Integer limit) {
    //     LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
    //     LocalDateTime now = LocalDateTime.now();
    //     return logMapper.findByTimeRange(yesterday, now, limit);
    // }
}
