Skip to content

Commit

Permalink
Merge pull request #350 from ODOICHON/hotfix/qa
Browse files Browse the repository at this point in the history
fix: 공인중개사 유저 정보 추가
  • Loading branch information
dldmsql authored Mar 4, 2024
2 parents 240a241 + 7873b1a commit f9afb57
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
}

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
)
)
Expand Down

0 comments on commit f9afb57

Please sign in to comment.