Skip to content

Commit

Permalink
Merge branch '14-refactor'
Browse files Browse the repository at this point in the history
  • Loading branch information
meltapplee committed Oct 23, 2024
2 parents 0624df3 + d603764 commit edb153c
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.meogo.domain.post.presentation.dto.response

import org.meogo.domain.post.domain.Post
import org.meogo.global.s3.FileUtil
import org.meogo.global.s3.Path

data class PostResponse(
val id: Long,
Expand All @@ -17,7 +15,7 @@ data class PostResponse(
) {
constructor(
post: Post,
fileUtil: FileUtil
image: String?
) : this(
post.id,
"익명",
Expand All @@ -26,7 +24,7 @@ data class PostResponse(
post.format(post.date),
post.keyWord?.split(",")?.map { it.trim() } ?: emptyList(),
post.schoolId,
post.image?.let { fileUtil.generateObjectUrl(it, Path.COMMUNITY) },
image?.substringBefore("?"),
post.good
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.meogo.domain.post.service
import org.meogo.domain.post.domain.PostRepository
import org.meogo.domain.post.presentation.dto.response.PostResponse
import org.meogo.global.s3.FileUtil
import org.meogo.global.s3.Path
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

Expand All @@ -17,9 +18,10 @@ class QueryAllPostService(
val posts = postRepository.findAll()

return posts.map { post ->
val image = post.image?.let { fileUtil.generateObjectUrl(it, Path.COMMUNITY) }
PostResponse(
post,
fileUtil
image
)
}.sortedWith(
compareByDescending<PostResponse> { it.good }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.meogo.domain.post.service
import org.meogo.domain.post.domain.PostRepository
import org.meogo.domain.post.presentation.dto.response.PostResponse
import org.meogo.global.s3.FileUtil
import org.meogo.global.s3.Path
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

Expand All @@ -17,9 +18,10 @@ class QuerySchoolPostService(
val posts = postRepository.findBySchoolId(schoolId)

return posts.map { post ->
val image = post.image?.let { fileUtil.generateObjectUrl(it, Path.COMMUNITY) }
PostResponse(
post,
fileUtil
image
)
}.sortedByDescending { it.id }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class QueryAllBySchoolIdService(
val user = userFacade.getUserById(review.userId) ?: throw UserNotFoundException
val profile = fileUtil.generateObjectUrl(user.profile, Path.USER)
val image = review.picture?.split(",")?.map { pic ->
fileUtil.generateObjectUrl(pic.trim(), Path.REVIEW)
fileUtil.generateObjectUrl(pic.trim(), Path.REVIEW).substringBefore("?")
} ?: emptyList()
ReviewResponse(
id = review.id,
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/org/meogo/domain/user/domain/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ data class User(

@Column(name = "device_token", nullable = true)
var deviceToken: String? = null

) : BaseUUIDEntity() {
fun updateProfile(name: String, enrolledSchool: Int, profile: String): User {
this.name = name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
package org.meogo.domain.user.presentation.dto.request

import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size

data class UserSignUpRequest(
@field:NotNull
@field:Size(min = 4, max = 20, message = "아이디는 4~20자 이내여야 합니다")
@field:Size(min = 5, max = 15, message = "아이디는 5~15자 이내여야 합니다")
@field:Pattern(
regexp = "^[a-z0-9]+$",
message = "아이디는 소문자 알파벳과 숫자만 포함할 수 있습니다."
)
val accountId: String,

@field:NotNull
@field:Size(min = 12, max = 20, message = "비밀번호는 12~20자 이내여야 합니다")
@field:Pattern(
regexp = "^(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[!@#$%^&*?_.]).{8,20}$",
message = "비밀번호는 영문 대소문자, 숫자, 특수문자를 최소 1자 포함해야 합니다."
)
val password: String,

@field:NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@ package org.meogo.domain.user.service
import org.meogo.domain.user.exception.UserNotFoundException
import org.meogo.domain.user.facade.UserFacade
import org.meogo.domain.user.presentation.dto.response.MyPageResponse
import org.meogo.global.s3.FileUtil
import org.meogo.global.s3.Path
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

@Service
class QueryMyPageService(
private val userFacade: UserFacade

private val userFacade: UserFacade,
private val fileUtil: FileUtil
) {
@Transactional
fun execute(): MyPageResponse {
val user = userFacade.currentUser() ?: throw UserNotFoundException
val image = fileUtil.generateObjectUrl(user.profile, Path.USER)

return MyPageResponse(
user.name,
user.accountId,
user.enrolledSchool,
user.profile
image.substringBefore("?")
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.meogo.domain.user.domain.UserRole
import org.meogo.domain.user.presentation.dto.request.UserSignUpRequest
import org.meogo.global.jwt.JwtTokenProvider
import org.meogo.global.jwt.dto.TokenResponse
import org.meogo.global.s3.FileUtil
import org.springframework.beans.factory.annotation.Value
import org.springframework.security.crypto.password.PasswordEncoder
import org.springframework.stereotype.Service
Expand All @@ -16,7 +15,6 @@ class UserSignUpService(
private val jwtTokenProvider: JwtTokenProvider,
private val userRepository: UserRepository,
private val passwordEncoder: PasswordEncoder,
private val fileUtil: FileUtil,
@Value("\${cloud.aws.s3.default-image}")
private val defaultImage: String

Expand Down

0 comments on commit edb153c

Please sign in to comment.