package org.wfc.system.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.wfc.common.core.domain.R;
import org.wfc.common.core.web.page.TableDataInfo;
import org.wfc.omada.api.log.model.DeleteSiteAlertLogListOpenApiVo;
import org.wfc.omada.api.log.model.ResolveSiteLogListOpenApiVo;
import org.wfc.system.service.ISysOmadaLogService;

/**
 * @description: omada log controller
 * @author: cyc
 * @since: 2025-06-03
 */
@RestController
@RequestMapping("/log")
public class SysOmadaLogController {

    @Autowired
    private ISysOmadaLogService sysOmadaLogService;

    @GetMapping("/alerts/{siteId}")
    public TableDataInfo getAlertLogsForSite(@PathVariable String siteId, @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize, @RequestParam(value = "filters.timeStart", required = true) Long filtersTimeStart, @RequestParam(value = "filters.timeEnd", required = true) Long filtersTimeEnd, @RequestParam(value = "filters.module", required = false) String filtersModule, @RequestParam(value = "filters.resolved", required = false) Boolean filtersResolved) {
        return sysOmadaLogService.getAlertLogsForSite(siteId, pageNum, pageSize, filtersTimeStart, filtersTimeEnd, filtersModule, filtersResolved);
    }

    @PostMapping("/alerts/{siteId}")
    public R<Boolean> resolveAlertForSite(@PathVariable(required = true) String siteId, @RequestBody(required = false) ResolveSiteLogListOpenApiVo resolveSiteLogListOpenApiVo) {
        return R.ok(sysOmadaLogService.resolveAlertForSite(siteId, resolveSiteLogListOpenApiVo));
    }

    @DeleteMapping("/alerts/{siteId}")
    public R<Boolean> deleteAlertLogsForSite(@PathVariable(required = true) String siteId, @RequestBody(required = false) DeleteSiteAlertLogListOpenApiVo deleteSiteAlertLogListOpenApiVo) {
        return R.ok(sysOmadaLogService.deleteAlertLogsForSite(siteId, deleteSiteAlertLogListOpenApiVo));
    }

}
