package com.njcn.event.controller.majornetwork;

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.common.utils.HttpResultUtil;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.event.service.majornetwork.AutonomeWaveService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @version 1.0.0
 * @author: zbj
 * @date: 2023/04/23
 */
@Slf4j
@Api(tags = "离线波形查看")
@RestController
@RequestMapping("/autonomeWave")
@RequiredArgsConstructor
public class AutonomeWaveController extends BaseController {

    private final AutonomeWaveService autonomeWaveService;

    /**
     * 上传文件并且展示波形
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/uploadFileAndViewWave")
    @ApiOperation("上传文件并且展示波形")
    public HttpResult<WaveDataDTO> uploadFileAndViewWave(@ApiParam(value = "文件1", required = true) @RequestPart("file1") MultipartFile file1,
                                                         @ApiParam(value = "文件2", required = true) @RequestPart("file2") MultipartFile file2) throws IOException {
        String methodDescribe = getMethodDescribe("uploadFileAndViewWave");
        WaveDataDTO result =  autonomeWaveService.uploadFileAndViewWave(file1, file2);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

}
