-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
69 additions
and
74 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
dateroad-api/src/main/java/org/dateroad/advertisement/api/AdvertisementController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.dateroad.advertisement.api; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.dateroad.advertisement.dto.response.AdvGetAllRes; | ||
import org.dateroad.advertisement.dto.response.AdvGetDetailRes; | ||
import org.dateroad.advertisement.service.AdvertisementService; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1/advertisments") | ||
public class AdvertisementController { | ||
private final AdvertisementService advertisementService; | ||
|
||
@GetMapping | ||
public ResponseEntity<AdvGetAllRes> getAllAdvertisements(){ | ||
return ResponseEntity.ok(advertisementService.getAllAdvertisments()); | ||
} | ||
|
||
@GetMapping("{advId}") | ||
public ResponseEntity<AdvGetDetailRes> getAllAdvertisements( | ||
final @PathVariable Long advId | ||
){ | ||
return ResponseEntity.ok(advertisementService.getAdvertisementsDetail(advId)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...tisment/dto/response/AdvGetDetailRes.java → ...isement/dto/response/AdvGetDetailRes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
dateroad-api/src/main/java/org/dateroad/advertisment/api/AdvertismentController.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...nt/repository/AdvertismentRepository.java → ...t/repository/AdvertisementRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
package org.dateroad.advertisement.repository; | ||
|
||
import java.util.List; | ||
import org.dateroad.advertisement.domain.Advertisment; | ||
import org.dateroad.advertisement.domain.Advertisement; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface AdvertismentRepository extends JpaRepository<Advertisment, Long> { | ||
@Query("SELECT a FROM Advertisment a ORDER BY a.createdAt DESC") | ||
List<Advertisment> findTop5ByOrderByCreatedDateDesc(Pageable pageable); | ||
public interface AdvertisementRepository extends JpaRepository<Advertisement, Long> { | ||
@Query("SELECT a FROM Advertisement a ORDER BY a.createdAt DESC") | ||
List<Advertisement> findTop5ByOrderByCreatedDateDesc(Pageable pageable); | ||
} |