-
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 #136 from SW13-Monstera/dev
Release
- Loading branch information
Showing
26 changed files
with
258 additions
and
133 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/io/csbroker/apiserver/common/enums/LikeType.kt
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,5 @@ | ||
package io.csbroker.apiserver.common.enums | ||
|
||
enum class LikeType { | ||
POST, COMMENT | ||
} |
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
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/io/csbroker/apiserver/controller/v1/post/response/CommentResponseDto.kt
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 io.csbroker.apiserver.controller.v1.post.response | ||
|
||
import io.csbroker.apiserver.model.Comment | ||
import java.time.LocalDateTime | ||
|
||
data class CommentResponseDto( | ||
val id: Long, | ||
val content: String, | ||
val username: String, | ||
val likeCount: Long, | ||
val isLiked: Boolean, | ||
val createdAt: LocalDateTime, | ||
) { | ||
constructor(comment: Comment, likeCount: Long, isLiked: Boolean) : this( | ||
id = comment.id, | ||
content = comment.content, | ||
username = comment.user.username, | ||
likeCount = likeCount, | ||
isLiked = isLiked, | ||
createdAt = comment.createdAt!!, | ||
) | ||
} |
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
4 changes: 3 additions & 1 deletion
4
src/main/kotlin/io/csbroker/apiserver/controller/v2/problem/request/SubmitLongProblemDto.kt
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,7 +1,9 @@ | ||
package io.csbroker.apiserver.controller.v2.problem.request | ||
|
||
import io.csbroker.apiserver.model.User | ||
|
||
data class SubmitLongProblemDto( | ||
val email: String, | ||
val user: User, | ||
val problemId: Long, | ||
val answer: String, | ||
) |
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,35 @@ | ||
package io.csbroker.apiserver.model | ||
|
||
import io.csbroker.apiserver.common.enums.LikeType | ||
import javax.persistence.Column | ||
import javax.persistence.Entity | ||
import javax.persistence.EnumType | ||
import javax.persistence.Enumerated | ||
import javax.persistence.FetchType | ||
import javax.persistence.GeneratedValue | ||
import javax.persistence.GenerationType | ||
import javax.persistence.Id | ||
import javax.persistence.JoinColumn | ||
import javax.persistence.ManyToOne | ||
import javax.persistence.Table | ||
|
||
@Entity | ||
@Table(name = "like") | ||
class Like( | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "like_id") | ||
val id: Long = 0, | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
val user: User, | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(name = "like_type") | ||
val type: LikeType, | ||
|
||
@Column(name = "target_id") | ||
val targetId: Long, | ||
|
||
) : BaseEntity() |
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
26 changes: 26 additions & 0 deletions
26
src/main/kotlin/io/csbroker/apiserver/repository/post/LikeRepository.kt
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,26 @@ | ||
package io.csbroker.apiserver.repository.post | ||
|
||
import io.csbroker.apiserver.common.enums.LikeType | ||
import io.csbroker.apiserver.model.Like | ||
import io.csbroker.apiserver.model.User | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.data.jpa.repository.Query | ||
|
||
interface LikeRepository : JpaRepository<Like, Long> { | ||
|
||
@Query( | ||
""" | ||
select l from Like l | ||
where l.type = :type and l.targetId in :targetIds | ||
""", | ||
) | ||
fun findAllByTargetIdIn(type: LikeType, targetIds: List<Long>): List<Like> | ||
|
||
@Query( | ||
""" | ||
select l from Like l | ||
where l.type = :type and l.targetId = :targetId and l.user = :user | ||
""", | ||
) | ||
fun findByTargetIdAndUser(type: LikeType, targetId: Long, user: User): Like? | ||
} |
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
7 changes: 5 additions & 2 deletions
7
src/main/kotlin/io/csbroker/apiserver/service/post/CommentService.kt
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,6 +1,9 @@ | ||
package io.csbroker.apiserver.service.post | ||
|
||
import io.csbroker.apiserver.model.User | ||
|
||
interface CommentService { | ||
fun create(postId: Long, content: String, email: String): Long | ||
fun deleteById(id: Long, email: String) | ||
fun create(postId: Long, content: String, user: User): Long | ||
fun deleteById(id: Long, user: User) | ||
fun like(id: Long, user: User) | ||
} |
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: 6 additions & 4 deletions
10
src/main/kotlin/io/csbroker/apiserver/service/post/PostService.kt
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,10 +1,12 @@ | ||
package io.csbroker.apiserver.service.post | ||
|
||
import io.csbroker.apiserver.controller.v1.post.response.PostResponseDto | ||
import io.csbroker.apiserver.model.User | ||
|
||
interface PostService { | ||
fun findByProblemId(problemId: Long, email: String?): List<PostResponseDto> | ||
fun create(problemId: Long, content: String, email: String): Long | ||
fun like(id: Long, email: String) | ||
fun deleteById(id: Long, email: String) | ||
fun findByProblemId(problemId: Long, emailIfLogin: String?): List<PostResponseDto> | ||
fun findByPostId(postId: Long, emailIfLogin: String?): PostResponseDto | ||
fun create(problemId: Long, content: String, user: User): Long | ||
fun like(id: Long, user: User) | ||
fun deleteById(id: Long, user: User) | ||
} |
Oops, something went wrong.