diff --git a/withaeng-api/src/main/kotlin/com/withaeng/api/applicationservice/accompany/AccompanyApplicationService.kt b/withaeng-api/src/main/kotlin/com/withaeng/api/applicationservice/accompany/AccompanyApplicationService.kt index a94502a..da9e478 100644 --- a/withaeng-api/src/main/kotlin/com/withaeng/api/applicationservice/accompany/AccompanyApplicationService.kt +++ b/withaeng-api/src/main/kotlin/com/withaeng/api/applicationservice/accompany/AccompanyApplicationService.kt @@ -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) } diff --git a/withaeng-api/src/main/kotlin/com/withaeng/api/config/SecurityConfig.kt b/withaeng-api/src/main/kotlin/com/withaeng/api/config/SecurityConfig.kt index 8e12e9c..7ff6b86 100644 --- a/withaeng-api/src/main/kotlin/com/withaeng/api/config/SecurityConfig.kt +++ b/withaeng-api/src/main/kotlin/com/withaeng/api/config/SecurityConfig.kt @@ -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) diff --git a/withaeng-api/src/main/kotlin/com/withaeng/api/controller/accompany/AccompanyController.kt b/withaeng-api/src/main/kotlin/com/withaeng/api/controller/accompany/AccompanyController.kt index d91f84b..2fdac73 100644 --- a/withaeng-api/src/main/kotlin/com/withaeng/api/controller/accompany/AccompanyController.kt +++ b/withaeng-api/src/main/kotlin/com/withaeng/api/controller/accompany/AccompanyController.kt @@ -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 { + accompanyApplicationService.delete(accompanyId) + return ApiResponse.success() + } } \ No newline at end of file diff --git a/withaeng-domain/src/main/kotlin/com/withaeng/domain/accompany/AccompanyService.kt b/withaeng-domain/src/main/kotlin/com/withaeng/domain/accompany/AccompanyService.kt index 42a9a01..e649eae 100644 --- a/withaeng-domain/src/main/kotlin/com/withaeng/domain/accompany/AccompanyService.kt +++ b/withaeng-domain/src/main/kotlin/com/withaeng/domain/accompany/AccompanyService.kt @@ -62,6 +62,11 @@ class AccompanyService( accompany.increaseViewCount() } + @Transactional + fun delete(accompanyId: Long) { + accompanyRepository.deleteById(accompanyId) + } + @Transactional(readOnly = true) fun findAll(): List { return accompanyRepository.findAll().map { it.toDto() }