change repository to service in wishlist, add @Lazy

This commit is contained in:
Patryk
2025-05-13 20:54:39 +02:00
parent cdd31fd6b7
commit f0e3a129d0
3 changed files with 17 additions and 26 deletions

View File

@@ -48,7 +48,6 @@ public class NoticeController {
if (dto.getCategory() == null) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new NoticeAdditionDTO("Nie ma takiej kategorii"));
}
dto.setPublishDate(java.time.LocalDateTime.now());
Long newNoticeId = noticeService.addNotice(dto);
@@ -56,7 +55,6 @@ public class NoticeController {
return ResponseEntity.status(HttpStatus.CREATED).body(new NoticeAdditionDTO(newNoticeId ,"Dodano ogłoszenie."));
}
// TODO: zamiast dodawać tutaj pętlą, musi to robić NoticeService, trzeba zaimplementować odpowienią metodę
@PostMapping("/bulk_add")
public ResponseEntity<String> addNotices(@RequestBody List<NoticeDTO> notices_list) {

View File

@@ -15,7 +15,6 @@ import java.util.List;
@RestController
@RequestMapping("/api/v1/wishlist")
public class WishlistController {
private final WishlistService wishlistService;
private final ClientService clientService;
private final NoticeService noticeService;
@@ -30,7 +29,6 @@ public class WishlistController {
public ResponseEntity<RequestResponseDTO> toggleWishlist(@RequestBody WishlistDTO wishlistDTO) {
Long noticeId = wishlistDTO.getNoticeId();
Long clientId = wishlistDTO.getClientId();
NoticeDTO noticeDTO = noticeService.getNoticeById(noticeId);
if (noticeDTO == null) {
return ResponseEntity.badRequest().body(new RequestResponseDTO("Notice not found"));
@@ -47,21 +45,15 @@ public class WishlistController {
}
}
@GetMapping("/{clientId}")
public ResponseEntity<List<WishlistDTO>> getWishlist(@PathVariable Long clientId) {
List<WishlistDTO> wishlist = wishlistService.getWishlistForClientId(clientId);
return ResponseEntity.ok(wishlist);
}
//
// @GetMapping("/get/all")
// public List<NoticeDTO> getAllNotices() {
// return noticeService.getAllNotices();
// @GetMapping("/{clientId}")
// public ResponseEntity<List<WishlistDTO>> getWishlist(@PathVariable Long clientId) {
// List<WishlistDTO> wishlist = wishlistService.getWishlistForClientId(clientId);
// return ResponseEntity.ok(wishlist);
// }
@GetMapping("/")
public List<NoticeDTO> getWishlistForClient() {
Long clientId =1L;
return wishlistService.getNoticesInWishlist(clientId);
}
@GetMapping("/")
public List<NoticeDTO> getWishlistForClient() {
Long clientId =1L;
return wishlistService.getNoticesInWishlist(clientId);
}
}