package com.njcn.filesync.controller;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.filesync.service.FileSyncService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * Description:
 * Date: 2025/10/20  下午 2:55【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/filesync")
@RequiredArgsConstructor
@Api(tags = "文件同步")
public class FileSyncController extends BaseController {
    private final FileSyncService fileSyncService;
    /**
     * 手动触发跨服务器同步
     */
    @PostMapping("/trigger")
    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @ApiOperation("暂态文件同步手动触发")
    public HttpResult<Boolean> triggerCrossSync() {
        String methodDescribe = getMethodDescribe("triggerCrossSync");

        boolean flag =fileSyncService.triggerCrossSync();

        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,flag , methodDescribe);
    }

    @GetMapping("/EventWavePathSYnc")
    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @ApiOperation("暂态文件同步手动触发")
    public HttpResult<Boolean> EventWavePathSYnc(@RequestParam("startDateTime")   String startDateTime, @RequestParam("endDateTime")  String endDateTime) {
        String methodDescribe = getMethodDescribe("triggerCrossSync");

        fileSyncService.EventWavePathSYnc(startDateTime,endDateTime);

        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,true , methodDescribe);
    }
}
