Skip to content

Commit

Permalink
Api-v0.0.3-7
Browse files Browse the repository at this point in the history
  • Loading branch information
kdomo committed Jul 9, 2023
2 parents 3fc92c6 + 227b2ed commit cb0eb71
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import com.depromeet.whatnow.domains.promise.adaptor.PromiseAdaptor
import com.depromeet.whatnow.domains.promise.domain.Promise
import com.depromeet.whatnow.domains.promise.domain.PromiseType
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.time.LocalDateTime
import javax.transaction.Transactional

@Service
class PromiseDomainService(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import javax.persistence.Enumerated
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
import javax.persistence.Id
import javax.persistence.PostPersist
import javax.persistence.Table

@Entity
Expand Down Expand Up @@ -49,8 +50,7 @@ class User(
val id: Long? = null,
) : BaseTimeEntity() {

// @PostPersist
// 원래 되어야하는데.. postpersist가 콜백이라서 그런지 아예 다른 스레드에서 돌아버리네요..
@PostPersist
fun registerEvent() {
Events.raise(UserSignUpEvent(this.id!!))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,23 @@ class UserDomainService(
oauthId: String,
): User {
return resultQueryByOauthInfo(oauthInfo).getOrElse {
val newUser = userAdapter.save(User(oauthInfo, username, profileImage, defaultImage, FcmNotificationVo("", false)))
newUser.registerEvent()
return newUser
return userAdapter.save(
User(
oauthInfo,
username,
profileImage,
defaultImage,
FcmNotificationVo("", false),
),
)
}
}

fun checkUserCanRegister(oauthInfo: OauthInfo): Boolean {
return resultQueryByOauthInfo(oauthInfo).isFailure // 유저가 없으면 회원가입 가능
}

@Transactional
fun registerUser(username: String, profileImage: String, defaultImage: Boolean, oauthInfo: OauthInfo, oauthId: String, fcmToken: String, appAlarm: Boolean): User {
return resultQueryByOauthInfo(oauthInfo).onSuccess { // 계정이 있는 경우엔 exception 발생
throw AlreadySignUpUserException.EXCEPTION
Expand Down

0 comments on commit cb0eb71

Please sign in to comment.