package com.njcn.rdms.module.system.api.file;

import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.module.system.api.file.dto.FileContentCreateReqDTO;
import com.njcn.rdms.module.system.api.file.dto.FileRespDTO;
import com.njcn.rdms.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(name = ApiConstants.NAME)
@Tag(name = "RPC 服务 - 文件")
public interface FileApi {

    String PREFIX = ApiConstants.PREFIX + "/file";

    @GetMapping(PREFIX + "/get-by-url")
    @Operation(summary = "通过文件 URL 查询文件")
    @Parameter(name = "url", description = "文件 URL", required = true)
    CommonResult<FileRespDTO> getFileByUrl(@RequestParam("url") String url);

    @GetMapping(PREFIX + "/get")
    @Operation(summary = "通过文件 ID 查询文件")
    @Parameter(name = "id", description = "文件 ID", required = true)
    CommonResult<FileRespDTO> getFile(@RequestParam("id") Long id);

    @GetMapping(PREFIX + "/content")
    @Operation(summary = "通过文件 ID 读取文件内容")
    @Parameter(name = "id", description = "文件 ID", required = true)
    CommonResult<byte[]> getFileContent(@RequestParam("id") Long id);

    @PostMapping(PREFIX + "/create-by-content")
    @Operation(summary = "通过文件字节创建文件")
    CommonResult<Long> createFileByContent(@RequestBody FileContentCreateReqDTO reqDTO);

}
