Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/main/java/land/leets/domain/auth/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,14 @@ public User getUser(String idToken) throws GeneralSecurityException, IOException
return bySub.get();
}

User user = User.builder()
.sub(userId)
.name((String) payload.get("name"))
.email(payload.getEmail())
.build();
User user = new User(
null,
(String) payload.get("name"),
null,
payload.getEmail(),
userId,
null
);

return userRepository.save(user);
}
Expand Down
56 changes: 0 additions & 56 deletions src/main/java/land/leets/domain/user/domain/User.java

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions src/main/java/land/leets/domain/user/usecase/UpdateUser.java

This file was deleted.

24 changes: 0 additions & 24 deletions src/main/java/land/leets/domain/user/usecase/UpdateUserImpl.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CreateApplicationImpl(
override fun execute(authDetails: AuthDetails, request: ApplicationRequest): Application {
val user: User = userRepository.findById(authDetails.uid).orElseThrow { UserNotFoundException() }

if (applicationRepository.findByUser_Uid(user.getUid()) != null) {
if (applicationRepository.findByUser_Uid(user.uid!!) != null) {
throw ApplicationAlreadyExistsException()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class GetAllApplicationImpl(
private fun mapApplications(applications: List<Application>): List<ApplicationResponse> {
return applications.map { application ->
val interview = getInterview.execute(application)
val phone = application.user.getPhone()
val phone = application.user.phone ?: ""
ApplicationResponse.of(application, interview, phone)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class GetApplicationDetailsImpl(

private fun getDetails(application: Application): ApplicationDetailsResponse {
val interview = getInterviewDetails.execute(application)
val phone = application.user.getPhone()
val phone = application.user.phone ?: ""
return ApplicationDetailsResponse.of(application, interview, phone)
}
}
34 changes: 34 additions & 0 deletions src/main/kotlin/land/leets/domain/user/domain/User.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package land.leets.domain.user.domain

import jakarta.persistence.*
import land.leets.domain.shared.BaseTimeEntity
import java.util.UUID

@Entity(name = "users")
class User(
@Column
var sid: String?,

@Column(nullable = false)
val name: String,

@Column
var phone: String?,

@Column(nullable = false)
val email: String,

@Column(nullable = false)
val sub: String,

@Id
@GeneratedValue(strategy = GenerationType.UUID)
@Column(columnDefinition = "BINARY(16)")
val uid: UUID? = null
) : BaseTimeEntity() {

fun updateUserInfo(sid: String?, phone: String) {
this.sid = sid
this.phone = phone
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package land.leets.domain.user.domain.repository

import land.leets.domain.user.domain.User
import org.springframework.data.jpa.repository.JpaRepository
import java.util.Optional
import java.util.UUID

interface UserRepository : JpaRepository<User, UUID> {
fun findBySub(sub: String): Optional<User>
fun findByEmail(email: String): Optional<User>
fun findByUid(uid: UUID): Optional<User>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package land.leets.domain.user.exception

import land.leets.global.error.ErrorCode
import land.leets.global.error.exception.ServiceException

class UserNotFoundException : ServiceException(ErrorCode.USER_NOT_FOUND)
Loading