|
@ -0,0 +1,40 @@ |
|
|
|
|
|
package com.qyft.gd.controller; |
|
|
|
|
|
|
|
|
|
|
|
import com.qyft.gd.system.common.result.Result; |
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation; |
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
import java.nio.file.Files; |
|
|
|
|
|
import java.util.Base64; |
|
|
|
|
|
|
|
|
|
|
|
@Tag(name = "照片") |
|
|
|
|
|
@RestController |
|
|
|
|
|
@RequestMapping("/api/photo") |
|
|
|
|
|
@RequiredArgsConstructor |
|
|
|
|
|
@Slf4j |
|
|
|
|
|
public class PhotoController { |
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "获取上次拍照的照片") |
|
|
|
|
|
@GetMapping("/develop") |
|
|
|
|
|
public Result<String> develop() { |
|
|
|
|
|
String filePath = "/home/firefly/Desktop/gd/1.jpg"; |
|
|
|
|
|
try { |
|
|
|
|
|
File file = new File(filePath); |
|
|
|
|
|
byte[] fileBytes = Files.readAllBytes(file.toPath()); |
|
|
|
|
|
String encodedString = Base64.getEncoder().encodeToString(fileBytes); |
|
|
|
|
|
return Result.success(encodedString); |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
log.error("获取上次拍照的照片失败", e); |
|
|
|
|
|
return Result.failed(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |