Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOTFIX 52 - 나눔 전체 내역 조회 조건문 변경 #52

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/kotlin/mara/server/config/cors/CorsConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class CorsConfig : WebMvcConfigurer {
.allowedOriginPatterns("*") // 모든 도메인에 대해 액세스 허용
.allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS") // 허용할 HTTP 메서드
.allowedHeaders("*") // 모든 헤더 허용
.exposedHeaders("*")
Copy link
Collaborator

@jhkang1517 jhkang1517 Mar 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

실제 header 값인 access token 과 refresh token , re-access token 등으로 변경하면 좋을 것 같습니다! 😄
Reference

.allowCredentials(true) // 자격 증명 허용
.maxAge(3600) // CORS preflight 요청 결과 캐싱 시간 (초 단위)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import org.springframework.data.jpa.repository.JpaRepository

interface ApplyShareRepository : JpaRepository<ApplyShare, Long> {
fun existsByUserAndShare(user: User, share: Share): Boolean

fun findByUserAndShare(user: User, share: Share): ApplyShare
fun countByUser(user: User): Long
}
4 changes: 2 additions & 2 deletions src/main/kotlin/mara/server/domain/share/ShareController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ShareController(private val shareService: ShareService) {

@DeleteMapping("/applies/{id}")
@Operation(summary = "나눔 신청 취소 API")
fun deleteApply(@PathVariable(name = "id") applyId: Long): CommonResponse<String> {
return success(shareService.deleteApplyShare(applyId))
fun deleteApply(@PathVariable(name = "id") shareId: Long): CommonResponse<String> {
return success(shareService.deleteApplyShare(shareId))
}
}
4 changes: 2 additions & 2 deletions src/main/kotlin/mara/server/domain/share/ShareRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ class CustomShareRepositoryImpl(
.fetch()

val query = queryFactory.selectFrom(share)
.where(share.id.`in`(appliedShareIdList).and(share.user.eq(user).and(share.status.eq(status))))
.where((share.id.`in`(appliedShareIdList).or(share.user.eq(user)).and(share.status.eq(status))))
.offset(pageable.offset)
.limit(pageable.pageSize.toLong())
.orderBy(share.createdAt.desc()).fetch()

val count = queryFactory.select(share.count()).from(share)
.where(share.id.`in`(appliedShareIdList).and(share.user.eq(user).and(share.status.eq(status)))).fetchOne()
.where((share.id.`in`(appliedShareIdList).or(share.user.eq(user)).and(share.status.eq(status)))).fetchOne()

return PageableExecutionUtils.getPage(query, pageable) { count!! }
}
Expand Down
10 changes: 4 additions & 6 deletions src/main/kotlin/mara/server/domain/share/ShareService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import mara.server.exception.IllegalAccessShareException
import mara.server.exception.IllegalAccessShareException.Companion.CREATED_BY_LOGIN_USER
import mara.server.exception.IllegalAccessShareException.Companion.DIFFERENT_USER
import mara.server.exception.IllegalAccessShareException.Companion.DUPLICATED_APPLY
import mara.server.exception.ShareException.Companion.NO_SUCH_APPLY_SHARE
import mara.server.exception.ShareException.Companion.NO_SUCH_INGREDIENT
import mara.server.exception.ShareException.Companion.NO_SUCH_SHARE
import org.springframework.data.domain.Page
Expand Down Expand Up @@ -151,16 +150,15 @@ class ShareService(
}

@Transactional
fun deleteApplyShare(applyId: Long): String {
fun deleteApplyShare(shareId: Long): String {
val user = userService.getCurrentLoginUser()
val applyShare = applyShareRepository.findById(applyId)
.orElseThrow { NoSuchElementException("$NO_SUCH_APPLY_SHARE Id: $applyId") }
if (user.userId != applyShare.user.userId) throw IllegalAccessShareException(DIFFERENT_USER)
val share = shareRepository.findById(shareId).orElseThrow { NoSuchElementException("$NO_SUCH_SHARE Id: $shareId") }
val applyShare = applyShareRepository.findByUserAndShare(user, share)
/**
신청을 취소하면 사람 수 차감
**/
applyShare.share.minusPeopleCount()
applyShareRepository.deleteById(applyId)
applyShareRepository.delete(applyShare)
return deleted
}
}
2 changes: 1 addition & 1 deletion src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cloud:

jwt:
secret-key: ${jwt-secret-key}
access-duration-mils: 1800000
access-duration-mils: 21600000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

시연용 설정은 원복해서 다시 배포하는 것이 좋을 것 같습니다! 🎡

refresh-duration-mins: 20160

logging:
Expand Down
Loading