From 8fdbc971e4e0e9acf979c51b6b32bb7157bd9732 Mon Sep 17 00:00:00 2001 From: dldmsql Date: Mon, 5 Feb 2024 23:49:21 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B4=80=EB=A6=AC=EC=9E=90=20-=20?= =?UTF-8?q?=EC=9C=A0=EC=A0=80=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/controller/AdminUserController.kt | 18 ++ .../admin/user/dto/AdminUserDto.kt | 17 +- .../admin/user/service/AdminUserService.kt | 11 ++ .../user/repository/UserRepositoryCustom.kt | 6 +- .../user/repository/UserRepositoryImpl.kt | 30 ++++ .../global/config/RequestServletFilter.kt | 44 ++--- .../global/config/RequestServletWrapper.kt | 128 ++++++------- .../jhouse_server/global/config/WebConfig.kt | 9 +- .../global/interceptor/LogInterceptor.kt | 120 ++++++------- .../resources/templates/fragments/nav.html | 1 + .../resources/templates/user/userManager.html | 170 ++++++++++++++++++ 11 files changed, 401 insertions(+), 153 deletions(-) create mode 100644 src/main/resources/templates/user/userManager.html diff --git a/src/main/kotlin/com/example/jhouse_server/admin/user/controller/AdminUserController.kt b/src/main/kotlin/com/example/jhouse_server/admin/user/controller/AdminUserController.kt index 1eb51ce1..b09d3e0d 100644 --- a/src/main/kotlin/com/example/jhouse_server/admin/user/controller/AdminUserController.kt +++ b/src/main/kotlin/com/example/jhouse_server/admin/user/controller/AdminUserController.kt @@ -148,4 +148,22 @@ class AdminUserController( return "user/withdrawalDetail" } + + @GetMapping("/manage") + fun getUserManage( + @ModelAttribute("searchForm") adminUserSearch: AdminUserWithdrawalSearch, + model: Model, + @PageableDefault(size=10, page=0) pageable: Pageable + ): String { + // 승인 요청된 게시글 목록 데이터 + val result = adminUserService.getUserWithSearchForm(adminUserSearch, pageable) + model.addAttribute("userList", result) + + // 페이징 데이터 + val pageCom = pageable.pageNumber / 5 + model.addAttribute("pageCom", pageCom) + model.addAttribute("filterList", UserSearchFilter.values()) + + return "user/userManager" + } } \ No newline at end of file diff --git a/src/main/kotlin/com/example/jhouse_server/admin/user/dto/AdminUserDto.kt b/src/main/kotlin/com/example/jhouse_server/admin/user/dto/AdminUserDto.kt index e8dbb0ed..3019e515 100644 --- a/src/main/kotlin/com/example/jhouse_server/admin/user/dto/AdminUserDto.kt +++ b/src/main/kotlin/com/example/jhouse_server/admin/user/dto/AdminUserDto.kt @@ -1,5 +1,10 @@ package com.example.jhouse_server.admin.user.dto +import com.example.jhouse_server.domain.user.entity.Age +import com.example.jhouse_server.domain.user.entity.UserType +import com.querydsl.core.annotations.QueryProjection +import java.time.LocalDateTime + /** * ============================================================================================ * AdminAgentSearch -- 공인중개사 검색 조건 @@ -54,5 +59,15 @@ enum class AgentSearchFilter(val value: String) { } enum class UserSearchFilter(val value: String){ - NICKNAME("이름") + NICKNAME("닉네임") } + +data class AdminUserList @QueryProjection constructor( + val id: Long, + val nickName: String, + val email: String, + val userType: UserType, + val phoneNum : String, + val createdAt : LocalDateTime, + val age: Age +) diff --git a/src/main/kotlin/com/example/jhouse_server/admin/user/service/AdminUserService.kt b/src/main/kotlin/com/example/jhouse_server/admin/user/service/AdminUserService.kt index bb706df1..372f2e15 100644 --- a/src/main/kotlin/com/example/jhouse_server/admin/user/service/AdminUserService.kt +++ b/src/main/kotlin/com/example/jhouse_server/admin/user/service/AdminUserService.kt @@ -2,10 +2,14 @@ package com.example.jhouse_server.admin.user.service import com.example.jhouse_server.admin.user.dto.AdminJoinAgentList +import com.example.jhouse_server.admin.user.dto.AdminUserList +import com.example.jhouse_server.admin.user.dto.AdminUserWithdrawalSearch import com.example.jhouse_server.admin.user.dto.AdminWithdrawalList import com.example.jhouse_server.domain.user.entity.agent.AgentStatus import com.example.jhouse_server.domain.user.repository.AgentRepository import com.example.jhouse_server.domain.user.repository.UserRepository +import org.springframework.data.domain.Page +import org.springframework.data.domain.Pageable import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional @@ -39,4 +43,11 @@ class AdminUserService( findUsers?.forEach { u -> u.withdrawalUser() } } + fun getUserWithSearchForm( + adminUserSearch: AdminUserWithdrawalSearch, + pageable: Pageable + ): Page { + return userRepository.getUserWithSearchForm(adminUserSearch, pageable) + } + } \ No newline at end of file diff --git a/src/main/kotlin/com/example/jhouse_server/domain/user/repository/UserRepositoryCustom.kt b/src/main/kotlin/com/example/jhouse_server/domain/user/repository/UserRepositoryCustom.kt index d233343b..0f13a6bb 100644 --- a/src/main/kotlin/com/example/jhouse_server/domain/user/repository/UserRepositoryCustom.kt +++ b/src/main/kotlin/com/example/jhouse_server/domain/user/repository/UserRepositoryCustom.kt @@ -3,9 +3,9 @@ package com.example.jhouse_server.domain.user.repository import com.example.jhouse_server.admin.anaylsis.dto.AnalysisAgeResponse import com.example.jhouse_server.admin.anaylsis.dto.AnalysisJoinPathResponse import com.example.jhouse_server.admin.user.dto.AdminAgentSearch +import com.example.jhouse_server.admin.user.dto.AdminUserList import com.example.jhouse_server.admin.user.dto.AdminUserWithdrawalSearch 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 org.springframework.data.domain.Page import org.springframework.data.domain.Pageable @@ -21,4 +21,8 @@ interface UserRepositoryCustom { fun getAgentWithdrawalReqResult(adminAgentSearch: AdminAgentSearch, pageable: Pageable): Page fun getUserWithdrawalReqResult(adminUserWithdrawalSearch: AdminUserWithdrawalSearch, pageable: Pageable): Page + fun getUserWithSearchForm( + adminUserSearch: AdminUserWithdrawalSearch, + pageable: Pageable + ): Page } \ No newline at end of file diff --git a/src/main/kotlin/com/example/jhouse_server/domain/user/repository/UserRepositoryImpl.kt b/src/main/kotlin/com/example/jhouse_server/domain/user/repository/UserRepositoryImpl.kt index a18a549c..cbc807c4 100644 --- a/src/main/kotlin/com/example/jhouse_server/domain/user/repository/UserRepositoryImpl.kt +++ b/src/main/kotlin/com/example/jhouse_server/domain/user/repository/UserRepositoryImpl.kt @@ -3,7 +3,9 @@ package com.example.jhouse_server.domain.user.repository import com.example.jhouse_server.admin.anaylsis.dto.AnalysisAgeResponse import com.example.jhouse_server.admin.anaylsis.dto.AnalysisJoinPathResponse import com.example.jhouse_server.admin.user.dto.AdminAgentSearch +import com.example.jhouse_server.admin.user.dto.AdminUserList import com.example.jhouse_server.admin.user.dto.AdminUserWithdrawalSearch +import com.example.jhouse_server.admin.user.dto.QAdminUserList import com.example.jhouse_server.domain.user.entity.Authority import com.example.jhouse_server.domain.user.entity.QUser.user import com.example.jhouse_server.domain.user.entity.QUserJoinPath.userJoinPath @@ -20,6 +22,7 @@ import com.example.jhouse_server.domain.user.repository.dto.QAdminUserAnalysisJo import com.querydsl.core.types.dsl.BooleanExpression import com.querydsl.jpa.impl.JPAQueryFactory import org.springframework.data.domain.Page +import org.springframework.data.domain.PageImpl import org.springframework.data.domain.Pageable import org.springframework.data.support.PageableExecutionUtils import java.util.stream.Collectors @@ -131,6 +134,33 @@ class UserRepositoryImpl( return PageableExecutionUtils.getPage(result, pageable) {countQuery.fetch().size.toLong()} } + + override fun getUserWithSearchForm( + adminUserSearch: AdminUserWithdrawalSearch, + pageable: Pageable + ): Page { + val result = jpaQueryFactory.select( + QAdminUserList( + user.id, + user.nickName, + user.email, + user.userType, + user.phoneNum, + user.createdAt, + user.age + ) + ).from(user) + .where(searchUserFilter(adminUserSearch)) + .offset(pageable.offset) + .limit(pageable.pageSize.toLong()) + .fetch() + + val countQuery = jpaQueryFactory + .selectFrom(user) + .where(searchUserFilter(adminUserSearch)) + .fetch().size.toLong() + return PageImpl(result, pageable, countQuery) + } /** * ============================================================================================ * PRIVATE FUNCTION diff --git a/src/main/kotlin/com/example/jhouse_server/global/config/RequestServletFilter.kt b/src/main/kotlin/com/example/jhouse_server/global/config/RequestServletFilter.kt index 1097073e..5929ed70 100644 --- a/src/main/kotlin/com/example/jhouse_server/global/config/RequestServletFilter.kt +++ b/src/main/kotlin/com/example/jhouse_server/global/config/RequestServletFilter.kt @@ -1,22 +1,22 @@ -package com.example.jhouse_server.global.config - -import org.springframework.stereotype.Component -import javax.servlet.Filter -import javax.servlet.FilterChain -import javax.servlet.ServletRequest -import javax.servlet.ServletResponse -import javax.servlet.http.HttpServletRequest - -@Component -class RequestServletFilter : Filter { - override fun doFilter( - request: ServletRequest, - response: ServletResponse, - chain: FilterChain - ) { - val wrappedRequest: HttpServletRequest = - RequestServletWrapper(request as HttpServletRequest) - - chain.doFilter(wrappedRequest, response) - } -} \ No newline at end of file +//package com.example.jhouse_server.global.config +// +//import org.springframework.stereotype.Component +//import javax.servlet.Filter +//import javax.servlet.FilterChain +//import javax.servlet.ServletRequest +//import javax.servlet.ServletResponse +//import javax.servlet.http.HttpServletRequest +// +//@Component +//class RequestServletFilter : Filter { +// override fun doFilter( +// request: ServletRequest, +// response: ServletResponse, +// chain: FilterChain +// ) { +// val wrappedRequest: HttpServletRequest = +// RequestServletWrapper(request as HttpServletRequest) +// +// chain.doFilter(wrappedRequest, response) +// } +//} \ No newline at end of file diff --git a/src/main/kotlin/com/example/jhouse_server/global/config/RequestServletWrapper.kt b/src/main/kotlin/com/example/jhouse_server/global/config/RequestServletWrapper.kt index 4b41b5cd..f69ee537 100644 --- a/src/main/kotlin/com/example/jhouse_server/global/config/RequestServletWrapper.kt +++ b/src/main/kotlin/com/example/jhouse_server/global/config/RequestServletWrapper.kt @@ -1,64 +1,64 @@ -package com.example.jhouse_server.global.config - -import java.io.IOException -import java.io.StringReader -import java.util.* -import javax.servlet.ReadListener -import javax.servlet.ServletInputStream -import javax.servlet.http.HttpServletRequest -import javax.servlet.http.HttpServletRequestWrapper - - -class RequestServletWrapper(request: HttpServletRequest) : HttpServletRequestWrapper(request) { - private var requestData: String? = null - - init { - try { - val s = request.inputStream?.let { Scanner(it).useDelimiter("\\A") } - if (s != null) { - requestData = if (s.hasNext()) s.next() else "" - } - } catch (e: IOException) { - e.printStackTrace() - } - } - - override fun getInputStream(): ServletInputStream { - val reader = StringReader(requestData) - - return object : ServletInputStream() { - private var readListener: ReadListener? = null - - @Throws(IOException::class) - override fun read(): Int { - return reader.read() - } - - override fun setReadListener(listener: ReadListener?) { - readListener = listener - try { - if (!isFinished) { - readListener?.onDataAvailable() - } else { - readListener?.onAllDataRead() - } - } catch (io: IOException) { - io.printStackTrace() - } - } - - override fun isReady(): Boolean { - return isFinished - } - - override fun isFinished(): Boolean { - try { - return reader.read() < 0 - } catch (e: IOException) { - e.printStackTrace() - } - return false - } - } - } -} \ No newline at end of file +//package com.example.jhouse_server.global.config +// +//import java.io.IOException +//import java.io.StringReader +//import java.util.* +//import javax.servlet.ReadListener +//import javax.servlet.ServletInputStream +//import javax.servlet.http.HttpServletRequest +//import javax.servlet.http.HttpServletRequestWrapper +// +// +//class RequestServletWrapper(request: HttpServletRequest) : HttpServletRequestWrapper(request) { +// private var requestData: String? = null +// +// init { +// try { +// val s = request.inputStream?.let { Scanner(it).useDelimiter("\\A") } +// if (s != null) { +// requestData = if (s.hasNext()) s.next() else "" +// } +// } catch (e: IOException) { +// e.printStackTrace() +// } +// } +// +// override fun getInputStream(): ServletInputStream { +// val reader = StringReader(requestData) +// +// return object : ServletInputStream() { +// private var readListener: ReadListener? = null +// +// @Throws(IOException::class) +// override fun read(): Int { +// return reader.read() +// } +// +// override fun setReadListener(listener: ReadListener?) { +// readListener = listener +// try { +// if (!isFinished) { +// readListener?.onDataAvailable() +// } else { +// readListener?.onAllDataRead() +// } +// } catch (io: IOException) { +// io.printStackTrace() +// } +// } +// +// override fun isReady(): Boolean { +// return isFinished +// } +// +// override fun isFinished(): Boolean { +// try { +// return reader.read() < 0 +// } catch (e: IOException) { +// e.printStackTrace() +// } +// return false +// } +// } +// } +//} \ No newline at end of file diff --git a/src/main/kotlin/com/example/jhouse_server/global/config/WebConfig.kt b/src/main/kotlin/com/example/jhouse_server/global/config/WebConfig.kt index bde3828f..6136da54 100644 --- a/src/main/kotlin/com/example/jhouse_server/global/config/WebConfig.kt +++ b/src/main/kotlin/com/example/jhouse_server/global/config/WebConfig.kt @@ -2,7 +2,6 @@ package com.example.jhouse_server.global.config import com.example.jhouse_server.admin.auth.interceptor.LoginCheckInterceptor import com.example.jhouse_server.global.interceptor.HttpInterceptor -import com.example.jhouse_server.global.interceptor.LogInterceptor import com.example.jhouse_server.global.interceptor.SmsInterceptor import com.example.jhouse_server.global.resolver.AuthUserResolver import org.springframework.context.annotation.Configuration @@ -17,7 +16,7 @@ class WebConfig ( val authUserResolver: AuthUserResolver, val httpInterceptor: HttpInterceptor, val smsInterceptor: SmsInterceptor, - val logInterceptor: LogInterceptor +// val logInterceptor: LogInterceptor ): WebMvcConfigurer { @@ -46,9 +45,9 @@ class WebConfig ( } override fun addInterceptors(registry: InterceptorRegistry) { - registry.addInterceptor(logInterceptor) - .addPathPatterns("/**") - .excludePathPatterns("/css/**", "/error") +// registry.addInterceptor(logInterceptor) +// .addPathPatterns("/**") +// .excludePathPatterns("/css/**", "/error") registry.addInterceptor(LoginCheckInterceptor()) .order(1) .addPathPatterns("/**") diff --git a/src/main/kotlin/com/example/jhouse_server/global/interceptor/LogInterceptor.kt b/src/main/kotlin/com/example/jhouse_server/global/interceptor/LogInterceptor.kt index 57e4ddbd..4df0db4b 100644 --- a/src/main/kotlin/com/example/jhouse_server/global/interceptor/LogInterceptor.kt +++ b/src/main/kotlin/com/example/jhouse_server/global/interceptor/LogInterceptor.kt @@ -1,60 +1,60 @@ -package com.example.jhouse_server.global.interceptor - -import com.fasterxml.jackson.databind.ObjectMapper -import org.slf4j.LoggerFactory -import org.springframework.stereotype.Component -import org.springframework.web.servlet.HandlerInterceptor -import org.springframework.web.servlet.ModelAndView -import java.util.* -import javax.servlet.http.HttpServletRequest -import javax.servlet.http.HttpServletResponse - -@Component -class LogInterceptor : HandlerInterceptor { - private val LOG_ID = "logId" - private val logger = LoggerFactory.getLogger(this::class.java) - override fun preHandle( - request: HttpServletRequest, - response: HttpServletResponse, - handler: Any - ): Boolean { - val uuid = UUID.randomUUID().toString(); - request.setAttribute(LOG_ID, uuid); - return if (request.method == "POST") { - val inputMap: Map = ObjectMapper().readValue( - request.inputStream, - Map::class.java - ) as Map - logger.info("요청 정보: $inputMap") - logger.info("요청 URL: " + request.requestURL) - true - } else { - logger.info("요청 정보: " + request.queryString) - logger.info("요청 URL: " + request.requestURL) - true - } - } - - override fun postHandle( - request: HttpServletRequest, - response: HttpServletResponse, - handler: Any, - modelAndView: ModelAndView? - ) { - logger.info("postHandle [{}]", modelAndView) - } - - override fun afterCompletion( - request: HttpServletRequest, - response: HttpServletResponse, - handler: Any, - ex: Exception? - ) { - val requestURI = request.requestURI - val logId = request.getAttribute(LOG_ID) as String - logger.info("RESPONSE [{}][{}][{}]", logId, requestURI, handler) - if (ex != null) { - logger.error("afterCompletion error!!", ex) - } - } -} \ No newline at end of file +//package com.example.jhouse_server.global.interceptor +// +//import com.fasterxml.jackson.databind.ObjectMapper +//import org.slf4j.LoggerFactory +//import org.springframework.stereotype.Component +//import org.springframework.web.servlet.HandlerInterceptor +//import org.springframework.web.servlet.ModelAndView +//import java.util.* +//import javax.servlet.http.HttpServletRequest +//import javax.servlet.http.HttpServletResponse +// +//@Component +//class LogInterceptor : HandlerInterceptor { +// private val LOG_ID = "logId" +// private val logger = LoggerFactory.getLogger(this::class.java) +// override fun preHandle( +// request: HttpServletRequest, +// response: HttpServletResponse, +// handler: Any +// ): Boolean { +// val uuid = UUID.randomUUID().toString(); +// request.setAttribute(LOG_ID, uuid); +// return if (request.method == "POST") { +// val inputMap: Map = ObjectMapper().readValue( +// request.inputStream, +// Map::class.java +// ) as Map +// logger.info("요청 정보: $inputMap") +// logger.info("요청 URL: " + request.requestURL) +// true +// } else { +// logger.info("요청 정보: " + request.queryString) +// logger.info("요청 URL: " + request.requestURL) +// true +// } +// } +// +// override fun postHandle( +// request: HttpServletRequest, +// response: HttpServletResponse, +// handler: Any, +// modelAndView: ModelAndView? +// ) { +// logger.info("postHandle [{}]", modelAndView) +// } +// +// override fun afterCompletion( +// request: HttpServletRequest, +// response: HttpServletResponse, +// handler: Any, +// ex: Exception? +// ) { +// val requestURI = request.requestURI +// val logId = request.getAttribute(LOG_ID) as String +// logger.info("RESPONSE [{}][{}][{}]", logId, requestURI, handler) +// if (ex != null) { +// logger.error("afterCompletion error!!", ex) +// } +// } +//} \ No newline at end of file diff --git a/src/main/resources/templates/fragments/nav.html b/src/main/resources/templates/fragments/nav.html index 6f0b6f5a..b0f67c19 100644 --- a/src/main/resources/templates/fragments/nav.html +++ b/src/main/resources/templates/fragments/nav.html @@ -37,6 +37,7 @@
  • 가입 승인
  • 공인중개사 탈퇴
  • 일반회원 탈퇴
  • +
  • 가입자 정보 확인
  • diff --git a/src/main/resources/templates/user/userManager.html b/src/main/resources/templates/user/userManager.html new file mode 100644 index 00000000..ac32d5f1 --- /dev/null +++ b/src/main/resources/templates/user/userManager.html @@ -0,0 +1,170 @@ + + + + + + + + + + +
    +
    +
    +
    + +
    +
    +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    No.닉네임이메일유저 타입전화번호가입일자 + +
    + 1 + + 관리자 + + admin@jmhouse.org + + USER + + 010-0000-0000 + + 2024.01.01 + + 20대 +
    + + + +
    + + + + \ No newline at end of file