Skip to content

Commit

Permalink
edit photo
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoyen05 committed Dec 24, 2024
1 parent b70c6a9 commit 7840041
Showing 1 changed file with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import java.util.Optional;
import com.example.lake_catalog.model.*;
import com.example.lake_catalog.repository.LakeRepository;
Expand Down Expand Up @@ -97,7 +99,7 @@ public ResponseEntity<Map<String, Boolean>> checkEmailUnique(@RequestBody Map<St

@PutMapping("/profile/{userId}/update-profile")
public ResponseEntity<Map<String, String>> updateUserProfile(
@PathVariable Long userId, // Заменили @RequestParam на @PathVariable для userId
@PathVariable Long userId,
@RequestParam String newName,
@RequestParam String newEmail) {
try {
Expand All @@ -113,11 +115,30 @@ public ResponseEntity<Map<String, String>> updateUserProfile(
}
}

@PutMapping("/profile/{userId}/update-photo-url")
public ResponseEntity<Map<String, String>> updateUserPhotoUrl(
@PathVariable Long userId,
@RequestBody Map<String, String> request) {
try {
String photoUrl = request.get("photoUrl");
userService.updateUserPhotoUrl(userId, photoUrl);

Map<String, String> response = new HashMap<>();
response.put("message", "Ссылка на фото обновлена успешно!");
return ResponseEntity.ok(response);
} catch (IllegalArgumentException e) {
return ResponseEntity.badRequest()
.body(Map.of("message", e.getMessage()));
}
}



@GetMapping("/profile/{userId}/imp_exp/export")
public void exportLakes(HttpServletResponse response) throws IOException {
List<Lake> lakes = lakeRepository.findAll();

// Преобразуем каждый объект в нужный формат

List<Map<String, Object>> exportData = new ArrayList<>();
for (Lake lake : lakes) {
Map<String, Object> lakeData = new HashMap<>();
Expand All @@ -132,7 +153,7 @@ public void exportLakes(HttpServletResponse response) throws IOException {
properties.put("photos", lake.getPhotos());

Map<String, Object> lakeItem = new HashMap<>();
lakeItem.put("identity", lake.getId()); // предполагаем, что getId() возвращает идентификатор
lakeItem.put("identity", lake.getId());
lakeItem.put("labels", List.of("Lake"));
lakeItem.put("properties", properties);

Expand Down

0 comments on commit 7840041

Please sign in to comment.