-
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.
- Loading branch information
1 parent
c4fda50
commit c096520
Showing
13 changed files
with
263 additions
and
16 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
4 changes: 3 additions & 1 deletion
4
src/main/java/com/unit/daybook/domain/board/dto/request/AddBoardRequestDto.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,5 +1,7 @@ | ||
package com.unit.daybook.domain.board.dto.request; | ||
|
||
|
||
public record AddBoardRequestDto(String content, Long respectBoardId, String category, Long hearts) { | ||
import java.util.List; | ||
|
||
public record AddBoardRequestDto(String content, Long respectBoardId, String category, Long hearts, List<String> hashtags) { | ||
} |
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
28 changes: 28 additions & 0 deletions
28
src/main/java/com/unit/daybook/domain/board/dto/response/BoardTmpResponse.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,28 @@ | ||
package com.unit.daybook.domain.board.dto.response; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
public class BoardTmpResponse { | ||
private Long boardId; | ||
private String content; | ||
private Long respectBoardId; | ||
private Long authorId; | ||
private String category; | ||
private Long hearts; | ||
private List<String> hashtags; | ||
|
||
@Builder | ||
public BoardTmpResponse(AddBoardResponseDto dto, List<String> hashtags) { | ||
this.boardId = dto.boardId(); | ||
this.content = dto.content(); | ||
this.respectBoardId = dto.respectBoardId(); | ||
this.authorId = dto.authorId(); | ||
this.category = dto.category(); | ||
this.hearts = dto.hearts(); | ||
this.hashtags = hashtags; | ||
} | ||
} |
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
44 changes: 44 additions & 0 deletions
44
src/main/java/com/unit/daybook/domain/board/entity/Hashtag.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,44 @@ | ||
package com.unit.daybook.domain.board.entity; | ||
|
||
|
||
import com.unit.daybook.domain.board.dto.request.AddBoardRequestDto; | ||
import com.unit.daybook.domain.member.domain.Member; | ||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@Entity | ||
@Table(name = "hashtag") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Hashtag { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "hashtag_id") | ||
private Long hashtagId; | ||
|
||
@Column | ||
private String content; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "board_id") | ||
private Board board; | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
public Hashtag(Long hashtagId, String content, Board board) { | ||
this.hashtagId = hashtagId; | ||
this.content = content; | ||
this.board = board; | ||
} | ||
|
||
public static Hashtag createHashtag(String content, Board board) { | ||
return Hashtag.builder() | ||
.content(content) | ||
.board(board) | ||
.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
10 changes: 10 additions & 0 deletions
10
src/main/java/com/unit/daybook/domain/board/repository/HashtagRepository.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,10 @@ | ||
package com.unit.daybook.domain.board.repository; | ||
|
||
import com.unit.daybook.domain.board.entity.Board; | ||
import com.unit.daybook.domain.board.entity.Hashtag; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface HashtagRepository extends JpaRepository<Hashtag, Long> { | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/com/unit/daybook/domain/board/repository/HashtagRepositoryCustom.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,4 @@ | ||
package com.unit.daybook.domain.board.repository; | ||
|
||
public interface HashtagRepositoryCustom { | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/com/unit/daybook/domain/board/repository/HashtagRepositoryImpl.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,47 @@ | ||
package com.unit.daybook.domain.board.repository; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import com.unit.daybook.domain.board.entity.Board; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
import static com.unit.daybook.domain.board.entity.QBoard.board; | ||
import static com.unit.daybook.domain.board.entity.QHashtag.hashtag; | ||
|
||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class HashtagRepositoryImpl implements HashtagRepositoryCustom { | ||
private final JPAQueryFactory queryFactory; | ||
|
||
public List<Board> test(Long boardId) { | ||
|
||
// return queryFactory | ||
// .selectFrom() | ||
// .join(hashtag.board, board).fetchJoin() | ||
// .where( | ||
// board.boardId.eq(1L) | ||
// ) | ||
// .fetch(); | ||
return null; | ||
|
||
} | ||
|
||
public List<String> findAllByBoardId(Long boardId) { | ||
return queryFactory | ||
.select(hashtag.content) | ||
.from(hashtag) | ||
.where( | ||
board.boardId.eq(boardId) | ||
).fetch(); | ||
} | ||
|
||
public long deleteByBoardId(Long boardId) { | ||
return queryFactory | ||
.delete(hashtag) | ||
.where(hashtag.board.boardId.eq(boardId)) | ||
.execute(); | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
src/main/java/com/unit/daybook/domain/comment/entity/Comment.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,22 @@ | ||
package com.unit.daybook.domain.comment.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@Entity | ||
@Table(name = "comment") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Comment { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "comment_id") | ||
private Long commentId; | ||
|
||
@Column | ||
private String content; | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/unit/daybook/domain/reaction/entity/Reaction.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,23 @@ | ||
package com.unit.daybook.domain.reaction.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
|
||
@Getter | ||
@Entity | ||
@Table(name = "reaction") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Reaction { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "reaction_id") | ||
private Long reactionId; | ||
|
||
@Column | ||
private String content; | ||
|
||
} |