-
Notifications
You must be signed in to change notification settings - Fork 0
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 #22 from tomato-market/feature/14_favorite
[Feature/14 favorite] 관심 등록
- Loading branch information
Showing
12 changed files
with
416 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.tomato.market.data.dto; | ||
|
||
import com.tomato.market.data.entity.FavoriteEntity; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
@Builder | ||
@Setter | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@ToString | ||
public class FavoriteDto { | ||
private String userId; | ||
private Integer postNum; | ||
private Integer status; | ||
|
||
public static FavoriteDto toFavoriteDto(FavoriteEntity favoriteEntity) { | ||
return FavoriteDto.builder() | ||
.userId(favoriteEntity.getUserId()) | ||
.postNum(favoriteEntity.getPostNum()) | ||
.status(favoriteEntity.getStatus()) | ||
.build(); | ||
} | ||
|
||
public static FavoriteEntity toFavoriteEntity(FavoriteDto favoriteDto) { | ||
return FavoriteEntity.builder() | ||
.userId(favoriteDto.getUserId()) | ||
.postNum(favoriteDto.getPostNum()) | ||
.status(favoriteDto.getStatus()) | ||
.build(); | ||
} | ||
} |
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,20 @@ | ||
package com.tomato.market.data.dto; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
public class ResponseDto<T> { | ||
private HttpStatus status; | ||
private String message; | ||
private T data; | ||
} |
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
30 changes: 30 additions & 0 deletions
30
src/main/java/com/tomato/market/data/entity/FavoriteEntity.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 com.tomato.market.data.entity; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@ToString | ||
@Table(name = "favorite") | ||
public class FavoriteEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Integer favoriteNum; | ||
private String userId; | ||
private Integer postNum; | ||
private Integer status; // 1 등록 0 취소 | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/tomato/market/data/repository/FavoriteRepository.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,9 @@ | ||
package com.tomato.market.data.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import com.tomato.market.data.entity.FavoriteEntity; | ||
|
||
public interface FavoriteRepository extends JpaRepository<FavoriteEntity, Integer> { | ||
FavoriteEntity findByUserIdAndPostNum(String userId, Integer postNum); | ||
} |
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.