Skip to content

Commit

Permalink
Merge: (#46) 진행상황 제거 API
Browse files Browse the repository at this point in the history
  • Loading branch information
alsdl0629 authored Dec 1, 2023
2 parents 03a5408 + ec4d375 commit 451d37c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ on:
pull_request:
branches:
- main
- develop
push:
branches:
- main
- develop

jobs:
ci:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ import team.sfe.server.domain.user.domain.UserEntity

interface GameInfoRepository : CrudRepository<GameInfoEntity, Long> {
fun findByUserEntity(userEntity: UserEntity): GameInfoEntity?

fun deleteByUserEntity(userEntity: UserEntity)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package team.sfe.server.domain.progress.presentation

import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PutMapping
import org.springframework.web.bind.annotation.RequestBody
Expand All @@ -26,4 +27,10 @@ class ProgressController(
fun getProgress(): GetProgressResponse {
return progressService.getProgress()
}

@ResponseStatus(HttpStatus.NO_CONTENT)
@DeleteMapping
fun deleteProgress() {
progressService.deleteProgress()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ interface ProgressService {
fun saveProgress(request: SaveProgressRequest)

fun getProgress(): GetProgressResponse

fun deleteProgress()
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ class ProgressServiceImpl(
)
}

@Transactional
override fun deleteProgress() {
val currentUser = userFacade.getCurrentUser()

val gameInfoEntity = gameInfoRepository.findByUserEntity(currentUser) ?: throw ProgressNotFoundException

kTimeLeapRepository.deleteAllByGameInfoEntity(gameInfoEntity)
gameInfoRepository.deleteByUserEntity(currentUser)
}

private fun saveGameInfo(request: SaveProgressRequest, currentUser: UserEntity) {
val savedGameInfoEntity = gameInfoRepository.save(request.toGameInfoEntity(currentUser))
kTimeLeapRepository.saveAll(request.toKTimeLeapEntity(savedGameInfoEntity))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class SecurityConfig(
it.requestMatchers(HttpMethod.PATCH, "/auth/tokens").hasAuthority(USER.name)
it.requestMatchers(HttpMethod.PUT, "/progresses").hasAuthority(USER.name)
it.requestMatchers(HttpMethod.GET, "/progresses").hasAuthority(USER.name)
it.requestMatchers(HttpMethod.DELETE, "/progresses").hasAuthority(USER.name)
.anyRequest().permitAll()
}
.addFilterBefore(JwtFilter(jwtParser), UsernamePasswordAuthenticationFilter::class.java)
Expand Down

0 comments on commit 451d37c

Please sign in to comment.