package org.security.feign;

import lombok.AllArgsConstructor;
import org.security.config.ImagePlateFormDockProperties;
import org.security.desk.feign.IImagesClient;
import org.security.imagePlatformDock.service.IUploadFileService;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * @author ：wzf
 * @since ：Created in 2022/9/9 17:37
 */
@RestController
@AllArgsConstructor
public class ImagesClientImpl implements IImagesClient {

	private final IUploadFileService uploadFileService;
	private final ImagePlateFormDockProperties imagePlateFormDockProperties;
	@Override
//	@GetMapping(IMAGES_DATA)
	public R<String> getFileData(String busiBeginDate, String contentId,String fileName) {
		String result;
		try {
			result = uploadFileService.getData(busiBeginDate, contentId, fileName);
		} catch (IOException e) {
			return R.fail(e.getMessage());
		}
		return R.data(result);
	}

	@Override
	@GetMapping(REMOVE_IMAGES)
	public R removeFileData(String busiBeginDate, String contentId) {
		return uploadFileService.removeFileData(busiBeginDate,contentId);
	}

	@Override
	@GetMapping(FILE_SAVE_PATH)
	public R<String> getFileSavePath() {
		return R.data(imagePlateFormDockProperties.getService_path());
	}
}
