File tree Expand file tree Collapse file tree
main/kotlin/com/wafflestudio/spring2025
test/kotlin/com/wafflestudio/spring2025/helper Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,12 +3,9 @@ package com.wafflestudio.spring2025.post.repository
33import com.wafflestudio.spring2025.post.model.Post
44import com.wafflestudio.spring2025.post.model.PostWithUserAndBoard
55import org.springframework.data.jdbc.repository.query.Query
6- import org.springframework.data.relational.core.sql.LockMode
7- import org.springframework.data.relational.repository.Lock
86import org.springframework.data.repository.CrudRepository
97import org.springframework.data.repository.query.Param
108import java.time.Instant
11- import java.util.Optional
129
1310interface PostRepository : CrudRepository <Post , Long > {
1411 @Query(
Original file line number Diff line number Diff line change @@ -5,11 +5,8 @@ import com.wafflestudio.spring2025.post.repository.PostRepository
55import com.wafflestudio.spring2025.postlike.model.PostLike
66import com.wafflestudio.spring2025.postlike.repository.PostLikeRepository
77import com.wafflestudio.spring2025.user.model.User
8- import org.springframework.dao.DataIntegrityViolationException
98import org.springframework.stereotype.Service
109import org.springframework.transaction.annotation.Transactional
11- import java.sql.SQLIntegrityConstraintViolationException
12- import kotlin.jvm.optionals.getOrNull
1310
1411@Service
1512class PostLikeService (
Original file line number Diff line number Diff line change @@ -3,10 +3,7 @@ package com.wafflestudio.spring2025.timetable.repository
33import com.wafflestudio.spring2025.common.enum.Semester
44import com.wafflestudio.spring2025.timetable.model.Timetable
55import org.springframework.data.jdbc.repository.query.Query
6- import org.springframework.data.relational.core.sql.LockMode
7- import org.springframework.data.relational.repository.Lock
86import org.springframework.data.repository.ListCrudRepository
9- import org.springframework.data.repository.query.Param
107
118interface TimetableRepository : ListCrudRepository <Timetable , Long > {
129 fun findByUserId (userId : Long ): List <Timetable >
Original file line number Diff line number Diff line change 11package com.wafflestudio.spring2025.user.controller
22
3- import com.wafflestudio.spring2025.user.LoggedInUser
43import com.wafflestudio.spring2025.user.dto.LoginRequest
54import com.wafflestudio.spring2025.user.dto.LoginResponse
65import com.wafflestudio.spring2025.user.dto.RegisterRequest
76import com.wafflestudio.spring2025.user.dto.RegisterResponse
8- import com.wafflestudio.spring2025.user.model.User
97import com.wafflestudio.spring2025.user.service.UserService
108import io.swagger.v3.oas.annotations.Operation
11- import io.swagger.v3.oas.annotations.Parameter
129import io.swagger.v3.oas.annotations.responses.ApiResponse
1310import io.swagger.v3.oas.annotations.responses.ApiResponses
1411import io.swagger.v3.oas.annotations.tags.Tag
@@ -17,7 +14,6 @@ import org.springframework.http.ResponseEntity
1714import org.springframework.web.bind.annotation.PostMapping
1815import org.springframework.web.bind.annotation.RequestBody
1916import org.springframework.web.bind.annotation.RequestMapping
20- import org.springframework.web.bind.annotation.RequestParam
2117import org.springframework.web.bind.annotation.RestController
2218
2319@RestController
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ import org.springframework.web.bind.annotation.RestController
2121@RequestMapping(" /api/v1/users" )
2222@Tag(name = " User" , description = " 사용자 API" )
2323class UserController (
24- private val userService : UserService
24+ private val userService : UserService ,
2525) {
2626 @Operation(summary = " 본인 정보 조회" , description = " 로그인한 사용자의 정보를 조회합니다" )
2727 @ApiResponses(
@@ -38,7 +38,7 @@ class UserController(
3838 @PostMapping(" /logout" )
3939 fun logout (
4040 @Parameter(hidden = true ) @LoggedInUser user : User ,
41- @RequestParam token : String
41+ @RequestParam token : String ,
4242 ): ResponseEntity <Unit > {
4343 userService.logout(user, token)
4444 return ResponseEntity .ok().build()
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import org.springframework.stereotype.Service
1616class UserService (
1717 private val userRepository : UserRepository ,
1818 private val jwtTokenProvider : JwtTokenProvider ,
19- private val redisTemplate : StringRedisTemplate
19+ private val redisTemplate : StringRedisTemplate ,
2020) {
2121 fun register (
2222 username : String ,
@@ -58,7 +58,7 @@ class UserService(
5858
5959 fun logout (
6060 user : User ,
61- token : String
61+ token : String ,
6262 ) {
6363 TODO ()
6464 }
Original file line number Diff line number Diff line change @@ -187,9 +187,10 @@ class DataGenerator(
187187 postId = targetPost.id!! ,
188188 )
189189
190- val updatedPost = targetPost.apply {
191- likeCount++
192- }
190+ val updatedPost =
191+ targetPost.apply {
192+ likeCount++
193+ }
193194 // DB에 저장
194195 postRepository.save(updatedPost)
195196 postLikeRepository.save(postLike)
Original file line number Diff line number Diff line change @@ -8,15 +8,17 @@ import org.testcontainers.utility.DockerImageName
88
99class MockRedis : ApplicationContextInitializer <ConfigurableApplicationContext > {
1010 override fun initialize (applicationContext : ConfigurableApplicationContext ) {
11- TestPropertyValues .of(
12- " spring.data.redis.host=${redisContainer.host} " ,
13- " spring.data.redis.port=${redisContainer.getMappedPort(6379 )} "
14- ).applyTo(applicationContext.environment)
11+ TestPropertyValues
12+ .of(
13+ " spring.data.redis.host=${redisContainer.host} " ,
14+ " spring.data.redis.port=${redisContainer.getMappedPort(6379 )} " ,
15+ ).applyTo(applicationContext.environment)
1516 }
1617
1718 companion object {
18- val redisContainer: GenericContainer <* > = GenericContainer (DockerImageName .parse(" redis:8.4-alpine" ))
19- .withExposedPorts(6379 )
20- .apply { start() }
19+ val redisContainer: GenericContainer <* > =
20+ GenericContainer (DockerImageName .parse(" redis:8.4-alpine" ))
21+ .withExposedPorts(6379 )
22+ .apply { start() }
2123 }
2224}
You can’t perform that action at this time.
0 commit comments