Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: 관리자 신고처리 #206

Merged
merged 7 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ tasks.jacocoTestReport {
excludes.add("**/build/generated/source/**")
excludes.add("com/example/jhouse_server/domain/user/repository/**")
excludes.add("com/example/jhouse_server/domain/board/repository/**")
excludes.add("com/example/jhouse_server/domain/house/repository/**")

classDirectories.setFrom(
sourceSets.main.get().output.asFileTree.matching {
Expand Down Expand Up @@ -187,6 +188,7 @@ tasks.jacocoTestCoverageVerification {
excludes.add("com/example/jhouse_server/admin/**")
excludes.add("com/example/jhouse_server/domain/board/entity/BoardCategoryConverter.kt")
excludes.add("com/example/jhouse_server/domain/board/entity/PrefixCategoryConverter.kt")
excludes.add("com/example/jhouse_server/domain/house/repository/**")
excludes.add("**/resources/**")


Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
container_name: redis_test
image: redis:latest
ports:
- "6375:6379"
- "6376:6379"
networks:
- db_network

Expand All @@ -19,7 +19,7 @@ services:
command:
- --default-authentication-plugin=mysql_native_password
ports:
- "3302:3306"
- "3303:3306"
networks:
- db_network

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping
@Controller
@RequestMapping("/admin/analysis")
class AdminAnalysisController (
var analysisService: AnalysisService
val analysisService: AnalysisService
){

@GetMapping("/join-path")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.springframework.stereotype.Service

@Service
class AnalysisService (
var userRepository: UserRepository
val userRepository: UserRepository
){

fun getAnalysisAgeResult() : List<Double> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import javax.servlet.http.HttpServletRequest
@Controller
@RequestMapping("/admin")
class AdminAuthController (
var userRepository: UserRepository,
var userService: UserService
val userRepository: UserRepository,
val userService: UserService
){

// 메인 페이지 - 로그인 화면
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes
@Controller
@RequestMapping("/admin/board")
class AdminBoardController(
var adminBoardService: AdminBoardService
val adminBoardService: AdminBoardService
) {


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.jhouse_server.admin.board.dto


data class AdminBoardDeleteList(
var deleteBoardList: List<Long>?
)

data class AdminBoardFixList(
val fixBoardIds : List<Long>?
)

data class AdminBoardSearch(
val filter: BoardSearchFilter?,
val keyword: String?
)

enum class BoardSearchFilter (val value: String){
TITLE("게시물 제목"),
CONTENT("게시물 내용"),
WRITER("게시물 작성자");
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes
@Service
@Transactional(readOnly = true)
class AdminBoardService(
var boardRepository: BoardRepository
val boardRepository: BoardRepository
) {

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.example.jhouse_server.admin.report.controller

import com.example.jhouse_server.admin.report.dto.ReportAgentList
import com.example.jhouse_server.admin.report.dto.ReportSearch
import com.example.jhouse_server.admin.report.dto.AdminReportSearchFilter
import com.example.jhouse_server.admin.report.service.AdminReportService
import com.example.jhouse_server.domain.house.repository.ReportRepository
import org.springframework.data.domain.Pageable
import org.springframework.data.web.PageableDefault
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.ModelAttribute
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.servlet.mvc.support.RedirectAttributes

@RequestMapping("/admin/report")
@Controller
class AdminReportController(
val reportRepository: ReportRepository,
val adminReportService: AdminReportService
) {

@GetMapping()
fun getReports(@ModelAttribute("searchForm") reportSearch: ReportSearch
, @ModelAttribute("agentList") agentList: ReportAgentList
, model: Model
, @PageableDefault(size=10, page=0) pageable: Pageable): String{

val pageCom = pageable.pageNumber / 5
model.addAttribute("pageCom", pageCom)
model.addAttribute("filterList", AdminReportSearchFilter.values())
model.addAttribute("reportList", reportRepository.getReports(reportSearch, pageable))

return "report/reports"
}

@GetMapping("{agent_id}")
fun getReportDetail(@PathVariable("agent_id") id: Long, model: Model): String{
val result = reportRepository.getReportDetail(id)
model.addAttribute("reportList", result)
return "report/reportDetail"
}

@PostMapping("{type}")
fun changeUserSuspensionStatus(@PathVariable("type") type: String
, @ModelAttribute("agentList") agentList: ReportAgentList
, redirectAttributes: RedirectAttributes): String {
if(type == "suspension") {
adminReportService.suspensionUser(agentList, redirectAttributes)
} else {
adminReportService.cancelSuspensionUser(agentList, redirectAttributes)
}
return "redirect:/admin/report"
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.example.jhouse_server.admin.report.dto

data class ReportSearch(
val filter: AdminReportSearchFilter?,
val keyword: String?
)

data class ReportAgentList(
val agentIds: List<Long>?
)

enum class AdminReportSearchFilter(val value: String) {
NICKNAME("닉네임")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.example.jhouse_server.admin.report.service

import com.example.jhouse_server.admin.report.dto.ReportAgentList
import com.example.jhouse_server.domain.house.repository.ReportRepository
import com.example.jhouse_server.domain.user.repository.UserRepository
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import org.springframework.web.servlet.mvc.support.RedirectAttributes

@Service
class AdminReportService(
val reportRepository: ReportRepository,
val userRepository: UserRepository
) {

// 계정 정지
@Transactional
fun suspensionUser(agentList: ReportAgentList, redirectAttributes: RedirectAttributes) {
val findUsers = agentList.agentIds?.let { userRepository.findByIds(it) }
findUsers?.forEach { u ->
if(u.suspension) redirectAttributes.addAttribute("already_suspension", "이미 정지처리 된 계정이 포함되어 있습니다.")
}
if (redirectAttributes.containsAttribute("already_suspension")) return
findUsers?.forEach { u -> u.updateSuspension(true) }
}

@Transactional
fun cancelSuspensionUser(agentList: ReportAgentList, redirectAttributes: RedirectAttributes) {
val findUsers = agentList.agentIds?.let { userRepository.findByIds(it) }
findUsers?.forEach { u ->
if(!u.suspension) redirectAttributes.addAttribute("already_cancel", "이미 정지해제된 계정이 포함되어 있습니다.")
}
if (redirectAttributes.containsAttribute("already_cancel")) return
findUsers?.forEach { u -> u.updateSuspension(false) }
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.example.jhouse_server.admin.user.controller

import com.example.jhouse_server.admin.user.dto.join.AdminAgentSearch
import com.example.jhouse_server.admin.user.dto.join.AdminJoinAgentList
import com.example.jhouse_server.admin.user.dto.join.AgentSearchFilter
import com.example.jhouse_server.admin.user.dto.withdrawal.AdminUserWithdrawalSearch
import com.example.jhouse_server.admin.user.dto.withdrawal.AdminWithdrawalList
import com.example.jhouse_server.admin.user.dto.withdrawal.UserSearchFilter
import com.example.jhouse_server.admin.user.dto.AdminAgentSearch
import com.example.jhouse_server.admin.user.dto.AdminJoinAgentList
import com.example.jhouse_server.admin.user.dto.AgentSearchFilter
import com.example.jhouse_server.admin.user.dto.AdminUserWithdrawalSearch
import com.example.jhouse_server.admin.user.dto.AdminWithdrawalList
import com.example.jhouse_server.admin.user.dto.UserSearchFilter
import com.example.jhouse_server.admin.user.service.AdminUserService
import com.example.jhouse_server.domain.user.entity.UserType
import com.example.jhouse_server.domain.user.entity.UserType.*
Expand All @@ -26,9 +26,9 @@ import org.springframework.web.bind.annotation.RequestMapping
@Controller
@RequestMapping("/admin/user")
class AdminUserController(
var userRepository: UserRepository,
var agentRepository: AgentRepository,
var adminUserService: AdminUserService
val userRepository: UserRepository,
val agentRepository: AgentRepository,
val adminUserService: AdminUserService
) {


Expand Down Expand Up @@ -93,4 +93,12 @@ class AdminUserController(
}
return "redirect:/admin/user/withdrawal"
}

@GetMapping("/withdrawal/reason/{id}")
fun withdrawalDetail(@PathVariable id: Long, model: Model): String {
val findUser = userRepository.findById(id).get()
model.addAttribute("user", findUser)

return "user/withdrawalDetail"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.example.jhouse_server.admin.user.dto


data class AdminAgentSearch(
val filter: AgentSearchFilter?,
val keyword: String?
)

data class AdminJoinAgentList(
val joinAgentIds: List<Long>?
)

data class AdminUserWithdrawalSearch(
val filter: UserSearchFilter?,
val keyword: String?
)

data class AdminWithdrawalList(
val withdrawalIds: List<Long>?
)

enum class AgentSearchFilter(val value: String) {
ESTATE("부동산");
}

enum class UserSearchFilter(val value: String){
NICKNAME("이름")
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.example.jhouse_server.admin.user.service

import com.example.jhouse_server.admin.user.dto.join.AdminJoinAgentList
import com.example.jhouse_server.admin.user.dto.withdrawal.AdminUserWithdrawalSearch
import com.example.jhouse_server.admin.user.dto.withdrawal.AdminWithdrawalList

import com.example.jhouse_server.admin.user.dto.AdminJoinAgentList
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
Expand Down
Loading