Skip to content

feat: 동행 삭제 기능 추가 #92

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

Merged
merged 1 commit into from
Sep 28, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ class AccompanyApplicationService(
accompanyJoinRequestService.rejectJoin(accompanyId, joinRequestId)
}

fun delete(accompanyId: Long) {
accompanyService.delete(accompanyId)
}

private fun increaseViewCount(accompanyId: Long) {
accompanyService.increaseViewCount(accompanyId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class SecurityConfig(
it
.requestMatchers("/api/v1/auth/**", "/api/v1/test/**", "/api/v1/destinations").permitAll()
.requestMatchers(HttpMethod.GET, "/api/v1/accompany/**").permitAll()
.requestMatchers(HttpMethod.DELETE, "/api/v1/accompany/**")
.hasRole(UserRole.ADMIN.getActualRoleName())
.anyRequest().hasAnyRole(UserRole.USER.getActualRoleName(), UserRole.ADMIN.getActualRoleName())
}
.addFilterBefore(JwtFilter(jwtAgent), UsernamePasswordAuthenticationFilter::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,17 @@ class AccompanyController(
)
return ApiResponse.success()
}

@Operation(
summary = "Delete Accompany API",
description = "동행 게시글 삭제 API (For Admin)",
security = [SecurityRequirement(name = "Authorization")]
)
@DeleteMapping("/{accompanyId}")
fun delete(
@Parameter(description = "동행 id") @PathVariable accompanyId: Long,
): ApiResponse<Unit> {
accompanyApplicationService.delete(accompanyId)
return ApiResponse.success()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ class AccompanyService(
accompany.increaseViewCount()
}

@Transactional
fun delete(accompanyId: Long) {
accompanyRepository.deleteById(accompanyId)
}

@Transactional(readOnly = true)
fun findAll(): List<AccompanyDto> {
return accompanyRepository.findAll().map { it.toDto() }
Expand Down
Loading