-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from kakao-tech-campus-2nd-step3/weekly
Weekly 정기 병합
- Loading branch information
Showing
48 changed files
with
1,017 additions
and
158 deletions.
There are no files selected for viewing
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
21 changes: 21 additions & 0 deletions
21
src/main/java/com/helpmeCookies/global/entity/BaseTimeEntity.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,21 @@ | ||
package com.helpmeCookies.global.entity; | ||
|
||
import jakarta.persistence.EntityListeners; | ||
import jakarta.persistence.MappedSuperclass; | ||
import java.time.LocalDateTime; | ||
import lombok.Getter; | ||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.annotation.LastModifiedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
@MappedSuperclass | ||
@EntityListeners(AuditingEntityListener.class) | ||
@Getter | ||
public abstract class BaseTimeEntity { | ||
|
||
@CreatedDate | ||
private LocalDateTime createdDate; | ||
|
||
@LastModifiedDate | ||
private LocalDateTime modifiedDate; | ||
} |
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
21 changes: 21 additions & 0 deletions
21
src/main/java/com/helpmeCookies/product/controller/docs/ProductApiDocs.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,21 @@ | ||
package com.helpmeCookies.product.controller.docs; | ||
|
||
import com.helpmeCookies.product.dto.ProductPage.Paging; | ||
import com.helpmeCookies.product.util.ProductSort; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
@Tag(name = "상품 관련 기능", description = "상품 관련 API") | ||
public interface ProductApiDocs { | ||
|
||
@Operation(summary = "상품 검색") | ||
ResponseEntity<Paging> getProductsByPage( | ||
String query, | ||
@Parameter(description = "default value 20") int size, | ||
int page, | ||
ProductSort productSort | ||
); | ||
|
||
} |
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
46 changes: 46 additions & 0 deletions
46
src/main/java/com/helpmeCookies/product/dto/ProductPage.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,46 @@ | ||
package com.helpmeCookies.product.dto; | ||
|
||
import com.helpmeCookies.product.repository.dto.ProductSearch; | ||
import java.util.List; | ||
import org.springframework.data.domain.Page; | ||
|
||
public class ProductPage { | ||
|
||
public record Info( | ||
Long id, | ||
String name, | ||
String artist, | ||
Long price, | ||
String thumbnailUrl | ||
) { | ||
public static Info from(ProductSearch productSearch) { | ||
return new Info( | ||
productSearch.getId(), | ||
productSearch.getName(), | ||
productSearch.getArtist(), | ||
productSearch.getPrice(), | ||
productSearch.getThumbnailUrl() | ||
); | ||
} | ||
|
||
public static List<Info> of(List<ProductSearch> content) { | ||
return content.stream() | ||
.map(Info::from) | ||
.toList(); | ||
} | ||
} | ||
|
||
public record Paging ( | ||
boolean hasNext, | ||
List<Info> products | ||
) { | ||
|
||
public static Paging from(Page<ProductSearch> productPage) { | ||
return new Paging( | ||
productPage.hasNext(), | ||
Info.of(productPage.getContent()) | ||
); | ||
} | ||
} | ||
|
||
} |
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
Oops, something went wrong.