Skip to content

Commit

Permalink
Merge pull request #16 from DDD-Community/feature/POLABO-108
Browse files Browse the repository at this point in the history
feat(POLABO-108): mvp 2차 개발
  • Loading branch information
dldmsql authored Aug 11, 2024
2 parents 5b23171 + b23da3b commit f15c1d1
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class OauthController(private val oauthService: OauthService) {
@Operation(summary = "회원가입/로그인", description = """
회원가입/로그인을 진행합니다.
이미 가입된 회원이라면 로그인을 진행하고, 가입되지 않은 회원이라면 회원가입을 진행합니다.
요청 바디의 값이 변경되었습니다. - 2024.08.11
""")
@PostMapping("/sign-in")
fun signIn(@RequestBody request: UserDto.Companion.CreateReq)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ import com.ddd.sonnypolabobe.global.util.DateConverter
import io.swagger.v3.oas.annotations.Operation
import org.springframework.security.core.context.SecurityContext
import org.springframework.security.core.context.SecurityContextHolder
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
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.bind.annotation.*
import java.time.LocalDateTime

@RestController
Expand Down Expand Up @@ -52,4 +47,12 @@ class UserController(
this.userService.withdraw(request, userInfoFromToken.id)
return ApplicationResponse.ok()
}

@Operation(summary = "회원 계정 존재 여부 확인", description = """
이메일로 계정 등록 여부를 확인합니다.
""")
@GetMapping("/check-exist")
fun checkExist(
@RequestParam("email") email: String
) = ApplicationResponse.ok(this.userService.checkExist(email))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.ddd.sonnypolabobe.domain.user.dto

enum class GenderType(val description: String) {
F("여성"),
M("남성"),
NONE("없음")
}
11 changes: 8 additions & 3 deletions src/main/kotlin/com/ddd/sonnypolabobe/domain/user/dto/UserDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
import org.springframework.security.core.GrantedAuthority
import org.springframework.security.core.authority.SimpleGrantedAuthority
import org.springframework.security.core.userdetails.UserDetails
import java.time.LocalDate
import java.time.LocalDateTime
import java.util.Date
import java.util.stream.Collectors
Expand All @@ -12,8 +13,10 @@ class UserDto {
companion object {
data class CreateReq(
val email: String,
val nickName: String
)
val nickName: String,
val birthDt : LocalDate,
val gender : GenderType
)

data class UpdateReq(
@JsonProperty("nickName")
Expand All @@ -28,7 +31,9 @@ class UserDto {

data class TokenRes(
val accessToken: String,
val expiredDate: Date
val expiredDate: Date,
val isNewUser : Boolean,
val nickName: String
)

data class ProfileRes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ddd.sonnypolabobe.domain.user.repository

import com.ddd.sonnypolabobe.domain.user.dto.UserDto
import com.ddd.sonnypolabobe.global.util.DateConverter
import com.ddd.sonnypolabobe.jooq.polabo.enums.UserGender
import com.ddd.sonnypolabobe.jooq.polabo.tables.User
import org.jooq.DSLContext
import org.springframework.stereotype.Repository
Expand All @@ -11,23 +12,21 @@ import java.time.LocalDateTime
class UserJooqRepositoryImpl(private val dslContext: DSLContext) : UserJooqRepository{
override fun insertOne(request: UserDto.Companion.CreateReq): Long {
val jUser = User.USER
val insertValue = jUser.newRecord().apply {
this.email = request.email
this.nickName = request.nickName
this.createdAt = DateConverter.convertToKst(LocalDateTime.now())
this.yn = 1
}
return this.dslContext.insertInto(jUser,
jUser.EMAIL,
jUser.NICK_NAME,
jUser.CREATED_AT,
jUser.YN
jUser.YN,
jUser.BIRTH_DT,
jUser.GENDER
)
.values(
insertValue.email,
insertValue.nickName,
insertValue.createdAt,
insertValue.yn
request.email,
request.nickName,
DateConverter.convertToKst(LocalDateTime.now()),
1,
request.birthDt,
UserGender.valueOf(request.gender.name)
)
.returningResult(jUser.ID)
.fetchOne(0, Long::class.java) ?: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,9 @@ class UserService(
this.withdrawJooqRepository.insertOne(request, id)
}

fun checkExist(email: String): Boolean {
return this.userJooqRepository.findByEmail(email) != null
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SecurityConfig(
it.requestMatchers("/api/v1/boards/create-available").permitAll()
it.requestMatchers("/api/v1/boards/total-count").permitAll()
it.requestMatchers("/api/v1/file/**").permitAll()
it.requestMatchers("/api/v1/oauth/sign-in", "/api/v1/oauth/re-issue").permitAll()
it.requestMatchers("/api/v1/oauth/sign-in", "/api/v1/oauth/re-issue", "/api/v1/user/check-exist").permitAll()
it.requestMatchers("/health", "/swagger-ui/**", "/v3/api-docs/**").permitAll()
it.requestMatchers("/api/v1/boards/{id}", "/api/v1/polaroids/{id}", "/api/v1/boards/{boardId}/polaroids").permitAll()
it.anyRequest().authenticated()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class JwtUtil(
.setExpiration(expiredDate)
.signWith(getKey(accessSecretKey), SignatureAlgorithm.HS512)
.compact()
return UserDto.Companion.TokenRes(accessToken, expiredDate)
return UserDto.Companion.TokenRes(accessToken, expiredDate, true, request.nickName)
}

fun getAuthenticatedMemberFromToken(accessToken: String): AuthenticatedMember {
Expand Down

0 comments on commit f15c1d1

Please sign in to comment.