From 7873b1ae8b743684ad5f0befc7abac317d55895d Mon Sep 17 00:00:00 2001 From: dldmsql Date: Tue, 5 Mar 2024 00:52:44 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B3=B5=EC=9D=B8=EC=A4=91=EA=B0=9C?= =?UTF-8?q?=EC=82=AC=20=EC=9C=A0=EC=A0=80=20=EC=A0=95=EB=B3=B4=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jhouse_server/domain/user/dto/UserDto.kt | 64 +++++++++++++++++-- .../domain/user/service/UserServiceImpl.kt | 5 ++ .../user/controller/UserControllerTest.kt | 6 ++ 3 files changed, 69 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/example/jhouse_server/domain/user/dto/UserDto.kt b/src/main/kotlin/com/example/jhouse_server/domain/user/dto/UserDto.kt index e58fc0a..86b94b8 100644 --- a/src/main/kotlin/com/example/jhouse_server/domain/user/dto/UserDto.kt +++ b/src/main/kotlin/com/example/jhouse_server/domain/user/dto/UserDto.kt @@ -5,6 +5,7 @@ import com.example.jhouse_server.domain.user.entity.Age import com.example.jhouse_server.domain.user.entity.Authority import com.example.jhouse_server.domain.user.entity.User import com.example.jhouse_server.domain.user.entity.UserType +import com.example.jhouse_server.domain.user.entity.agent.Agent import com.fasterxml.jackson.annotation.JsonProperty import java.time.LocalDateTime import javax.validation.constraints.Email @@ -125,8 +126,62 @@ data class UserResDto( val userType: UserType, val email : String?, val suspenseReason : String?, - val reportedAt : LocalDateTime? -) + val reportedAt : LocalDateTime?, + val agentCode: String?, + val companyName: String?, + val companyAddress: String?, + val companyPhoneNum: String?, + val agentName: String?, + val assistantName: String?, +) { + companion object { + fun toDto(user: User, report: Report?) : UserResDto { + val suspenseReason = if(report == null) null else user.reports.last().reportType.value + return UserResDto( + user.id, + user.userName, + user.nickName, + user.phoneNum, + user.authority, + user.age, + user.profileImageUrl, + user.userType, + user.email, + suspenseReason, + report?.createdAt, + null, + null, + null, + null, + null, + null + ) + } + + fun toDto(user: Agent, report: Report?) : UserResDto { + val suspenseReason = if(report == null) null else user.reports.last().reportType.value + return UserResDto( + user.id, + user.userName, + user.nickName, + user.phoneNum, + user.authority, + user.age, + user.profileImageUrl, + user.userType, + user.email, + suspenseReason, + report?.createdAt, + user.agentCode, + user.companyName, + user.companyAddress, + user.companyPhoneNum, + user.agentName, + user.assistantName + ) + } + } +} data class WithdrawalUserReqDto( @NotNull @@ -142,7 +197,4 @@ data class DefaultUser ( val profileImageUrl: String = "https://duaily-content.s3.ap-northeast-2.amazonaws.com/default_profile_image.png" ) -fun toDto(user: User, report: Report?) : UserResDto { - val suspenseReason = if(report == null) null else user.reports.last().reportType.value - return UserResDto(user.id, user.userName, user.nickName, user.phoneNum, user.authority, user.age, user.profileImageUrl, user.userType, user.email, suspenseReason, report?.createdAt) -} + diff --git a/src/main/kotlin/com/example/jhouse_server/domain/user/service/UserServiceImpl.kt b/src/main/kotlin/com/example/jhouse_server/domain/user/service/UserServiceImpl.kt index b7ec954..72bc626 100644 --- a/src/main/kotlin/com/example/jhouse_server/domain/user/service/UserServiceImpl.kt +++ b/src/main/kotlin/com/example/jhouse_server/domain/user/service/UserServiceImpl.kt @@ -2,8 +2,10 @@ package com.example.jhouse_server.domain.user.service import com.example.jhouse_server.domain.house.repository.ReportRepository import com.example.jhouse_server.domain.user.dto.* +import com.example.jhouse_server.domain.user.dto.UserResDto.Companion.toDto import com.example.jhouse_server.domain.user.entity.* import com.example.jhouse_server.domain.user.entity.WithdrawalStatus.WAIT +import com.example.jhouse_server.domain.user.entity.agent.Agent import com.example.jhouse_server.domain.user.repository.UserRepository import com.example.jhouse_server.domain.user.repository.WithdrawalRepository import com.example.jhouse_server.domain.user.service.common.UserServiceCommonMethod @@ -37,6 +39,9 @@ class UserServiceImpl ( // 신고 유저이면, 신고 정보 반환 val findUser = userRepository.findById(userId).orElseThrow{ApplicationException(NOT_FOUND_EXCEPTION)} val reported = reportRepository.findByOwner(findUser).lastOrNull() + if (findUser is Agent) { + return toDto(findUser, reported) + } return toDto(findUser, reported) } diff --git a/src/test/kotlin/com/example/jhouse_server/domain/user/controller/UserControllerTest.kt b/src/test/kotlin/com/example/jhouse_server/domain/user/controller/UserControllerTest.kt index 9bbc147..a7f9b1f 100644 --- a/src/test/kotlin/com/example/jhouse_server/domain/user/controller/UserControllerTest.kt +++ b/src/test/kotlin/com/example/jhouse_server/domain/user/controller/UserControllerTest.kt @@ -76,6 +76,12 @@ internal class UserControllerTest @Autowired constructor( fieldWithPath("data.email").description("사용자 이메일 계정"), fieldWithPath("data.suspenseReason").description("최근 신고 사유"), fieldWithPath("data.reportedAt").description("신고일시"), + fieldWithPath("data.agentCode").description("공인중개사 코드").optional(), + fieldWithPath("data.companyName").description("회사명").optional(), + fieldWithPath("data.companyAddress").description("회사 주소").optional(), + fieldWithPath("data.companyPhoneNum").description("회사 전화번호").optional(), + fieldWithPath("data.agentName").description("공인중개사 이름").optional(), + fieldWithPath("data.assistantName").description("보조공인중개사 이름").optional(), ) ) )