diff --git a/app-main/build.gradle b/app-main/build.gradle index 5adbc55d6..6d2dc5e21 100644 --- a/app-main/build.gradle +++ b/app-main/build.gradle @@ -20,14 +20,11 @@ spotless { target '**/*.java' // 네이버 자바 컨벤션 적용 - importOrder() // import 순서 정리 + importOrder("java","javax","org","net","com","") // import 순서 정리 removeUnusedImports() // 네이버 코딩 컨벤션 XML 파일 사용 eclipse().configFile('naver-eclipse-formatter.xml') - - trimTrailingWhitespace() - endWithNewline() } } diff --git a/app-main/src/main/java/net/causw/app/main/api/BoardController.java b/app-main/src/main/java/net/causw/app/main/api/BoardController.java index 87a638acc..1482d59a0 100644 --- a/app-main/src/main/java/net/causw/app/main/api/BoardController.java +++ b/app-main/src/main/java/net/causw/app/main/api/BoardController.java @@ -16,8 +16,6 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; -import net.causw.app.main.domain.community.board.service.BoardService; import net.causw.app.main.api.dto.board.BoardAppliesResponseDto; import net.causw.app.main.api.dto.board.BoardApplyRequestDto; import net.causw.app.main.api.dto.board.BoardApplyResponseDto; @@ -28,6 +26,8 @@ import net.causw.app.main.api.dto.board.BoardResponseDto; import net.causw.app.main.api.dto.board.BoardSubscribeResponseDto; import net.causw.app.main.api.dto.board.BoardUpdateRequestDto; +import net.causw.app.main.domain.community.board.service.BoardService; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.global.exception.BadRequestException; import net.causw.global.exception.InternalServerException; import net.causw.global.exception.UnauthorizedException; @@ -48,8 +48,7 @@ public class BoardController { @GetMapping @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "게시판 검색 API(완료)" - , description = "전체 게시판을 불러오는 api로 관리자 권한을 가진 경우 삭제된 게시판도 확인할 수 있습니다.
" + + @Operation(summary = "게시판 검색 API(완료)", description = "전체 게시판을 불러오는 api로 관리자 권한을 가진 경우 삭제된 게시판도 확인할 수 있습니다.
" + "학적이 GRADUATED인 졸업생이 접근할 경우 크자회에게 제공되는 (isAlumni가 true) 게시판만 조회됩니다.") @ApiResponses(value = { @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -60,15 +59,14 @@ public class BoardController { @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public List findAllBoard( - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.boardService.findAllBoard(userDetails.getUser()); } @GetMapping("/main") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "게시판 검색 API(완료)" - , description = "전체 게시판을 불러오는 api로 관리자 권한을 가진 경우 삭제된 게시판도 확인할 수 있습니다.
" + @Operation(summary = "게시판 검색 API(완료)", description = "전체 게시판을 불러오는 api로 관리자 권한을 가진 경우 삭제된 게시판도 확인할 수 있습니다.
" + "학적이 GRADUATED인 졸업생이 접근할 경우 크자회에게 제공되는 (isAlumni가 true) 게시판만 조회됩니다.") @ApiResponses(value = { @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -79,8 +77,8 @@ public List findAllBoard( @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public List mainBoard( - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.boardService.mainBoard(userDetails.getUser()); } @@ -92,8 +90,8 @@ public List mainBoard( @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public BoardNameCheckResponseDto checkBoardName( - @RequestBody @Valid BoardNameCheckRequestDto boardNameCheckRequestDto - ) { + @RequestBody @Valid + BoardNameCheckRequestDto boardNameCheckRequestDto) { return this.boardService.checkBoardName(boardNameCheckRequestDto); } @@ -109,9 +107,10 @@ public BoardNameCheckResponseDto checkBoardName( @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public void applyBoard( - @RequestBody @Valid BoardApplyRequestDto boardApplyRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @RequestBody @Valid + BoardApplyRequestDto boardApplyRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { this.boardService.applyBoard(userDetails.getUser(), boardApplyRequestDto); } @@ -128,9 +127,10 @@ public void applyBoard( @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public BoardResponseDto createBoard( - @Valid @RequestBody BoardCreateRequestDto boardCreateRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @Valid @RequestBody + BoardCreateRequestDto boardCreateRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.boardService.createNoticeBoard(userDetails.getUser(), boardCreateRequestDto); } @@ -163,8 +163,8 @@ public List findAllBoardApply() { @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public BoardApplyResponseDto findBoardApplyById( - @PathVariable("id") String id - ) { + @PathVariable("id") + String id) { return this.boardService.findBoardApplyByApplyId(id); } @@ -182,8 +182,8 @@ public BoardApplyResponseDto findBoardApplyById( @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public BoardApplyResponseDto acceptApply( - @PathVariable("applyId") String applyId - ) { + @PathVariable("applyId") + String applyId) { return this.boardService.accept(applyId); } @@ -202,8 +202,8 @@ public BoardApplyResponseDto acceptApply( @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public BoardApplyResponseDto rejectApply( - @PathVariable("applyId") String applyId - ) { + @PathVariable("applyId") + String applyId) { return this.boardService.reject(applyId); } @@ -224,10 +224,12 @@ public BoardApplyResponseDto rejectApply( @ApiResponse(responseCode = "5001", description = "Board id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public BoardResponseDto updateBoard( - @PathVariable("id") String id, - @Valid @RequestBody BoardUpdateRequestDto boardUpdateRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @Valid @RequestBody + BoardUpdateRequestDto boardUpdateRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.boardService.updateBoard(userDetails.getUser(), id, boardUpdateRequestDto); } @@ -247,9 +249,10 @@ public BoardResponseDto updateBoard( @ApiResponse(responseCode = "5000", description = "Board id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public BoardResponseDto deleteBoard( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.boardService.deleteBoard(userDetails.getUser(), id); } @@ -270,43 +273,43 @@ public BoardResponseDto deleteBoard( @ApiResponse(responseCode = "5000", description = "Board id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public BoardResponseDto restoreBoard( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable("id") String id - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable("id") + String id) { return this.boardService.restoreBoard(userDetails.getUser(), id); } @PostMapping("/subscribe/{id}") @ResponseStatus(HttpStatus.OK) - @Operation(summary = "로그인한 사용자의 게시판 알람 설정 켜기" - , description = "id에는 board id 값을 넣어주세요") + @Operation(summary = "로그인한 사용자의 게시판 알람 설정 켜기", description = "id에는 board id 값을 넣어주세요") public BoardSubscribeResponseDto subscribeBoard( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable("id") String id - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable("id") + String id) { return boardService.setBoardSubscribe(userDetails.getUser(), id, true); } @DeleteMapping("/subscribe/{id}") @ResponseStatus(HttpStatus.OK) - @Operation(summary = "로그인한 사용자의 게시판 알람 설정 끄기" - , description = "id에는 board id 값을 넣어주세요") + @Operation(summary = "로그인한 사용자의 게시판 알람 설정 끄기", description = "id에는 board id 값을 넣어주세요") public BoardSubscribeResponseDto unsubscribeBoard( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable("id") String id - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable("id") + String id) { return boardService.setBoardSubscribe(userDetails.getUser(), id, false); } @PostMapping("/subscribe") @ResponseStatus(HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "게시판 구독 데이터 생성 API(관리자용/임시)", - description = "id에는 board id 값을 넣어주세요
" + - "기존 게시판들의 구독 여부 저장을 위한 임시 api 입니다. 설정후 삭제 예정이고, 추후에는 공지게시판 생성과 동시에 구독여부도 저장될 예정입니다.") + @Operation(summary = "게시판 구독 데이터 생성 API(관리자용/임시)", description = "id에는 board id 값을 넣어주세요
" + + "기존 게시판들의 구독 여부 저장을 위한 임시 api 입니다. 설정후 삭제 예정이고, 추후에는 공지게시판 생성과 동시에 구독여부도 저장될 예정입니다.") public void createBoardSubscribe( - @RequestParam("id") String id - ) { + @RequestParam("id") + String id) { this.boardService.createBoardSubscribe(id); } diff --git a/app-main/src/main/java/net/causw/app/main/api/CalendarController.java b/app-main/src/main/java/net/causw/app/main/api/CalendarController.java index b790fbd9a..3e5218776 100644 --- a/app-main/src/main/java/net/causw/app/main/api/CalendarController.java +++ b/app-main/src/main/java/net/causw/app/main/api/CalendarController.java @@ -45,7 +45,8 @@ public class CalendarController { @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @ApiResponse(responseCode = "5000", description = "User id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) - public CalendarsResponseDto findCalendars(@RequestParam("year") Integer year) { + public CalendarsResponseDto findCalendars(@RequestParam("year") + Integer year) { return calendarService.findCalendarByYear(year); } @@ -59,7 +60,8 @@ public CalendarsResponseDto findCalendars(@RequestParam("year") Integer year) { @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @ApiResponse(responseCode = "5000", description = "User id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) - public CalendarResponseDto findCalendars(@PathVariable("calendarId") String calendarId) { + public CalendarResponseDto findCalendars(@PathVariable("calendarId") + String calendarId) { return calendarService.findCalendar(calendarId); } @@ -88,9 +90,10 @@ public CalendarResponseDto findHomeCalendar() { @ApiResponse(responseCode = "5000", description = "User id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public CalendarResponseDto createCalendar( - @RequestPart(value = "calendarCreateRequestDto") @Valid CalendarCreateRequestDto calendarCreateRequestDto, - @RequestPart(value = "image") MultipartFile image - ) { + @RequestPart(value = "calendarCreateRequestDto") @Valid + CalendarCreateRequestDto calendarCreateRequestDto, + @RequestPart(value = "image") + MultipartFile image) { return calendarService.createCalendar(calendarCreateRequestDto, image); } @@ -105,10 +108,12 @@ public CalendarResponseDto createCalendar( @ApiResponse(responseCode = "5000", description = "User id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public CalendarResponseDto updateCalendar( - @PathVariable("calendarId") String calendarId, - @RequestPart(value = "calendarUpdateRequestDto") @Valid CalendarUpdateRequestDto calendarUpdateRequestDto, - @RequestPart(value = "image") MultipartFile image - ) { + @PathVariable("calendarId") + String calendarId, + @RequestPart(value = "calendarUpdateRequestDto") @Valid + CalendarUpdateRequestDto calendarUpdateRequestDto, + @RequestPart(value = "image") + MultipartFile image) { return calendarService.updateCalendar(calendarId, calendarUpdateRequestDto, image); } @@ -123,8 +128,8 @@ public CalendarResponseDto updateCalendar( @ApiResponse(responseCode = "5000", description = "User id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public CalendarResponseDto deleteCalendar( - @PathVariable("calendarId") String calendarId - ) { + @PathVariable("calendarId") + String calendarId) { return calendarService.deleteCalendar(calendarId); } } diff --git a/app-main/src/main/java/net/causw/app/main/api/CeremonyController.java b/app-main/src/main/java/net/causw/app/main/api/CeremonyController.java index a683960b1..15d492ea6 100644 --- a/app-main/src/main/java/net/causw/app/main/api/CeremonyController.java +++ b/app-main/src/main/java/net/causw/app/main/api/CeremonyController.java @@ -19,7 +19,6 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.app.main.api.dto.ceremony.CeremonyNotificationSettingResponseDto; import net.causw.app.main.api.dto.ceremony.CeremonyResponseDto; import net.causw.app.main.api.dto.ceremony.CreateCeremonyNotificationSettingDto; @@ -29,6 +28,7 @@ import net.causw.app.main.domain.community.ceremony.enums.CeremonyContext; import net.causw.app.main.domain.community.ceremony.enums.CeremonyState; import net.causw.app.main.domain.community.ceremony.service.CeremonyService; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import io.swagger.v3.oas.annotations.Operation; import jakarta.validation.Valid; @@ -50,51 +50,54 @@ public class CeremonyController { @PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(value = HttpStatus.CREATED) - @Operation(summary = "사용자 본인의 경조사 생성", - description = "사용자 본인의 경조사 생성합니다.") + @Operation(summary = "사용자 본인의 경조사 생성", description = "사용자 본인의 경조사 생성합니다.") public CeremonyResponseDto createCeremony( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestPart(value = "createCeremonyRequestDTO") @Valid CreateCeremonyRequestDto createCeremonyRequestDTO, - @RequestPart(value = "imageFileList", required = false) List imageFileList - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestPart(value = "createCeremonyRequestDTO") @Valid + CreateCeremonyRequestDto createCeremonyRequestDTO, + @RequestPart(value = "imageFileList", required = false) + List imageFileList) { return ceremonyService.createCeremony(userDetails.getUser(), createCeremonyRequestDTO, imageFileList); } @GetMapping @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "사용자 본인의 경조사 신청 내역 조회", - description = "사용자 본인의 경조사 신청 내역을 조회합니다.") + @Operation(summary = "사용자 본인의 경조사 신청 내역 조회", description = "사용자 본인의 경조사 신청 내역을 조회합니다.") public Page getCeremonies( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestParam(name = "ceremonyState", defaultValue = "ACCEPT") CeremonyState state, - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestParam(name = "ceremonyState", defaultValue = "ACCEPT") + CeremonyState state, + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum) { return ceremonyService.getUserCeremonyResponses(userDetails.getUser(), state, pageNum); } @GetMapping("/list/await") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES_AND_LEADER_ALUMNI)") - @Operation(summary = "전체 경조사 승인 대기 목록 조회(관리자용)", - description = "전체 경조사 승인 대기 목록을 조회합니다.") + @Operation(summary = "전체 경조사 승인 대기 목록 조회(관리자용)", description = "전체 경조사 승인 대기 목록을 조회합니다.") public Page getAllUserAwaitingCeremonyPage( - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum - ) { + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum) { return ceremonyService.getAllUserAwaitingCeremonyPage(pageNum); } @GetMapping("/{ceremonyId}") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "유저 경조사 정보 상세 보기", - description = "유저 경조사 정보를 조회합니다. 접근한 페이지에 따라 Request Param을 다르게 해주세요.
" + - "general : 전체 알림 페이지에서 접근
" + - "my : 내 경조사 목록에서 접근
" + - "admin : 관리자용 경조사 관리 페이지에서 접근
") + @Operation(summary = "유저 경조사 정보 상세 보기", description = "유저 경조사 정보를 조회합니다. 접근한 페이지에 따라 Request Param을 다르게 해주세요.
" + + + "general : 전체 알림 페이지에서 접근
" + + "my : 내 경조사 목록에서 접근
" + + "admin : 관리자용 경조사 관리 페이지에서 접근
") public CeremonyResponseDto getUserCeremonyInfo( - @PathVariable("ceremonyId") String ceremonyId, - @RequestParam(name = "context") String contextParam, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("ceremonyId") + String ceremonyId, + @RequestParam(name = "context") + String contextParam, + @AuthenticationPrincipal + CustomUserDetails userDetails) { CeremonyContext context = CeremonyContext.fromString(contextParam); return ceremonyService.getCeremony(ceremonyId, context, userDetails.getUser()); } @@ -102,33 +105,32 @@ public CeremonyResponseDto getUserCeremonyInfo( @PutMapping("/state") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES_AND_LEADER_ALUMNI)") - @Operation(summary = "유저 경조사 승인 상태 변경(승인/거부)(관리자용)", - description = "유저 경조사 승인 상태를 변경합니다.") + @Operation(summary = "유저 경조사 승인 상태 변경(승인/거부)(관리자용)", description = "유저 경조사 승인 상태를 변경합니다.") public CeremonyResponseDto updateUserCeremonyStatus( - @RequestBody @Valid UpdateCeremonyStateRequestDto updateCeremonyStateRequestDto - ) { + @RequestBody @Valid + UpdateCeremonyStateRequestDto updateCeremonyStateRequestDto) { return ceremonyService.updateUserCeremonyStatus(updateCeremonyStateRequestDto); } @PutMapping("/state/close/{ceremonyId}") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "유저 경조사 신청 취소(사용자용)", - description = "유저가 본인의 경조사 승인 상태를 close로 변경합니다.") + @Operation(summary = "유저 경조사 신청 취소(사용자용)", description = "유저가 본인의 경조사 승인 상태를 close로 변경합니다.") public CeremonyResponseDto closeUserCeremonyStatus( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable(name = "ceremonyId") String ceremonyId - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable(name = "ceremonyId") + String ceremonyId) { return ceremonyService.closeUserCeremonyStatus(userDetails.getUser(), ceremonyId); } @PostMapping("/notification-setting") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "유저 경조사 알람 설정 생성", - description = "유저 경조사 알람 설정을 생성합니다. 학번은 2자리로 입력해주세요. (ex. 19)") + @Operation(summary = "유저 경조사 알람 설정 생성", description = "유저 경조사 알람 설정을 생성합니다. 학번은 2자리로 입력해주세요. (ex. 19)") public CeremonyNotificationSettingResponseDto createCeremonyNotificationSetting( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestBody @Valid CreateCeremonyNotificationSettingDto ceremonyNotificationSettingDTO - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestBody @Valid + CreateCeremonyNotificationSettingDto ceremonyNotificationSettingDTO) { return ceremonyService.createCeremonyNotificationSettings(userDetails.getUser(), ceremonyNotificationSettingDTO); } @@ -137,7 +139,8 @@ public CeremonyNotificationSettingResponseDto createCeremonyNotificationSetting( @ResponseStatus(value = HttpStatus.OK) @Operation(summary = "유저 경조사 알람 설정 조회", description = "유저의 경조사 알람 설정을 조회합니다.") public CeremonyNotificationSettingResponseDto getCeremonyNotificationSetting( - @AuthenticationPrincipal CustomUserDetails userDetails) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { return ceremonyService.getCeremonyNotificationSetting(userDetails.getUser()); } @@ -145,9 +148,10 @@ public CeremonyNotificationSettingResponseDto getCeremonyNotificationSetting( @ResponseStatus(value = HttpStatus.OK) @Operation(summary = "유저 경조사 알람 설정 수정", description = "유저의 경조사 알람 설정을 수정합니다. 학번은 2자리로 입력해주세요. (ex. 19)") public CeremonyNotificationSettingResponseDto updateCeremonyNotificationSetting( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestBody @Valid CreateCeremonyNotificationSettingDto createCeremonyNotificationSettingDTO - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestBody @Valid + CreateCeremonyNotificationSettingDto createCeremonyNotificationSettingDTO) { return ceremonyService.updateUserSettings(userDetails.getUser(), createCeremonyNotificationSettingDTO); } diff --git a/app-main/src/main/java/net/causw/app/main/api/ChildCommentController.java b/app-main/src/main/java/net/causw/app/main/api/ChildCommentController.java index 4e487e709..662cce4fe 100644 --- a/app-main/src/main/java/net/causw/app/main/api/ChildCommentController.java +++ b/app-main/src/main/java/net/causw/app/main/api/ChildCommentController.java @@ -11,11 +11,11 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; -import net.causw.app.main.domain.community.comment.service.ChildCommentService; import net.causw.app.main.api.dto.comment.ChildCommentCreateRequestDto; import net.causw.app.main.api.dto.comment.ChildCommentResponseDto; import net.causw.app.main.api.dto.comment.ChildCommentUpdateRequestDto; +import net.causw.app.main.domain.community.comment.service.ChildCommentService; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.global.exception.BadRequestException; import net.causw.global.exception.UnauthorizedException; @@ -59,9 +59,10 @@ public class ChildCommentController { @ApiResponse(responseCode = "4004", description = "삭제된 동아리입니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public ChildCommentResponseDto createChildComment( - @Valid @RequestBody ChildCommentCreateRequestDto childCommentCreateRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @Valid @RequestBody + ChildCommentCreateRequestDto childCommentCreateRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.childCommentService.createChildComment(userDetails.getUser(), childCommentCreateRequestDto); } @@ -93,10 +94,12 @@ public ChildCommentResponseDto createChildComment( @ApiResponse(responseCode = "5000", description = "Comment id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public ChildCommentResponseDto updateChildComment( - @PathVariable("id") String id, - @Valid @RequestBody ChildCommentUpdateRequestDto childCommentUpdateRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @Valid @RequestBody + ChildCommentUpdateRequestDto childCommentUpdateRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.childCommentService.updateChildComment(userDetails.getUser(), id, childCommentUpdateRequestDto); } @@ -127,9 +130,10 @@ public ChildCommentResponseDto updateChildComment( @ApiResponse(responseCode = "5000", description = "Comment id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public ChildCommentResponseDto deleteChildComment( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.childCommentService.deleteChildComment(userDetails.getUser(), id); } @@ -148,16 +152,16 @@ public ChildCommentResponseDto deleteChildComment( @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public void likeChildComment( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails) { this.childCommentService.likeChildComment(userDetails.getUser(), id); } @DeleteMapping(value = "/{id}/like") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "대댓글 좋아요 취소 API(완료)", - description = "특정 유저가 특정 대댓글에 좋아요를 누른 걸 취소하는 Api 입니다.") + @Operation(summary = "대댓글 좋아요 취소 API(완료)", description = "특정 유저가 특정 대댓글에 좋아요를 누른 걸 취소하는 Api 입니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -170,9 +174,10 @@ public void likeChildComment( @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public void cancelLikeChildComment( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails) { this.childCommentService.cancelLikeChildComment(userDetails.getUser(), id); } } diff --git a/app-main/src/main/java/net/causw/app/main/api/CircleController.java b/app-main/src/main/java/net/causw/app/main/api/CircleController.java index 6be7ba818..b65dfcd14 100644 --- a/app-main/src/main/java/net/causw/app/main/api/CircleController.java +++ b/app-main/src/main/java/net/causw/app/main/api/CircleController.java @@ -22,7 +22,6 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.app.main.api.dto.circle.CircleBoardsResponseDto; import net.causw.app.main.api.dto.circle.CircleCreateRequestDto; import net.causw.app.main.api.dto.circle.CircleMemberResponseDto; @@ -35,6 +34,7 @@ import net.causw.app.main.api.dto.form.response.FormResponseDto; import net.causw.app.main.domain.campus.circle.enums.CircleMemberStatus; import net.causw.app.main.domain.campus.circle.service.CircleService; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.app.main.shared.util.ConstraintValidator; import net.causw.global.exception.BadRequestException; import net.causw.global.exception.InternalServerException; @@ -71,8 +71,8 @@ public class CircleController { @ApiResponse(responseCode = "4004", description = "삭제된 {동아리명} 입니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public CircleResponseDto findById( - @PathVariable(name = "circleId") String circleId - ) { + @PathVariable(name = "circleId") + String circleId) { return this.circleService.findById(circleId); } @@ -93,8 +93,8 @@ public CircleResponseDto findById( @ApiResponse(responseCode = "4109", description = "가입이 거절된 사용자 입니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UnauthorizedException.class))) }) public List findAll( - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.circleService.findAll(userDetails.getUser()); } @@ -118,9 +118,10 @@ public List findAll( @ApiResponse(responseCode = "4108", description = "로그인된 사용자가 가입 신청한 소모임이 아닙니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UnauthorizedException.class))) }) public CircleBoardsResponseDto findBoards( - @PathVariable(name = "circleId") String circleId, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable(name = "circleId") + String circleId, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.circleService.findBoards(userDetails.getUser(), circleId); } @@ -138,8 +139,8 @@ public CircleBoardsResponseDto findBoards( @ApiResponse(responseCode = "4000", description = "소모임을 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public Long getNumMember( - @PathVariable(name = "circleId") String circleId - ) { + @PathVariable(name = "circleId") + String circleId) { return this.circleService.getNumMember(circleId); } @@ -167,16 +168,17 @@ public Long getNumMember( @ApiResponse(responseCode = "4000", description = "소모임원을 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public List getUserList( - @PathVariable("circleId") String circleId, - @RequestParam("circleMemberStatus") @NotNull(message = "동아리원 상태는 null이 아니어야 합니다.") CircleMemberStatus circleMemberStatus, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("circleId") + String circleId, + @RequestParam("circleMemberStatus") @NotNull(message = "동아리원 상태는 null이 아니어야 합니다.") + CircleMemberStatus circleMemberStatus, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.circleService.getUserList( userDetails.getUser(), circleId, - circleMemberStatus - ); + circleMemberStatus); } @GetMapping(value = "/{circleId}/memberList") @@ -196,11 +198,10 @@ public List getUserList( @ApiResponse(responseCode = "4000", description = "소모임원을 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public List findCircleMemberList( - @PathVariable("circleId") String circleId - ) { + @PathVariable("circleId") + String circleId) { return this.circleService.getMemberList( - circleId - ); + circleId); } /** @@ -211,10 +212,7 @@ public List findCircleMemberList( @PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(value = HttpStatus.CREATED) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation( - summary = "동아리 생성 API / create (완료)", - description = "생성하고자 하는 동아리의 정보를 입력해주세요. 동아리장의 권한은 일반 유저만 가능하며, 생성 요청은 관리자(admin), 학생회장(president)만 가능합니다." - ) + @Operation(summary = "동아리 생성 API / create (완료)", description = "생성하고자 하는 동아리의 정보를 입력해주세요. 동아리장의 권한은 일반 유저만 가능하며, 생성 요청은 관리자(admin), 학생회장(president)만 가능합니다.") @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "Created", content = @Content(mediaType = "application/json", schema = @Schema(implementation = void.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -232,8 +230,10 @@ public List findCircleMemberList( @ApiResponse(responseCode = "5000", description = "Circle id immediately can be used, but exception occured", content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public void create( - @RequestPart(value = "circleCreateRequestDto") @Valid CircleCreateRequestDto circleCreateRequestDto, - @RequestPart(value = "mainImage", required = false) MultipartFile mainImage + @RequestPart(value = "circleCreateRequestDto") @Valid + CircleCreateRequestDto circleCreateRequestDto, + @RequestPart(value = "mainImage", required = false) + MultipartFile mainImage ) { circleService.create(circleCreateRequestDto, mainImage); @@ -248,12 +248,10 @@ public void create( @PutMapping(value = "/{circleId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES_AND_CIRCLE_LEADER)") - @Operation( - summary = "동아리 수정 API / update (완료)", - description = "circleId 에는 수정하고자 하는 동아리의 UUID 형식의 ID String 값을 입력해주세요.\n" + - "circleUpdateRequestDto 에는 수정하고자 하는 동아리의 정보를 입력해주세요.\n" + - "동아리장의 권한은 일반 유저만 가능하며, 생성 요청은 관리자(admin), 학생회장(president)만 가능합니다." - ) + @Operation(summary = "동아리 수정 API / update (완료)", description = "circleId 에는 수정하고자 하는 동아리의 UUID 형식의 ID String 값을 입력해주세요.\n" + + + "circleUpdateRequestDto 에는 수정하고자 하는 동아리의 정보를 입력해주세요.\n" + + "동아리장의 권한은 일반 유저만 가능하며, 생성 요청은 관리자(admin), 학생회장(president)만 가능합니다.") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = CircleResponseDto.class))), @ApiResponse(responseCode = "4000", description = "수정할 소모임을 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -271,10 +269,14 @@ public void create( @ApiResponse(responseCode = "5000", description = "Circle id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public CircleResponseDto update( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable(name = "circleId") String circleId, - @RequestPart(value = "circleUpdateRequestDto") @Valid CircleUpdateRequestDto circleUpdateRequestDto, - @RequestPart(value = "mainImage", required = false) MultipartFile mainImage + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable(name = "circleId") + String circleId, + @RequestPart(value = "circleUpdateRequestDto") @Valid + CircleUpdateRequestDto circleUpdateRequestDto, + @RequestPart(value = "mainImage", required = false) + MultipartFile mainImage ) { return this.circleService.update(userDetails.getUser(), circleId, circleUpdateRequestDto, mainImage); @@ -288,12 +290,9 @@ public CircleResponseDto update( @DeleteMapping(value = "/{circleId}") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES_AND_CIRCLE_LEADER)") - @Operation( - summary = "동아리 삭제 API", - description = "동아리 삭제 API 입니다.\n" + - "동아리 고유 ID 값(PK)을 입력해주세요.\n" + - "삭제 시 동아리 데이터가 아예 삭제되는 것이 아닌 isDeleted 가 true 로 바뀝니다." - ) + @Operation(summary = "동아리 삭제 API", description = "동아리 삭제 API 입니다.\n" + + "동아리 고유 ID 값(PK)을 입력해주세요.\n" + + "삭제 시 동아리 데이터가 아예 삭제되는 것이 아닌 isDeleted 가 true 로 바뀝니다.") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = CircleMemberResponseDto.class))), @ApiResponse(responseCode = "4000", description = "삭제할 소모임을 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -311,19 +310,17 @@ public CircleResponseDto update( @ApiResponse(responseCode = "5000", description = "Circle id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public CircleResponseDto delete( - @PathVariable(name = "circleId") String circleId, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable(name = "circleId") + String circleId, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.circleService.delete(userDetails.getUser(), circleId); } @PostMapping(value = "/{circleId}/applications") @ResponseStatus(value = HttpStatus.CREATED) - @Operation( - summary = "사용자 동아리 지원 API", - description = "사용자가 동아리에 지원하는 API 입니다.\n" + - "현재 로그인한 사용자 기준으로 동아리 ID와 해당 동아리 신청서(Form)의 답변을 입력하면 해당 동아리에 지원됩니다." - ) + @Operation(summary = "사용자 동아리 지원 API", description = "사용자가 동아리에 지원하는 API 입니다.\n" + + "현재 로그인한 사용자 기준으로 동아리 ID와 해당 동아리 신청서(Form)의 답변을 입력하면 해당 동아리에 지원됩니다.") @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "Created", content = @Content(mediaType = "application/json", schema = @Schema(implementation = void.class))), @ApiResponse(responseCode = "4000", description = "신청할 소모임을 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -343,10 +340,12 @@ public CircleResponseDto delete( @ApiResponse(responseCode = "5000", description = "Application id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public void userApply( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable(name = "circleId") String circleId, - @RequestBody @Valid FormReplyRequestDto formReplyRequestDto - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable(name = "circleId") + String circleId, + @RequestBody @Valid + FormReplyRequestDto formReplyRequestDto) { circleService.userApply(userDetails.getUser(), circleId, formReplyRequestDto); } @@ -357,16 +356,11 @@ public void userApply( */ @GetMapping(value = "/{circleName}/is-duplicated") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "동아리 이름 중복 검사 API", - description = "동아리 이름 중복 검사 API 입니다. 이름 기준으로 검사하면 String 형식으로 동아리 이름을 넣어주세요.") - @ApiResponse( - responseCode = "200", - description = "OK", - content = @Content(mediaType = "application/json", schema = @Schema(implementation = DuplicatedCheckResponseDto.class)) - ) + @Operation(summary = "동아리 이름 중복 검사 API", description = "동아리 이름 중복 검사 API 입니다. 이름 기준으로 검사하면 String 형식으로 동아리 이름을 넣어주세요.") + @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = DuplicatedCheckResponseDto.class))) public DuplicatedCheckResponseDto isDuplicatedName( - @PathVariable(name = "circleName") @NotBlank(message = "동아리명은 공백이 아니어야 합니다.") String circleName - ) { + @PathVariable(name = "circleName") @NotBlank(message = "동아리명은 공백이 아니어야 합니다.") + String circleName) { return this.circleService.isDuplicatedName(circleName); } @@ -377,11 +371,8 @@ public DuplicatedCheckResponseDto isDuplicatedName( */ @PutMapping(value = "/{circleId}/users/leave") @ResponseStatus(value = HttpStatus.OK) - @Operation( - summary = "동아리 탈퇴 API", - description = "현재 로그인 된 유저 기준으로 동아리에서 탈퇴합니다.\n" + - "탈퇴 시 해당 유저의 동아리 가입 정보가 LEAVE 상태로 변경됩니다." - ) + @Operation(summary = "동아리 탈퇴 API", description = "현재 로그인 된 유저 기준으로 동아리에서 탈퇴합니다.\n" + + "탈퇴 시 해당 유저의 동아리 가입 정보가 LEAVE 상태로 변경됩니다.") @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = CircleMemberResponseDto.class))) @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없거나 탈퇴할 소모임을 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) @ApiResponse(responseCode = "4001", description = "이미 소모임에 가입한 사용자입니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) @@ -390,9 +381,10 @@ public DuplicatedCheckResponseDto isDuplicatedName( @ApiResponse(responseCode = "4102", description = "추방된 사용자이거나 다른 권한 관련 오류가 발생했습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UnauthorizedException.class))) @ApiResponse(responseCode = "5000", description = "동아리에 대한 특정 예외가 발생했습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) public CircleMemberResponseDto leaveUser( - @PathVariable(name = "circleId") String circleId, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable(name = "circleId") + String circleId, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.circleService.leaveUser(userDetails.getUser(), circleId); } @@ -405,8 +397,7 @@ public CircleMemberResponseDto leaveUser( @PutMapping(value = "/{circleId}/users/{userId}/drop") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES_AND_CIRCLE_LEADER)") - @Operation(summary = "동아리원 제거 API", - description = "동아리원을 제거하는 API 입니다. userId 에는 제거하려는 유저를, circleId 에는 타깃 동아리를 넣어주세요.") + @Operation(summary = "동아리원 제거 API", description = "동아리원을 제거하는 API 입니다. userId 에는 제거하려는 유저를, circleId 에는 타깃 동아리를 넣어주세요.") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = CircleMemberResponseDto.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없거나 추방할 사용자를 찾을 수 없거나 소모임을 찾을 수 없거나 추방시킬 사용자가 가입 신청한 소모임이 아닙니다.", content = @Content(schema = @Schema(implementation = BadRequestException.class))), @@ -424,15 +415,16 @@ public CircleMemberResponseDto leaveUser( @ApiResponse(responseCode = "5000", description = "Application id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public CircleMemberResponseDto dropUser( - @PathVariable(name = "userId") String userId, - @PathVariable(name = "circleId") String circleId, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable(name = "userId") + String userId, + @PathVariable(name = "circleId") + String circleId, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.circleService.dropUser( userDetails.getUser(), userId, - circleId - ); + circleId); } /** @@ -443,10 +435,9 @@ public CircleMemberResponseDto dropUser( @PutMapping(value = "/applications/{applicationId}/accept") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES_AND_CIRCLE_LEADER)") - @Operation(summary = "동아리 가입 신청 수락 API", - description = "동아리 가입 신청에 대해 수락하는 API 입니다.\n" + - "동아리 가입 신청 건수 고유의 ID 값(PK)을 입력해주세요.\n" + - "수락 시 동아리원 데이터의 상태(status)가 AWAIT 에서 MEMBER 로 변경됩니다.") + @Operation(summary = "동아리 가입 신청 수락 API", description = "동아리 가입 신청에 대해 수락하는 API 입니다.\n" + + "동아리 가입 신청 건수 고유의 ID 값(PK)을 입력해주세요.\n" + + "수락 시 동아리원 데이터의 상태(status)가 AWAIT 에서 MEMBER 로 변경됩니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = CircleMemberResponseDto.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없거나 소모임 가입 신청을 찾을 수 없거나 가입 요청한 사용자를 찾을 수 없습니다.", content = @Content(schema = @Schema(implementation = BadRequestException.class))), @@ -460,9 +451,10 @@ public CircleMemberResponseDto dropUser( @ApiResponse(responseCode = "5000", description = "This circle has not circle leader or Application id checked, but exception occurred", content = @Content(schema = @Schema(implementation = InternalServerException.class))) }) public CircleMemberResponseDto acceptUser( - @PathVariable(name = "applicationId") String applicationId, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable(name = "applicationId") + String applicationId, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.circleService.acceptUser(userDetails.getUser(), applicationId); } @@ -474,10 +466,9 @@ public CircleMemberResponseDto acceptUser( @PutMapping(value = "/applications/{applicationId}/reject") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES_AND_CIRCLE_LEADER)") - @Operation(summary = "동아리 가입 신청 거절 API", - description = "동아리 가입 신청에 대해 거절하는 API 입니다.\n" + - "동아리 가입 신청 건수 고유의 ID 값(PK)을 입력해주세요.\n" + - "거절 시 동아리원으로의 데이터가 삭제되는 것이 아니라 상태(status)가 REJECT 로 변경됩니다.") + @Operation(summary = "동아리 가입 신청 거절 API", description = "동아리 가입 신청에 대해 거절하는 API 입니다.\n" + + "동아리 가입 신청 건수 고유의 ID 값(PK)을 입력해주세요.\n" + + "거절 시 동아리원으로의 데이터가 삭제되는 것이 아니라 상태(status)가 REJECT 로 변경됩니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = CircleMemberResponseDto.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없거나 소모임 가입 신청을 찾을 수 없거나 가입 요청한 사용자를 찾을 수 없습니다.", content = @Content(schema = @Schema(implementation = BadRequestException.class))), @@ -491,9 +482,10 @@ public CircleMemberResponseDto acceptUser( @ApiResponse(responseCode = "5000", description = "This circle has not circle leader or Application id checked, but exception occurred", content = @Content(schema = @Schema(implementation = InternalServerException.class))) }) public CircleMemberResponseDto rejectUser( - @PathVariable(name = "applicationId") String applicationId, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable(name = "applicationId") + String applicationId, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.circleService.rejectUser(userDetails.getUser(), applicationId); } @@ -506,10 +498,9 @@ public CircleMemberResponseDto rejectUser( @PutMapping(value = "/{circleId}/users/{userId}/restore") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES_AND_CIRCLE_LEADER)") - @Operation(summary = "추방된 동아리원 복구 API", - description = "추방된 동아리원을 복구 시키는 API 입니다. 복구 시 동아리원으로 바꿔줍니다.\n" + - "해당하는 동아리 고유의 ID 값(PK)과 복구하려는 유저 고유의 ID 값(PK)를 입력해주세요.\n" + - "복구 시 동아리원으로 상태(status)가 ACTIVE 로 변경됩니다.") + @Operation(summary = "추방된 동아리원 복구 API", description = "추방된 동아리원을 복구 시키는 API 입니다. 복구 시 동아리원으로 바꿔줍니다.\n" + + "해당하는 동아리 고유의 ID 값(PK)과 복구하려는 유저 고유의 ID 값(PK)를 입력해주세요.\n" + + "복구 시 동아리원으로 상태(status)가 ACTIVE 로 변경됩니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = CircleMemberResponseDto.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없거나 소모임 가입 신청을 찾을 수 없거나 가입 요청한 사용자를 찾을 수 없습니다.", content = @Content(schema = @Schema(implementation = BadRequestException.class))), @@ -525,90 +516,80 @@ public CircleMemberResponseDto rejectUser( @ApiResponse(responseCode = "5000", description = "This circle has not circle leader or Application id checked, but exception occurred", content = @Content(schema = @Schema(implementation = InternalServerException.class))) }) public CircleMemberResponseDto restoreUser( - @PathVariable(name = "circleId") String circleId, - @PathVariable(name = "userId") String userId, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable(name = "circleId") + String circleId, + @PathVariable(name = "userId") + String userId, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.circleService.restoreUser(userDetails.getUser(), circleId, userId); } @GetMapping(value = "/{circleId}/users/excel") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES_AND_CIRCLE_LEADER)") - @Operation( - summary = "동아리원 엑셀 다운로드 API", - description = "동아리원 정보를 엑셀로 다운로드 하는 API 입니다.\n" + - "동아리 고유 ID 값(PK)을 입력해주세요.\n" + - "엑셀 다운로드 시 해당 동아리의 동아리원 정보가 엑셀로 다운로드 됩니다." - ) + @Operation(summary = "동아리원 엑셀 다운로드 API", description = "동아리원 정보를 엑셀로 다운로드 하는 API 입니다.\n" + + "동아리 고유 ID 값(PK)을 입력해주세요.\n" + + "엑셀 다운로드 시 해당 동아리의 동아리원 정보가 엑셀로 다운로드 됩니다.") public void exportExcel( - @PathVariable(name = "circleId") String circleId, - HttpServletResponse response - ) { + @PathVariable(name = "circleId") + String circleId, + HttpServletResponse response) { circleService.exportCircleMembersToExcel(circleId, response); } @PostMapping(value = "/{circleId}/apply/application") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRole(@Role.LEADER_CIRCLE)") - @Operation( - summary = "동아리 가입 신청서 생성/수정 API", - description = "동아리 가입 신청서를 수정하는 API 입니다.\n" + - "동아리 고유 ID 값(PK)을 입력해주세요.\n" + - "동아리 가입 신청서를 수정하면 해당 동아리에 가입 신청서가 생성/수정됩니다. (기존에 있던 신청서 모두 비활성화)" - ) + @Operation(summary = "동아리 가입 신청서 생성/수정 API", description = "동아리 가입 신청서를 수정하는 API 입니다.\n" + + "동아리 고유 ID 값(PK)을 입력해주세요.\n" + + "동아리 가입 신청서를 수정하면 해당 동아리에 가입 신청서가 생성/수정됩니다. (기존에 있던 신청서 모두 비활성화)") public void createApplicationForm( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable(name = "circleId") String circleId, - @RequestBody @Valid FormCreateRequestDto formCreateRequestDto - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable(name = "circleId") + String circleId, + @RequestBody @Valid + FormCreateRequestDto formCreateRequestDto) { circleService.createApplicationForm(userDetails.getUser(), circleId, formCreateRequestDto); } @GetMapping(value = "/{circleId}/apply/application/is-exist") @ResponseStatus(value = HttpStatus.OK) - @Operation( - summary = "동아리 가입 신청서 존재 여부 확인 API", - description = "현재 모집 중인 동아리 가입 신청서가 존재하는지 확인하는 API 입니다.\n" + - "동아리 고유 ID 값(PK)을 입력해주세요.\n" + - "동아리 가입 신청서가 존재하면 true, 존재하지 않으면 false 를 반환합니다." - ) + @Operation(summary = "동아리 가입 신청서 존재 여부 확인 API", description = "현재 모집 중인 동아리 가입 신청서가 존재하는지 확인하는 API 입니다.\n" + + "동아리 고유 ID 값(PK)을 입력해주세요.\n" + + "동아리 가입 신청서가 존재하면 true, 존재하지 않으면 false 를 반환합니다.") public Boolean isCircleApplicationFormExist( - @PathVariable(name = "circleId") String circleId - ) { + @PathVariable(name = "circleId") + String circleId) { return circleService.isCircleApplicationFormExist(circleId); } @GetMapping(value = "/{circleId}/apply/application") @ResponseStatus(value = HttpStatus.OK) - @Operation( - summary = "동아리 가입 신청서 조회 API", - description = "동아리 가입 신청서를 조회하는 API 입니다.\n" + - "동아리 고유 ID 값(PK)을 입력해주세요.\n" + - "동아리 가입 신청서를 조회하면 해당 동아리에 가입 신청서가 반환됩니다." - ) + @Operation(summary = "동아리 가입 신청서 조회 API", description = "동아리 가입 신청서를 조회하는 API 입니다.\n" + + "동아리 고유 ID 값(PK)을 입력해주세요.\n" + + "동아리 가입 신청서를 조회하면 해당 동아리에 가입 신청서가 반환됩니다.") public FormResponseDto getCircleApplicationForm( - @PathVariable(name = "circleId") String circleId - ) { + @PathVariable(name = "circleId") + String circleId) { return circleService.getCircleApplicationForm(circleId); } @GetMapping(value = "/{circleId}/apply/application/all") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES_AND_CIRCLE_LEADER)") - @Operation( - summary = "모든 동아리 가입 신청서 페이징 조회 API", - description = "모든 동아리 가입 신청서를 조회하는 API 입니다.\n" + - "동아리 고유 ID 값(PK)을 입력해주세요.\n" + - "모든 동아리 가입 신청서를 조회하면 해당 동아리에 마감되었거나 삭제된 가입 신청서를 포함해 모든 가입 신청서가가 반환됩니다. (동아리장 및 관리자/학생회장 포함)" - ) + @Operation(summary = "모든 동아리 가입 신청서 페이징 조회 API", description = "모든 동아리 가입 신청서를 조회하는 API 입니다.\n" + + "동아리 고유 ID 값(PK)을 입력해주세요.\n" + + "모든 동아리 가입 신청서를 조회하면 해당 동아리에 마감되었거나 삭제된 가입 신청서를 포함해 모든 가입 신청서가가 반환됩니다. (동아리장 및 관리자/학생회장 포함)") public Page getAllCircleApplicationFormList( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable(name = "circleId") String circleId, - @ParameterObject Pageable pageable - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable(name = "circleId") + String circleId, + @ParameterObject + Pageable pageable) { return circleService.getAllCircleApplicationFormList(userDetails.getUser(), circleId, pageable); } } - diff --git a/app-main/src/main/java/net/causw/app/main/api/CommentController.java b/app-main/src/main/java/net/causw/app/main/api/CommentController.java index 904869278..cffe3df07 100644 --- a/app-main/src/main/java/net/causw/app/main/api/CommentController.java +++ b/app-main/src/main/java/net/causw/app/main/api/CommentController.java @@ -14,12 +14,12 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; -import net.causw.app.main.domain.community.comment.service.CommentService; import net.causw.app.main.api.dto.comment.CommentCreateRequestDto; import net.causw.app.main.api.dto.comment.CommentResponseDto; import net.causw.app.main.api.dto.comment.CommentSubscribeResponseDto; import net.causw.app.main.api.dto.comment.CommentUpdateRequestDto; +import net.causw.app.main.domain.community.comment.service.CommentService; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.global.exception.BadRequestException; import net.causw.global.exception.UnauthorizedException; @@ -60,10 +60,12 @@ public class CommentController { @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public Page findAllComments( - @RequestParam("postId") String postId, - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @RequestParam("postId") + String postId, + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.commentService.findAllComments(userDetails.getUser(), postId, pageNum); } @@ -91,9 +93,10 @@ public Page findAllComments( @ApiResponse(responseCode = "4004", description = "삭제된 동아리입니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public CommentResponseDto createComment( - @Valid @RequestBody CommentCreateRequestDto commentCreateRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @Valid @RequestBody + CommentCreateRequestDto commentCreateRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.commentService.createComment(userDetails.getUser(), commentCreateRequestDto); } @@ -123,15 +126,16 @@ public CommentResponseDto createComment( @ApiResponse(responseCode = "5000", description = "Comment id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public CommentResponseDto updateComment( - @PathVariable("id") String id, - @Valid @RequestBody CommentUpdateRequestDto commentUpdateRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @Valid @RequestBody + CommentUpdateRequestDto commentUpdateRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.commentService.updateComment( userDetails.getUser(), id, - commentUpdateRequestDto - ); + commentUpdateRequestDto); } @DeleteMapping(value = "/{id}") @@ -161,9 +165,10 @@ public CommentResponseDto updateComment( @ApiResponse(responseCode = "5000", description = "Comment id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public CommentResponseDto deleteComment( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.commentService.deleteComment(userDetails.getUser(), id); } @@ -182,38 +187,38 @@ public CommentResponseDto deleteComment( @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public void likeComment( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails) { this.commentService.likeComment(userDetails.getUser(), id); } @PostMapping("/subscribe/{id}") @ResponseStatus(HttpStatus.OK) - @Operation(summary = "로그인한 사용자의 댓글 알람 설정 켜기" - , description = "id에는 comment id 값을 넣어주세요") + @Operation(summary = "로그인한 사용자의 댓글 알람 설정 켜기", description = "id에는 comment id 값을 넣어주세요") public CommentSubscribeResponseDto subscribeComment( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable("id") String id - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable("id") + String id) { return commentService.setCommentSubscribe(userDetails.getUser(), id, true); } @DeleteMapping("/subscribe/{id}") @ResponseStatus(HttpStatus.OK) - @Operation(summary = "로그인한 사용자의 댓글 알람 설정 끄기" - , description = "id에는 comment id 값을 넣어주세요") + @Operation(summary = "로그인한 사용자의 댓글 알람 설정 끄기", description = "id에는 comment id 값을 넣어주세요") public CommentSubscribeResponseDto unsubscribeComment( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable("id") String id - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable("id") + String id) { return commentService.setCommentSubscribe(userDetails.getUser(), id, false); } @DeleteMapping(value = "/{id}/like") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "댓글 좋아요 취소 API(완료)", - description = "특정 유저가 특정 댓글에 좋아요를 누른 걸 취소하는 Api 입니다.") + @Operation(summary = "댓글 좋아요 취소 API(완료)", description = "특정 유저가 특정 댓글에 좋아요를 누른 걸 취소하는 Api 입니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -226,9 +231,10 @@ public CommentSubscribeResponseDto unsubscribeComment( @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public void cancelLikeComment( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails) { this.commentService.cancelLikeComment(userDetails.getUser(), id); } } diff --git a/app-main/src/main/java/net/causw/app/main/api/CommonController.java b/app-main/src/main/java/net/causw/app/main/api/CommonController.java index 248b83534..06330e6ee 100644 --- a/app-main/src/main/java/net/causw/app/main/api/CommonController.java +++ b/app-main/src/main/java/net/causw/app/main/api/CommonController.java @@ -15,10 +15,10 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.app.main.api.dto.homepage.HomePageResponseDto; -import net.causw.app.main.domain.etc.textfield.service.CommonService; import net.causw.app.main.domain.community.homepage.service.HomePageService; +import net.causw.app.main.domain.etc.textfield.service.CommonService; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; @@ -33,12 +33,11 @@ public class CommonController { @GetMapping("/api/v1/home") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("!@security.isGraduatedUser()") - @Operation(summary = "홈페이지 불러오기 API(완료)", - description = "동아리에 속하지 않고 삭제되지 않은 게시판과 해당 게시판의 최신 글 3개의 정보를 반환합니다.\n" + - "개발 db상에는 동아리에 속하지 않은 많은 더미 데이터가 있지만 실제 운영될 때는 동아리에 속하지 않는 게시판은 학생회 공지게시판 뿐입니다.\n" + - "졸업생은 해당 api에 접근이 불가합니다." - ) - public List getHomePage(@AuthenticationPrincipal CustomUserDetails userDetails) { + @Operation(summary = "홈페이지 불러오기 API(완료)", description = "동아리에 속하지 않고 삭제되지 않은 게시판과 해당 게시판의 최신 글 3개의 정보를 반환합니다.\n" + + "개발 db상에는 동아리에 속하지 않은 많은 더미 데이터가 있지만 실제 운영될 때는 동아리에 속하지 않는 게시판은 학생회 공지게시판 뿐입니다.\n" + + "졸업생은 해당 api에 접근이 불가합니다.") + public List getHomePage(@AuthenticationPrincipal + CustomUserDetails userDetails) { return this.homePageService.getHomePage(userDetails.getUser()); } @@ -46,10 +45,11 @@ public List getHomePage(@AuthenticationPrincipal CustomUser @GetMapping("/api/v1/home/alumni") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.isGraduatedUser()") - @Operation(summary = "크자회 전용 홈페이지 불러오기 API(완료)", - description = "크자회 전용 홈페이지에 보여질 크자회 공지 게시판, 소통 게시판을 반환하기 위한 api 입니다.\n" + - "db상에 isAlumni, isHome 값이 모두 true 인 경우를 반환합니다.") - public List getAlumniHomePage(@AuthenticationPrincipal CustomUserDetails userDetails) { + @Operation(summary = "크자회 전용 홈페이지 불러오기 API(완료)", description = "크자회 전용 홈페이지에 보여질 크자회 공지 게시판, 소통 게시판을 반환하기 위한 api 입니다.\n" + + + "db상에 isAlumni, isHome 값이 모두 true 인 경우를 반환합니다.") + public List getAlumniHomePage(@AuthenticationPrincipal + CustomUserDetails userDetails) { return this.homePageService.getAlumniHomePage(userDetails.getUser()); } @@ -69,26 +69,26 @@ public Map healthCheck() { @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRole(@Role.ADMIN)") public Boolean createFlag( - @RequestParam("key") String key, - @RequestParam("value") Boolean value - ) { + @RequestParam("key") + String key, + @RequestParam("value") + Boolean value) { return commonService.createFlag( key, - value - ); + value); } @PutMapping("/api/v1/flag") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRole(@Role.ADMIN)") public Boolean updateFlag( - @RequestParam("key") String key, - @RequestParam("value") Boolean value - ) { + @RequestParam("key") + String key, + @RequestParam("value") + Boolean value) { return this.commonService.updateFlag( key, - value - ); + value); } } diff --git a/app-main/src/main/java/net/causw/app/main/api/EventController.java b/app-main/src/main/java/net/causw/app/main/api/EventController.java index 4f6d9e3ae..c48ff68e5 100644 --- a/app-main/src/main/java/net/causw/app/main/api/EventController.java +++ b/app-main/src/main/java/net/causw/app/main/api/EventController.java @@ -56,9 +56,10 @@ public EventsResponseDto findEvents() { }) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES_AND_LEADER_ALUMNI)") public EventResponseDto createEvent( - @RequestPart(value = "eventCreateRequestDto") @Valid EventCreateRequestDto eventCreateRequestDto, - @RequestPart(value = "eventImage") MultipartFile eventImage - ) { + @RequestPart(value = "eventCreateRequestDto") @Valid + EventCreateRequestDto eventCreateRequestDto, + @RequestPart(value = "eventImage") + MultipartFile eventImage) { return eventService.createEvent(eventCreateRequestDto, eventImage); } @@ -73,10 +74,12 @@ public EventResponseDto createEvent( }) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES_AND_LEADER_ALUMNI)") public EventResponseDto updateEvent( - @PathVariable("eventId") String eventId, - @RequestPart(value = "eventUpdateRequestDto") @Valid EventUpdateRequestDto eventUpdateRequestDto, - @RequestPart(value = "eventImage", required = false) MultipartFile eventImage - ) { + @PathVariable("eventId") + String eventId, + @RequestPart(value = "eventUpdateRequestDto") @Valid + EventUpdateRequestDto eventUpdateRequestDto, + @RequestPart(value = "eventImage", required = false) + MultipartFile eventImage) { return eventService.updateEvent(eventId, eventUpdateRequestDto, eventImage); } @@ -90,7 +93,8 @@ public EventResponseDto updateEvent( @ApiResponse(responseCode = "5000", description = "User id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES_AND_LEADER_ALUMNI)") - public EventResponseDto deleteEvent(@PathVariable("eventId") String eventId) { + public EventResponseDto deleteEvent(@PathVariable("eventId") + String eventId) { return eventService.deleteEvent(eventId); } diff --git a/app-main/src/main/java/net/causw/app/main/api/FormController.java b/app-main/src/main/java/net/causw/app/main/api/FormController.java index a31fe5990..c48d8a5af 100644 --- a/app-main/src/main/java/net/causw/app/main/api/FormController.java +++ b/app-main/src/main/java/net/causw/app/main/api/FormController.java @@ -17,13 +17,13 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; -import net.causw.app.main.domain.community.form.service.FormService; import net.causw.app.main.api.dto.form.request.FormReplyRequestDto; import net.causw.app.main.api.dto.form.response.FormResponseDto; import net.causw.app.main.api.dto.form.response.QuestionSummaryResponseDto; import net.causw.app.main.api.dto.form.response.reply.ReplyPageResponseDto; import net.causw.app.main.api.dto.form.response.reply.UserReplyResponseDto; +import net.causw.app.main.domain.community.form.service.FormService; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import io.swagger.v3.oas.annotations.Operation; import jakarta.servlet.http.HttpServletResponse; @@ -42,10 +42,12 @@ public class FormController { @ResponseStatus(HttpStatus.OK) @Operation(summary = "신청서 마감 여부 설정", description = "신청서의 마감 여부를 설정합니다.") public void setFormIsClosed( - @PathVariable(name = "formId") String formId, - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestHeader @NotNull Boolean targetIsClosed - ) { + @PathVariable(name = "formId") + String formId, + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestHeader @NotNull + Boolean targetIsClosed) { formService.setFormIsClosed(formId, userDetails.getUser(), targetIsClosed); } @@ -53,9 +55,10 @@ public void setFormIsClosed( @ResponseStatus(HttpStatus.OK) @Operation(summary = "신청서 응답 가능 여부 조회", description = "신청서 응답이 가능한지 여부를 조회합니다.") public Boolean getCanReplyToPostForm( - @PathVariable(name = "formId") String formId, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable(name = "formId") + String formId, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return formService.getCanReplyToPostForm(userDetails.getUser(), formId); } @@ -63,9 +66,10 @@ public Boolean getCanReplyToPostForm( @ResponseStatus(HttpStatus.OK) @Operation(summary = "신청서 조회", description = "신청서를 조회합니다.") public FormResponseDto getForm( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable(name = "formId") String formId - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable(name = "formId") + String formId) { return formService.getFormById(userDetails.getUser(), formId); } @@ -73,10 +77,12 @@ public FormResponseDto getForm( @ResponseStatus(HttpStatus.OK) @Operation(summary = "신청서 응답 작성", description = "신청서 응답을 작성합니다.") public void replyForm( - @PathVariable(name = "formId") String formId, - @Valid @RequestBody FormReplyRequestDto formReplyRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable(name = "formId") + String formId, + @Valid @RequestBody + FormReplyRequestDto formReplyRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { formService.replyForm(formId, formReplyRequestDto, userDetails.getUser()); } @@ -84,10 +90,12 @@ public void replyForm( @ResponseStatus(HttpStatus.OK) @Operation(summary = "신청서 결과 전체 페이징 조회", description = "신청서 결과 전체를 페이징으로 조회합니다. 게시글의 신청서는 게시글 작성자만, 동아리 신청서는 동아리장만 조회가 가능합니다.") public ReplyPageResponseDto findAllReplyPageByForm( - @PathVariable(name = "formId") String formId, - @ParameterObject Pageable pageable, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable(name = "formId") + String formId, + @ParameterObject + Pageable pageable, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return formService.findAllReplyPageByForm(formId, pageable, userDetails.getUser()); } @@ -95,9 +103,10 @@ public ReplyPageResponseDto findAllReplyPageByForm( @ResponseStatus(HttpStatus.OK) @Operation(summary = "신청서 결과 요약 조회", description = "신청서 결과를 요약 조회합니다.") public List findSummaryReply( - @PathVariable(name = "formId") String formId, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable(name = "formId") + String formId, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return formService.findSummaryReply(formId, userDetails.getUser()); } @@ -106,9 +115,10 @@ public List findSummaryReply( @Operation(summary = "동아리 신청서 답변 유저별 조회", description = "각 유저의 동아리 신청서에 대한 답변을 조회합니다.") @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES_AND_CIRCLE_LEADER)") public List findReplyByUserAndCircle( - @PathVariable(name = "userId") String userId, - @PathVariable(name = "circleId") String circleId - ) { + @PathVariable(name = "userId") + String userId, + @PathVariable(name = "circleId") + String circleId) { return formService.getReplyByUserAndCircle(userId, circleId); } @@ -116,10 +126,11 @@ public List findReplyByUserAndCircle( @ResponseStatus(HttpStatus.OK) @Operation(summary = "신청서 결과 엑셀 다운로드", description = "신청서 결과를 엑셀로 다운로드합니다.") public void exportFormResult( - @PathVariable(name = "formId") String formId, - @AuthenticationPrincipal CustomUserDetails userDetails, - HttpServletResponse response - ) { + @PathVariable(name = "formId") + String formId, + @AuthenticationPrincipal + CustomUserDetails userDetails, + HttpServletResponse response) { formService.exportFormResult(formId, userDetails.getUser(), response); } } diff --git a/app-main/src/main/java/net/causw/app/main/api/LockerController.java b/app-main/src/main/java/net/causw/app/main/api/LockerController.java index cdb982bfa..12d2bc6f3 100644 --- a/app-main/src/main/java/net/causw/app/main/api/LockerController.java +++ b/app-main/src/main/java/net/causw/app/main/api/LockerController.java @@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.app.main.api.dto.locker.LockerCreateRequestDto; import net.causw.app.main.api.dto.locker.LockerExpiredAtRequestDto; import net.causw.app.main.api.dto.locker.LockerExtendPeriodRequestDto; @@ -30,6 +29,7 @@ import net.causw.app.main.api.dto.locker.LockerUpdateRequestDto; import net.causw.app.main.api.dto.locker.LockersResponseDto; import net.causw.app.main.domain.asset.locker.service.LockerService; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import io.swagger.v3.oas.annotations.Operation; import jakarta.validation.Valid; @@ -45,9 +45,10 @@ public class LockerController { @Operation(summary = "사물함 조회 Api", description = "사물함 id를 바탕으로 사물함 정보를 가져오는 Api 입니다.") @ResponseStatus(value = HttpStatus.OK) public LockerResponseDto findById( - @PathVariable("lockerId") String lockerId, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("lockerId") + String lockerId, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.lockerService.findById(lockerId, userDetails.getUser()); } @@ -56,9 +57,10 @@ public LockerResponseDto findById( @ResponseStatus(value = HttpStatus.CREATED) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") public LockerResponseDto create( - @Valid @RequestBody LockerCreateRequestDto lockerCreateRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @Valid @RequestBody + LockerCreateRequestDto lockerCreateRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.lockerService.create(userDetails.getUser(), lockerCreateRequestDto); } @@ -67,15 +69,16 @@ public LockerResponseDto create( @Operation(summary = "사물함 상태 update Api", description = "사물함 상태를 변경하는 Api입니다.\n" + "허용 동작 목록: \"ENABLE(관리자/회장 전용)\", \"DISABLE(관리자/회장 전용)\", \"REGISTER\", \"RETURN\", \"EXTEND\"") public LockerResponseDto update( - @PathVariable("lockerId") String lockerId, - @Valid @RequestBody LockerUpdateRequestDto lockerUpdateRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("lockerId") + String lockerId, + @Valid @RequestBody + LockerUpdateRequestDto lockerUpdateRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.lockerService.update( userDetails.getUser(), lockerId, - lockerUpdateRequestDto - ); + lockerUpdateRequestDto); } @PutMapping(value = "/{lockerId}/move") @@ -83,15 +86,16 @@ public LockerResponseDto update( @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") @Operation(summary = "사물함 위치 이동 Api(관리자/회장 전용)", description = "사물함의 위치(locker location)를 이동(변경)시키는 Api입니다. ex) 1번 사물함에 있어서 1층 1번 -> 2층 1번, 층만 바뀜") public LockerResponseDto move( - @PathVariable("lockerId") String lockerId, - @Valid @RequestBody LockerMoveRequestDto lockerMoveRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("lockerId") + String lockerId, + @Valid @RequestBody + LockerMoveRequestDto lockerMoveRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.lockerService.move( userDetails.getUser(), lockerId, - lockerMoveRequestDto - ); + lockerMoveRequestDto); } @DeleteMapping(value = "/{lockerId}") @@ -99,16 +103,18 @@ public LockerResponseDto move( @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") @Operation(summary = "사물함 삭제 Api(관리자/회장 전용)", description = "사물함을 삭제하는 Api입니다.") public LockerResponseDto delete( - @PathVariable("lockerId") String lockerId, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("lockerId") + String lockerId, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.lockerService.delete(userDetails.getUser(), lockerId); } @GetMapping(value = "/locations") @ResponseStatus(value = HttpStatus.OK) @Operation(summary = "사물함 층별 사용가능 여부 조회 Api", description = "사물함 층별 개수 정보와 사용 가능 개수를 제공하는 API입니다.") - public LockerLocationsResponseDto findAllLocation(@AuthenticationPrincipal CustomUserDetails userDetails) { + public LockerLocationsResponseDto findAllLocation(@AuthenticationPrincipal + CustomUserDetails userDetails) { return this.lockerService.findAllLocation(userDetails.getUser()); } @@ -116,9 +122,10 @@ public LockerLocationsResponseDto findAllLocation(@AuthenticationPrincipal Custo @Operation(summary = "사물함 특정 층별 사용가능 여부 조회 Api", description = "사물함 특정 층별 개수 정보와 사용 가능 개수를 제공하는 API입니다.") @ResponseStatus(value = HttpStatus.OK) public LockersResponseDto findByLocation( - @PathVariable("locationId") String locationId, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("locationId") + String locationId, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.lockerService.findByLocation(locationId, userDetails.getUser()); } @@ -127,9 +134,10 @@ public LockersResponseDto findByLocation( @ResponseStatus(value = HttpStatus.CREATED) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") public LockerLocationResponseDto createLocation( - @Valid @RequestBody LockerLocationCreateRequestDto lockerLocationCreateRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @Valid @RequestBody + LockerLocationCreateRequestDto lockerLocationCreateRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.lockerService.createLocation(userDetails.getUser(), lockerLocationCreateRequestDto); } @@ -138,15 +146,16 @@ public LockerLocationResponseDto createLocation( @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") public LockerLocationResponseDto updateLocation( - @PathVariable("locationId") String locationId, - @Valid @RequestBody LockerLocationUpdateRequestDto lockerLocationUpdateRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("locationId") + String locationId, + @Valid @RequestBody + LockerLocationUpdateRequestDto lockerLocationUpdateRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.lockerService.updateLocation( userDetails.getUser(), locationId, - lockerLocationUpdateRequestDto - ); + lockerLocationUpdateRequestDto); } @DeleteMapping(value = "/locations/{locationId}") @@ -154,9 +163,10 @@ public LockerLocationResponseDto updateLocation( @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") public LockerLocationResponseDto deleteLocation( - @PathVariable("locationId") String locationId, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("locationId") + String locationId, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.lockerService.deleteLocation(userDetails.getUser(), locationId); } @@ -165,8 +175,8 @@ public LockerLocationResponseDto deleteLocation( @Operation(summary = "사물함 로그 조회 API(관리자/회장 전용)", description = "사물함 로그를 조회하는 API입니다.") @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") public List findLog( - @PathVariable("lockerId") String lockerId - ) { + @PathVariable("lockerId") + String lockerId) { return this.lockerService.findLog(lockerId); } @@ -175,9 +185,10 @@ public List findLog( @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") public void setExpireDate( - @Valid @RequestBody LockerExpiredAtRequestDto lockerExpiredAtRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @Valid @RequestBody + LockerExpiredAtRequestDto lockerExpiredAtRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { this.lockerService.setExpireAt(userDetails.getUser(), lockerExpiredAtRequestDto); } @@ -186,9 +197,10 @@ public void setExpireDate( @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") public void setExtendPeriod( - @Valid @RequestBody LockerExtendPeriodRequestDto lockerExtendPeriodRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @Valid @RequestBody + LockerExtendPeriodRequestDto lockerExtendPeriodRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { this.lockerService.setExtendPeriod(userDetails.getUser(), lockerExtendPeriodRequestDto); } @@ -197,9 +209,10 @@ public void setExtendPeriod( @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") public void setRegisterPeriod( - @Valid @RequestBody LockerRegisterPeriodRequestDto lockerRegisterPeriodRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @Valid @RequestBody + LockerRegisterPeriodRequestDto lockerRegisterPeriodRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { this.lockerService.setRegisterPeriod(userDetails.getUser(), lockerRegisterPeriodRequestDto); } @@ -207,7 +220,8 @@ public void setRegisterPeriod( @Operation(summary = "사물함 전체 생성 API(관리자/회장 전용)", description = "현재 존재하는 모든 사물함을 생성하는 API입니다.") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - public void createAllLockers(@AuthenticationPrincipal CustomUserDetails userDetails) { + public void createAllLockers(@AuthenticationPrincipal + CustomUserDetails userDetails) { this.lockerService.createAllLockers(userDetails.getUser()); } @@ -215,7 +229,8 @@ public void createAllLockers(@AuthenticationPrincipal CustomUserDetails userDeta @Operation(summary = "만료된 사물함 일괄 반납 API(관리자/회장 전용)", description = "만료된 사물함을 일괄 반납 처리하는 API입니다.") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - public void returnExpiredLockers(@AuthenticationPrincipal CustomUserDetails userDetails) { + public void returnExpiredLockers(@AuthenticationPrincipal + CustomUserDetails userDetails) { this.lockerService.returnExpiredLockers(userDetails.getUser()); } } diff --git a/app-main/src/main/java/net/causw/app/main/api/NotificationLogController.java b/app-main/src/main/java/net/causw/app/main/api/NotificationLogController.java index 6f720d932..640a254ca 100644 --- a/app-main/src/main/java/net/causw/app/main/api/NotificationLogController.java +++ b/app-main/src/main/java/net/causw/app/main/api/NotificationLogController.java @@ -13,10 +13,10 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.app.main.api.dto.notification.NotificationCountResponseDto; import net.causw.app.main.api.dto.notification.NotificationResponseDto; import net.causw.app.main.domain.notification.notification.service.NotificationLogService; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; @@ -31,9 +31,10 @@ public class NotificationLogController { @ResponseStatus(HttpStatus.OK) @Operation(summary = "유저에게 온 일반 알람 조회", description = "유저의 일반 알림을 조회합니다.") public Page getGeneralNotification( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum) { return notificationLogService.getGeneralNotification(userDetails.getUser(), pageNum); } @@ -41,54 +42,52 @@ public Page getGeneralNotification( @ResponseStatus(value = HttpStatus.OK) @Operation(summary = "유저에게 온 경조사 알람 조회", description = "유저의 경조사 알람을 조회합니다.") public Page getCeremonyNotification( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum) { return notificationLogService.getCeremonyNotification(userDetails.getUser(), pageNum); } @GetMapping("/general/top4") @ResponseStatus(HttpStatus.OK) - @Operation(summary = "유저에게 온 일반 알람 조회" - , description = "유저의 일반 알림을 조회합니다.
" + + @Operation(summary = "유저에게 온 일반 알람 조회", description = "유저의 일반 알림을 조회합니다.
" + "해당 api는 웹상의 사이드 바 형태의 읽지 않은 알람 4개를 표시할 때 사용됩니다.") public List getGeneralNotificationTop4( - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { return notificationLogService.getGeneralNotificationTop4(userDetails.getUser()); } @GetMapping("/ceremony/top4") @ResponseStatus(HttpStatus.OK) - @Operation(summary = "유저에게 온 경조사 알람 조회" - , description = "유저의 경조사 알림을 조회합니다.
" + + @Operation(summary = "유저에게 온 경조사 알람 조회", description = "유저의 경조사 알림을 조회합니다.
" + "해당 api는 웹상의 사이드 바 형태의 읽지 않은 알람 4개를 표시할 때 사용됩니다.") public List getCeremonyNotificationTop4( - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { return notificationLogService.getCeremonyNotificationTop4(userDetails.getUser()); } @PostMapping("/isRead/{id}") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "유저에게 온 알람 읽음 여부 변경", - description = "유저의 알람 조회 여부를 참으로 변경합니다
" + - "id에는 notification_log id를 넣어주세요") + @Operation(summary = "유저에게 온 알람 읽음 여부 변경", description = "유저의 알람 조회 여부를 참으로 변경합니다
" + + "id에는 notification_log id를 넣어주세요") public void readNotification( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable("id") String id - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable("id") + String id) { notificationLogService.readNotification(userDetails.getUser(), id); } @GetMapping("/count") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "유저에게 온 일반, 경조사 알림 중 읽지 않은 알림 총 개수 반환", - description = "유저의 읽지 않은 알림 개수를 반환합니다.
" + - "UI 상에서 10개 이상은 9+로 표기되기 때문에 10개까지 카운팅 되도록 하였습니다.") + @Operation(summary = "유저에게 온 일반, 경조사 알림 중 읽지 않은 알림 총 개수 반환", description = "유저의 읽지 않은 알림 개수를 반환합니다.
" + + "UI 상에서 10개 이상은 9+로 표기되기 때문에 10개까지 카운팅 되도록 하였습니다.") public NotificationCountResponseDto getNotificationLogCount( - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { return notificationLogService.getNotificationLogCount(userDetails.getUser()); } diff --git a/app-main/src/main/java/net/causw/app/main/api/PostController.java b/app-main/src/main/java/net/causw/app/main/api/PostController.java index 87c6ea753..7f87aefa1 100644 --- a/app-main/src/main/java/net/causw/app/main/api/PostController.java +++ b/app-main/src/main/java/net/causw/app/main/api/PostController.java @@ -17,8 +17,6 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; -import net.causw.app.main.domain.community.post.service.PostService; import net.causw.app.main.api.dto.post.BoardPostsResponseDto; import net.causw.app.main.api.dto.post.PostCreateRequestDto; import net.causw.app.main.api.dto.post.PostCreateResponseDto; @@ -27,6 +25,8 @@ import net.causw.app.main.api.dto.post.PostSubscribeResponseDto; import net.causw.app.main.api.dto.post.PostUpdateRequestDto; import net.causw.app.main.api.dto.post.PostUpdateWithFormRequestDto; +import net.causw.app.main.domain.community.post.service.PostService; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.global.exception.BadRequestException; import net.causw.global.exception.InternalServerException; import net.causw.global.exception.UnauthorizedException; @@ -67,16 +67,16 @@ public class PostController { @ApiResponse(responseCode = "4102", description = "동아리에서 추방된 사용자입니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UnauthorizedException.class))) }) public PostResponseDto findPostById( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.postService.findPostById(userDetails.getUser(), id); } @GetMapping @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "게시글 전체 조회 API(완료)", - description = "전체 게시글을 불러오는 API로 페이지 별로 불러올 수 있습니다. 현재 한 페이지당 20개의 게시글이 조회 가능합니다. 1페이지는 value값이 0입니다.") + @Operation(summary = "게시글 전체 조회 API(완료)", description = "전체 게시글을 불러오는 API로 페이지 별로 불러올 수 있습니다. 현재 한 페이지당 20개의 게시글이 조회 가능합니다. 1페이지는 value값이 0입니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -95,11 +95,14 @@ public PostResponseDto findPostById( @ApiResponse(responseCode = "4102", description = "동아리에서 추방된 사용자입니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UnauthorizedException.class))) }) public BoardPostsResponseDto findAllPost( - @RequestParam("boardId") String boardId, // 게시판 id - @RequestParam(name = "keyword", defaultValue = "") String keyword, - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum, // PageNation - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @RequestParam("boardId") + String boardId, // 게시판 id + @RequestParam(name = "keyword", defaultValue = "") + String keyword, + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum, // PageNation + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.postService.findAllPost(userDetails.getUser(), boardId, keyword, pageNum); } @@ -107,16 +110,16 @@ public BoardPostsResponseDto findAllPost( @ResponseStatus(value = HttpStatus.OK) @Operation(summary = "앱 자체 공지사항 확인 API(프론트에 없음)", description = "현재 프론트단에 코드가 존재하지 않습니다") public BoardPostsResponseDto findAllAppNotice( - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.postService.findAllAppNotice(userDetails.getUser(), pageNum); } @PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(value = HttpStatus.CREATED) - @Operation(summary = "게시글 생성 API(완료)", - description = "게시글을 생성하는 API로 각 게시판의 createrolelist에 따라서 작성할 수 있는 권한이 달라집니다.") + @Operation(summary = "게시글 생성 API(완료)", description = "게시글을 생성하는 API로 각 게시판의 createrolelist에 따라서 작성할 수 있는 권한이 달라집니다.") @ApiResponses({ @ApiResponse(responseCode = "201", description = "Created", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -136,17 +139,18 @@ public BoardPostsResponseDto findAllAppNotice( @ApiResponse(responseCode = "4107", description = "사용자가 해당 동아리의 동아리장이 아닙니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UnauthorizedException.class))) }) public PostCreateResponseDto createPost( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestPart(value = "postCreateRequestDto") @Valid PostCreateRequestDto postCreateRequestDto, - @RequestPart(value = "attachImageList", required = false) List attachImageList - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestPart(value = "postCreateRequestDto") @Valid + PostCreateRequestDto postCreateRequestDto, + @RequestPart(value = "attachImageList", required = false) + List attachImageList) { return this.postService.createPost(userDetails.getUser(), postCreateRequestDto, attachImageList); } @PostMapping(value = "/form", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(value = HttpStatus.CREATED) - @Operation(summary = "신청서 첨부 게시글 생성 API(완료)", - description = "신청서와 함께 게시글을 생성하는 API로 각 게시판의 createrolelist에 따라서 작성할 수 있는 권한이 달라집니다.") + @Operation(summary = "신청서 첨부 게시글 생성 API(완료)", description = "신청서와 함께 게시글을 생성하는 API로 각 게시판의 createrolelist에 따라서 작성할 수 있는 권한이 달라집니다.") @ApiResponses({ @ApiResponse(responseCode = "201", description = "Created", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -166,18 +170,19 @@ public PostCreateResponseDto createPost( @ApiResponse(responseCode = "4107", description = "사용자가 해당 동아리의 동아리장이 아닙니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UnauthorizedException.class))) }) public PostCreateResponseDto createPostWithForm( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestPart(value = "postCreateWithFormRequestDto") @Valid PostCreateWithFormRequestDto postCreateWithFormRequestDto, - @RequestPart(value = "attachImageList", required = false) List attachImageList - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestPart(value = "postCreateWithFormRequestDto") @Valid + PostCreateWithFormRequestDto postCreateWithFormRequestDto, + @RequestPart(value = "attachImageList", required = false) + List attachImageList) { return this.postService.createPostWithForm(userDetails.getUser(), postCreateWithFormRequestDto, attachImageList); } @DeleteMapping(value = "/{id}") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "게시글 삭제 API(완료)", - description = "게시글을 삭제하는 API로 작성자 본인이나 해당 게시판이 속한 동아리의 동아리장, 관리자, 학생회장의 경우 삭제 가능합니다.") + @Operation(summary = "게시글 삭제 API(완료)", description = "게시글을 삭제하는 API로 작성자 본인이나 해당 게시판이 속한 동아리의 동아리장, 관리자, 학생회장의 경우 삭제 가능합니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -199,9 +204,10 @@ public PostCreateResponseDto createPostWithForm( @ApiResponse(responseCode = "5000", description = "Post id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public void deletePost( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails) { postService.deletePost(userDetails.getUser(), id); } @@ -215,8 +221,7 @@ public void deletePost( */ @PutMapping(value = "/{id}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "게시글 업데이트 API(완료)", - description = "게시글을 업데이트하는 API로 작성자 본인이나 해당 게시판이 속한 동아리의 동아리장, 관리자, 학생회장의 경우 업데이트 가능합니다. 기존에 신청서가 있었던 게시글의 경우 신청서가 사라집니다.") + @Operation(summary = "게시글 업데이트 API(완료)", description = "게시글을 업데이트하는 API로 작성자 본인이나 해당 게시판이 속한 동아리의 동아리장, 관리자, 학생회장의 경우 업데이트 가능합니다. 기존에 신청서가 있었던 게시글의 경우 신청서가 사라집니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -241,24 +246,25 @@ public void deletePost( @ApiResponse(responseCode = "5000", description = "Post id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public void updatePost( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable("id") String id, - @RequestPart(value = "postUpdateRequestDto") @Valid PostUpdateRequestDto postUpdateRequestDto, - @RequestPart(value = "attachImageList", required = false) List attachImageList - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable("id") + String id, + @RequestPart(value = "postUpdateRequestDto") @Valid + PostUpdateRequestDto postUpdateRequestDto, + @RequestPart(value = "attachImageList", required = false) + List attachImageList) { postService.updatePost( userDetails.getUser(), id, postUpdateRequestDto, - attachImageList - ); + attachImageList); } @PutMapping(value = "/{id}/form", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "신청서 첨부 게시글 업데이트 API(완료)", - description = "신청서와 함께 게시글을 업데이트하는 API로 작성자 본인이나 해당 게시판이 속한 동아리의 동아리장, 관리자, 학생회장의 경우 업데이트 가능합니다.") + @Operation(summary = "신청서 첨부 게시글 업데이트 API(완료)", description = "신청서와 함께 게시글을 업데이트하는 API로 작성자 본인이나 해당 게시판이 속한 동아리의 동아리장, 관리자, 학생회장의 경우 업데이트 가능합니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -283,18 +289,20 @@ public void updatePost( @ApiResponse(responseCode = "5000", description = "Post id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public void updatePostWithForm( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable("id") String id, - @RequestPart(value = "postUpdateWithFormRequestDto") @Valid PostUpdateWithFormRequestDto postUpdateWithFormRequestDto, - @RequestPart(value = "attachImageList", required = false) List attachImageList - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable("id") + String id, + @RequestPart(value = "postUpdateWithFormRequestDto") @Valid + PostUpdateWithFormRequestDto postUpdateWithFormRequestDto, + @RequestPart(value = "attachImageList", required = false) + List attachImageList) { postService.updatePostWithForm(userDetails.getUser(), id, postUpdateWithFormRequestDto, attachImageList); } @PutMapping(value = "/{id}/restore") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "게시글 복구 API(완료)", - description = "게시글을 복구하는 API로 작성자 본인이나 해당 게시판이 속한 동아리의 동아리장, 관리자, 학생회장의 경우 복구 가능합니다.") + @Operation(summary = "게시글 복구 API(완료)", description = "게시글을 복구하는 API로 작성자 본인이나 해당 게시판이 속한 동아리의 동아리장, 관리자, 학생회장의 경우 복구 가능합니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -319,19 +327,18 @@ public void updatePostWithForm( @ApiResponse(responseCode = "5000", description = "Post id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public void restorePost( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails) { postService.restorePost( userDetails.getUser(), - id - ); + id); } @PostMapping(value = "/{id}/like") @ResponseStatus(value = HttpStatus.CREATED) - @Operation(summary = "게시글 좋아요 저장 API(완료)", - description = "특정 유저가 특정 게시글에 좋아요를 누른 걸 저장하는 Api 입니다.") + @Operation(summary = "게시글 좋아요 저장 API(완료)", description = "특정 유저가 특정 게시글에 좋아요를 누른 걸 저장하는 Api 입니다.") @ApiResponses({ @ApiResponse(responseCode = "201", description = "Created", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -344,16 +351,16 @@ public void restorePost( @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public void likePost( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails) { this.postService.likePost(userDetails.getUser(), id); } @DeleteMapping(value = "/{id}/like") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "게시글 좋아요 취소 API(완료)", - description = "특정 유저가 특정 게시글에 좋아요를 누른 걸 취소하는 Api 입니다.") + @Operation(summary = "게시글 좋아요 취소 API(완료)", description = "특정 유저가 특정 게시글에 좋아요를 누른 걸 취소하는 Api 입니다.") @ApiResponses({ @ApiResponse(responseCode = "201", description = "Created", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -366,16 +373,16 @@ public void likePost( @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public void cancelLikePost( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails) { this.postService.cancelLikePost(userDetails.getUser(), id); } @PostMapping(value = "/{id}/favorite") @ResponseStatus(value = HttpStatus.CREATED) - @Operation(summary = "게시글 즐겨찾기 저장 API(완료)", - description = "특정 유저가 특정 게시글에 즐겨찾기를 누른 걸 저장하는 Api 입니다.") + @Operation(summary = "게시글 즐겨찾기 저장 API(완료)", description = "특정 유저가 특정 게시글에 즐겨찾기를 누른 걸 저장하는 Api 입니다.") @ApiResponses({ @ApiResponse(responseCode = "201", description = "Created", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -389,16 +396,16 @@ public void cancelLikePost( @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public void favoritePost( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails) { this.postService.favoritePost(userDetails.getUser(), id); } @DeleteMapping(value = "/{id}/favorite") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "게시글 즐겨찾기 취소 API(완료)", - description = "특정 유저가 특정 게시글에 즐겨찾기를 누른 걸 취소하는 Api 입니다.") + @Operation(summary = "게시글 즐겨찾기 취소 API(완료)", description = "특정 유저가 특정 게시글에 즐겨찾기를 누른 걸 취소하는 Api 입니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -413,31 +420,32 @@ public void favoritePost( @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public void cancelFavoritePost( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails) { this.postService.cancelFavoritePost(userDetails.getUser(), id); } @PostMapping("/subscribe/{id}") @ResponseStatus(HttpStatus.OK) - @Operation(summary = "로그인한 사용자의 게시글 알람 설정 켜기" - , description = "id에는 post id 값을 넣어주세요") + @Operation(summary = "로그인한 사용자의 게시글 알람 설정 켜기", description = "id에는 post id 값을 넣어주세요") public PostSubscribeResponseDto subscribePost( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable("id") String id - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable("id") + String id) { return postService.setPostSubscribe(userDetails.getUser(), id, true); } @DeleteMapping("/subscribe/{id}") @ResponseStatus(HttpStatus.OK) - @Operation(summary = "로그인한 사용자의 게시글 알람 설정 끄기" - , description = "id에는 post id 값을 넣어주세요") + @Operation(summary = "로그인한 사용자의 게시글 알람 설정 끄기", description = "id에는 post id 값을 넣어주세요") public PostSubscribeResponseDto unsubscribePost( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable("id") String id - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable("id") + String id) { return postService.setPostSubscribe(userDetails.getUser(), id, false); } diff --git a/app-main/src/main/java/net/causw/app/main/api/ReportController.java b/app-main/src/main/java/net/causw/app/main/api/ReportController.java index 19e441696..2ed347d0e 100644 --- a/app-main/src/main/java/net/causw/app/main/api/ReportController.java +++ b/app-main/src/main/java/net/causw/app/main/api/ReportController.java @@ -13,13 +13,13 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.app.main.api.dto.report.ReportCreateRequestDto; import net.causw.app.main.api.dto.report.ReportCreateResponseDto; import net.causw.app.main.api.dto.report.ReportedCommentResponseDto; import net.causw.app.main.api.dto.report.ReportedPostResponseDto; import net.causw.app.main.api.dto.report.ReportedUserResponseDto; import net.causw.app.main.domain.community.report.service.ReportService; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.global.exception.BadRequestException; import net.causw.global.exception.UnauthorizedException; @@ -48,9 +48,10 @@ public class ReportController { @ApiResponse(responseCode = "401", description = "권한이 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UnauthorizedException.class))) }) public ReportCreateResponseDto createReport( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestBody @Valid ReportCreateRequestDto request - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestBody @Valid + ReportCreateRequestDto request) { return reportService.createReport(userDetails.getUser(), request); } @@ -63,8 +64,8 @@ public ReportCreateResponseDto createReport( @ApiResponse(responseCode = "401", description = "권한이 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UnauthorizedException.class))) }) public Page getReportedPosts( - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum - ) { + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum) { return reportService.getReportedPosts(pageNum); } @@ -77,8 +78,8 @@ public Page getReportedPosts( @ApiResponse(responseCode = "401", description = "권한이 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UnauthorizedException.class))) }) public Page getReportedComments( - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum - ) { + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum) { return reportService.getReportedComments(pageNum); } @@ -91,8 +92,8 @@ public Page getReportedComments( @ApiResponse(responseCode = "401", description = "권한이 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UnauthorizedException.class))) }) public Page getReportedUsers( - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum - ) { + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum) { return reportService.getReportedUsers(pageNum); } @@ -105,10 +106,10 @@ public Page getReportedUsers( @ApiResponse(responseCode = "401", description = "권한이 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UnauthorizedException.class))) }) public Page getReportedPostsByUser( - @Parameter(description = "사용자 ID", example = "user-uuid") - @PathVariable String userId, - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum - ) { + @Parameter(description = "사용자 ID", example = "user-uuid") @PathVariable + String userId, + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum) { return reportService.getReportedPostsByUser(userId, pageNum); } @@ -121,10 +122,10 @@ public Page getReportedPostsByUser( @ApiResponse(responseCode = "401", description = "권한이 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UnauthorizedException.class))) }) public Page getReportedCommentsByUser( - @Parameter(description = "사용자 ID", example = "user-uuid") - @PathVariable String userId, - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum - ) { + @Parameter(description = "사용자 ID", example = "user-uuid") @PathVariable + String userId, + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum) { return reportService.getReportedCommentsByUser(userId, pageNum); } } \ No newline at end of file diff --git a/app-main/src/main/java/net/causw/app/main/api/SemesterController.java b/app-main/src/main/java/net/causw/app/main/api/SemesterController.java index 058ca4ff3..92f8bc0bd 100644 --- a/app-main/src/main/java/net/causw/app/main/api/SemesterController.java +++ b/app-main/src/main/java/net/causw/app/main/api/SemesterController.java @@ -14,10 +14,10 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.app.main.api.dto.semester.CreateSemesterRequestDto; import net.causw.app.main.api.dto.semester.CurrentSemesterResponseDto; import net.causw.app.main.domain.campus.semester.service.SemesterService; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; @@ -50,9 +50,10 @@ public List getSemesterList() { @PreAuthorize("@security.hasRole(@Role.ADMIN)") @Operation(summary = "학기 생성(개발 테스트 및 관리자용)", description = "새로운 학기를 생성합니다.") public void createSemester( - @RequestBody CreateSemesterRequestDto createSemesterRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @RequestBody + CreateSemesterRequestDto createSemesterRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { semesterService.createSemester(createSemesterRequestDto, userDetails.getUser()); } @@ -65,8 +66,8 @@ public void createSemester( @PreAuthorize("@security.hasRoleGroup(RoleGroup.EXECUTIVES)") @Operation(summary = "다음 학기 생성(재학 인증 일괄 요청)", description = "다음 학기를 생성합니다. 자동으로 재학 인증도 일괄 요청 됩니다.") public void createNextSemester( - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { semesterService.createNextSemester(userDetails.getUser()); } @@ -75,8 +76,8 @@ public void createNextSemester( @PreAuthorize("@security.hasRole(@Role.ADMIN)") @Operation(summary = "학기 삭제(개발 테스트 및 관리자용)", description = "특정 학기를 삭제합니다.") public void deleteSemester( - @PathVariable(value = "semesterId") String semesterId - ) { + @PathVariable(value = "semesterId") + String semesterId) { semesterService.deleteSemester(semesterId); } } diff --git a/app-main/src/main/java/net/causw/app/main/api/StorageController.java b/app-main/src/main/java/net/causw/app/main/api/StorageController.java index e41cc8eeb..de094c8ad 100644 --- a/app-main/src/main/java/net/causw/app/main/api/StorageController.java +++ b/app-main/src/main/java/net/causw/app/main/api/StorageController.java @@ -1,6 +1,6 @@ package net.causw.app.main.api; -import static org.springframework.util.MimeTypeUtils.*; +import static org.springframework.util.MimeTypeUtils.APPLICATION_JSON_VALUE; import org.springframework.http.MediaType; import org.springframework.security.access.prepost.PreAuthorize; @@ -27,9 +27,10 @@ public class StorageController { @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @PreAuthorize("@security.hasRole(@Role.ADMIN)") public FileResponseDto post( - @RequestPart("file") MultipartFile multipartFile, - @RequestParam("type") FilePath filePath - ) { + @RequestPart("file") + MultipartFile multipartFile, + @RequestParam("type") + FilePath filePath) { return FileResponseDto.from(uuidFileService.saveFile(multipartFile, filePath).getFileUrl()); } diff --git a/app-main/src/main/java/net/causw/app/main/api/UserAcademicRecordApplicationController.java b/app-main/src/main/java/net/causw/app/main/api/UserAcademicRecordApplicationController.java index 647ab8e51..ef8aea416 100644 --- a/app-main/src/main/java/net/causw/app/main/api/UserAcademicRecordApplicationController.java +++ b/app-main/src/main/java/net/causw/app/main/api/UserAcademicRecordApplicationController.java @@ -20,7 +20,6 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.app.main.api.dto.semester.CurrentSemesterResponseDto; import net.causw.app.main.api.dto.user.UserAcademicStatusNoteUpdateDto; import net.causw.app.main.api.dto.userAcademicRecordApplication.CreateUserAcademicRecordApplicationRequestDto; @@ -35,6 +34,7 @@ import net.causw.app.main.domain.campus.semester.service.SemesterService; import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; import net.causw.app.main.domain.user.academic.service.UserAcademicRecordApplicationService; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import io.swagger.v3.oas.annotations.Operation; import jakarta.servlet.http.HttpServletResponse; @@ -52,18 +52,15 @@ public class UserAcademicRecordApplicationController { @GetMapping("/export") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "학적 정보 엑셀 파일로 내보내기(관리자용)", - description = "학적 정보를 엑셀 파일로 내보냅니다.") + @Operation(summary = "학적 정보 엑셀 파일로 내보내기(관리자용)", description = "학적 정보를 엑셀 파일로 내보냅니다.") public void exportUserAcademicRecord( - HttpServletResponse response - ) { + HttpServletResponse response) { userAcademicRecordApplicationService.exportUserAcademicRecordListToExcel(response); } @GetMapping("/semester/current") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "현재 학기 조회", - description = "현재 학기를 조회합니다.") + @Operation(summary = "현재 학기 조회", description = "현재 학기를 조회합니다.") public CurrentSemesterResponseDto getCurrentSemesterYearAndType() { return semesterService.getCurrentSemester(); } @@ -76,11 +73,10 @@ public CurrentSemesterResponseDto getCurrentSemesterYearAndType() { @GetMapping("/list/active-users") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "전체 유저의 학적 정보 목록 조회(관리자용)", - description = "전체 유저의 학적 정보 목록을 조회합니다.") + @Operation(summary = "전체 유저의 학적 정보 목록 조회(관리자용)", description = "전체 유저의 학적 정보 목록을 조회합니다.") public Page getAllUserAcademicRecordPage( - @ParameterObject Pageable pageable - ) { + @ParameterObject + Pageable pageable) { return userAcademicRecordApplicationService.getAllUserAcademicRecordPage(pageable); } @@ -92,11 +88,10 @@ public Page getAllUserAcademicRecordPage( @GetMapping("/list/await") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "전체 학적 인증 승인 대기 목록 조회(관리자용)", - description = "전체 학적 인증 승인 대기 목록 조회합니다.") + @Operation(summary = "전체 학적 인증 승인 대기 목록 조회(관리자용)", description = "전체 학적 인증 승인 대기 목록 조회합니다.") public Page getAllUserAwaitingAcademicRecordPage( - @ParameterObject Pageable pageable - ) { + @ParameterObject + Pageable pageable) { return userAcademicRecordApplicationService.getAllUserAwaitingAcademicRecordPage(pageable); } @@ -108,11 +103,10 @@ public Page getAllUserAwaitingAcad @GetMapping("/record/{userId}") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "유저 학적 정보 상세 보기(관리자용)", - description = "유저 학적 정보 상세를 조회합니다.") + @Operation(summary = "유저 학적 정보 상세 보기(관리자용)", description = "유저 학적 정보 상세를 조회합니다.") public UserAcademicRecordInfoResponseDto getUserAcademicRecordInfo( - @PathVariable("userId") String userId - ) { + @PathVariable("userId") + String userId) { return userAcademicRecordApplicationService.getUserAcademicRecordInfo(userId); } @@ -125,12 +119,12 @@ public UserAcademicRecordInfoResponseDto getUserAcademicRecordInfo( @PutMapping("/record/{userId}") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "유저 학적 정보 노트 변경(관리자용)", - description = "유저 학적 정보 노트를 변경합니다.") + @Operation(summary = "유저 학적 정보 노트 변경(관리자용)", description = "유저 학적 정보 노트를 변경합니다.") public UserAcademicRecordInfoResponseDto updateUserAcademicRecordNote( - @PathVariable("userId") String userId, - @RequestBody UserAcademicStatusNoteUpdateDto userAcademicStatusNoteUpdateDto - ) { + @PathVariable("userId") + String userId, + @RequestBody + UserAcademicStatusNoteUpdateDto userAcademicStatusNoteUpdateDto) { return userAcademicRecordApplicationService.updateUserAcademicRecordNote(userId, userAcademicStatusNoteUpdateDto); } @@ -144,12 +138,12 @@ public UserAcademicRecordInfoResponseDto updateUserAcademicRecordNote( @GetMapping("/application/{userId}/{applicationId}") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "유저 학적 승인 요청 상세 보기(관리자용)", - description = "유저 학적 승인 요청 상세를 조회합니다.") + @Operation(summary = "유저 학적 승인 요청 상세 보기(관리자용)", description = "유저 학적 승인 요청 상세를 조회합니다.") public UserAcademicRecordApplicationInfoResponseDto getUserAcademicRecordApplicationInfo( - @PathVariable("userId") String userId, - @PathVariable("applicationId") String applicationId - ) { + @PathVariable("userId") + String userId, + @PathVariable("applicationId") + String applicationId) { return userAcademicRecordApplicationService.getUserAcademicRecordApplicationInfo(userId, applicationId); } @@ -162,12 +156,12 @@ public UserAcademicRecordApplicationInfoResponseDto getUserAcademicRecordApplica @PutMapping("/update") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "유저 학적 정보 상태 변경(관리자용)", - description = "유저 학적 정보 상태를 변경합니다.") + @Operation(summary = "유저 학적 정보 상태 변경(관리자용)", description = "유저 학적 정보 상태를 변경합니다.") public UserAcademicRecordInfoResponseDto updateUserAcademicStatus( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestBody @Valid UpdateUserAcademicStatusRequestDto updateUserAcademicStatusRequestDto - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestBody @Valid + UpdateUserAcademicStatusRequestDto updateUserAcademicStatusRequestDto) { return userAcademicRecordApplicationService.updateUserAcademicStatus(userDetails.getUser(), updateUserAcademicStatusRequestDto); } @@ -181,12 +175,12 @@ public UserAcademicRecordInfoResponseDto updateUserAcademicStatus( @PutMapping("/application/admin") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "유저 학적 인증 승인 상태 변경(승인/거부)(관리자용)", - description = "유저 학적 인증 승인 상태를 변경합니다.") + @Operation(summary = "유저 학적 인증 승인 상태 변경(승인/거부)(관리자용)", description = "유저 학적 인증 승인 상태를 변경합니다.") public UserAcademicRecordApplicationResponseDto updateUserAcademicRecordApplicationStatus( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestBody @Valid UpdateUserAcademicRecordApplicationStateRequestDto updateUserAcademicRecordApplicationStateRequestDto - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestBody @Valid + UpdateUserAcademicRecordApplicationStateRequestDto updateUserAcademicRecordApplicationStateRequestDto) { return userAcademicRecordApplicationService.updateUserAcademicRecordApplicationStatus(userDetails.getUser(), updateUserAcademicRecordApplicationStateRequestDto); } @@ -197,11 +191,10 @@ public UserAcademicRecordApplicationResponseDto updateUserAcademicRecordApplicat */ @GetMapping("current") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "사용자 본인의 학적 증빙 상태 조회", - description = "사용자 본인의 학적 증빙 상태를 조회합니다.") + @Operation(summary = "사용자 본인의 학적 증빙 상태 조회", description = "사용자 본인의 학적 증빙 상태를 조회합니다.") public AcademicStatus getCurrentUserAcademicRecord( - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { return userAcademicRecordApplicationService.getCurrentUserAcademicRecord(userDetails.getUser()); } @@ -211,11 +204,10 @@ public AcademicStatus getCurrentUserAcademicRecord( */ @GetMapping("current/not-accepted") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "사용자 본인의 학적 증빙 제출 서류 조회(승인 대기/거절 중인 것만)", - description = "사용자 본인의 대기/거절 중인 학적 증빙 제출 서류를 조회합니다.") + @Operation(summary = "사용자 본인의 학적 증빙 제출 서류 조회(승인 대기/거절 중인 것만)", description = "사용자 본인의 대기/거절 중인 학적 증빙 제출 서류를 조회합니다.") public CurrentUserAcademicRecordApplicationResponseDto getCurrentUserAcademicRecordApplication( - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { return userAcademicRecordApplicationService.getCurrentUserAcademicRecordApplication(userDetails.getUser()); } @@ -228,13 +220,14 @@ public CurrentUserAcademicRecordApplicationResponseDto getCurrentUserAcademicRec */ @PostMapping(value = "/application/create", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(value = HttpStatus.CREATED) - @Operation(summary = "사용자 본인의 학적 증빙 서류 제출", - description = "사용자 본인의 학적 증빙 서류를 제출합니다.") + @Operation(summary = "사용자 본인의 학적 증빙 서류 제출", description = "사용자 본인의 학적 증빙 서류를 제출합니다.") public UserAcademicRecordApplicationResponseDto createUserAcademicRecordApplication( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestPart(value = "createUserAcademicRecordApplicationRequestDto") @Valid CreateUserAcademicRecordApplicationRequestDto createUserAcademicRecordApplicationRequestDto, - @RequestPart(value = "imageFileList", required = false) List imageFileList - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestPart(value = "createUserAcademicRecordApplicationRequestDto") @Valid + CreateUserAcademicRecordApplicationRequestDto createUserAcademicRecordApplicationRequestDto, + @RequestPart(value = "imageFileList", required = false) + List imageFileList) { return userAcademicRecordApplicationService.createUserAcademicRecordApplication(userDetails.getUser().getId(), createUserAcademicRecordApplicationRequestDto, imageFileList); } diff --git a/app-main/src/main/java/net/causw/app/main/api/UserBlockController.java b/app-main/src/main/java/net/causw/app/main/api/UserBlockController.java index f4dd6682d..5ea13f3d5 100644 --- a/app-main/src/main/java/net/causw/app/main/api/UserBlockController.java +++ b/app-main/src/main/java/net/causw/app/main/api/UserBlockController.java @@ -1,6 +1,6 @@ package net.causw.app.main.api; -import static org.springframework.util.MimeTypeUtils.*; +import static org.springframework.util.MimeTypeUtils.APPLICATION_JSON_VALUE; import org.springframework.http.HttpStatus; import org.springframework.security.core.annotation.AuthenticationPrincipal; @@ -10,10 +10,10 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.app.main.api.dto.userBlock.response.CreateBlockByChildCommentResponseDto; import net.causw.app.main.api.dto.userBlock.response.CreateBlockByCommentResponseDto; import net.causw.app.main.api.dto.userBlock.response.CreateBlockByPostResponseDto; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.app.main.domain.user.relation.service.BlockByChildCommentUseCaseService; import net.causw.app.main.domain.user.relation.service.BlockByCommentUseCaseService; import net.causw.app.main.domain.user.relation.service.BlockByPostUseCaseService; @@ -34,8 +34,10 @@ public class UserBlockController { @ResponseStatus(value = HttpStatus.OK) @Operation(summary = "게시물을 통한 차단 api", description = "게시물을 통해 유저를 차단할 수 있습니다.") public CreateBlockByPostResponseDto createBlockByPost( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable("postId") String postId + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable("postId") + String postId ) { return blockByPostUseCaseService.execute(userDetails, postId); @@ -45,8 +47,10 @@ public CreateBlockByPostResponseDto createBlockByPost( @ResponseStatus(value = HttpStatus.OK) @Operation(summary = "댓글을 통한 차단 api", description = "댓글을 통해 유저를 차단할 수 있습니다.") public CreateBlockByCommentResponseDto createBlockByComment( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable("commentId") String commentId + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable("commentId") + String commentId ) { return blockByCommentUseCaseService.execute(userDetails, commentId); @@ -56,8 +60,10 @@ public CreateBlockByCommentResponseDto createBlockByComment( @ResponseStatus(value = HttpStatus.OK) @Operation(summary = "대댓글을 통한 차단 api", description = "대댓글을 통해 유저를 차단할 수 있습니다.") public CreateBlockByChildCommentResponseDto createBlockByChildComment( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable("childCommentId") String childCommentId + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable("childCommentId") + String childCommentId ) { return blockByChildCommentUseCaseService.execute(userDetails, childCommentId); diff --git a/app-main/src/main/java/net/causw/app/main/api/UserController.java b/app-main/src/main/java/net/causw/app/main/api/UserController.java index a932fa641..0a458d53c 100644 --- a/app-main/src/main/java/net/causw/app/main/api/UserController.java +++ b/app-main/src/main/java/net/causw/app/main/api/UserController.java @@ -21,7 +21,6 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.app.main.api.dto.circle.CircleResponseDto; import net.causw.app.main.api.dto.duplicate.DuplicatedCheckResponseDto; import net.causw.app.main.api.dto.user.BatchRegisterResponseDto; @@ -51,6 +50,7 @@ import net.causw.app.main.domain.user.account.service.RegisterGraduatedUsersUseCaseService; import net.causw.app.main.domain.user.account.service.UserRoleService; import net.causw.app.main.domain.user.account.service.UserService; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.global.exception.BadRequestException; import net.causw.global.exception.UnauthorizedException; @@ -81,8 +81,7 @@ public class UserController { @GetMapping(value = "/{userId}") @ResponseStatus(value = HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES_AND_CIRCLE_LEADER)") - @Operation(summary = "사용자 정보 조회 API (완료)", - description = "userId에는 사용자 고유 id 값을 입력해주세요.") + @Operation(summary = "사용자 정보 조회 API (완료)", description = "userId에는 사용자 고유 id 값을 입력해주세요.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UserResponseDto.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -94,9 +93,10 @@ public class UserController { @ApiResponse(responseCode = "4108", description = "해당 유저는 소모임 회원이 아닙니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public UserResponseDto findByUserId( - @AuthenticationPrincipal CustomUserDetails userDetails, - @PathVariable("userId") String userId - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @PathVariable("userId") + String userId) { return this.userService.findByUserId(userId, userDetails.getUser()); } @@ -106,8 +106,7 @@ public UserResponseDto findByUserId( */ @GetMapping(value = "/me") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "로그인한 사용자 정보 조회 API (완료)", - description = "현재 로그인한 사용자의 정보를 조회합니다.") + @Operation(summary = "로그인한 사용자 정보 조회 API (완료)", description = "현재 로그인한 사용자의 정보를 조회합니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UserResponseDto.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -116,8 +115,8 @@ public UserResponseDto findByUserId( @ApiResponse(responseCode = "5000", description = "소모임장이 아닙니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public UserResponseDto findCurrentUser( - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userService.findCurrentUser(userDetails.getUser()); } @@ -126,16 +125,16 @@ public UserResponseDto findCurrentUser( @ResponseStatus(value = HttpStatus.OK) @Operation(summary = "(구)로그인한 사용자의 게시글 조회 API(삭제 예정 -> posts/written으로 변경)") public UserPostsResponseDto findPosts( - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userService.findPosts(userDetails.getUser(), pageNum); } @GetMapping(value = "/posts/written") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "로그인한 사용자가 작성한 게시글 기록 조회 API(완료)", - description = "로그인한 사용자가 작성한 게시글의 목록을 조회하는 Api 입니다.") + @Operation(summary = "로그인한 사용자가 작성한 게시글 기록 조회 API(완료)", description = "로그인한 사용자가 작성한 게시글의 목록을 조회하는 Api 입니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -146,16 +145,16 @@ public UserPostsResponseDto findPosts( @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public UserPostsResponseDto findMyWrittenPosts( - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userService.findPosts(userDetails.getUser(), pageNum); } @GetMapping(value = "/posts/favorite") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "로그인한 사용자가 누른 즐겨찾기 게시글 기록 조회 API(완료)", - description = "로그인한 사용자가 즐겨찾기한 게시글의 목록을 조회하는 Api 입니다.") + @Operation(summary = "로그인한 사용자가 누른 즐겨찾기 게시글 기록 조회 API(완료)", description = "로그인한 사용자가 즐겨찾기한 게시글의 목록을 조회하는 Api 입니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -166,16 +165,16 @@ public UserPostsResponseDto findMyWrittenPosts( @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public UserPostsResponseDto findMyFavoritePosts( - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userService.findFavoritePosts(userDetails.getUser(), pageNum); } @GetMapping(value = "/posts/like") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "로그인한 사용자가 좋아요 누른 게시글 기록 조회 API(완료)", - description = "로그인한 사용자가 좋아요 누른 게시글의 목록을 조회하는 Api 입니다.") + @Operation(summary = "로그인한 사용자가 좋아요 누른 게시글 기록 조회 API(완료)", description = "로그인한 사용자가 좋아요 누른 게시글의 목록을 조회하는 Api 입니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UserPostsResponseDto.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -186,16 +185,16 @@ public UserPostsResponseDto findMyFavoritePosts( @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public UserPostsResponseDto findMyLikePosts( - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userService.findLikePosts(userDetails.getUser(), pageNum); } @GetMapping(value = "/comments/written") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "로그인한 사용자가 작성한 댓글들의 게시물 기록 조회 API(완료)", - description = "로그인한 사용자가 작성한 댓글들의 게시물 기록 조회하는 Api 입니다.") + @Operation(summary = "로그인한 사용자가 작성한 댓글들의 게시물 기록 조회 API(완료)", description = "로그인한 사용자가 작성한 댓글들의 게시물 기록 조회하는 Api 입니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -206,9 +205,10 @@ public UserPostsResponseDto findMyLikePosts( @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public UserPostsResponseDto findMyCommentedPosts( - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userService.findCommentedPosts(userDetails.getUser(), pageNum); } @@ -216,9 +216,10 @@ public UserPostsResponseDto findMyCommentedPosts( @ResponseStatus(value = HttpStatus.OK) @Operation(summary = "로그인한 사용자의 댓글 조회 API(완료)") public UserCommentsResponseDto findComments( - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userService.findComments(userDetails.getUser(), pageNum); } @@ -227,9 +228,10 @@ public UserCommentsResponseDto findComments( @PreAuthorize("@security.hasRoleGroup(@RoleGroup.OPERATIONS_TEAM)") @Operation(summary = "유저 관리 시 사용자 이름으로 검색 API(완료)") public List findByName( - @PathVariable("name") String name, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("name") + String name, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userService.findByName(userDetails.getUser(), name); } @@ -238,8 +240,8 @@ public List findByName( @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") @Operation(summary = "특별한 권한을 가진 사용자 목록 확인 API(완료)", description = "학생회장, 부학생회장, 학생회, 학년대표, 동문회장 역할을 가지는 사용자를 반환합니다. \n 권한 역임을 할 수 있기 때문에 중복되는 사용자가 존재합니다.(ex. PRESIDENT_N_LEADER_CIRCLE)") public UserPrivilegedResponseDto findPrivilegedUsers( - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { return findPrivilegedUsersUseCaseService.execute(userDetails.getUser()); } @@ -248,11 +250,14 @@ public UserPrivilegedResponseDto findPrivilegedUsers( @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") @Operation(summary = "유저 관리 시 사용자의 상태(ACTIVE, INACTIVE 등) 에 따라 검색하는 API(완료)", description = "유저를 관리할 때 사용자가 활성, 비활성 상태인지에 따라서 분류하여 검색할 수 있습니다. \n state 는 ACTIVE, INACTIVE, AWAIT, REJECT, DROP 으로 검색가능합니다.") public Page findByState( - @PathVariable("state") String state, - @RequestParam(name = "user name", required = false) String name, - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("state") + String state, + @RequestParam(name = "user name", required = false) + String name, + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userService.findByState(userDetails.getUser(), state, name, pageNum); } @@ -274,8 +279,8 @@ public Page findByState( @ApiResponse(responseCode = "4001", description = "이미 존재하는 전화번호입니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public UserResponseDto signUp( - @Valid @RequestBody UserCreateRequestDto userCreateDto - ) { + @Valid @RequestBody + UserCreateRequestDto userCreateDto) { return this.userService.signUp(userCreateDto); } @@ -298,9 +303,9 @@ public UserResponseDto signUp( @ApiResponse(responseCode = "4109", description = "가입이 거절된 사용자 입니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public UserSignInResponseDto signIn( - @RequestBody UserSignInRequestDto userSignInRequestDto, - HttpServletRequest request - ) { + @RequestBody + UserSignInRequestDto userSignInRequestDto, + HttpServletRequest request) { String userAgent = request.getHeader("User-Agent"); String ipAddress = extractClientIp(request); return this.userService.signIn(userSignInRequestDto); @@ -331,7 +336,8 @@ private String extractClientIp(HttpServletRequest request) { @ApiResponse(responseCode = "4001", description = "이미 존재하는 전화번호입니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @ApiResponse(responseCode = "4001", description = "이미 존재하는 학번입니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) - public BatchRegisterResponseDto registerAlumni(@RequestParam("csvFile") MultipartFile csvFile) { + public BatchRegisterResponseDto registerAlumni(@RequestParam("csvFile") + MultipartFile csvFile) { return registerGraduatedUsersUseCaseService.execute(csvFile); } @@ -348,7 +354,8 @@ public BatchRegisterResponseDto registerAlumni(@RequestParam("csvFile") Multipar @ApiResponse(responseCode = "4000", description = "해당 사용자를 찾을 수 없습니다", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @ApiResponse(responseCode = "4002", description = "복구할 수 없는 계정 상태입니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) - public UserSignInResponseDto recoverUser(@Valid @RequestBody UserRecoverRequestDto userRecoverRequestDto) { + public UserSignInResponseDto recoverUser(@Valid @RequestBody + UserRecoverRequestDto userRecoverRequestDto) { return this.userService.recoverUser(userRecoverRequestDto.getEmail()); } @@ -364,7 +371,8 @@ public UserSignInResponseDto recoverUser(@Valid @RequestBody UserRecoverRequestD @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4001", description = "탈퇴한 계정의 재가입은 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) - public DuplicatedCheckResponseDto isDuplicatedEmail(@PathVariable("email") String email) { + public DuplicatedCheckResponseDto isDuplicatedEmail(@PathVariable("email") + String email) { return this.userService.isDuplicatedEmail(email); } @@ -380,7 +388,8 @@ public DuplicatedCheckResponseDto isDuplicatedEmail(@PathVariable("email") Strin @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4001", description = "탈퇴한 계정의 재가입은 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) - public DuplicatedCheckResponseDto isDuplicatedNickname(@PathVariable("nickname") String nickname) { + public DuplicatedCheckResponseDto isDuplicatedNickname(@PathVariable("nickname") + String nickname) { return this.userService.isDuplicatedNickname(nickname); } @@ -397,7 +406,8 @@ public DuplicatedCheckResponseDto isDuplicatedNickname(@PathVariable("nickname") @ApiResponse(responseCode = "4001", description = "탈퇴한 계정의 재가입은 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @ApiResponse(responseCode = "5000", description = "User id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) - public DuplicatedCheckResponseDto isDuplicatedStudentId(@PathVariable("studentId") String studentId) { + public DuplicatedCheckResponseDto isDuplicatedStudentId(@PathVariable("studentId") + String studentId) { return this.userService.isDuplicatedStudentId(studentId); } @@ -413,7 +423,8 @@ public DuplicatedCheckResponseDto isDuplicatedStudentId(@PathVariable("studentId @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4001", description = "탈퇴한 계정의 재가입은 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) - public DuplicatedCheckResponseDto isDuplicatedPhoneNumber(@PathVariable("phoneNumber") String phoneNumber) { + public DuplicatedCheckResponseDto isDuplicatedPhoneNumber(@PathVariable("phoneNumber") + String phoneNumber) { return this.userService.isDuplicatedPhoneNumber(phoneNumber); } @@ -440,58 +451,60 @@ public DuplicatedCheckResponseDto isDuplicatedPhoneNumber(@PathVariable("phoneNu @ApiResponse(responseCode = "4001", description = "이미 존재하는 전화번호입니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public UserResponseDto update( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestPart(value = "userUpdateDto") @Valid UserUpdateRequestDto userUpdateDto, - @RequestPart(value = "profileImage", required = false) MultipartFile profileImage - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestPart(value = "userUpdateDto") @Valid + UserUpdateRequestDto userUpdateDto, + @RequestPart(value = "profileImage", required = false) + MultipartFile profileImage) { return this.userService.update(userDetails.getUser(), userUpdateDto, profileImage); } @PutMapping(value = "/{delegateeId}/delegate-role") @ResponseStatus(value = HttpStatus.OK) - @Operation( - summary = "자신의 권한 위임", - description = """ - 로그인된 사용자가 자신의 권한 중 하나를 특정 사용자에게 위임합니다. - - 위임자는 해당 권한이 회수 됩니다. - - 고유 권한(ex. 학생회장 등)을 위임할 경우, 기존 모든 사용자로부터 해당 권한이 제거됩니다. - - 학생회장 권한 위임 시, 학생회 전체 권한(부회장, 학생회 등)이 초기화됩니다. - """ - ) + @Operation(summary = "자신의 권한 위임", description = """ + 로그인된 사용자가 자신의 권한 중 하나를 특정 사용자에게 위임합니다. + - 위임자는 해당 권한이 회수 됩니다. + - 고유 권한(ex. 학생회장 등)을 위임할 경우, 기존 모든 사용자로부터 해당 권한이 제거됩니다. + - 학생회장 권한 위임 시, 학생회 전체 권한(부회장, 학생회 등)이 초기화됩니다. + """) public UserResponseDto delegateRole( - @PathVariable("delegateeId") String delegateeId, - @Valid @RequestBody UserUpdateRoleRequestDto userUpdateRoleRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("delegateeId") + String delegateeId, + @Valid @RequestBody + UserUpdateRoleRequestDto userUpdateRoleRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userRoleService.delegateRole(userDetails.getUser(), delegateeId, userUpdateRoleRequestDto); } @PutMapping(value = "/{granteeId}/grant-role") @ResponseStatus(value = HttpStatus.OK) - @Operation( - summary = "타인에게 권한 부여", - description = """ - 로그인된 사용자가 타인에게 권한을 부여합니다. - - 부여일 경우 delegatorId는 생략해야 합니다. - - delegatorId가 존재하면, 위임의 형태로 간주되어 delegator의 권한이 회수됩니다. - - 고유 권한(ex. 학생회장 등) 부여 시 기존 모든 사용자로부터 해당 권한이 제거됩니다. - - 학생회장 권한 부여 시, 학생회 전체 권한(부회장, 학생회 등)이 초기화됩니다. - """ - ) + @Operation(summary = "타인에게 권한 부여", description = """ + 로그인된 사용자가 타인에게 권한을 부여합니다. + - 부여일 경우 delegatorId는 생략해야 합니다. + - delegatorId가 존재하면, 위임의 형태로 간주되어 delegator의 권한이 회수됩니다. + - 고유 권한(ex. 학생회장 등) 부여 시 기존 모든 사용자로부터 해당 권한이 제거됩니다. + - 학생회장 권한 부여 시, 학생회 전체 권한(부회장, 학생회 등)이 초기화됩니다. + """) public UserResponseDto grantRole( - @RequestParam(value = "delegatorId", required = false) String delegatorId, - @PathVariable("granteeId") String granteeId, - @Valid @RequestBody UserUpdateRoleRequestDto userUpdateRoleRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @RequestParam(value = "delegatorId", required = false) + String delegatorId, + @PathVariable("granteeId") + String granteeId, + @Valid @RequestBody + UserUpdateRoleRequestDto userUpdateRoleRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userRoleService.grantRole(userDetails.getUser(), delegatorId, granteeId, userUpdateRoleRequestDto); } @PutMapping(value = "/password/find") @ResponseStatus(value = HttpStatus.OK) @Operation(summary = "비밀번호 찾기 API (완료)", description = "비밀번호 재설정 이메일 전송 API입니다.") - public void findPassword(@Valid @RequestBody UserFindPasswordRequestDto userFindPasswordRequestDto) { + public void findPassword(@Valid @RequestBody + UserFindPasswordRequestDto userFindPasswordRequestDto) { this.userService.findPassword(userFindPasswordRequestDto); } @@ -499,9 +512,10 @@ public void findPassword(@Valid @RequestBody UserFindPasswordRequestDto userFind @ResponseStatus(value = HttpStatus.OK) @Operation(summary = "비밀번호 업데이트 API (완료)") public UserResponseDto updatePassword( - @Valid @RequestBody UserUpdatePasswordRequestDto userUpdatePasswordRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @Valid @RequestBody + UserUpdatePasswordRequestDto userUpdatePasswordRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userService.updatePassword(userDetails.getUser(), userUpdatePasswordRequestDto); } @@ -525,7 +539,8 @@ public UserResponseDto updatePassword( @ApiResponse(responseCode = "4107", description = "접근 권한이 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @ApiResponse(responseCode = "5000", description = "User id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) - public UserResponseDto leave(@AuthenticationPrincipal CustomUserDetails userDetails) { + public UserResponseDto leave(@AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userService.leave(userDetails.getUser()); } @@ -546,8 +561,10 @@ public UserResponseDto leave(@AuthenticationPrincipal CustomUserDetails userDeta @ApiResponse(responseCode = "4107", description = "접근 권한이 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @ApiResponse(responseCode = "5000", description = "User id checked, but exception occurred", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) - public UserResponseDto delete(@PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails) { + public UserResponseDto delete(@PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userService.eraseUserData(userDetails.getUser(), id); } @@ -557,10 +574,12 @@ public UserResponseDto delete(@PathVariable("id") String id, @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") @Operation(summary = "사용자 추방 및 사물함 반환 API (완료)") public UserResponseDto drop( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestBody String dropReason - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestBody + String dropReason) { return this.userService.dropUser(userDetails.getUser(), id, dropReason); } @@ -568,8 +587,8 @@ public UserResponseDto drop( @ResponseStatus(value = HttpStatus.OK) @Operation(summary = "사용자가 속한 동아리 목록 불러오기 API(완료)", description = "관리자, 학생회장인 경우 모든 동아리 불러오기") public List getCircleList( - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userService.getCircleList(userDetails.getUser()); } @@ -578,9 +597,10 @@ public List getCircleList( @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") @Operation(summary = "가입 대기 사용자 정보 확인 API (완료)") public UserAdmissionResponseDto findAdmissionById( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userService.findAdmissionById(userDetails.getUser(), id); } @@ -589,10 +609,12 @@ public UserAdmissionResponseDto findAdmissionById( @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") @Operation(summary = "모든 가입 대기 사용자 목록 확인 API (완료)") public Page findAllAdmissions( - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum, - @RequestParam(name = "name", required = false) String name, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum, + @RequestParam(name = "name", required = false) + String name, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userService.findAllAdmissions(userDetails.getUser(), name, pageNum); } @@ -607,10 +629,12 @@ public Page findAllAdmissions( @ApiResponse(responseCode = "4107", description = "이미 등록된 사용자 입니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public UserAdmissionResponseDto createAdmission( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestPart(value = "userAdmissionCreateRequestDto") @Valid UserAdmissionCreateRequestDto userAdmissionCreateRequestDto, - @RequestPart(value = "userAdmissionAttachImageList") List userAdmissionAttachImageList - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestPart(value = "userAdmissionCreateRequestDto") @Valid + UserAdmissionCreateRequestDto userAdmissionCreateRequestDto, + @RequestPart(value = "userAdmissionAttachImageList") + List userAdmissionAttachImageList) { return this.userService.createAdmission(userDetails.getUser(), userAdmissionCreateRequestDto, userAdmissionAttachImageList); } @@ -619,8 +643,8 @@ public UserAdmissionResponseDto createAdmission( @ResponseStatus(value = HttpStatus.OK) @Operation(summary = "현재 사용자의 가입 신청 정보 확인 API") public UserAdmissionResponseDto getCurrentUserAdmission( - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userService.getCurrentUserAdmission(userDetails.getUser()); } @@ -639,9 +663,10 @@ public UserAdmissionResponseDto getCurrentUserAdmission( @ApiResponse(responseCode = "5000", description = "User id checked, but exception occurred", content = @io.swagger.v3.oas.annotations.media.Content(mediaType = "application/json", schema = @io.swagger.v3.oas.annotations.media.Schema(implementation = BadRequestException.class))) }) public UserAdmissionResponseDto acceptAdmission( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userService.accept(userDetails.getUser(), id); } @@ -666,10 +691,12 @@ public UserAdmissionResponseDto acceptAdmission( @ApiResponse(responseCode = "5000", description = "User id checked, but exception occurred", content = @io.swagger.v3.oas.annotations.media.Content(mediaType = "application/json", schema = @io.swagger.v3.oas.annotations.media.Schema(implementation = BadRequestException.class))) }) public UserAdmissionResponseDto rejectAdmission( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestBody String rejectReason - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestBody + String rejectReason) { return this.userService.reject(userDetails.getUser(), id, rejectReason); } @@ -679,9 +706,10 @@ public UserAdmissionResponseDto rejectAdmission( @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") @Operation(summary = "사용자 복구 API(완료)", description = "복구할 사용자의 id를 넣어주세요") public UserResponseDto restore( - @PathVariable("id") String id, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("id") + String id, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return this.userService.restore(userDetails.getUser(), id); } @@ -693,8 +721,8 @@ public UserResponseDto restore( @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public UserSignInResponseDto updateToken( - @Valid @RequestBody UserUpdateTokenRequestDto userUpdateTokenRequestDto - ) { + @Valid @RequestBody + UserUpdateTokenRequestDto userUpdateTokenRequestDto) { return this.userService.updateToken(userUpdateTokenRequestDto.getRefreshToken()); } @@ -705,9 +733,10 @@ public UserSignInResponseDto updateToken( @ApiResponse(responseCode = "200", description = "OK", content = @io.swagger.v3.oas.annotations.media.Content(mediaType = "application/json", schema = @io.swagger.v3.oas.annotations.media.Schema(implementation = UserSignInResponseDto.class))) }) public UserSignOutResponseDto signOut( - @Valid @RequestBody UserSignOutRequestDto userSignOutRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @Valid @RequestBody + UserSignOutRequestDto userSignOutRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { return userService.signOut(userDetails.getUser(), userSignOutRequestDto); } @@ -723,8 +752,8 @@ public UserSignOutResponseDto signOut( @ApiResponse(responseCode = "4000", description = "해당 사용자를 찾을 수 없습니다", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public UserFindIdResponseDto findUserId( - @Valid @RequestBody UserFindIdRequestDto userFindIdRequestDto - ) { + @Valid @RequestBody + UserFindIdRequestDto userFindIdRequestDto) { return userService.findUserId(userFindIdRequestDto); } @@ -739,8 +768,8 @@ public UserFindIdResponseDto findUserId( @ApiResponse(responseCode = "4107", description = "접근 권한이 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), }) public List findByStudentId( - @PathVariable("studentId") String studentId - ) { + @PathVariable("studentId") + String studentId) { return userService.findByStudentId(studentId); } @@ -758,49 +787,46 @@ public void exportUserList(HttpServletResponse response) { @PutMapping(value = "/update/isV2") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "사용자 isV2 칼럼 업데이트(v1->v2 DB 마이그레이션 전용)", - description = "사용자 isV2 칼럼 업데이트(v1->v2 DB 마이그레이션 전용) API입니다. isV2를 true로 업데이트 합니다. 학부 인증과 학적 상태 인증이 모두 끝난 유저만 업데이트가 가능합니다.") + @Operation(summary = "사용자 isV2 칼럼 업데이트(v1->v2 DB 마이그레이션 전용)", description = "사용자 isV2 칼럼 업데이트(v1->v2 DB 마이그레이션 전용) API입니다. isV2를 true로 업데이트 합니다. 학부 인증과 학적 상태 인증이 모두 끝난 유저만 업데이트가 가능합니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UserResponseDto.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public UserResponseDto updateUserIsV2( - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { return userService.updateUserIsV2(userDetails.getUser()); } @PostMapping(value = "/fcm") @ResponseStatus(value = HttpStatus.CREATED) - @Operation(summary = "사용자 fcmToken 등록", - description = "로그인한 사용자의 fcmToken을 등록합니다") + @Operation(summary = "사용자 fcmToken 등록", description = "로그인한 사용자의 fcmToken을 등록합니다") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UserResponseDto.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public UserFcmTokenResponseDto registerFcmToken( - @AuthenticationPrincipal CustomUserDetails userDetails, - @Valid @RequestBody UserFcmCreateRequestDto userFcmCreateRequestDto - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @Valid @RequestBody + UserFcmCreateRequestDto userFcmCreateRequestDto) { return userService.registerFcmToken(userDetails.getUser(), userFcmCreateRequestDto); } @GetMapping(value = "/fcm") @ResponseStatus(value = HttpStatus.OK) - @Operation(summary = "사용자 fcmToken 조회", - description = "로그인한 사용자의 fcmToken을 조회합니다") + @Operation(summary = "사용자 fcmToken 조회", description = "로그인한 사용자의 fcmToken을 조회합니다") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UserResponseDto.class))), @ApiResponse(responseCode = "4000", description = "로그인된 사용자를 찾을 수 없습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @ApiResponse(responseCode = "4012", description = "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))) }) public UserFcmTokenResponseDto getFcmToken( - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { return userService.getUserFcmToken(userDetails.getUser()); } } - diff --git a/app-main/src/main/java/net/causw/app/main/api/UserCouncilFeeController.java b/app-main/src/main/java/net/causw/app/main/api/UserCouncilFeeController.java index 86d559019..825e1658d 100644 --- a/app-main/src/main/java/net/causw/app/main/api/UserCouncilFeeController.java +++ b/app-main/src/main/java/net/causw/app/main/api/UserCouncilFeeController.java @@ -17,13 +17,13 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; -import net.causw.app.main.domain.finance.usercouncilfee.service.UserCouncilFeeService; import net.causw.app.main.api.dto.userCouncilFee.CreateUserCouncilFeeWithFakeUserRequestDto; import net.causw.app.main.api.dto.userCouncilFee.CreateUserCouncilFeeWithUserRequestDto; import net.causw.app.main.api.dto.userCouncilFee.CurrentUserCouncilFeeResponseDto; import net.causw.app.main.api.dto.userCouncilFee.UserCouncilFeeListResponseDto; import net.causw.app.main.api.dto.userCouncilFee.UserCouncilFeeResponseDto; +import net.causw.app.main.domain.finance.usercouncilfee.service.UserCouncilFeeService; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.global.constant.MessageUtil; import net.causw.global.exception.BadRequestException; import net.causw.global.exception.InternalServerException; @@ -49,56 +49,51 @@ public class UserCouncilFeeController { @GetMapping("/export/excel") @ResponseStatus(HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "학생회비 엑셀 다운로드", - description = "학생회비 엑셀 파일을 다운로드합니다.") + @Operation(summary = "학생회비 엑셀 다운로드", description = "학생회비 엑셀 파일을 다운로드합니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "5000", description = MessageUtil.FAIL_TO_GENERATE_EXCEL_FILE, content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))), @ApiResponse(responseCode = "5000", description = MessageUtil.INTERNAL_SERVER_ERROR, content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public void exportUserCouncilFeeToExcel( - HttpServletResponse response - ) { + HttpServletResponse response) { userCouncilFeeService.exportUserCouncilFeeToExcel(response); } @GetMapping("/list") @ResponseStatus(HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "학생회비 납부자 목록 조회", - description = "학생회비 납부자 목록을 조회합니다.") + @Operation(summary = "학생회비 납부자 목록 조회", description = "학생회비 납부자 목록을 조회합니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Page.class))), @ApiResponse(responseCode = "4000", description = MessageUtil.USER_NOT_FOUND, content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @ApiResponse(responseCode = "5000", description = MessageUtil.INTERNAL_SERVER_ERROR, content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public Page getUserCouncilFeeList( - @ParameterObject Pageable pageable - ) { + @ParameterObject + Pageable pageable) { return userCouncilFeeService.getUserCouncilFeeList(pageable); } @GetMapping("/info/{userCouncilFeeId}") @ResponseStatus(HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "학생회비 납부자 상세 조회", - description = "학생회비 납부자 상세 정보를 조회합니다.") + @Operation(summary = "학생회비 납부자 상세 조회", description = "학생회비 납부자 상세 정보를 조회합니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UserCouncilFeeResponseDto.class))), @ApiResponse(responseCode = "4000", description = MessageUtil.USER_COUNCIL_FEE_NOT_FOUND, content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @ApiResponse(responseCode = "5000", description = MessageUtil.INTERNAL_SERVER_ERROR, content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public UserCouncilFeeResponseDto getUserCouncilFeeInfo( - @PathVariable(value = "userCouncilFeeId") String userCouncilFeeId - ) { + @PathVariable(value = "userCouncilFeeId") + String userCouncilFeeId) { return userCouncilFeeService.getUserCouncilFeeInfo(userCouncilFeeId); } @PostMapping("/create-user") @ResponseStatus(HttpStatus.CREATED) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "학생회비 납부자 등록(가입 유저 대상)", - description = "동문네트워크 가입자 대상으로 학생회비 납부자를 등록합니다.") + @Operation(summary = "학생회비 납부자 등록(가입 유저 대상)", description = "동문네트워크 가입자 대상으로 학생회비 납부자를 등록합니다.") @ApiResponses({ @ApiResponse(responseCode = "201", description = "학생회비 납부자 등록 완료", content = @Content), @ApiResponse(responseCode = "4000", description = MessageUtil.INVALID_USER_COUNCIL_FEE_INFO, content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -108,9 +103,10 @@ public UserCouncilFeeResponseDto getUserCouncilFeeInfo( @ApiResponse(responseCode = "5000", description = MessageUtil.INTERNAL_SERVER_ERROR, content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public void createUserCouncilFeeWithUser( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestBody @Valid CreateUserCouncilFeeWithUserRequestDto createUserCouncilFeeWithUserRequestDto - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestBody @Valid + CreateUserCouncilFeeWithUserRequestDto createUserCouncilFeeWithUserRequestDto) { userCouncilFeeService.createUserCouncilFeeWithUser(userDetails.getUser(), createUserCouncilFeeWithUserRequestDto); } @@ -118,8 +114,7 @@ public void createUserCouncilFeeWithUser( @PostMapping("/create-fake-user") @ResponseStatus(HttpStatus.CREATED) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "학생회비 납부자 등록(미가입자 대상)", - description = "동문네트워크 미 가입자 대상으로 학생회비 납부자를 등록합니다.") + @Operation(summary = "학생회비 납부자 등록(미가입자 대상)", description = "동문네트워크 미 가입자 대상으로 학생회비 납부자를 등록합니다.") @ApiResponses({ @ApiResponse(responseCode = "201", description = "학생회비 납부자 등록 완료", content = @Content), @ApiResponse(responseCode = "4000", description = MessageUtil.INVALID_USER_COUNCIL_FEE_INFO, content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -129,17 +124,17 @@ public void createUserCouncilFeeWithUser( @ApiResponse(responseCode = "5000", description = MessageUtil.INTERNAL_SERVER_ERROR, content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public void createUserCouncilFeeWithFakeUser( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestBody @Valid CreateUserCouncilFeeWithFakeUserRequestDto createUserCouncilFeeRequestDto - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestBody @Valid + CreateUserCouncilFeeWithFakeUserRequestDto createUserCouncilFeeRequestDto) { userCouncilFeeService.creatUserCouncilFeeWithFakeUser(userDetails.getUser(), createUserCouncilFeeRequestDto); } @PutMapping("/update-user") @ResponseStatus(HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "학생회비 납부자 수정(가입 유저 대상)", - description = "학생회비 납부자를 수정합니다.(가입 유저 대상)") + @Operation(summary = "학생회비 납부자 수정(가입 유저 대상)", description = "학생회비 납부자를 수정합니다.(가입 유저 대상)") @ApiResponses({ @ApiResponse(responseCode = "200", description = "학생회비 납부자 수정 완료", content = @Content), @ApiResponse(responseCode = "4000", description = MessageUtil.INVALID_USER_COUNCIL_FEE_INFO, content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -149,14 +144,12 @@ public void createUserCouncilFeeWithFakeUser( @ApiResponse(responseCode = "5000", description = MessageUtil.INTERNAL_SERVER_ERROR, content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public void updateUserCouncilFeeWithUser( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestHeader @Pattern( - regexp = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", - message = "id 값은 대시(-)를 포함하고, 32자리의 UUID 형식이어야 합니다." - ) - @NotBlank(message = "대상 사용자 고유 id 값은 필수 입력 값입니다.") String userCouncilFeeId, - @RequestBody @Valid CreateUserCouncilFeeWithUserRequestDto createUserCouncilFeeWithUserRequestDto - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestHeader @Pattern(regexp = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", message = "id 값은 대시(-)를 포함하고, 32자리의 UUID 형식이어야 합니다.") @NotBlank(message = "대상 사용자 고유 id 값은 필수 입력 값입니다.") + String userCouncilFeeId, + @RequestBody @Valid + CreateUserCouncilFeeWithUserRequestDto createUserCouncilFeeWithUserRequestDto) { userCouncilFeeService.updateUserCouncilFeeWithUser(userDetails.getUser(), userCouncilFeeId, createUserCouncilFeeWithUserRequestDto); } @@ -164,8 +157,7 @@ public void updateUserCouncilFeeWithUser( @PutMapping("/update-fake-user") @ResponseStatus(HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "학생회비 납부자 수정(미가입자 대상)", - description = "학생회비 납부자를 수정합니다.") + @Operation(summary = "학생회비 납부자 수정(미가입자 대상)", description = "학생회비 납부자를 수정합니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "학생회비 납부자 수정 완료", content = @Content), @ApiResponse(responseCode = "4000", description = MessageUtil.INVALID_USER_COUNCIL_FEE_INFO, content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @@ -175,14 +167,12 @@ public void updateUserCouncilFeeWithUser( @ApiResponse(responseCode = "5000", description = MessageUtil.INTERNAL_SERVER_ERROR, content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public void updateUserCouncilFeeWithFakeUser( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestHeader @Pattern( - regexp = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", - message = "id 값은 대시(-)를 포함하고, 32자리의 UUID 형식이어야 합니다." - ) - @NotBlank(message = "대상 사용자 고유 id 값은 필수 입력 값입니다.") String userCouncilFeeId, - @RequestBody @Valid CreateUserCouncilFeeWithFakeUserRequestDto createUserCouncilFeeRequestDto - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestHeader @Pattern(regexp = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", message = "id 값은 대시(-)를 포함하고, 32자리의 UUID 형식이어야 합니다.") @NotBlank(message = "대상 사용자 고유 id 값은 필수 입력 값입니다.") + String userCouncilFeeId, + @RequestBody @Valid + CreateUserCouncilFeeWithFakeUserRequestDto createUserCouncilFeeRequestDto) { userCouncilFeeService.updateUserCouncilFeeWithFakeUser(userDetails.getUser(), userCouncilFeeId, createUserCouncilFeeRequestDto); } @@ -190,79 +180,75 @@ public void updateUserCouncilFeeWithFakeUser( @DeleteMapping("/delete") @ResponseStatus(HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "학생회비 납부자 삭제", - description = "학생회비 납부자를 삭제합니다.") + @Operation(summary = "학생회비 납부자 삭제", description = "학생회비 납부자를 삭제합니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "학생회비 납부자 삭제 완료", content = @Content), @ApiResponse(responseCode = "4000", description = MessageUtil.USER_COUNCIL_FEE_NOT_FOUND, content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @ApiResponse(responseCode = "5000", description = MessageUtil.INTERNAL_SERVER_ERROR, content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public void deleteUserCouncilFee( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestHeader String userCouncilFeeId - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestHeader + String userCouncilFeeId) { userCouncilFeeService.deleteUserCouncilFee(userDetails.getUser(), userCouncilFeeId); } @GetMapping("/getUserIdByStudentId") @ResponseStatus(HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "학번으로 사용자 id 조회", - description = "학번으로 사용자 id를 조회합니다.") + @Operation(summary = "학번으로 사용자 id 조회", description = "학번으로 사용자 id를 조회합니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "사용자 ID 조회 완료", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "4000", description = MessageUtil.USER_NOT_FOUND, content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @ApiResponse(responseCode = "5000", description = MessageUtil.INTERNAL_SERVER_ERROR, content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public String getUserIdByStudentId( - @RequestHeader String studentId - ) { + @RequestHeader + String studentId) { return userCouncilFeeService.getUserIdByStudentId(studentId); } @GetMapping("/isCurrentSemesterApplied") @ResponseStatus(HttpStatus.OK) @PreAuthorize("@security.hasRoleGroup(@RoleGroup.EXECUTIVES)") - @Operation(summary = "특정 사용자가 현재 학생회비 적용 학기인지 여부 조회", - description = "특정 사용자가 현재 학생회비 적용 학기인지 여부를 조회합니다.") + @Operation(summary = "특정 사용자가 현재 학생회비 적용 학기인지 여부 조회", description = "특정 사용자가 현재 학생회비 적용 학기인지 여부를 조회합니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Boolean.class))), @ApiResponse(responseCode = "4000", description = MessageUtil.USER_NOT_FOUND, content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @ApiResponse(responseCode = "5000", description = MessageUtil.INTERNAL_SERVER_ERROR, content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public Boolean isCurrentSemesterApplied( - @RequestHeader String userId - ) { + @RequestHeader + String userId) { return userCouncilFeeService.isCurrentSemesterApplied(userId); } @GetMapping("/isCurrentSemesterApplied/self") @ResponseStatus(HttpStatus.OK) - @Operation(summary = "본인이 현재 학생회비 적용 학기인지 여부 조회", - description = "본인이 현재 학생회비 적용 학기인지 여부를 조회합니다.") + @Operation(summary = "본인이 현재 학생회비 적용 학기인지 여부 조회", description = "본인이 현재 학생회비 적용 학기인지 여부를 조회합니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Boolean.class))), @ApiResponse(responseCode = "4000", description = MessageUtil.USER_NOT_FOUND, content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @ApiResponse(responseCode = "5000", description = MessageUtil.INTERNAL_SERVER_ERROR, content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public Boolean isCurrentSemesterAppliedBySelf( - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { return userCouncilFeeService.isCurrentSemesterAppliedBySelf(userDetails.getUser()); } @GetMapping("/isCurrentSemesterApplied/self/info") @ResponseStatus(HttpStatus.OK) - @Operation(summary = "본인이 현재 학생회비 적용 학기인지 여부 상세 조회", - description = "본인이 현재 학생회비 적용 학기인지 여부를 상세 조회합니다.") + @Operation(summary = "본인이 현재 학생회비 적용 학기인지 여부 상세 조회", description = "본인이 현재 학생회비 적용 학기인지 여부를 상세 조회합니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = CurrentUserCouncilFeeResponseDto.class))), @ApiResponse(responseCode = "4000", description = MessageUtil.USER_NOT_FOUND, content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadRequestException.class))), @ApiResponse(responseCode = "5000", description = MessageUtil.INTERNAL_SERVER_ERROR, content = @Content(mediaType = "application/json", schema = @Schema(implementation = InternalServerException.class))) }) public CurrentUserCouncilFeeResponseDto isCurrentSemesterAppliedBySelfInfo( - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { return userCouncilFeeService.isCurrentSemesterAppliedBySelfInfo(userDetails.getUser()); } diff --git a/app-main/src/main/java/net/causw/app/main/api/UserInfoController.java b/app-main/src/main/java/net/causw/app/main/api/UserInfoController.java index 1db96dd07..8f6dab6f1 100644 --- a/app-main/src/main/java/net/causw/app/main/api/UserInfoController.java +++ b/app-main/src/main/java/net/causw/app/main/api/UserInfoController.java @@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.app.main.api.dto.userInfo.UserInfoResponseDto; import net.causw.app.main.api.dto.userInfo.UserInfoSearchConditionDto; import net.causw.app.main.api.dto.userInfo.UserInfoSummaryResponseDto; @@ -23,6 +22,7 @@ import net.causw.app.main.domain.user.account.service.GetUserInfoUseCaseService; import net.causw.app.main.domain.user.account.service.SearchUserInfoListUseCaseService; import net.causw.app.main.domain.user.account.service.UpdateUserInfoUseCaseService; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.global.exception.BadRequestException; import io.swagger.v3.oas.annotations.Operation; @@ -51,8 +51,8 @@ public class UserInfoController { @ResponseStatus(value = HttpStatus.OK) @Operation(summary = "사용자 id로 사용자 세부정보 조회 API") public UserInfoResponseDto getUserInfoByUserId( - @PathVariable("userId") String userId - ) { + @PathVariable("userId") + String userId) { return getUserInfoUseCaseService.execute(userId); } @@ -60,9 +60,10 @@ public UserInfoResponseDto getUserInfoByUserId( @ResponseStatus(value = HttpStatus.OK) @Operation(summary = "전체 사용자 리스트 검색 및 조회 API", description = "최근 수정된 순서대로 정렬") public Page searchUserInfos( - @RequestParam(name = "pageNum", defaultValue = "0") Integer pageNum, - @ModelAttribute UserInfoSearchConditionDto userInfoSearchCondition - ) { + @RequestParam(name = "pageNum", defaultValue = "0") + Integer pageNum, + @ModelAttribute + UserInfoSearchConditionDto userInfoSearchCondition) { return searchUserInfoListUseCaseService.execute(userInfoSearchCondition, pageNum); } @@ -70,8 +71,8 @@ public Page searchUserInfos( @ResponseStatus(value = HttpStatus.OK) @Operation(summary = "자신의 세부정보 조회 API") public UserInfoResponseDto getCurrentUser( - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails) { return getUserInfoUseCaseService.execute(userDetails.getUserId()); } @@ -85,10 +86,12 @@ public UserInfoResponseDto getCurrentUser( }) public UserInfoResponseDto updateCurrentUser( - @AuthenticationPrincipal CustomUserDetails userDetails, - @RequestPart(value = "userInfoUpdateDto") @Valid UserInfoUpdateRequestDto userInfoUpdateDto, - @RequestPart(value = "profileImage", required = false) MultipartFile profileImage - ) { + @AuthenticationPrincipal + CustomUserDetails userDetails, + @RequestPart(value = "userInfoUpdateDto") @Valid + UserInfoUpdateRequestDto userInfoUpdateDto, + @RequestPart(value = "profileImage", required = false) + MultipartFile profileImage) { return updateUserInfoUseCaseService.execute(userDetails.getUserId(), userInfoUpdateDto, profileImage); } } \ No newline at end of file diff --git a/app-main/src/main/java/net/causw/app/main/api/VoteController.java b/app-main/src/main/java/net/causw/app/main/api/VoteController.java index 1192db9ea..e5ff1b1e0 100644 --- a/app-main/src/main/java/net/causw/app/main/api/VoteController.java +++ b/app-main/src/main/java/net/causw/app/main/api/VoteController.java @@ -11,11 +11,11 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.app.main.api.dto.vote.CastVoteRequestDto; import net.causw.app.main.api.dto.vote.CreateVoteRequestDto; import net.causw.app.main.api.dto.vote.VoteResponseDto; import net.causw.app.main.domain.community.vote.service.VoteService; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import io.swagger.v3.oas.annotations.Operation; import jakarta.validation.Valid; @@ -32,9 +32,10 @@ public class VoteController { @ResponseStatus(HttpStatus.CREATED) @Operation(summary = "투표 생성", description = "새로운 투표를 생성합니다.") public ResponseEntity createVote( - @Valid @RequestBody CreateVoteRequestDto createVoteRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @Valid @RequestBody + CreateVoteRequestDto createVoteRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { VoteResponseDto voteResponse = voteService.createVote(createVoteRequestDto, userDetails.getUser()); return ResponseEntity.status(HttpStatus.CREATED).body(voteResponse); } @@ -43,9 +44,10 @@ public ResponseEntity createVote( @ResponseStatus(HttpStatus.OK) @Operation(summary = "투표 참여", description = "해당 투표에 참여합니다.") public ResponseEntity castVote( - @Valid @RequestBody CastVoteRequestDto castVoteRequestDto, - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @Valid @RequestBody + CastVoteRequestDto castVoteRequestDto, + @AuthenticationPrincipal + CustomUserDetails userDetails) { String result = voteService.castVote(castVoteRequestDto, userDetails.getUser()); return ResponseEntity.ok(result); } @@ -54,9 +56,10 @@ public ResponseEntity castVote( @ResponseStatus(HttpStatus.OK) @Operation(summary = "투표 종료", description = "특정 투표를 종료합니다.") public ResponseEntity endVote( - @PathVariable("voteId") String voteId, // 파라미터 이름 명시 - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("voteId") + String voteId, // 파라미터 이름 명시 + @AuthenticationPrincipal + CustomUserDetails userDetails) { return ResponseEntity.ok(voteService.endVote(voteId, userDetails.getUser())); } @@ -64,9 +67,10 @@ public ResponseEntity endVote( @ResponseStatus(HttpStatus.OK) @Operation(summary = "투표 재시작", description = "특정 투표를 재시작합니다.") public ResponseEntity restartVote( - @PathVariable("voteId") String voteId, // 파라미터 이름 명시 - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("voteId") + String voteId, // 파라미터 이름 명시 + @AuthenticationPrincipal + CustomUserDetails userDetails) { return ResponseEntity.ok(voteService.restartVote(voteId, userDetails.getUser())); } @@ -74,9 +78,10 @@ public ResponseEntity restartVote( @ResponseStatus(HttpStatus.OK) @Operation(summary = "투표 조회", description = "특정 투표에 대한 정보를 조회합니다.") public ResponseEntity getVoteById( - @PathVariable("voteId") String voteId, // 파라미터 이름 명시 - @AuthenticationPrincipal CustomUserDetails userDetails - ) { + @PathVariable("voteId") + String voteId, // 파라미터 이름 명시 + @AuthenticationPrincipal + CustomUserDetails userDetails) { VoteResponseDto voteResponse = voteService.getVoteById(voteId, userDetails.getUser()); return ResponseEntity.ok(voteResponse); } diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/circle/CircleBoardsResponseDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/circle/CircleBoardsResponseDto.java index a2079e916..b2aeff190 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/circle/CircleBoardsResponseDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/circle/CircleBoardsResponseDto.java @@ -24,8 +24,7 @@ public class CircleBoardsResponseDto { public static CircleBoardsResponseDto from( CircleResponseDto circle, - List boardList - ) { + List boardList) { return CircleBoardsResponseDto.builder() .circle(circle) .boardList(boardList) diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/circle/CircleCreateRequestDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/circle/CircleCreateRequestDto.java index 5d48393e3..badfc7f22 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/circle/CircleCreateRequestDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/circle/CircleCreateRequestDto.java @@ -24,10 +24,7 @@ public class CircleCreateRequestDto { @Schema(description = "동아리 설명", example = "ICT위원회는 동문 네트워크 서비스를 만드는 특별기구이자 동아리입니다.") private String description; - @Pattern( - regexp = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", - message = "id 값은 대시(-)를 포함하고, 32자리의 UUID 형식이어야 합니다." - ) + @Pattern(regexp = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", message = "id 값은 대시(-)를 포함하고, 32자리의 UUID 형식이어야 합니다.") @NotBlank(message = "동아리장 id를 입력해 주세요.") private String leaderId; diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/exception/ConstraintExceptionDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/exception/ConstraintExceptionDto.java index 49fe2eaee..0b9bbaf48 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/exception/ConstraintExceptionDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/exception/ConstraintExceptionDto.java @@ -23,8 +23,8 @@ public class ConstraintExceptionDto { public static ConstraintExceptionDto of(ErrorCode errorCode, String message, ConstraintViolationException exception) { List errors = new ArrayList<>(); - exception.getConstraintViolations().forEach(violation -> - errors.add(violation.getRootBeanClass().getName() + " " + + exception.getConstraintViolations() + .forEach(violation -> errors.add(violation.getRootBeanClass().getName() + " " + violation.getPropertyPath() + ": " + violation.getMessage())); return ConstraintExceptionDto.builder() diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/form/request/create/FormCreateRequestDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/form/request/create/FormCreateRequestDto.java index 129d53302..faa85abe6 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/form/request/create/FormCreateRequestDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/form/request/create/FormCreateRequestDto.java @@ -23,9 +23,7 @@ public class FormCreateRequestDto { @Schema(description = "재학생 답변 허용 여부", example = "ture", requiredMode = Schema.RequiredMode.REQUIRED) private Boolean isAllowedEnrolled; - @Schema(description = "재학생 답변 허용 시, 답변 가능한 등록 완료 학기(상관없음 시 1차부터 9차 이상까지 넣어서 요청)", - example = "[FIRST_SEMESTER,SECOND_SEMESTER,THIRD_SEMESTER,FORTH_SEMESTER,FIFTH_SEMESTER,SIXTH_SEMESTER,SEVENTH_SEMESTER,EIGHTH_SEMESTER,ABOVE_NINTH_SEMESTER]", - requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(description = "재학생 답변 허용 시, 답변 가능한 등록 완료 학기(상관없음 시 1차부터 9차 이상까지 넣어서 요청)", example = "[FIRST_SEMESTER,SECOND_SEMESTER,THIRD_SEMESTER,FORTH_SEMESTER,FIFTH_SEMESTER,SIXTH_SEMESTER,SEVENTH_SEMESTER,EIGHTH_SEMESTER,ABOVE_NINTH_SEMESTER]", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private List enrolledRegisteredSemesterList; @Schema(description = "재학생 답변 허용 시, 학생회비 납부 필요 여부(isAllowedEnrolled가 true일 때 null이면 안 됩니다)", example = "ture", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @@ -35,9 +33,7 @@ public class FormCreateRequestDto { @Schema(description = "휴학생 답변 허용 여부", example = "ture", requiredMode = Schema.RequiredMode.REQUIRED) private Boolean isAllowedLeaveOfAbsence; - @Schema(description = "휴학생 답변 허용 시, 답변 가능한 등록 완료 학기(상관없음 시 1차부터 9차 이상까지 넣어서 요청)", - example = "[FIRST_SEMESTER,SECOND_SEMESTER,THIRD_SEMESTER,FORTH_SEMESTER,FIFTH_SEMESTER,SIXTH_SEMESTER,SEVENTH_SEMESTER,EIGHTH_SEMESTER,ABOVE_NINTH_SEMESTER]", - requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(description = "휴학생 답변 허용 시, 답변 가능한 등록 완료 학기(상관없음 시 1차부터 9차 이상까지 넣어서 요청)", example = "[FIRST_SEMESTER,SECOND_SEMESTER,THIRD_SEMESTER,FORTH_SEMESTER,FIFTH_SEMESTER,SIXTH_SEMESTER,SEVENTH_SEMESTER,EIGHTH_SEMESTER,ABOVE_NINTH_SEMESTER]", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private List leaveOfAbsenceRegisteredSemesterList; @Schema(description = "졸업생 답변 허용 여부", example = "ture", requiredMode = Schema.RequiredMode.REQUIRED) diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/form/response/FormResponseDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/form/response/FormResponseDto.java index 496423bf4..a327038ea 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/form/response/FormResponseDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/form/response/FormResponseDto.java @@ -29,8 +29,7 @@ public class FormResponseDto { @Schema(description = "재학생 답변 허용 여부", example = "true") private Boolean isAllowedEnrolled; - @Schema(description = "재학생 답변 허용 시, 답변 가능한 등록 완료 학기(상관없음 시 1차부터 9차 이상까지)", - example = "[FIRST_SEMESTER,SECOND_SEMESTER ... EIGHTH_SEMESTER,ABOVE_NIGHT_SEMESTER]") + @Schema(description = "재학생 답변 허용 시, 답변 가능한 등록 완료 학기(상관없음 시 1차부터 9차 이상까지)", example = "[FIRST_SEMESTER,SECOND_SEMESTER ... EIGHTH_SEMESTER,ABOVE_NIGHT_SEMESTER]") private List enrolledRegisteredSemesterList; @Schema(description = "재학생 답변 허용 시, 학생회비 납부 필요 여부", example = "ture") @@ -40,8 +39,7 @@ public class FormResponseDto { @Schema(description = "휴학생 답변 허용 여부", example = "ture") private Boolean isAllowedLeaveOfAbsence; - @Schema(description = "휴학생 답변 허용 시, 답변 가능한 등록 완료 학기(상관없음 시 1차부터 9차 이상까지)", - example = "[FIRST_SEMESTER,SECOND_SEMESTER ... EIGHTH_SEMESTER,ABOVE_NIGHT_SEMESTER]") + @Schema(description = "휴학생 답변 허용 시, 답변 가능한 등록 완료 학기(상관없음 시 1차부터 9차 이상까지)", example = "[FIRST_SEMESTER,SECOND_SEMESTER ... EIGHTH_SEMESTER,ABOVE_NIGHT_SEMESTER]") private List leaveOfAbsenceRegisteredSemesterList; @Schema(description = "졸업생 답변 허용 여부", example = "ture") @@ -56,12 +54,12 @@ public static FormResponseDto empty() { .title("") .isClosed(false) .isAllowedEnrolled(false) - .enrolledRegisteredSemesterList(List.of()) // 빈 리스트 - .isNeedCouncilFeePaid(false) // 기본값 false - .isAllowedLeaveOfAbsence(false) // 기본값 false - .leaveOfAbsenceRegisteredSemesterList(List.of()) // 빈 리스트 - .isAllowedGraduation(false) // 기본값 false - .questionResponseDtoList(List.of()) // 빈 리스트 + .enrolledRegisteredSemesterList(List.of()) // 빈 리스트 + .isNeedCouncilFeePaid(false) // 기본값 false + .isAllowedLeaveOfAbsence(false) // 기본값 false + .leaveOfAbsenceRegisteredSemesterList(List.of()) // 빈 리스트 + .isAllowedGraduation(false) // 기본값 false + .questionResponseDtoList(List.of()) // 빈 리스트 .build(); } } diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/homepage/HomePageResponseDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/homepage/HomePageResponseDto.java index cd44fcc9c..5195bd2fc 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/homepage/HomePageResponseDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/homepage/HomePageResponseDto.java @@ -18,8 +18,7 @@ public class HomePageResponseDto { public static HomePageResponseDto of( BoardResponseDto board, - Page posts - ) { + Page posts) { return HomePageResponseDto.builder() .board(board) .posts(posts) diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/locker/LockerLocationResponseDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/locker/LockerLocationResponseDto.java index e7156a0f8..5b9cfb7c3 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/locker/LockerLocationResponseDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/locker/LockerLocationResponseDto.java @@ -18,8 +18,7 @@ public class LockerLocationResponseDto { public static LockerLocationResponseDto of( LockerLocation lockerLocation, Long enableLockerCount, - Long totalLockerCount - ) { + Long totalLockerCount) { return LockerLocationResponseDto.builder() .id(lockerLocation.getId()) .name(lockerLocation.getName()) diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/locker/LockerLocationsResponseDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/locker/LockerLocationsResponseDto.java index 0c4afe421..7a76e0f90 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/locker/LockerLocationsResponseDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/locker/LockerLocationsResponseDto.java @@ -15,8 +15,7 @@ public class LockerLocationsResponseDto { public static LockerLocationsResponseDto of( List lockerLocations, - LockerResponseDto myLocker - ) { + LockerResponseDto myLocker) { return LockerLocationsResponseDto.builder() .lockerLocations(lockerLocations) .myLocker(myLocker) diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/locker/LockerResponseDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/locker/LockerResponseDto.java index 0b022e19b..f03824acd 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/locker/LockerResponseDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/locker/LockerResponseDto.java @@ -37,8 +37,7 @@ public static LockerResponseDto of(Locker locker, User user) { public static LockerResponseDto of( Locker locker, User user, - String locationName - ) { + String locationName) { String location = locationName + " " + locker.getLockerNumber(); return LockerResponseDto.builder() diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/notification/BoardNotificationDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/notification/BoardNotificationDto.java index 7bf803241..b4cb99947 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/notification/BoardNotificationDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/notification/BoardNotificationDto.java @@ -15,8 +15,7 @@ public class BoardNotificationDto { public static BoardNotificationDto of(Board board, Post post) { return BoardNotificationDto.builder() .title(String.format("%s", - board.getName() - )) + board.getName())) .body(String.format("새 게시글 : %s", post.getTitle())) .build(); diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/notification/CeremonyListNotificationDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/notification/CeremonyListNotificationDto.java index f6438ca2c..7fb1edf62 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/notification/CeremonyListNotificationDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/notification/CeremonyListNotificationDto.java @@ -7,9 +7,9 @@ @Builder public class CeremonyListNotificationDto { private String id; - private String writer; // 이름(학번) - private String category; // 경조사 종류 - private String date; // 20xx.0x.0x ~ 20xx.0x.0x + private String writer; // 이름(학번) + private String category; // 경조사 종류 + private String date; // 20xx.0x.0x ~ 20xx.0x.0x private String description; // 설명 - private String createdAt; // 알림 신청일 + private String createdAt; // 알림 신청일 } diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/notification/CommentNotificationDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/notification/CommentNotificationDto.java index 59948ac97..871533ccb 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/notification/CommentNotificationDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/notification/CommentNotificationDto.java @@ -15,8 +15,7 @@ public class CommentNotificationDto { public static CommentNotificationDto of(Comment comment, ChildComment childComment) { return CommentNotificationDto.builder() .title(String.format("%s", - comment.getContent() - )) + comment.getContent())) .body(String.format("새 대댓글 : %s", childComment.getContent())) .build(); diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/notification/NotificationCountResponseDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/notification/NotificationCountResponseDto.java index 2e39ad145..bb6d872fe 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/notification/NotificationCountResponseDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/notification/NotificationCountResponseDto.java @@ -14,4 +14,3 @@ public class NotificationCountResponseDto { @Schema(description = "읽지 않은 알림 개수", example = "1, 2, 3,...") private Integer notificationLogCount; } - diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/notification/PostNotificationDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/notification/PostNotificationDto.java index e052e069a..3eeeacba9 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/notification/PostNotificationDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/notification/PostNotificationDto.java @@ -15,8 +15,7 @@ public class PostNotificationDto { public static PostNotificationDto of(Post post, Comment comment) { return PostNotificationDto.builder() .title(String.format("%s", - post.getTitle() - )) + post.getTitle())) .body(String.format("새 댓글 : %s", comment.getContent())) .build(); diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/post/PostCreateResponseDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/post/PostCreateResponseDto.java index 8fe63f95f..246823423 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/post/PostCreateResponseDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/post/PostCreateResponseDto.java @@ -12,7 +12,3 @@ public class PostCreateResponseDto { private String id; } - - - - diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/user/GraduatedUserCommand.java b/app-main/src/main/java/net/causw/app/main/api/dto/user/GraduatedUserCommand.java index 9bab2253d..aa255ddd3 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/user/GraduatedUserCommand.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/user/GraduatedUserCommand.java @@ -10,6 +10,5 @@ public record GraduatedUserCommand( Integer graduationYear, String nickname, Department department, - String phoneNumber -) { + String phoneNumber) { } diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/user/GraduatedUserRegisterRequestDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/user/GraduatedUserRegisterRequestDto.java index 68d5099f5..199721d51 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/user/GraduatedUserRegisterRequestDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/user/GraduatedUserRegisterRequestDto.java @@ -20,22 +20,19 @@ public record GraduatedUserRegisterRequestDto( @NotNull Integer graduationYear, - @Email - @NotBlank + @Email @NotBlank String email, @NotBlank String password, - @NotBlank - @Pattern(regexp = "^01(?:0|1|[6-9])-(\\d{3}|\\d{4})-\\d{4}$", message = "전화번호 형식에 맞지 않습니다.") + @NotBlank @Pattern(regexp = "^01(?:0|1|[6-9])-(\\d{3}|\\d{4})-\\d{4}$", message = "전화번호 형식에 맞지 않습니다.") String phoneNumber, @NotNull Department department, - String studentId -) { + String studentId) { public GraduatedUserCommand toGraduatedUserCommand() { return new GraduatedUserCommand( this.email, @@ -45,7 +42,6 @@ public GraduatedUserCommand toGraduatedUserCommand() { this.graduationYear, this.nickname, this.department, - this.phoneNumber - ); + this.phoneNumber); } } diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/user/UserCreateRequestDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/user/UserCreateRequestDto.java index f609387dd..deb77bcd0 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/user/UserCreateRequestDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/user/UserCreateRequestDto.java @@ -30,10 +30,7 @@ public class UserCreateRequestDto { private String name; @NotBlank(message = "비밀번호를 입력해 주세요.") - @Pattern( - regexp = "^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[!@#$%^&*()-_?]).{8,20}$", - message = "비밀번호는 8자 이상 20자 이하이며, 영문, 숫자, 특수문자가 각 1개 이상 포함되어야 합니다." - ) + @Pattern(regexp = "^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[!@#$%^&*()-_?]).{8,20}$", message = "비밀번호는 8자 이상 20자 이하이며, 영문, 숫자, 특수문자가 각 1개 이상 포함되어야 합니다.") @Schema(description = "비밀번호", example = "password00!!") private String password; diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/userAcademicRecordApplication/UpdateUserAcademicRecordApplicationRequestDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/userAcademicRecordApplication/UpdateUserAcademicRecordApplicationRequestDto.java index bc8379a86..d565a9452 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/userAcademicRecordApplication/UpdateUserAcademicRecordApplicationRequestDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/userAcademicRecordApplication/UpdateUserAcademicRecordApplicationRequestDto.java @@ -11,10 +11,7 @@ public class UpdateUserAcademicRecordApplicationRequestDto { @Schema(description = "변경 목표 학적 정보 신청 고유 id 값", requiredMode = Schema.RequiredMode.REQUIRED, example = "uuid 형식의 String 값입니다.") - @Pattern( - regexp = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", - message = "id 값은 대시(-)를 포함하고, 32자리의 UUID 형식이어야 합니다." - ) + @Pattern(regexp = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", message = "id 값은 대시(-)를 포함하고, 32자리의 UUID 형식이어야 합니다.") @NotBlank(message = "변경 목표 학적 정보 신청 고유 id 값은 필수 입력 값입니다.") private String applicationId; diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/userBlock/response/CreateBlockByChildCommentResponseDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/userBlock/response/CreateBlockByChildCommentResponseDto.java index 2a66b25af..255b06772 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/userBlock/response/CreateBlockByChildCommentResponseDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/userBlock/response/CreateBlockByChildCommentResponseDto.java @@ -1,6 +1,5 @@ package net.causw.app.main.api.dto.userBlock.response; public record CreateBlockByChildCommentResponseDto( - String message -) { + String message) { } diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/userBlock/response/CreateBlockByCommentResponseDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/userBlock/response/CreateBlockByCommentResponseDto.java index cc1ab9308..cded1c48a 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/userBlock/response/CreateBlockByCommentResponseDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/userBlock/response/CreateBlockByCommentResponseDto.java @@ -1,6 +1,5 @@ package net.causw.app.main.api.dto.userBlock.response; public record CreateBlockByCommentResponseDto( - String message -) { + String message) { } diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/userBlock/response/CreateBlockByPostResponseDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/userBlock/response/CreateBlockByPostResponseDto.java index 0cd0aa341..ca38a6729 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/userBlock/response/CreateBlockByPostResponseDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/userBlock/response/CreateBlockByPostResponseDto.java @@ -1,6 +1,5 @@ package net.causw.app.main.api.dto.userBlock.response; public record CreateBlockByPostResponseDto( - String message -) { + String message) { } diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/userInfo/UserInfoSearchConditionDto.java b/app-main/src/main/java/net/causw/app/main/api/dto/userInfo/UserInfoSearchConditionDto.java index 070508197..1db79ed33 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/userInfo/UserInfoSearchConditionDto.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/userInfo/UserInfoSearchConditionDto.java @@ -15,6 +15,5 @@ public record UserInfoSearchConditionDto( @Schema(description = "입학 년도 검색 구간 상방", example = "2020") Integer admissionYearEnd, @Schema(description = "학적 상태(ENROLLED, LEAVE_OF_ABSENCE, GRADUATED, 그외 등등)", example = "ENROLLED") - List academicStatus -) { + List academicStatus) { } diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/BoardDtoMapper.java b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/BoardDtoMapper.java index b88d31c0f..9a5131805 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/BoardDtoMapper.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/BoardDtoMapper.java @@ -14,11 +14,11 @@ import net.causw.app.main.api.dto.board.BoardResponseDto; import net.causw.app.main.api.dto.board.BoardSubscribeResponseDto; import net.causw.app.main.api.dto.circle.CircleResponseDto; +import net.causw.app.main.api.dto.post.PostContentDto; +import net.causw.app.main.api.dto.user.UserResponseDto; import net.causw.app.main.domain.community.board.entity.Board; import net.causw.app.main.domain.community.board.entity.BoardApply; import net.causw.app.main.domain.community.post.entity.Post; -import net.causw.app.main.api.dto.post.PostContentDto; -import net.causw.app.main.api.dto.user.UserResponseDto; import net.causw.app.main.domain.notification.notification.entity.UserBoardSubscribe; @Mapper(componentModel = "spring") diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/CeremonyDtoMapper.java b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/CeremonyDtoMapper.java index 9e80f9acc..1735fe74e 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/CeremonyDtoMapper.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/CeremonyDtoMapper.java @@ -31,7 +31,7 @@ public interface CeremonyDtoMapper { @Mapping(target = "applicantStudentId", source = "user.studentId") @Mapping(target = "applicantName", source = "user.name") @Mapping(target = "title", source = ".", qualifiedByName = "mapTitle") - @Mapping(target = "isSetAll", ignore = true) // general에서는 숨김 + @Mapping(target = "isSetAll", ignore = true) // general에서는 숨김 @Mapping(target = "targetAdmissionYears", ignore = true) // general에서는 숨김 CeremonyResponseDto toCeremonyResponseDto(Ceremony ceremony); @@ -48,7 +48,7 @@ public interface CeremonyDtoMapper { @Mapping(target = "applicantStudentId", source = "user.studentId") @Mapping(target = "applicantName", source = "user.name") @Mapping(target = "title", source = ".", qualifiedByName = "mapTitle") - @Mapping(target = "isSetAll", source = "ceremony.setAll") // 상세 조회에서는 표시 + @Mapping(target = "isSetAll", source = "ceremony.setAll") // 상세 조회에서는 표시 @Mapping(target = "targetAdmissionYears", source = "targetAdmissionYears") // 상세 조회에서는 표시 CeremonyResponseDto toDetailedCeremonyResponseDto(Ceremony ceremony); diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/CircleDtoMapper.java b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/CircleDtoMapper.java index 4cc7b8d6a..3c1d375b9 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/CircleDtoMapper.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/CircleDtoMapper.java @@ -18,13 +18,13 @@ import net.causw.app.main.api.dto.circle.CirclesResponseDto; import net.causw.app.main.api.dto.circle.ExportCircleMemberToExcelResponseDto; import net.causw.app.main.api.dto.duplicate.DuplicatedCheckResponseDto; +import net.causw.app.main.api.dto.user.UserResponseDto; import net.causw.app.main.api.dto.util.dtoMapper.custom.UuidFileToUrlDtoMapper; +import net.causw.app.main.domain.campus.circle.entity.Circle; +import net.causw.app.main.domain.campus.circle.entity.CircleMember; import net.causw.app.main.domain.community.board.entity.Board; import net.causw.app.main.domain.community.post.entity.Post; import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFee; -import net.causw.app.main.api.dto.user.UserResponseDto; -import net.causw.app.main.domain.campus.circle.entity.Circle; -import net.causw.app.main.domain.campus.circle.entity.CircleMember; import net.causw.app.main.domain.user.account.entity.user.User; // Custom Annotation을 사용하여 중복되는 @Mapping을 줄일 수 있습니다. @@ -32,8 +32,7 @@ @Target({ElementType.METHOD}) @Mapping(target = "leaderId", expression = "java(circle.getLeader().map(User::getId).orElse(null))") @Mapping(target = "leaderName", expression = "java(circle.getLeader().map(User::getName).orElse(null))") -@interface CircleCommonWriterMappings { -} +@interface CircleCommonWriterMappings{} @Mapper(componentModel = "spring") public interface CircleDtoMapper extends UuidFileToUrlDtoMapper { @@ -120,7 +119,6 @@ ExportCircleMemberToExcelResponseDto toExportCircleMemberToExcelResponseDto( UserCouncilFee userCouncilFee, Integer restOfSemester, Boolean isAppliedThisSemester, - Integer appliedSemester - ); + Integer appliedSemester); } diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/CommentDtoMapper.java b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/CommentDtoMapper.java index 281da8aeb..ad20fa268 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/CommentDtoMapper.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/CommentDtoMapper.java @@ -40,8 +40,7 @@ CommentResponseDto toCommentResponseDto( Boolean updatable, Boolean deletable, Boolean isCommentSubscribed, - Boolean isBlocked - ); + Boolean isBlocked); @Mapping(target = "writerName", source = "childComment.writer.name") @Mapping(target = "writerNickname", source = "childComment.writer.nickname") @@ -58,8 +57,7 @@ ChildCommentResponseDto toChildCommentResponseDto( Boolean isOwner, Boolean updatable, Boolean deletable, - Boolean isBlocked - ); + Boolean isBlocked); @Mapping(target = "commentId", source = "comment.id") @Mapping(target = "userId", source = "user.id") diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/FormDtoMapper.java b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/FormDtoMapper.java index b0826607f..e48aace4c 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/FormDtoMapper.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/FormDtoMapper.java @@ -9,6 +9,11 @@ import org.mapstruct.factory.Mappers; import org.springframework.data.domain.Page; +import net.causw.app.main.api.dto.form.response.FormResponseDto; +import net.causw.app.main.api.dto.form.response.OptionResponseDto; +import net.causw.app.main.api.dto.form.response.OptionSummaryResponseDto; +import net.causw.app.main.api.dto.form.response.QuestionResponseDto; +import net.causw.app.main.api.dto.form.response.QuestionSummaryResponseDto; import net.causw.app.main.api.dto.form.response.reply.ReplyPageResponseDto; import net.causw.app.main.api.dto.form.response.reply.ReplyQuestionResponseDto; import net.causw.app.main.api.dto.form.response.reply.ReplyResponseDto; @@ -24,11 +29,6 @@ import net.causw.app.main.domain.community.form.entity.ReplyQuestion; import net.causw.app.main.domain.community.form.enums.RegisteredSemester; import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFee; -import net.causw.app.main.api.dto.form.response.FormResponseDto; -import net.causw.app.main.api.dto.form.response.OptionResponseDto; -import net.causw.app.main.api.dto.form.response.OptionSummaryResponseDto; -import net.causw.app.main.api.dto.form.response.QuestionResponseDto; -import net.causw.app.main.api.dto.form.response.QuestionSummaryResponseDto; import net.causw.app.main.domain.user.account.entity.user.User; @Mapper(componentModel = "spring") diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/PostDtoMapper.java b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/PostDtoMapper.java index 2716f94a0..de83515a4 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/PostDtoMapper.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/PostDtoMapper.java @@ -12,12 +12,6 @@ import org.mapstruct.factory.Mappers; import org.springframework.data.domain.Page; -import net.causw.app.main.api.dto.util.dtoMapper.custom.UuidFileToUrlDtoMapper; -import net.causw.app.main.api.dto.vote.VoteResponseDto; -import net.causw.app.main.domain.asset.file.entity.joinEntity.PostAttachImage; -import net.causw.app.main.domain.community.board.entity.Board; -import net.causw.app.main.domain.community.post.entity.Post; -import net.causw.app.main.domain.community.post.repository.query.PostQueryResult; import net.causw.app.main.api.dto.form.response.FormResponseDto; import net.causw.app.main.api.dto.post.BoardPostsResponseDto; import net.causw.app.main.api.dto.post.PostContentDto; @@ -25,6 +19,12 @@ import net.causw.app.main.api.dto.post.PostResponseDto; import net.causw.app.main.api.dto.post.PostSubscribeResponseDto; import net.causw.app.main.api.dto.post.PostsResponseDto; +import net.causw.app.main.api.dto.util.dtoMapper.custom.UuidFileToUrlDtoMapper; +import net.causw.app.main.api.dto.vote.VoteResponseDto; +import net.causw.app.main.domain.asset.file.entity.joinEntity.PostAttachImage; +import net.causw.app.main.domain.community.board.entity.Board; +import net.causw.app.main.domain.community.post.entity.Post; +import net.causw.app.main.domain.community.post.repository.query.PostQueryResult; import net.causw.app.main.domain.notification.notification.entity.UserPostSubscribe; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.domain.user.account.enums.user.UserState; @@ -36,8 +36,7 @@ @Mapping(target = "writerName", source = "post.writer.name") @Mapping(target = "writerAdmissionYear", source = "post.writer.admissionYear") @Mapping(target = "writerProfileImage", source = "post.writer.profileImage") -@interface CommonPostWriterMappings { -} +@interface CommonPostWriterMappings{} @Mapper(componentModel = "spring") public interface PostDtoMapper extends UuidFileToUrlDtoMapper { @@ -78,8 +77,7 @@ PostsResponseDto toPostsResponseDto(Post post, Long numComment, Long numPostLike @Mapping(target = "postAttachImage", source = "queryResult.postAttachImage") @Mapping(target = "isPostVote", source = "queryResult.isPostVote") @Mapping(target = "isPostForm", source = "queryResult.isPostForm") - @Mapping(target = "displayWriterNickname", - expression = "java(getDisplayWriterNickname(queryResult.hasWriter(), queryResult.writerUserState(), queryResult.isAnonymous(), queryResult.writerNickname()))") + @Mapping(target = "displayWriterNickname", expression = "java(getDisplayWriterNickname(queryResult.hasWriter(), queryResult.writerUserState(), queryResult.isAnonymous(), queryResult.writerNickname()))") PostsResponseDto toPostsResponseDto(PostQueryResult queryResult); default String getDisplayWriterNickname(boolean hasWriter, UserState state, boolean isAnonymous, String nickname) { @@ -131,8 +129,7 @@ PostResponseDto toPostResponseDtoExtended( VoteResponseDto voteResponseDto, Boolean isPostVote, Boolean isPostForm, - Boolean isPostSubscribed - ); + Boolean isPostSubscribed); @Mapping(target = "title", source = "post.title") @Mapping(target = "contentId", source = "post.id") diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/SemesterDtoMapper.java b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/SemesterDtoMapper.java index b6b0f56d8..f10ac4b81 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/SemesterDtoMapper.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/SemesterDtoMapper.java @@ -14,8 +14,7 @@ @Retention(RetentionPolicy.CLASS) @Target({ElementType.METHOD}) -@interface SemesterCommonWriterMappings { -} +@interface SemesterCommonWriterMappings{} @Mapper(componentModel = "spring") public interface SemesterDtoMapper { diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/UserAcademicRecordDtoMapper.java b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/UserAcademicRecordDtoMapper.java index 5717d08ee..690f63eaf 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/UserAcademicRecordDtoMapper.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/UserAcademicRecordDtoMapper.java @@ -27,8 +27,7 @@ @Mapping(target = "userId", source = "user.id") @Mapping(target = "userName", source = "user.name") @Mapping(target = "studentId", source = "user.studentId") -@interface UserCommonWriterMappings { -} +@interface UserCommonWriterMappings{} @Mapper(componentModel = "spring") public interface UserAcademicRecordDtoMapper extends UuidFileToUrlDtoMapper { diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/UserCouncilFeeDtoMapper.java b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/UserCouncilFeeDtoMapper.java index 373436035..8dff25cfd 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/UserCouncilFeeDtoMapper.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/UserCouncilFeeDtoMapper.java @@ -18,8 +18,7 @@ @Retention(RetentionPolicy.CLASS) @Target({ElementType.METHOD}) -@interface UserCouncilFeeWriterMappings { -} +@interface UserCouncilFeeWriterMappings{} @Mapper(componentModel = "spring") public interface UserCouncilFeeDtoMapper { diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/UserDtoMapper.java b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/UserDtoMapper.java index b43bb8bad..68fe2c458 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/UserDtoMapper.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/UserDtoMapper.java @@ -12,25 +12,25 @@ import net.causw.app.main.api.dto.comment.CommentsOfUserResponseDto; import net.causw.app.main.api.dto.duplicate.DuplicatedCheckResponseDto; -import net.causw.app.main.api.dto.user.UserAdmissionsResponseDto; -import net.causw.app.main.api.dto.user.UserFindIdResponseDto; -import net.causw.app.main.api.dto.userInfo.UserCareerDto; -import net.causw.app.main.api.dto.userInfo.UserInfoResponseDto; -import net.causw.app.main.api.dto.userInfo.UserInfoSummaryResponseDto; -import net.causw.app.main.api.dto.util.dtoMapper.custom.UuidFileToUrlDtoMapper; -import net.causw.app.main.domain.community.board.entity.Board; -import net.causw.app.main.domain.community.comment.entity.Comment; -import net.causw.app.main.domain.community.post.entity.Post; import net.causw.app.main.api.dto.post.PostsResponseDto; import net.causw.app.main.api.dto.user.UserAdmissionResponseDto; +import net.causw.app.main.api.dto.user.UserAdmissionsResponseDto; import net.causw.app.main.api.dto.user.UserCommentsResponseDto; import net.causw.app.main.api.dto.user.UserFcmTokenResponseDto; +import net.causw.app.main.api.dto.user.UserFindIdResponseDto; import net.causw.app.main.api.dto.user.UserPostResponseDto; import net.causw.app.main.api.dto.user.UserPostsResponseDto; import net.causw.app.main.api.dto.user.UserPrivilegedResponseDto; import net.causw.app.main.api.dto.user.UserResponseDto; import net.causw.app.main.api.dto.user.UserSignInResponseDto; import net.causw.app.main.api.dto.user.UserSignOutResponseDto; +import net.causw.app.main.api.dto.userInfo.UserCareerDto; +import net.causw.app.main.api.dto.userInfo.UserInfoResponseDto; +import net.causw.app.main.api.dto.userInfo.UserInfoSummaryResponseDto; +import net.causw.app.main.api.dto.util.dtoMapper.custom.UuidFileToUrlDtoMapper; +import net.causw.app.main.domain.community.board.entity.Board; +import net.causw.app.main.domain.community.comment.entity.Comment; +import net.causw.app.main.domain.community.post.entity.Post; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.entity.user.UserAdmission; import net.causw.app.main.domain.user.account.entity.user.UserAdmissionLog; @@ -210,8 +210,8 @@ default List mapUserCareerListToResponseDtoList(List .endYear(career.getEndYear()) .endMonth(career.getEndMonth()) .description(career.getDescription()) - .build() - ).collect(Collectors.toList()); + .build()) + .collect(Collectors.toList()); } @Mapping(target = "id", source = "userInfo.id") @@ -224,7 +224,7 @@ default List mapUserCareerListToResponseDtoList(List @Mapping(target = "department", source = "userInfo.user.department") @Mapping(target = "description", source = "userInfo.description") @Mapping(target = "job", source = "userInfo.job") - // @Mapping(target = "userCareer", source = "userInfo.userCareer", qualifiedByName = "mapUserCareerListToResponseDtoList") + // @Mapping(target = "userCareer", source = "userInfo.userCareer", qualifiedByName = "mapUserCareerListToResponseDtoList") UserInfoSummaryResponseDto toUserInfoSummaryResponseDto(UserInfo userInfo); @Mapping(target = "id", source = "userInfo.id") diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/VoteDtoMapper.java b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/VoteDtoMapper.java index e82c3ac4d..6fe794d7d 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/VoteDtoMapper.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/VoteDtoMapper.java @@ -6,11 +6,11 @@ import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; +import net.causw.app.main.api.dto.user.UserResponseDto; import net.causw.app.main.api.dto.vote.VoteOptionResponseDto; import net.causw.app.main.api.dto.vote.VoteResponseDto; import net.causw.app.main.domain.community.vote.entity.Vote; import net.causw.app.main.domain.community.vote.entity.VoteOption; -import net.causw.app.main.api.dto.user.UserResponseDto; @Mapper(componentModel = "spring") public interface VoteDtoMapper { diff --git a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/custom/UuidFileToUrlDtoMapper.java b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/custom/UuidFileToUrlDtoMapper.java index f91fdde54..f78574559 100644 --- a/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/custom/UuidFileToUrlDtoMapper.java +++ b/app-main/src/main/java/net/causw/app/main/api/dto/util/dtoMapper/custom/UuidFileToUrlDtoMapper.java @@ -20,8 +20,7 @@ default String mapUuidFileToFileUrl(JoinEntity joinEntity) { if (joinEntity == null) { return null; } else { - return joinEntity.getUuidFile() == null ? - null + return joinEntity.getUuidFile() == null ? null : joinEntity.getUuidFile().getFileUrl(); } } diff --git a/app-main/src/main/java/net/causw/app/main/core/aop/LogAspect.java b/app-main/src/main/java/net/causw/app/main/core/aop/LogAspect.java index 5f9346788..2d74791cb 100644 --- a/app-main/src/main/java/net/causw/app/main/core/aop/LogAspect.java +++ b/app-main/src/main/java/net/causw/app/main/core/aop/LogAspect.java @@ -18,8 +18,7 @@ public class LogAspect { // @MeasureTime 애노테이션이 붙은 클래스의 메서드를 대상으로 설정 @Pointcut("@within(net.causw.app.main.core.aop.annotation.MeasureTime)") - private void timer() { - } + private void timer() {} // 메서드 실행 전,후로 시간을 측정하고, 실행된 메서드와 실행시간을 로깅 @Around("timer()") diff --git a/app-main/src/main/java/net/causw/app/main/core/aop/annotation/MeasureTime.java b/app-main/src/main/java/net/causw/app/main/core/aop/annotation/MeasureTime.java index 8160ab5ad..be6a10b4a 100644 --- a/app-main/src/main/java/net/causw/app/main/core/aop/annotation/MeasureTime.java +++ b/app-main/src/main/java/net/causw/app/main/core/aop/annotation/MeasureTime.java @@ -7,5 +7,4 @@ @Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE}) @Retention(RetentionPolicy.RUNTIME) -public @interface MeasureTime { -} \ No newline at end of file +public @interface MeasureTime{} \ No newline at end of file diff --git a/app-main/src/main/java/net/causw/app/main/core/batch/BatchScheduler.java b/app-main/src/main/java/net/causw/app/main/core/batch/BatchScheduler.java index f219d9131..659aac282 100644 --- a/app-main/src/main/java/net/causw/app/main/core/batch/BatchScheduler.java +++ b/app-main/src/main/java/net/causw/app/main/core/batch/BatchScheduler.java @@ -47,7 +47,7 @@ public void scheduleCleanUpJob() { jobLauncher.run(cleanUpUnusedFilesJob, jobParameters); } catch (Exception e) { - log.error("Batch job failed: {}", e.getMessage()); // 예외 로깅 추가 + log.error("Batch job failed: {}", e.getMessage()); // 예외 로깅 추가 throw new InternalServerException(ErrorCode.INTERNAL_SERVER, MessageUtil.BATCH_FAIL + e.getMessage()); } } diff --git a/app-main/src/main/java/net/causw/app/main/core/batch/listener/CheckMeasureStepListener.java b/app-main/src/main/java/net/causw/app/main/core/batch/listener/CheckMeasureStepListener.java index 0f279a949..624ba34f8 100644 --- a/app-main/src/main/java/net/causw/app/main/core/batch/listener/CheckMeasureStepListener.java +++ b/app-main/src/main/java/net/causw/app/main/core/batch/listener/CheckMeasureStepListener.java @@ -27,8 +27,8 @@ public ExitStatus afterStep(StepExecution stepExecution) { long executionTime = endTime - startTime; // 실행 시간과 마지막 pageNum을 ExitStatus에 기록 - String exitDescription = - "Completed Step. Last PageNum: " + dataRow + ", Execution Time: " + executionTime + " ms"; + String exitDescription = "Completed Step. Last PageNum: " + dataRow + ", Execution Time: " + executionTime + + " ms"; stepExecution.setExitStatus(new ExitStatus("COMPLETED", exitDescription)); return ExitStatus.COMPLETED; diff --git a/app-main/src/main/java/net/causw/app/main/core/batch/listener/DeleteFileStepListener.java b/app-main/src/main/java/net/causw/app/main/core/batch/listener/DeleteFileStepListener.java index 757479f71..2797fab78 100644 --- a/app-main/src/main/java/net/causw/app/main/core/batch/listener/DeleteFileStepListener.java +++ b/app-main/src/main/java/net/causw/app/main/core/batch/listener/DeleteFileStepListener.java @@ -10,7 +10,8 @@ public class DeleteFileStepListener implements StepExecutionListener { @Override - public void beforeStep(@NotNull StepExecution stepExecution) { + public void beforeStep(@NotNull + StepExecution stepExecution) { // Step 실행 전 로직: Step 시작 시간 기록 stepExecution.getExecutionContext().putLong("startTime", System.currentTimeMillis()); } @@ -26,8 +27,8 @@ public ExitStatus afterStep(StepExecution stepExecution) { long executionTime = endTime - startTime; // Exit 메시지에 삭제된 파일 수 기록 - String exitDescription = - "Deleted " + deletedFileCount + " unused files. Execution Time: " + executionTime + " ms"; + String exitDescription = "Deleted " + deletedFileCount + " unused files. Execution Time: " + executionTime + + " ms"; stepExecution.setExitStatus(new ExitStatus("COMPLETED", exitDescription)); return stepExecution.getExitStatus(); } diff --git a/app-main/src/main/java/net/causw/app/main/core/batch/listener/DeleteUnusedFileJobCompletionNotificationListener.java b/app-main/src/main/java/net/causw/app/main/core/batch/listener/DeleteUnusedFileJobCompletionNotificationListener.java index aef0cecf5..baf980c30 100644 --- a/app-main/src/main/java/net/causw/app/main/core/batch/listener/DeleteUnusedFileJobCompletionNotificationListener.java +++ b/app-main/src/main/java/net/causw/app/main/core/batch/listener/DeleteUnusedFileJobCompletionNotificationListener.java @@ -10,7 +10,8 @@ public class DeleteUnusedFileJobCompletionNotificationListener implements JobExecutionListener { @Override - public void beforeJob(@NotNull JobExecution jobExecution) { + public void beforeJob(@NotNull + JobExecution jobExecution) { // Step 실행 전 로직: Step 시작 시간 기록 jobExecution.getExecutionContext().putLong("startTime", System.currentTimeMillis()); } diff --git a/app-main/src/main/java/net/causw/app/main/core/config/async/AsyncConfig.java b/app-main/src/main/java/net/causw/app/main/core/config/async/AsyncConfig.java index 05e5a0d36..923d5dcb5 100644 --- a/app-main/src/main/java/net/causw/app/main/core/config/async/AsyncConfig.java +++ b/app-main/src/main/java/net/causw/app/main/core/config/async/AsyncConfig.java @@ -14,9 +14,9 @@ public class AsyncConfig { @Bean(name = "asyncExecutor") public Executor asyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(5); // 기본 스레드 수 - executor.setMaxPoolSize(20); // 최대 스레드 수 - executor.setQueueCapacity(100); // 큐에 쌓이는 작업 수 + executor.setCorePoolSize(5); // 기본 스레드 수 + executor.setMaxPoolSize(20); // 최대 스레드 수 + executor.setQueueCapacity(100); // 큐에 쌓이는 작업 수 executor.setThreadNamePrefix("Async-"); // 로그 확인용 쓰레드 이름 접두사 executor.initialize(); return executor; diff --git a/app-main/src/main/java/net/causw/app/main/core/config/batch/CleanUnusedUuidFilesBatchConfig.java b/app-main/src/main/java/net/causw/app/main/core/config/batch/CleanUnusedUuidFilesBatchConfig.java index 4b009d02b..b66dae599 100644 --- a/app-main/src/main/java/net/causw/app/main/core/config/batch/CleanUnusedUuidFilesBatchConfig.java +++ b/app-main/src/main/java/net/causw/app/main/core/config/batch/CleanUnusedUuidFilesBatchConfig.java @@ -47,17 +47,26 @@ public RetryTemplate retryTemplate() { @Bean public Job cleanUpUnusedFilesJob(JobRepository jobRepository, DeleteUnusedFileJobCompletionNotificationListener deleteUnusedFileJobCompletionNotificationListener, - @Qualifier("initIsUsedUuidFileIntegrationStep") Step initIsUsedUuidFileIntegrationStep, - @Qualifier("checkIsUsedWithCalendarAttachImageIntegrationStep") Step checkIsUsedWithCalendarAttachImageIntegrationStep, - @Qualifier("checkIsUsedWithCircleMainImageIntegrationStep") Step checkIsUsedWithCircleMainImageIntegrationStep, - @Qualifier("checkIsUsedWithEventAttachImageIntegrationStep") Step checkIsUsedWithEventAttachImageIntegrationStep, - @Qualifier("checkIsUsedWithPostAttachImageIntegrationStep") Step checkIsUsedWithPostAttachImageIntegrationStep, - @Qualifier("checkIsUsedWithUserAcademicRecordApplicationAttachImageIntegrationStep") Step checkIsUsedWithUserAcademicRecordApplicationAttachImageIntegrationStep, - @Qualifier("checkIsUsedWithUserAdmissionAttachImageIntegrationStep") Step checkIsUsedWithUserAdmissionAttachImageIntegrationStep, - @Qualifier("checkIsUsedWithUserAdmissionLogAttachImageIntegrationStep") Step checkIsUsedWithUserAdmissionLogAttachImageIntegrationStep, - @Qualifier("checkIsUsedWithUserProfileImageIntegrationStep") Step checkIsUsedWithUserProfileImageIntegrationStep, - @Qualifier("deleteFileNotUsedStep") Step deleteFileNotUsedStep - ) { + @Qualifier("initIsUsedUuidFileIntegrationStep") + Step initIsUsedUuidFileIntegrationStep, + @Qualifier("checkIsUsedWithCalendarAttachImageIntegrationStep") + Step checkIsUsedWithCalendarAttachImageIntegrationStep, + @Qualifier("checkIsUsedWithCircleMainImageIntegrationStep") + Step checkIsUsedWithCircleMainImageIntegrationStep, + @Qualifier("checkIsUsedWithEventAttachImageIntegrationStep") + Step checkIsUsedWithEventAttachImageIntegrationStep, + @Qualifier("checkIsUsedWithPostAttachImageIntegrationStep") + Step checkIsUsedWithPostAttachImageIntegrationStep, + @Qualifier("checkIsUsedWithUserAcademicRecordApplicationAttachImageIntegrationStep") + Step checkIsUsedWithUserAcademicRecordApplicationAttachImageIntegrationStep, + @Qualifier("checkIsUsedWithUserAdmissionAttachImageIntegrationStep") + Step checkIsUsedWithUserAdmissionAttachImageIntegrationStep, + @Qualifier("checkIsUsedWithUserAdmissionLogAttachImageIntegrationStep") + Step checkIsUsedWithUserAdmissionLogAttachImageIntegrationStep, + @Qualifier("checkIsUsedWithUserProfileImageIntegrationStep") + Step checkIsUsedWithUserProfileImageIntegrationStep, + @Qualifier("deleteFileNotUsedStep") + Step deleteFileNotUsedStep) { return new JobBuilder("cleanUpUnusedFilesJob", jobRepository) .listener(deleteUnusedFileJobCompletionNotificationListener) .start(initIsUsedUuidFileIntegrationStep) diff --git a/app-main/src/main/java/net/causw/app/main/core/config/persistence/JpaConfig.java b/app-main/src/main/java/net/causw/app/main/core/config/persistence/JpaConfig.java index 28203c5f8..f24533365 100644 --- a/app-main/src/main/java/net/causw/app/main/core/config/persistence/JpaConfig.java +++ b/app-main/src/main/java/net/causw/app/main/core/config/persistence/JpaConfig.java @@ -5,5 +5,4 @@ @Configuration @EnableJpaAuditing -public class JpaConfig { -} +public class JpaConfig {} diff --git a/app-main/src/main/java/net/causw/app/main/core/config/scheduling/SchedulingConfig.java b/app-main/src/main/java/net/causw/app/main/core/config/scheduling/SchedulingConfig.java index b49dea662..ffed87d73 100644 --- a/app-main/src/main/java/net/causw/app/main/core/config/scheduling/SchedulingConfig.java +++ b/app-main/src/main/java/net/causw/app/main/core/config/scheduling/SchedulingConfig.java @@ -5,5 +5,4 @@ @Configuration @EnableScheduling -public class SchedulingConfig { -} +public class SchedulingConfig {} diff --git a/app-main/src/main/java/net/causw/app/main/core/datasourceProxy/ApiQueryCountListener.java b/app-main/src/main/java/net/causw/app/main/core/datasourceProxy/ApiQueryCountListener.java index dcf90295d..b3b5b3d87 100644 --- a/app-main/src/main/java/net/causw/app/main/core/datasourceProxy/ApiQueryCountListener.java +++ b/app-main/src/main/java/net/causw/app/main/core/datasourceProxy/ApiQueryCountListener.java @@ -2,43 +2,44 @@ import java.util.List; import java.util.stream.Collectors; + +import org.springframework.stereotype.Component; + import net.ttddyy.dsproxy.ExecutionInfo; import net.ttddyy.dsproxy.QueryInfo; import net.ttddyy.dsproxy.listener.QueryExecutionListener; import net.ttddyy.dsproxy.proxy.ParameterSetOperation; -import org.springframework.stereotype.Component; @Component public class ApiQueryCountListener implements QueryExecutionListener { - @Override - public void afterQuery(ExecutionInfo execInfo, List queryInfoList) { - if (queryInfoList.isEmpty()) { - return; - } - - String query = queryInfoList.stream() - .map(QueryInfo::getQuery) - .collect(Collectors.joining(";\n")); - - List params = queryInfoList.stream() - .flatMap(info -> extractParams(info).stream()) - .collect(Collectors.toList()); - - QueryContext.addQuery(new QueryContext.QueryInfo( - query, - execInfo.getElapsedTime(), - params - )); - } - - @Override - public void beforeQuery(ExecutionInfo execInfo, List queryInfoList) {} - - private List extractParams(QueryInfo queryInfo) { - return queryInfo.getParametersList().stream() - .flatMap(params -> params.stream()) - .map(param -> ((ParameterSetOperation) param).getArgs()[1]) - .collect(Collectors.toList()); - } + @Override + public void afterQuery(ExecutionInfo execInfo, List queryInfoList) { + if (queryInfoList.isEmpty()) { + return; + } + + String query = queryInfoList.stream() + .map(QueryInfo::getQuery) + .collect(Collectors.joining(";\n")); + + List params = queryInfoList.stream() + .flatMap(info -> extractParams(info).stream()) + .collect(Collectors.toList()); + + QueryContext.addQuery(new QueryContext.QueryInfo( + query, + execInfo.getElapsedTime(), + params)); + } + + @Override + public void beforeQuery(ExecutionInfo execInfo, List queryInfoList) {} + + private List extractParams(QueryInfo queryInfo) { + return queryInfo.getParametersList().stream() + .flatMap(params -> params.stream()) + .map(param -> ((ParameterSetOperation)param).getArgs()[1]) + .collect(Collectors.toList()); + } } diff --git a/app-main/src/main/java/net/causw/app/main/core/datasourceProxy/ApiQueryLoggingAspect.java b/app-main/src/main/java/net/causw/app/main/core/datasourceProxy/ApiQueryLoggingAspect.java index 418bc5e8f..d067d66c8 100644 --- a/app-main/src/main/java/net/causw/app/main/core/datasourceProxy/ApiQueryLoggingAspect.java +++ b/app-main/src/main/java/net/causw/app/main/core/datasourceProxy/ApiQueryLoggingAspect.java @@ -1,9 +1,7 @@ package net.causw.app.main.core.datasourceProxy; -import jakarta.servlet.http.HttpServletRequest; import java.util.List; -import lombok.extern.slf4j.Slf4j; -import net.causw.app.main.core.datasourceProxy.QueryContext.QueryInfo; + import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; @@ -11,62 +9,66 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; +import net.causw.app.main.core.datasourceProxy.QueryContext.QueryInfo; + +import jakarta.servlet.http.HttpServletRequest; +import lombok.extern.slf4j.Slf4j; + @Aspect @Component @Slf4j public class ApiQueryLoggingAspect { - @Around("@annotation(org.springframework.web.bind.annotation.GetMapping) || " + - "@annotation(org.springframework.web.bind.annotation.PostMapping) || " + - "@annotation(org.springframework.web.bind.annotation.PutMapping) || " + - "@annotation(org.springframework.web.bind.annotation.DeleteMapping)") - public Object logApiQueries(ProceedingJoinPoint joinPoint) throws Throwable { - QueryContext.clear(); - long startTime = System.currentTimeMillis(); + @Around("@annotation(org.springframework.web.bind.annotation.GetMapping) || " + + "@annotation(org.springframework.web.bind.annotation.PostMapping) || " + + "@annotation(org.springframework.web.bind.annotation.PutMapping) || " + + "@annotation(org.springframework.web.bind.annotation.DeleteMapping)") + public Object logApiQueries(ProceedingJoinPoint joinPoint) throws Throwable { + QueryContext.clear(); + long startTime = System.currentTimeMillis(); - ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); - String method = ""; - String path = ""; - if (attributes != null) { - HttpServletRequest request = attributes.getRequest(); - method = request.getMethod(); - path = request.getRequestURI(); - } + ServletRequestAttributes attributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes(); + String method = ""; + String path = ""; + if (attributes != null) { + HttpServletRequest request = attributes.getRequest(); + method = request.getMethod(); + path = request.getRequestURI(); + } - try { - Object result = joinPoint.proceed(); - return result; - } finally { - long totalTime = System.currentTimeMillis() - startTime; - List queries = QueryContext.getQueries(); - long totalQueryTime = queries.stream() - .mapToLong(QueryContext.QueryInfo::getExecutionTime) - .sum(); + try { + Object result = joinPoint.proceed(); + return result; + } finally { + long totalTime = System.currentTimeMillis() - startTime; + List queries = QueryContext.getQueries(); + long totalQueryTime = queries.stream() + .mapToLong(QueryContext.QueryInfo::getExecutionTime) + .sum(); - log.info("=== API Performance : {} {} ===", method, path); - log.info("Total: {}ms | Query: {}ms | Overhead: {}ms | Query Count : {}", - totalTime, - totalQueryTime, - totalTime-totalQueryTime, - queries.size() - ); + log.info("=== API Performance : {} {} ===", method, path); + log.info("Total: {}ms | Query: {}ms | Overhead: {}ms | Query Count : {}", + totalTime, + totalQueryTime, + totalTime - totalQueryTime, + queries.size()); - if(totalTime > 1000){ - log.warn("Slow API Detected: {} {} | Time: {}", method, path, totalTime); - } + if (totalTime > 1000) { + log.warn("Slow API Detected: {} {} | Time: {}", method, path, totalTime); + } - if(queries.size()>10){ // TODO: 하드코딩 제거 필요 - log.warn("Too Many Queries: {} {} | Count: {}", method, path, queries.size()); - } + if (queries.size() > 10) { // TODO: 하드코딩 제거 필요 + log.warn("Too Many Queries: {} {} | Count: {}", method, path, queries.size()); + } - // 쿼리별 상세 정보 (선택적) - for (int i = 0; i < queries.size(); i++) { - QueryContext.QueryInfo q = queries.get(i); - log.debug("Query Detail #{}: {}ms - {}", - i + 1, q.getExecutionTime(), q.getQuery()); - } + // 쿼리별 상세 정보 (선택적) + for (int i = 0; i < queries.size(); i++) { + QueryContext.QueryInfo q = queries.get(i); + log.debug("Query Detail #{}: {}ms - {}", + i + 1, q.getExecutionTime(), q.getQuery()); + } - QueryContext.clear(); - } - } + QueryContext.clear(); + } + } } diff --git a/app-main/src/main/java/net/causw/app/main/core/datasourceProxy/DatasourceProxyConfig.java b/app-main/src/main/java/net/causw/app/main/core/datasourceProxy/DatasourceProxyConfig.java index 23e1938f8..d5e0475ca 100644 --- a/app-main/src/main/java/net/causw/app/main/core/datasourceProxy/DatasourceProxyConfig.java +++ b/app-main/src/main/java/net/causw/app/main/core/datasourceProxy/DatasourceProxyConfig.java @@ -1,29 +1,29 @@ package net.causw.app.main.core.datasourceProxy; -import com.zaxxer.hikari.HikariDataSource; import javax.sql.DataSource; -import net.ttddyy.dsproxy.listener.QueryExecutionListener; -import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; + import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; +import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; + +import com.zaxxer.hikari.HikariDataSource; + @Configuration public class DatasourceProxyConfig { - @Bean - @Primary - // 기본 HikaridataSource를 Proxy로 감싸서 Datasource 생성 - public DataSource dataSource(DataSourceProperties properties, ApiQueryCountListener listener) { - HikariDataSource hikari = properties.initializeDataSourceBuilder() - .type(HikariDataSource.class) - .build(); + @Bean + @Primary + // 기본 HikaridataSource를 Proxy로 감싸서 Datasource 생성 + public DataSource dataSource(DataSourceProperties properties, ApiQueryCountListener listener) { + HikariDataSource hikari = properties.initializeDataSourceBuilder() + .type(HikariDataSource.class) + .build(); - return ProxyDataSourceBuilder.create(hikari) - .listener(listener) - .build(); - } + return ProxyDataSourceBuilder.create(hikari) + .listener(listener) + .build(); + } } diff --git a/app-main/src/main/java/net/causw/app/main/core/datasourceProxy/QueryContext.java b/app-main/src/main/java/net/causw/app/main/core/datasourceProxy/QueryContext.java index 8228df3e7..b4fe23d6b 100644 --- a/app-main/src/main/java/net/causw/app/main/core/datasourceProxy/QueryContext.java +++ b/app-main/src/main/java/net/causw/app/main/core/datasourceProxy/QueryContext.java @@ -2,34 +2,33 @@ import java.util.ArrayList; import java.util.List; + import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import org.springframework.stereotype.Component; @NoArgsConstructor(access = AccessLevel.PRIVATE) public class QueryContext { - private static final ThreadLocal> queries = - ThreadLocal.withInitial(ArrayList::new); + private static final ThreadLocal> queries = ThreadLocal.withInitial(ArrayList::new); - public static void addQuery(QueryInfo queryInfo) { - queries.get().add(queryInfo); - } + public static void addQuery(QueryInfo queryInfo) { + queries.get().add(queryInfo); + } - public static List getQueries() { - return new ArrayList<>(queries.get()); - } + public static List getQueries() { + return new ArrayList<>(queries.get()); + } - public static void clear() { - queries.remove(); - } + public static void clear() { + queries.remove(); + } - @Data - @AllArgsConstructor - public static class QueryInfo { - private String query; - private long executionTime; - private List params; - } + @Data + @AllArgsConstructor + public static class QueryInfo { + private String query; + private long executionTime; + private List params; + } } diff --git a/app-main/src/main/java/net/causw/app/main/core/favicon/FaviconController.java b/app-main/src/main/java/net/causw/app/main/core/favicon/FaviconController.java index 9a7da9a69..f58a3afc5 100644 --- a/app-main/src/main/java/net/causw/app/main/core/favicon/FaviconController.java +++ b/app-main/src/main/java/net/causw/app/main/core/favicon/FaviconController.java @@ -8,6 +8,5 @@ class FaviconController { @GetMapping("/favicon.ico") - void returnNoFavicon() { - } + void returnNoFavicon() {} } diff --git a/app-main/src/main/java/net/causw/app/main/core/security/CustomAuthenticationEntryPoint.java b/app-main/src/main/java/net/causw/app/main/core/security/CustomAuthenticationEntryPoint.java index 34637d767..042a203f6 100644 --- a/app-main/src/main/java/net/causw/app/main/core/security/CustomAuthenticationEntryPoint.java +++ b/app-main/src/main/java/net/causw/app/main/core/security/CustomAuthenticationEntryPoint.java @@ -40,8 +40,7 @@ public void commence(HttpServletRequest request, HttpServletResponse response, private void setResponse( HttpServletResponse response, ErrorCode errorCode, - String message - ) throws IOException { + String message) throws IOException { response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); response.setContentType("application/json;charset=UTF-8"); diff --git a/app-main/src/main/java/net/causw/app/main/core/security/JwtAuthenticationFilter.java b/app-main/src/main/java/net/causw/app/main/core/security/JwtAuthenticationFilter.java index ce587286c..041fe16ee 100644 --- a/app-main/src/main/java/net/causw/app/main/core/security/JwtAuthenticationFilter.java +++ b/app-main/src/main/java/net/causw/app/main/core/security/JwtAuthenticationFilter.java @@ -24,9 +24,12 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter { private final JwtTokenProvider jwtTokenProvider; @Override - protected void doFilterInternal(@NotNull HttpServletRequest request, - @NotNull HttpServletResponse response, - @NotNull FilterChain chain) throws ServletException, IOException { + protected void doFilterInternal(@NotNull + HttpServletRequest request, + @NotNull + HttpServletResponse response, + @NotNull + FilterChain chain) throws ServletException, IOException { String token = jwtTokenProvider.resolveToken(request); if (StringUtils.hasText(token)) { diff --git a/app-main/src/main/java/net/causw/app/main/core/security/JwtTokenProvider.java b/app-main/src/main/java/net/causw/app/main/core/security/JwtTokenProvider.java index cb118d2b1..7629baaa5 100644 --- a/app-main/src/main/java/net/causw/app/main/core/security/JwtTokenProvider.java +++ b/app-main/src/main/java/net/causw/app/main/core/security/JwtTokenProvider.java @@ -11,9 +11,9 @@ import org.springframework.security.core.userdetails.UserDetails; import org.springframework.stereotype.Component; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetailsService; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.domain.user.account.enums.user.UserState; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetailsService; import net.causw.app.main.shared.infra.redis.RedisUtils; import net.causw.global.constant.MessageUtil; import net.causw.global.constant.StaticValue; diff --git a/app-main/src/main/java/net/causw/app/main/core/security/RequestAuthorizationBinder.java b/app-main/src/main/java/net/causw/app/main/core/security/RequestAuthorizationBinder.java index e33179661..2f99a9997 100644 --- a/app-main/src/main/java/net/causw/app/main/core/security/RequestAuthorizationBinder.java +++ b/app-main/src/main/java/net/causw/app/main/core/security/RequestAuthorizationBinder.java @@ -74,8 +74,7 @@ public static RequestAuthorizationBinder with( public RequestAuthorizationBinder bind( String name, AuthorizationManager manager, - String... patterns - ) { + String... patterns) { List matchers = Arrays.stream(patterns) .map(pattern -> { String antPath = PatternUtil.toAntPath(pattern); @@ -83,8 +82,7 @@ public RequestAuthorizationBinder bind( return new RequestAuthorizationBinder.DescriptiveRequestMatcher( new AntPathRequestMatcher(antPath), antPath, - null - ); + null); }) .collect(Collectors.toList()); @@ -104,8 +102,7 @@ public RequestAuthorizationBinder bind( String name, AuthorizationManager manager, HttpMethod method, - String... patterns - ) { + String... patterns) { List matchers = Arrays.stream(patterns) .map(pattern -> { String antPath = PatternUtil.toAntPath(pattern); @@ -113,8 +110,7 @@ public RequestAuthorizationBinder bind( return new RequestAuthorizationBinder.DescriptiveRequestMatcher( new AntPathRequestMatcher(antPath, method.name()), antPath, - method - ); + method); }) .collect(Collectors.toList()); @@ -132,14 +128,12 @@ public RequestAuthorizationBinder bind( public RequestAuthorizationBinder bind( String name, AuthorizationManager manager, - SecurityEndpoints.SecurityEndpoint... endpoints - ) { + SecurityEndpoints.SecurityEndpoint... endpoints) { List matchers = Stream.of(endpoints) .map(e -> new RequestAuthorizationBinder.DescriptiveRequestMatcher( e.toRequestMatcher(), PatternUtil.toAntPath(e.pattern()), - e.httpMethod() - )) + e.httpMethod())) .collect(Collectors.toList()); return bind(new RequestAuthorization(name, manager, matchers)); @@ -235,8 +229,7 @@ private List flattenRequestAuthorization(List new RequestAuthorization( auth.name, auth.authorizationManager(), - Collections.singletonList(matcher) - ))) + Collections.singletonList(matcher)))) .collect(Collectors.toCollection(ArrayList::new)); } @@ -263,8 +256,7 @@ private List groupRequestAuthorization(List authorizationManager, - List matchers - ) { + List matchers) { } /** @@ -312,7 +303,6 @@ public record RequestAuthorization( private record DescriptiveRequestMatcher( RequestMatcher matcher, String pattern, - HttpMethod httpMethod - ) { + HttpMethod httpMethod) { } } diff --git a/app-main/src/main/java/net/causw/app/main/core/security/SecurityEndpoints.java b/app-main/src/main/java/net/causw/app/main/core/security/SecurityEndpoints.java index 5c500fde9..56817ccec 100644 --- a/app-main/src/main/java/net/causw/app/main/core/security/SecurityEndpoints.java +++ b/app-main/src/main/java/net/causw/app/main/core/security/SecurityEndpoints.java @@ -1,7 +1,9 @@ package net.causw.app.main.core.security; -import static net.causw.app.main.core.security.SecurityEndpoints.SecurityEndpoint.*; -import static org.springframework.http.HttpMethod.*; +import static net.causw.app.main.core.security.SecurityEndpoints.SecurityEndpoint.of; +import static org.springframework.http.HttpMethod.GET; +import static org.springframework.http.HttpMethod.POST; +import static org.springframework.http.HttpMethod.PUT; import org.springframework.http.HttpMethod; import org.springframework.security.web.util.matcher.AntPathRequestMatcher; @@ -108,8 +110,7 @@ public class SecurityEndpoints { */ public record SecurityEndpoint( String pattern, - HttpMethod httpMethod - ) { + HttpMethod httpMethod) { public static SecurityEndpoint of(String pattern) { return new SecurityEndpoint(pattern, null); } diff --git a/app-main/src/main/java/net/causw/app/main/core/security/WebSecurityConfig.java b/app-main/src/main/java/net/causw/app/main/core/security/WebSecurityConfig.java index c92cfa84f..0f6fbf372 100644 --- a/app-main/src/main/java/net/causw/app/main/core/security/WebSecurityConfig.java +++ b/app-main/src/main/java/net/causw/app/main/core/security/WebSecurityConfig.java @@ -47,20 +47,19 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .sessionManagement( sessionManagement -> sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .authorizeHttpRequests(registry -> { - registry.requestMatchers(CorsUtils::isPreFlightRequest).permitAll(); - RequestAuthorizationBinder.with(registry) - .bind("Public", authorizationManager.permitAll(), SecurityEndpoints.PUBLIC_ENDPOINTS) - .bind("Authenticated", authorizationManager.authenticated(), - SecurityEndpoints.AUTHENTICATED_ENDPOINTS) - .bind("Active", authorizationManager.isActiveUser(), SecurityEndpoints.ACTIVE_USER_ENDPOINTS) - .bind("Certified", authorizationManager.isCertifiedUser(), - SecurityEndpoints.CERTIFIED_USER_ENDPOINTS) - .sort(true) - .log(true) - .apply(); - registry.anyRequest().authenticated(); - } - ) + registry.requestMatchers(CorsUtils::isPreFlightRequest).permitAll(); + RequestAuthorizationBinder.with(registry) + .bind("Public", authorizationManager.permitAll(), SecurityEndpoints.PUBLIC_ENDPOINTS) + .bind("Authenticated", authorizationManager.authenticated(), + SecurityEndpoints.AUTHENTICATED_ENDPOINTS) + .bind("Active", authorizationManager.isActiveUser(), SecurityEndpoints.ACTIVE_USER_ENDPOINTS) + .bind("Certified", authorizationManager.isCertifiedUser(), + SecurityEndpoints.CERTIFIED_USER_ENDPOINTS) + .sort(true) + .log(true) + .apply(); + registry.anyRequest().authenticated(); + }) .exceptionHandling(exceptionHandling -> exceptionHandling .authenticationEntryPoint(customAuthenticationEntryPoint)) .addFilterBefore(new JwtAuthenticationFilter(jwtTokenProvider), UsernamePasswordAuthenticationFilter.class); diff --git a/app-main/src/main/java/net/causw/app/main/core/security/WebSecurityConfigProd.java b/app-main/src/main/java/net/causw/app/main/core/security/WebSecurityConfigProd.java index e876857e7..e6368dc4e 100644 --- a/app-main/src/main/java/net/causw/app/main/core/security/WebSecurityConfigProd.java +++ b/app-main/src/main/java/net/causw/app/main/core/security/WebSecurityConfigProd.java @@ -69,10 +69,9 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti "/api/v1/users/user-id/find", "/swagger-ui/**", "/v3/api-docs/**", - "/actuator/**" - ).permitAll() - .anyRequest().authenticated() - ) + "/actuator/**") + .permitAll() + .anyRequest().authenticated()) .cors(cors -> cors.configurationSource(corsConfigurationSource())) .addFilterBefore(new JwtAuthenticationFilter(this.jwtTokenProvider), UsernamePasswordAuthenticationFilter.class); diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/CalendarAttachImage.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/CalendarAttachImage.java index 8c545681d..c0cdd768a 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/CalendarAttachImage.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/CalendarAttachImage.java @@ -21,11 +21,10 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) @Entity -@Table(name = "tb_calendar_attach_image_uuid_file", - indexes = { - @Index(name = "idx_calendar_attach_image_calendar_id", columnList = "calendar_id"), - @Index(name = "idx_calendar_attach_image_uuid_file_id", columnList = "uuid_file_id") - }) +@Table(name = "tb_calendar_attach_image_uuid_file", indexes = { + @Index(name = "idx_calendar_attach_image_calendar_id", columnList = "calendar_id"), + @Index(name = "idx_calendar_attach_image_uuid_file_id", columnList = "uuid_file_id") +}) public class CalendarAttachImage extends JoinEntity { @Getter diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/CeremonyAttachImage.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/CeremonyAttachImage.java index 01fa09ee7..77b76257a 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/CeremonyAttachImage.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/CeremonyAttachImage.java @@ -22,11 +22,10 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) @Entity -@Table(name = "tb_ceremony_attach_image_uuid_file", - indexes = { - @Index(name = "idx_ceremony_attach_image_ceremony_id", columnList = "ceremony_id"), - @Index(name = "idx_ceremony_attach_image_uuid_file_id", columnList = "uuid_file_id") - }) +@Table(name = "tb_ceremony_attach_image_uuid_file", indexes = { + @Index(name = "idx_ceremony_attach_image_ceremony_id", columnList = "ceremony_id"), + @Index(name = "idx_ceremony_attach_image_uuid_file_id", columnList = "uuid_file_id") +}) public class CeremonyAttachImage extends JoinEntity { @Getter @Setter(AccessLevel.PUBLIC) @@ -45,4 +44,3 @@ public static CeremonyAttachImage of(Ceremony ceremony, UuidFile uuidFile) { .build(); } } - diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/CircleMainImage.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/CircleMainImage.java index bcc33dae3..93f6501bc 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/CircleMainImage.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/CircleMainImage.java @@ -21,11 +21,10 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) @Entity -@Table(name = "tb_circle_main_image_uuid_file", - indexes = { - @Index(name = "idx_circle_main_image_circle_id", columnList = "circle_id"), - @Index(name = "idx_circle_main_image_uuid_file_id", columnList = "uuid_file_id") - }) +@Table(name = "tb_circle_main_image_uuid_file", indexes = { + @Index(name = "idx_circle_main_image_circle_id", columnList = "circle_id"), + @Index(name = "idx_circle_main_image_uuid_file_id", columnList = "uuid_file_id") +}) public class CircleMainImage extends JoinEntity { @Getter diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/EventAttachImage.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/EventAttachImage.java index c73ff3842..c815196ab 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/EventAttachImage.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/EventAttachImage.java @@ -21,11 +21,10 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) @Entity -@Table(name = "tb_event_attach_image_uuid_file", - indexes = { - @Index(name = "idx_event_attach_image_event_id", columnList = "event_id"), - @Index(name = "idx_event_attach_image_uuid_file_id", columnList = "uuid_file_id") - }) +@Table(name = "tb_event_attach_image_uuid_file", indexes = { + @Index(name = "idx_event_attach_image_event_id", columnList = "event_id"), + @Index(name = "idx_event_attach_image_uuid_file_id", columnList = "uuid_file_id") +}) public class EventAttachImage extends JoinEntity { @Getter diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/PostAttachImage.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/PostAttachImage.java index c534af85e..abe5b7099 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/PostAttachImage.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/PostAttachImage.java @@ -22,11 +22,10 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) @Entity -@Table(name = "tb_post_attach_image_uuid_file", - indexes = { - @Index(name = "idx_post_attach_image_post_id", columnList = "post_id"), - @Index(name = "idx_post_attach_image_uuid_file_id", columnList = "uuid_file_id") - }) +@Table(name = "tb_post_attach_image_uuid_file", indexes = { + @Index(name = "idx_post_attach_image_post_id", columnList = "post_id"), + @Index(name = "idx_post_attach_image_uuid_file_id", columnList = "uuid_file_id") +}) public class PostAttachImage extends JoinEntity { @Getter diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserAcademicRecordApplicationAttachImage.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserAcademicRecordApplicationAttachImage.java index c3b8b8301..99b1a8b0d 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserAcademicRecordApplicationAttachImage.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserAcademicRecordApplicationAttachImage.java @@ -21,11 +21,10 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) @Entity -@Table(name = "tb_user_academic_record_application_attach_image_uuid_file", - indexes = { - @Index(name = "idx_user_academic_record_application_attach_image_application_id", columnList = "user_academic_record_application_id"), - @Index(name = "idx_user_academic_record_application_attach_image_uuid_file_id", columnList = "uuid_file_id") - }) +@Table(name = "tb_user_academic_record_application_attach_image_uuid_file", indexes = { + @Index(name = "idx_user_academic_record_application_attach_image_application_id", columnList = "user_academic_record_application_id"), + @Index(name = "idx_user_academic_record_application_attach_image_uuid_file_id", columnList = "uuid_file_id") +}) public class UserAcademicRecordApplicationAttachImage extends JoinEntity { @Getter diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserAcademicRecordLogAttachImage.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserAcademicRecordLogAttachImage.java index 25e3b337e..1e5cd76f5 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserAcademicRecordLogAttachImage.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserAcademicRecordLogAttachImage.java @@ -21,11 +21,10 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) @Entity -@Table(name = "tb_user_academic_record_log_attach_image", - indexes = { - @Index(name = "idx_user_academic_record_log_attach_image_log_id", columnList = "user_academic_record_log_id"), - @Index(name = "idx_user_academic_record_log_attach_image_uuid_file_id", columnList = "uuid_file_id") - }) +@Table(name = "tb_user_academic_record_log_attach_image", indexes = { + @Index(name = "idx_user_academic_record_log_attach_image_log_id", columnList = "user_academic_record_log_id"), + @Index(name = "idx_user_academic_record_log_attach_image_uuid_file_id", columnList = "uuid_file_id") +}) public class UserAcademicRecordLogAttachImage extends JoinEntity { @Getter diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserAdmissionAttachImage.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserAdmissionAttachImage.java index 58101deb8..7fb8f6516 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserAdmissionAttachImage.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserAdmissionAttachImage.java @@ -22,11 +22,10 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) @Entity -@Table(name = "tb_user_admission_attach_image_uuid_file", - indexes = { - @Index(name = "idx_user_admission_attach_image__admission_id", columnList = "user_admission_id"), - @Index(name = "idx_user_admission_attach_image_uuid_file_id", columnList = "uuid_file_id") - }) +@Table(name = "tb_user_admission_attach_image_uuid_file", indexes = { + @Index(name = "idx_user_admission_attach_image__admission_id", columnList = "user_admission_id"), + @Index(name = "idx_user_admission_attach_image_uuid_file_id", columnList = "uuid_file_id") +}) public class UserAdmissionAttachImage extends JoinEntity { @Getter diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserAdmissionLogAttachImage.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserAdmissionLogAttachImage.java index cc1bdca19..dbfaa7333 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserAdmissionLogAttachImage.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserAdmissionLogAttachImage.java @@ -21,11 +21,10 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) @Entity -@Table(name = "tb_user_admission_log_attach_image_uuid_file", - indexes = { - @Index(name = "idx_user_admission_log_attach_image_log_id", columnList = "user_admission_log_id"), - @Index(name = "idx_user_admission_log_attach_image_uuid_file_id", columnList = "uuid_file_id") - }) +@Table(name = "tb_user_admission_log_attach_image_uuid_file", indexes = { + @Index(name = "idx_user_admission_log_attach_image_log_id", columnList = "user_admission_log_id"), + @Index(name = "idx_user_admission_log_attach_image_uuid_file_id", columnList = "uuid_file_id") +}) public class UserAdmissionLogAttachImage extends JoinEntity { @Getter diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserProfileImage.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserProfileImage.java index d9b9af3d7..c2f81822e 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserProfileImage.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/entity/joinEntity/UserProfileImage.java @@ -21,11 +21,10 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) @Entity -@Table(name = "tb_user_profile_uuid_file", - indexes = { - @Index(name = "idx_user_profile_user_id", columnList = "user_id"), - @Index(name = "idx_user_profile_uuid_file_id", columnList = "uuid_file_id") - }) +@Table(name = "tb_user_profile_uuid_file", indexes = { + @Index(name = "idx_user_profile_user_id", columnList = "user_id"), + @Index(name = "idx_user_profile_uuid_file_id", columnList = "uuid_file_id") +}) public class UserProfileImage extends JoinEntity { @Setter(AccessLevel.PUBLIC) diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/enums/FilePath.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/enums/FilePath.java index 0b76f9e80..b2311edc8 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/enums/FilePath.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/enums/FilePath.java @@ -13,26 +13,22 @@ public enum FilePath { "user/profile", 5 * 1024 * 1024L, // 5MB 1, - List.of(FileExtensionType.IMAGE) - ), + List.of(FileExtensionType.IMAGE)), USER_ADMISSION( "user/admission", 5 * 1024 * 1024L, // 5MB 5, - List.of(FileExtensionType.IMAGE) - ), + List.of(FileExtensionType.IMAGE)), USER_ACADEMIC_RECORD_APPLICATION( "user/academic-record-service", 5 * 1024 * 1024L, // 5MB 5, - List.of(FileExtensionType.IMAGE) - ), + List.of(FileExtensionType.IMAGE)), CIRCLE_PROFILE( "circle/profile", 5 * 1024 * 1024L, // 5MB 1, - List.of(FileExtensionType.IMAGE) - ), + List.of(FileExtensionType.IMAGE)), POST( "post", 10 * 1024 * 1024L, // 10MB @@ -44,20 +40,16 @@ public enum FilePath { FileExtensionType.TEXT, FileExtensionType.DOCUMENT, FileExtensionType.COMPRESS, - FileExtensionType.ETC - ) - ), + FileExtensionType.ETC)), CALENDAR("calendar", 50 * 1024 * 1024L, // 50MB 1, - List.of(FileExtensionType.IMAGE) - ), + List.of(FileExtensionType.IMAGE)), EVENT( "event", 50 * 1024 * 1024L, // 50MB 1, - List.of(FileExtensionType.IMAGE) - ), + List.of(FileExtensionType.IMAGE)), ETC( "etc", 100 * 1024 * 1024L, // 100MB @@ -69,9 +61,7 @@ public enum FilePath { FileExtensionType.TEXT, FileExtensionType.DOCUMENT, FileExtensionType.COMPRESS, - FileExtensionType.ETC - ) - ); + FileExtensionType.ETC)); private final String directory; private final Long maxFileSize; diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/CalendarAttachImageRepository.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/CalendarAttachImageRepository.java index f4828acdf..205d77236 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/CalendarAttachImageRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/CalendarAttachImageRepository.java @@ -12,6 +12,7 @@ public interface CalendarAttachImageRepository extends JpaRepository { @NotNull - Page findAll(@NotNull Pageable pageable); + Page findAll(@NotNull + Pageable pageable); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/EventAttachImageRepository.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/EventAttachImageRepository.java index ebde482a6..06126e80b 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/EventAttachImageRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/EventAttachImageRepository.java @@ -6,5 +6,4 @@ import net.causw.app.main.domain.asset.file.entity.joinEntity.EventAttachImage; @Repository -public interface EventAttachImageRepository extends JpaRepository { -} +public interface EventAttachImageRepository extends JpaRepository {} diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/PostAttachImageRepository.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/PostAttachImageRepository.java index 04f995386..b4bb54d89 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/PostAttachImageRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/PostAttachImageRepository.java @@ -6,5 +6,4 @@ import net.causw.app.main.domain.asset.file.entity.joinEntity.PostAttachImage; @Repository -public interface PostAttachImageRepository extends JpaRepository { -} +public interface PostAttachImageRepository extends JpaRepository {} diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/UserAdmissionAttachImageRepository.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/UserAdmissionAttachImageRepository.java index 62b603528..1b22bada3 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/UserAdmissionAttachImageRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/UserAdmissionAttachImageRepository.java @@ -6,5 +6,4 @@ import net.causw.app.main.domain.asset.file.entity.joinEntity.UserAdmissionAttachImage; @Repository -public interface UserAdmissionAttachImageRepository extends JpaRepository { -} +public interface UserAdmissionAttachImageRepository extends JpaRepository {} diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/UserAdmissionLogAttachImageRepository.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/UserAdmissionLogAttachImageRepository.java index 5c3ec412b..b14948020 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/UserAdmissionLogAttachImageRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/UserAdmissionLogAttachImageRepository.java @@ -6,5 +6,4 @@ import net.causw.app.main.domain.asset.file.entity.joinEntity.UserAdmissionLogAttachImage; @Repository -public interface UserAdmissionLogAttachImageRepository extends JpaRepository { -} +public interface UserAdmissionLogAttachImageRepository extends JpaRepository {} diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/UserProfileImageRepository.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/UserProfileImageRepository.java index 896d44c6e..e90f50c34 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/UserProfileImageRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/repository/UserProfileImageRepository.java @@ -6,5 +6,4 @@ import net.causw.app.main.domain.asset.file.entity.joinEntity.UserProfileImage; @Repository -public interface UserProfileImageRepository extends JpaRepository { -} +public interface UserProfileImageRepository extends JpaRepository {} diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/service/CleanUnusedUuidFileService.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/service/CleanUnusedUuidFileService.java index 088b72c67..7af580550 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/service/CleanUnusedUuidFileService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/service/CleanUnusedUuidFileService.java @@ -61,8 +61,7 @@ public void initIsUsedUuidFileIntegration(StepExecution stepExecution) { stepExecution.getJobExecution().getExecutionContext().putInt( "dataRow", - getPriorPageNum("uuidFile") * StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE - ); + getPriorPageNum("uuidFile") * StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE); redisUtils.setPageNumData("uuidFile", -1, StaticValue.CLEAN_UNUSED_UUID_FILE_REDIS_EXPIRED_TIME); } @@ -73,8 +72,7 @@ public Boolean initIsUsedUuidFile() { Page uuidFilePage = uuidFileRepository.findAll( PageRequest.of( pageNum, - StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE) - ); + StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE)); uuidFilePage.forEach(uuidFile -> uuidFile.setIsUsed(false)); uuidFileRepository.saveAll(uuidFilePage); pageNum++; @@ -95,8 +93,7 @@ public void checkIsUsedWithCalendarAttachImageIntegration(StepExecution stepExec stepExecution.getJobExecution().getExecutionContext().putInt( "dataRow", - getPriorPageNum("calendarAttachImage") * StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE - ); + getPriorPageNum("calendarAttachImage") * StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE); redisUtils.setPageNumData("calendarAttachImage", -1, StaticValue.CLEAN_UNUSED_UUID_FILE_REDIS_EXPIRED_TIME); } @@ -107,8 +104,7 @@ public Boolean checkIsUsedWithCalendarAttachImage() { Page calendarAttachImagePage = calendarAttachImageRepository.findAll( PageRequest.of( pageNum, - StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE) - ); + StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE)); Set uuidFileSet = calendarAttachImagePage.stream() .map(CalendarAttachImage::getUuidFile) .collect(Collectors.toSet()); @@ -133,8 +129,7 @@ public void checkIsUsedWithCircleMainImageIntegration(StepExecution stepExecutio stepExecution.getJobExecution().getExecutionContext().putInt( "dataRow", - getPriorPageNum("circleMainImage") * StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE - ); + getPriorPageNum("circleMainImage") * StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE); redisUtils.setPageNumData("circleMainImage", -1, StaticValue.CLEAN_UNUSED_UUID_FILE_REDIS_EXPIRED_TIME); } @@ -145,8 +140,7 @@ public Boolean checkIsUsedWithCircleMainImage() { Page circleMainImagePage = circleMainImageRepository.findAll( PageRequest.of( pageNum, - StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE) - ); + StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE)); Set uuidFileSet = circleMainImagePage.stream() .map(CircleMainImage::getUuidFile) .collect(Collectors.toSet()); @@ -170,8 +164,7 @@ public void checkIsUsedWithEventAttachImageIntegration(StepExecution stepExecuti stepExecution.getJobExecution().getExecutionContext().putInt( "dataRow", - getPriorPageNum("eventAttachImage") * StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE - ); + getPriorPageNum("eventAttachImage") * StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE); redisUtils.setPageNumData("eventAttachImage", -1, StaticValue.CLEAN_UNUSED_UUID_FILE_REDIS_EXPIRED_TIME); } @@ -182,8 +175,7 @@ public Boolean checkIsUsedWithEventAttachImage() { Page eventAttachImagePage = eventAttachImageRepository.findAll( PageRequest.of( pageNum, - StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE) - ); + StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE)); Set uuidFileSet = eventAttachImagePage.stream() .map(EventAttachImage::getUuidFile) .collect(Collectors.toSet()); @@ -207,8 +199,7 @@ public void checkIsUsedWithPostAttachImageIntegration(StepExecution stepExecutio stepExecution.getJobExecution().getExecutionContext().putInt( "dataRow", - getPriorPageNum("postAttachImage") * StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE - ); + getPriorPageNum("postAttachImage") * StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE); redisUtils.setPageNumData("postAttachImage", -1, StaticValue.CLEAN_UNUSED_UUID_FILE_REDIS_EXPIRED_TIME); } @@ -219,8 +210,7 @@ public Boolean checkIsUsedWithPostAttachImage() { Page postAttachImagePage = postAttachImageRepository.findAll( PageRequest.of( pageNum, - StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE) - ); + StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE)); Set uuidFileSet = postAttachImagePage.stream() .map(PostAttachImage::getUuidFile) .collect(Collectors.toSet()); @@ -244,8 +234,8 @@ public void checkIsUsedWithUserAcademicRecordApplicationAttachImageIntegration(S stepExecution.getJobExecution().getExecutionContext().putInt( "dataRow", - getPriorPageNum("userAcademicRecordApplicationAttachImage") * StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE - ); + getPriorPageNum("userAcademicRecordApplicationAttachImage") + * StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE); redisUtils.setPageNumData("userAcademicRecordApplicationAttachImage", -1, StaticValue.CLEAN_UNUSED_UUID_FILE_REDIS_EXPIRED_TIME); @@ -254,11 +244,11 @@ public void checkIsUsedWithUserAcademicRecordApplicationAttachImageIntegration(S @Transactional public Boolean checkIsUsedWithUserAcademicRecordApplicationAttachImage() { Integer pageNum = getPriorPageNum("userAcademicRecordApplicationAttachImage"); - Page userAcademicRecordApplicationAttachImagePage = userAcademicRecordApplicationAttachImageRepository.findAll( - PageRequest.of( - pageNum, - StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE) - ); + Page userAcademicRecordApplicationAttachImagePage = userAcademicRecordApplicationAttachImageRepository + .findAll( + PageRequest.of( + pageNum, + StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE)); Set uuidFileSet = userAcademicRecordApplicationAttachImagePage.stream() .map(UserAcademicRecordApplicationAttachImage::getUuidFile) .collect(Collectors.toSet()); @@ -283,8 +273,7 @@ public void checkIsUsedWithUserAdmissionAttachImageIntegration(StepExecution ste stepExecution.getJobExecution().getExecutionContext().putInt( "dataRow", - getPriorPageNum("userAdmissionAttachImage") * StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE - ); + getPriorPageNum("userAdmissionAttachImage") * StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE); redisUtils.setPageNumData("userAdmissionAttachImage", -1, StaticValue.CLEAN_UNUSED_UUID_FILE_REDIS_EXPIRED_TIME); @@ -296,8 +285,7 @@ public Boolean checkIsUsedWithUserAdmissionAttachImage() { Page userAdmissionAttachImagePage = userAdmissionAttachImageRepository.findAll( PageRequest.of( pageNum, - StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE) - ); + StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE)); Set uuidFileSet = userAdmissionAttachImagePage.stream() .map(UserAdmissionAttachImage::getUuidFile) .collect(Collectors.toSet()); @@ -322,8 +310,7 @@ public void checkIsUsedWithUserAdmissionLogAttachImageIntegration(StepExecution stepExecution.getJobExecution().getExecutionContext().putInt( "dataRow", - getPriorPageNum("userAdmissionLog") * StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE - ); + getPriorPageNum("userAdmissionLog") * StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE); redisUtils.setPageNumData("userAdmissionLog", -1, StaticValue.CLEAN_UNUSED_UUID_FILE_REDIS_EXPIRED_TIME); } @@ -331,11 +318,11 @@ public void checkIsUsedWithUserAdmissionLogAttachImageIntegration(StepExecution @Transactional public Boolean checkIsUsedWithUserAdmissionLogAttachImage() { Integer pageNum = getPriorPageNum("userAdmissionLog"); - Page userAdmissionLogAttachImagePage = userAdmissionLogAttachImageRepository.findAll( - PageRequest.of( - pageNum, - StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE) - ); + Page userAdmissionLogAttachImagePage = userAdmissionLogAttachImageRepository + .findAll( + PageRequest.of( + pageNum, + StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE)); Set uuidFileSet = userAdmissionLogAttachImagePage.stream() .map(UserAdmissionLogAttachImage::getUuidFile) .collect(Collectors.toSet()); @@ -359,8 +346,7 @@ public void checkIsUsedWithUserProfileImageIntegration(StepExecution stepExecuti stepExecution.getJobExecution().getExecutionContext().putInt( "dataRow", - getPriorPageNum("userProfileImage") * StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE - ); + getPriorPageNum("userProfileImage") * StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE); redisUtils.setPageNumData("userProfileImage", -1, StaticValue.CLEAN_UNUSED_UUID_FILE_REDIS_EXPIRED_TIME); } @@ -371,8 +357,7 @@ public Boolean checkIsUsedWithUserProfileImage() { Page userProfileImagePage = userProfileImageRepository.findAll( PageRequest.of( pageNum, - StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE) - ); + StaticValue.SELECT_UNUSED_UUID_FILE_PAGE_SIZE)); Set uuidFileSet = userProfileImagePage.stream() .map(UserProfileImage::getUuidFile) .collect(Collectors.toSet()); diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/file/service/UuidFileService.java b/app-main/src/main/java/net/causw/app/main/domain/asset/file/service/UuidFileService.java index 699fdffe7..00f3e703c 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/file/service/UuidFileService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/file/service/UuidFileService.java @@ -37,18 +37,22 @@ public UuidFileService(AmazonS3Client amazonS3Client, UuidFileRepository uuidFil this.uuidFileRepository = uuidFileRepository; } - public UuidFile findUuidFileById(@NotBlank String id) { + public UuidFile findUuidFileById(@NotBlank + String id) { return uuidFileRepository.findById(id).orElseThrow( () -> new BadRequestException(ErrorCode.ROW_DOES_NOT_EXIST, MessageUtil.FILE_NOT_FOUND)); } - public UuidFile findUuidFileByFileUrl(@NotBlank String fileUrl) { + public UuidFile findUuidFileByFileUrl(@NotBlank + String fileUrl) { return uuidFileRepository.findByFileUrl(fileUrl).orElseThrow( () -> new BadRequestException(ErrorCode.ROW_DOES_NOT_EXIST, MessageUtil.FILE_NOT_FOUND)); } @Transactional - public UuidFile saveFile(@NotNull MultipartFile file, @NotNull FilePath filePath) { + public UuidFile saveFile(@NotNull + MultipartFile file, @NotNull + FilePath filePath) { this.validateFile(file, filePath); String uuid = UUID.randomUUID().toString(); @@ -67,14 +71,15 @@ public UuidFile saveFile(@NotNull MultipartFile file, @NotNull FilePath filePath fileInfoStringMap.get(FileInfo.FILE_URL), rawFileName, extension, - filePath - ); + filePath); return uuidFileRepository.save(uuidFile); } @Transactional - public List saveFileList(@NotNull List fileList, @NotNull FilePath filePath) { + public List saveFileList(@NotNull + List fileList, @NotNull + FilePath filePath) { this.validateFileListSize(fileList, filePath); return fileList.stream() .map(file -> this.saveFile(file, filePath)) @@ -82,7 +87,9 @@ public List saveFileList(@NotNull List fileList, @NotNu } @Transactional - public UuidFile updateFile(UuidFile priorUuidFile, @NotNull MultipartFile file, @NotNull FilePath filePath) { + public UuidFile updateFile(UuidFile priorUuidFile, @NotNull + MultipartFile file, @NotNull + FilePath filePath) { if (priorUuidFile != null) { this.deleteFile(priorUuidFile); } @@ -100,7 +107,8 @@ public List updateFileList(List priorUuidFileList, List uuidFileList) { + public void deleteFileList(@NotNull + List uuidFileList) { for (UuidFile uuidFile : uuidFileList) { this.deleteFile(uuidFile); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/entity/Locker.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/entity/Locker.java index 13d8a715d..e46cbd506 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/entity/Locker.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/entity/Locker.java @@ -50,8 +50,7 @@ public static Locker of( Boolean isActive, User user, LockerLocation location, - LocalDateTime expireDate - ) { + LocalDateTime expireDate) { return Locker.builder() .lockerNumber(lockerNumber) .isActive(isActive) diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/entity/LockerLog.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/entity/LockerLog.java index 90b60364d..60b5d30d4 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/entity/LockerLog.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/entity/LockerLog.java @@ -46,8 +46,7 @@ public static LockerLog of( String userEmail, String userName, LockerLogAction action, - String message - ) { + String message) { return LockerLog.builder() .lockerNumber(lockerNumber) .lockerLocationName(lockerLocationName) diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/enums/LockerLogAction.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/enums/LockerLogAction.java index 0c5309c23..9df6ed296 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/enums/LockerLogAction.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/enums/LockerLogAction.java @@ -25,8 +25,6 @@ public static LockerLogAction of(String value) { .orElseThrow( () -> new BadRequestException( ErrorCode.INVALID_REQUEST_ROLE, - String.format("'%s' is invalid : not supported", value) - ) - ); + String.format("'%s' is invalid : not supported", value))); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/repository/LockerRepository.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/repository/LockerRepository.java index c3fb6c595..a52321667 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/repository/LockerRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/repository/LockerRepository.java @@ -19,11 +19,13 @@ public interface LockerRepository extends JpaRepository { @Query("SELECT l FROM Locker l WHERE l.id = :id") @Lock(LockModeType.PESSIMISTIC_WRITE) - Optional findByIdForWrite(@Param("id") String id); + Optional findByIdForWrite(@Param("id") + String id); @Query("SELECT l FROM Locker l WHERE l.id = :id") @Lock(LockModeType.PESSIMISTIC_READ) - Optional findByIdForRead(@Param("id") String id); + Optional findByIdForRead(@Param("id") + String id); Optional findByLockerNumber(Long lockerNumber); diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerAction.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerAction.java index 05dae0570..a8a5d3f2f 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerAction.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerAction.java @@ -11,6 +11,5 @@ Optional updateLockerDomainModel( Locker locker, User user, LockerService lockerService, - CommonService commonService - ); + CommonService commonService); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionDisable.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionDisable.java index 1218708ee..8dde5a870 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionDisable.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionDisable.java @@ -4,8 +4,8 @@ import java.util.Set; import net.causw.app.main.domain.asset.locker.entity.Locker; -import net.causw.app.main.domain.etc.textfield.service.CommonService; import net.causw.app.main.domain.asset.locker.util.LockerIsDeactivatedValidator; +import net.causw.app.main.domain.etc.textfield.service.CommonService; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.util.UserRoleValidator; import net.causw.app.main.shared.ValidatorBucket; @@ -19,8 +19,7 @@ public Optional updateLockerDomainModel( Locker locker, User user, LockerService lockerService, - CommonService commonService - ) { + CommonService commonService) { ValidatorBucket.of() .consistOf(UserRoleValidator.of(user.getRoles(), Set.of())) .consistOf(LockerIsDeactivatedValidator.of(locker.getIsActive())) diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionEnable.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionEnable.java index 01c7449d7..d907e35bd 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionEnable.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionEnable.java @@ -4,8 +4,8 @@ import java.util.Set; import net.causw.app.main.domain.asset.locker.entity.Locker; -import net.causw.app.main.domain.etc.textfield.service.CommonService; import net.causw.app.main.domain.asset.locker.util.LockerIsActiveValidator; +import net.causw.app.main.domain.etc.textfield.service.CommonService; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.util.UserRoleValidator; import net.causw.app.main.shared.ValidatorBucket; @@ -19,8 +19,7 @@ public Optional updateLockerDomainModel( Locker locker, User user, LockerService lockerService, - CommonService commonService - ) { + CommonService commonService) { ValidatorBucket.of() .consistOf(UserRoleValidator.of(user.getRoles(), Set.of())) .consistOf(LockerIsActiveValidator.of(locker.getIsActive())) diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionExtend.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionExtend.java index c9cbf0d5c..903da5825 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionExtend.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionExtend.java @@ -1,15 +1,15 @@ package net.causw.app.main.domain.asset.locker.service; -import static net.causw.global.constant.StaticValue.*; +import static net.causw.global.constant.StaticValue.LOCKER_EXTEND; import java.time.LocalDateTime; import java.util.Optional; import java.util.Set; import net.causw.app.main.domain.asset.locker.entity.Locker; -import net.causw.app.main.domain.etc.textfield.service.CommonService; import net.causw.app.main.domain.asset.locker.util.ExtendLockerExpiredAtValidator; import net.causw.app.main.domain.asset.locker.util.LockerExtendAccessValidator; +import net.causw.app.main.domain.etc.textfield.service.CommonService; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.domain.user.account.util.UserRoleValidator; @@ -29,13 +29,11 @@ public Optional updateLockerDomainModel( Locker locker, User user, LockerService lockerService, - CommonService commonService - ) { + CommonService commonService) { if (locker.getUser().isEmpty()) { throw new BadRequestException( ErrorCode.CANNOT_PERFORMED, - MessageUtil.LOCKER_UNUSED - ); + MessageUtil.LOCKER_UNUSED); } // 사물함 보유자와 신청자가 같은지 확인 @@ -54,16 +52,14 @@ public Optional updateLockerDomainModel( commonService.findByKeyInTextField(StaticValue.NEXT_EXPIRED_AT).orElseThrow( () -> new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.LOCKER_NEXT_EXPIRE_TIME_NOT_SET - ) - ), StaticValue.LOCKER_DATE_TIME_FORMATTER); + MessageUtil.LOCKER_NEXT_EXPIRE_TIME_NOT_SET)), + StaticValue.LOCKER_DATE_TIME_FORMATTER); - Optional.ofNullable(locker.getExpireDate()).ifPresent(expiredAt -> - ValidatorBucket.of() - .consistOf(ExtendLockerExpiredAtValidator.of( - expiredAt, - expiredAtToExtend)) - .validate()); + Optional.ofNullable(locker.getExpireDate()).ifPresent(expiredAt -> ValidatorBucket.of() + .consistOf(ExtendLockerExpiredAtValidator.of( + expiredAt, + expiredAtToExtend)) + .validate()); locker.extendExpireDate(expiredAtToExtend); return Optional.of(locker); diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionFactory.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionFactory.java index 938f53d95..059bb4c64 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionFactory.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionFactory.java @@ -30,8 +30,7 @@ public LockerAction getLockerAction(LockerLogAction action) { if (updateAction == null) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_PARAMETER - ); + MessageUtil.INVALID_PARAMETER); } return updateAction.get(); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionRegister.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionRegister.java index f0c862714..f2657c117 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionRegister.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionRegister.java @@ -1,6 +1,6 @@ package net.causw.app.main.domain.asset.locker.service; -import static net.causw.global.constant.StaticValue.*; +import static net.causw.global.constant.StaticValue.LOCKER_ACCESS; import java.time.LocalDateTime; import java.util.Optional; @@ -8,10 +8,10 @@ import net.causw.app.main.domain.asset.locker.entity.Locker; import net.causw.app.main.domain.asset.locker.entity.LockerLog; import net.causw.app.main.domain.asset.locker.enums.LockerLogAction; -import net.causw.app.main.domain.etc.textfield.service.CommonService; import net.causw.app.main.domain.asset.locker.util.LockerAccessValidator; import net.causw.app.main.domain.asset.locker.util.LockerInUseValidator; import net.causw.app.main.domain.asset.locker.util.LockerIsDeactivatedValidator; +import net.causw.app.main.domain.etc.textfield.service.CommonService; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.shared.ValidatorBucket; @@ -29,8 +29,7 @@ public Optional updateLockerDomainModel( Locker locker, User user, LockerService lockerService, - CommonService commonService - ) { + CommonService commonService) { ValidatorBucket.of() .consistOf(LockerInUseValidator.of(locker.getUser().isPresent())) .consistOf(LockerIsDeactivatedValidator.of(locker.getIsActive())) @@ -50,8 +49,7 @@ public Optional updateLockerDomainModel( user.getEmail(), user.getName(), LockerLogAction.RETURN, - "사물함 반납" - ); + "사물함 반납"); }); } @@ -60,10 +58,8 @@ public Optional updateLockerDomainModel( LocalDateTime.parse(commonService.findByKeyInTextField(StaticValue.EXPIRED_AT).orElseThrow( () -> new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.LOCKER_EXPIRE_TIME_NOT_SET - ) - ), StaticValue.LOCKER_DATE_TIME_FORMATTER) - ); + MessageUtil.LOCKER_EXPIRE_TIME_NOT_SET)), + StaticValue.LOCKER_DATE_TIME_FORMATTER)); return Optional.of(locker); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionReturn.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionReturn.java index aa25f1693..2c434425f 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionReturn.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerActionReturn.java @@ -1,13 +1,13 @@ package net.causw.app.main.domain.asset.locker.service; -import static net.causw.global.constant.StaticValue.*; +import static net.causw.global.constant.StaticValue.LOCKER_ACCESS; import java.util.Optional; import java.util.Set; import net.causw.app.main.domain.asset.locker.entity.Locker; -import net.causw.app.main.domain.etc.textfield.service.CommonService; import net.causw.app.main.domain.asset.locker.util.LockerAccessValidator; +import net.causw.app.main.domain.etc.textfield.service.CommonService; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.domain.user.account.util.UserRoleValidator; @@ -25,13 +25,11 @@ public Optional updateLockerDomainModel( Locker locker, User user, LockerService lockerService, - CommonService commonService - ) { + CommonService commonService) { if (locker.getUser().isEmpty()) { throw new BadRequestException( ErrorCode.CANNOT_PERFORMED, - MessageUtil.LOCKER_UNUSED - ); + MessageUtil.LOCKER_UNUSED); } if (!user.getId().equals(locker.getUser().get().getId())) diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerService.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerService.java index d5116d000..506a2dcb0 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/service/LockerService.java @@ -9,7 +9,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import net.causw.app.main.core.aop.annotation.MeasureTime; import net.causw.app.main.api.dto.locker.LockerCreateRequestDto; import net.causw.app.main.api.dto.locker.LockerExpiredAtRequestDto; import net.causw.app.main.api.dto.locker.LockerExtendPeriodRequestDto; @@ -23,20 +22,20 @@ import net.causw.app.main.api.dto.locker.LockerResponseDto; import net.causw.app.main.api.dto.locker.LockerUpdateRequestDto; import net.causw.app.main.api.dto.locker.LockersResponseDto; -import net.causw.app.main.domain.etc.flag.entity.Flag; +import net.causw.app.main.core.aop.annotation.MeasureTime; import net.causw.app.main.domain.asset.locker.entity.Locker; import net.causw.app.main.domain.asset.locker.entity.LockerLocation; import net.causw.app.main.domain.asset.locker.entity.LockerLog; import net.causw.app.main.domain.asset.locker.entity.LockerName; import net.causw.app.main.domain.asset.locker.enums.LockerLogAction; -import net.causw.app.main.domain.etc.flag.repository.FlagRepository; import net.causw.app.main.domain.asset.locker.repository.LockerLocationRepository; import net.causw.app.main.domain.asset.locker.repository.LockerLogRepository; import net.causw.app.main.domain.asset.locker.repository.LockerRepository; -import net.causw.app.main.domain.etc.textfield.service.CommonService; -import net.causw.app.main.shared.util.ConstraintValidator; import net.causw.app.main.domain.asset.locker.util.LockerExpiredAtValidator; import net.causw.app.main.domain.asset.locker.util.LockerInUseValidator; +import net.causw.app.main.domain.etc.flag.entity.Flag; +import net.causw.app.main.domain.etc.flag.repository.FlagRepository; +import net.causw.app.main.domain.etc.textfield.service.CommonService; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.domain.user.account.repository.user.UserRepository; @@ -44,6 +43,7 @@ import net.causw.app.main.domain.user.account.util.UserRoleValidator; import net.causw.app.main.domain.user.account.util.UserStateValidator; import net.causw.app.main.shared.ValidatorBucket; +import net.causw.app.main.shared.util.ConstraintValidator; import net.causw.global.constant.MessageUtil; import net.causw.global.constant.StaticValue; import net.causw.global.exception.BadRequestException; @@ -70,19 +70,16 @@ public class LockerService { public LockerResponseDto findById(String id, User user) { return LockerResponseDto.of(lockerRepository.findByIdForRead(id).orElseThrow( - () -> new BadRequestException( - ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.LOCKER_NOT_FOUND - )), - user - ); + () -> new BadRequestException( + ErrorCode.ROW_DOES_NOT_EXIST, + MessageUtil.LOCKER_NOT_FOUND)), + user); } @Transactional public LockerResponseDto create( User user, - LockerCreateRequestDto lockerCreateRequestDto - ) { + LockerCreateRequestDto lockerCreateRequestDto) { ValidatorBucket validatorBucket = ValidatorBucket.of(); Set roles = user.getRoles(); @@ -90,15 +87,12 @@ public LockerResponseDto create( .orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.LOCKER_WRONG_POSITION - ) - ); + MessageUtil.LOCKER_WRONG_POSITION)); if (lockerRepository.findByLockerNumber(lockerCreateRequestDto.getLockerNumber()).isPresent()) { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.LOCKER_DUPLICATE_NUMBER - ); + MessageUtil.LOCKER_DUPLICATE_NUMBER); } Locker locker = Locker.of(lockerCreateRequestDto.getLockerNumber(), true, user, lockerLocation, null); validatorBucket @@ -120,14 +114,12 @@ public LockerResponseDto create( public LockerResponseDto update( User user, String lockerId, - LockerUpdateRequestDto lockerUpdateRequestDto - ) { + LockerUpdateRequestDto lockerUpdateRequestDto) { Set roles = user.getRoles(); Locker locker = lockerRepository.findById(lockerId).orElseThrow(() -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.LOCKER_NOT_FOUND - )); + MessageUtil.LOCKER_NOT_FOUND)); ValidatorBucket.of() .consistOf(UserStateValidator.of(user.getState())) @@ -136,14 +128,12 @@ public LockerResponseDto update( locker = this.lockerActionFactory .getLockerAction(LockerLogAction.of( - lockerUpdateRequestDto.getAction() - )) + lockerUpdateRequestDto.getAction())) .updateLockerDomainModel( locker, user, this, - commonService - ) + commonService) .orElseThrow( () -> new InternalServerException(ErrorCode.LOCKER_ACTION_ERROR, MessageUtil.LOCKER_ACTION_ERROR)); @@ -153,11 +143,9 @@ public LockerResponseDto update( user.getEmail(), user.getName(), LockerLogAction.of( - lockerUpdateRequestDto.getAction() - ), + lockerUpdateRequestDto.getAction()), lockerUpdateRequestDto.getMessage() - .orElse(lockerUpdateRequestDto.getAction()) - ); + .orElse(lockerUpdateRequestDto.getAction())); lockerRepository.save(locker); lockerLogRepository.save(lockerLog); @@ -168,22 +156,18 @@ public LockerResponseDto update( public LockerResponseDto move( User user, String lockerId, - LockerMoveRequestDto lockerMoveRequestDto - ) { + LockerMoveRequestDto lockerMoveRequestDto) { Set roles = user.getRoles(); Locker locker = lockerRepository.findById(lockerId).orElseThrow(() -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.LOCKER_NOT_FOUND - )); + MessageUtil.LOCKER_NOT_FOUND)); LockerLocation lockerLocation = lockerLocationRepository.findById(lockerMoveRequestDto.getLockerLocationId()) .orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.LOCKER_WRONG_POSITION - ) - ); + MessageUtil.LOCKER_WRONG_POSITION)); locker.move(lockerLocation); @@ -209,8 +193,7 @@ public LockerResponseDto delete(User user, String lockerId) { Locker locker = lockerRepository.findById(lockerId).orElseThrow(() -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.LOCKER_NOT_FOUND - )); + MessageUtil.LOCKER_NOT_FOUND)); ValidatorBucket.of() .consistOf(LockerInUseValidator.of(locker.getUser().isPresent())) @@ -233,9 +216,7 @@ public LockersResponseDto findByLocation(String locationId, User user) { .orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.LOCKER_WRONG_POSITION - ) - ); + MessageUtil.LOCKER_WRONG_POSITION)); String lockerPeriod = flagRepository.findByValue(true) .map(Flag::getKey) @@ -247,8 +228,7 @@ public LockersResponseDto findByLocation(String locationId, User user) { lockerRepository.findByLocation_IdOrderByLockerNumberAsc(lockerLocation.getId()) .stream() .map(locker -> LockerResponseDto.of(locker, user)) - .collect(Collectors.toList()) - ); + .collect(Collectors.toList())); } public LockerLocationsResponseDto findAllLocation(User user) { @@ -258,8 +238,7 @@ public LockerLocationsResponseDto findAllLocation(User user) { .map(locker -> LockerResponseDto.of( locker, user, - locker.getLocation().getName() - )) + locker.getLocation().getName())) .orElse(null); return LockerLocationsResponseDto.of( @@ -268,30 +247,25 @@ public LockerLocationsResponseDto findAllLocation(User user) { .map(lockerLocation -> LockerLocationResponseDto.of( lockerLocation, lockerRepository.countByLocationIdAndIsActiveIsTrueAndUserIdIsNull(lockerLocation.getId()), - lockerRepository.countByLocationId(lockerLocation.getId()) - )) + lockerRepository.countByLocationId(lockerLocation.getId()))) .collect(Collectors.toList()), - myLocker - ); + myLocker); } @Transactional public LockerLocationResponseDto createLocation( User user, - LockerLocationCreateRequestDto lockerLocationCreateRequestDto - ) { + LockerLocationCreateRequestDto lockerLocationCreateRequestDto) { Set roles = user.getRoles(); if (lockerLocationRepository.findByName(lockerLocationCreateRequestDto.getName()).isPresent()) { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.LOCKER_ALREADY_REGISTERED - ); + MessageUtil.LOCKER_ALREADY_REGISTERED); } LockerLocation lockerLocation = LockerLocation.of( - LockerName.valueOf(lockerLocationCreateRequestDto.getName()) - ); + LockerName.valueOf(lockerLocationCreateRequestDto.getName())); ValidatorBucket.of() .consistOf(UserStateValidator.of(user.getState())) @@ -304,36 +278,30 @@ public LockerLocationResponseDto createLocation( return LockerLocationResponseDto.of( location, 0L, - 0L - ); + 0L); } @Transactional public LockerLocationResponseDto updateLocation( User user, String locationId, - LockerLocationUpdateRequestDto lockerLocationRequestDto - ) { + LockerLocationUpdateRequestDto lockerLocationRequestDto) { Set roles = user.getRoles(); LockerLocation lockerLocation = lockerLocationRepository.findById(locationId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.LOCKER_WRONG_POSITION - ) - ); + MessageUtil.LOCKER_WRONG_POSITION)); if (!lockerLocation.getName().equals(lockerLocationRequestDto.getName())) { if (lockerLocationRepository.findByName(lockerLocationRequestDto.getName()).isPresent()) { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.LOCKER_ALREADY_REGISTERED - ); + MessageUtil.LOCKER_ALREADY_REGISTERED); } } lockerLocation.update( - LockerName.valueOf(lockerLocationRequestDto.getName()) - ); + LockerName.valueOf(lockerLocationRequestDto.getName())); ValidatorBucket.of() .consistOf(UserStateValidator.of(user.getState())) @@ -345,8 +313,7 @@ public LockerLocationResponseDto updateLocation( return LockerLocationResponseDto.of( lockerLocation, lockerRepository.countByLocationIdAndIsActiveIsTrueAndUserIdIsNull(lockerLocation.getId()), - lockerRepository.countByLocationId(lockerLocation.getId()) - ); + lockerRepository.countByLocationId(lockerLocation.getId())); } @Transactional @@ -355,15 +322,12 @@ public LockerLocationResponseDto deleteLocation(User user, String lockerLocation LockerLocation lockerLocation = lockerLocationRepository.findById(lockerLocationId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.LOCKER_WRONG_POSITION - ) - ); + MessageUtil.LOCKER_WRONG_POSITION)); if (lockerRepository.countByLocationId(lockerLocation.getId()) != 0L) { throw new BadRequestException( ErrorCode.CANNOT_PERFORMED, - MessageUtil.LOCKER_ALREADY_EXIST - ); + MessageUtil.LOCKER_ALREADY_EXIST); } ValidatorBucket.of() @@ -381,9 +345,7 @@ public List findLog(String id) { Locker locker = lockerRepository.findByIdForRead(id).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.LOCKER_NOT_FOUND - ) - ); + MessageUtil.LOCKER_NOT_FOUND)); return lockerLogRepository.findByLockerNumber(locker.getLockerNumber()) .stream() .map(LockerLogResponseDto::from) @@ -393,8 +355,7 @@ public List findLog(String id) { @Transactional public void setExpireAt( User user, - LockerExpiredAtRequestDto lockerExpiredAtRequestDto - ) { + LockerExpiredAtRequestDto lockerExpiredAtRequestDto) { Set roles = user.getRoles(); ValidatorBucket.of() @@ -405,29 +366,26 @@ public void setExpireAt( commonService.findByKeyInTextField(StaticValue.EXPIRED_AT) .ifPresentOrElse(textField -> { - ValidatorBucket.of() - // FIXME : LockerExpiredAtValidator에서 기존값보다 이전 날짜로 변경하는 것을 막을 필요가 있는지 검토 필요 (만료일, 반납에 대한 정책 정리 필요) - .consistOf(LockerExpiredAtValidator.of( - LocalDateTime.parse(textField, StaticValue.LOCKER_DATE_TIME_FORMATTER), - lockerExpiredAtRequestDto.getExpiredAt())) - .validate(); - - commonService.updateTextField( - StaticValue.EXPIRED_AT, - lockerExpiredAtRequestDto.getExpiredAt().toString() - ); - }, + ValidatorBucket.of() + // FIXME : LockerExpiredAtValidator에서 기존값보다 이전 날짜로 변경하는 것을 막을 필요가 있는지 검토 필요 (만료일, 반납에 대한 정책 정리 필요) + .consistOf(LockerExpiredAtValidator.of( + LocalDateTime.parse(textField, StaticValue.LOCKER_DATE_TIME_FORMATTER), + lockerExpiredAtRequestDto.getExpiredAt())) + .validate(); + + commonService.updateTextField( + StaticValue.EXPIRED_AT, + lockerExpiredAtRequestDto.getExpiredAt().toString()); + }, () -> commonService.createTextField( StaticValue.EXPIRED_AT, - lockerExpiredAtRequestDto.getExpiredAt().toString()) - ); + lockerExpiredAtRequestDto.getExpiredAt().toString())); } @Transactional public void setExtendPeriod( User user, - LockerExtendPeriodRequestDto lockerExtendPeriodRequestDto - ) { + LockerExtendPeriodRequestDto lockerExtendPeriodRequestDto) { Set roles = user.getRoles(); ValidatorBucket.of() @@ -442,8 +400,7 @@ public void setExtendPeriod( if (!lockerExtendPeriodRequestDto.getExtendStartAt().isBefore(lockerExtendPeriodRequestDto.getExtendEndAt())) { throw new BadRequestException( ErrorCode.INVALID_PERIOD, - MessageUtil.LOCKER_INVALID_EXTEND_PERIOD - ); + MessageUtil.LOCKER_INVALID_EXTEND_PERIOD); } // 현재 만료일 < 다음 만료일 체크 @@ -451,13 +408,11 @@ public void setExtendPeriod( .map(dateString -> LocalDateTime.parse(dateString, StaticValue.LOCKER_DATE_TIME_FORMATTER)) .orElseThrow(() -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.LOCKER_EXPIRE_DATE_NOT_FOUND - )); + MessageUtil.LOCKER_EXPIRE_DATE_NOT_FOUND)); if (!currentExpiredAt.isBefore(lockerExtendPeriodRequestDto.getNextExpiredAt())) { throw new BadRequestException( ErrorCode.INVALID_EXPIRE_DATE, - MessageUtil.LOCKER_INVALID_NEXT_EXPIRE_DATE - ); + MessageUtil.LOCKER_INVALID_NEXT_EXPIRE_DATE); } // 연장 시작일 설정 @@ -473,8 +428,7 @@ public void setExtendPeriod( @Transactional public void setRegisterPeriod( User user, - LockerRegisterPeriodRequestDto lockerRegisterPeriodRequestDto - ) { + LockerRegisterPeriodRequestDto lockerRegisterPeriodRequestDto) { Set roles = user.getRoles(); ValidatorBucket.of() @@ -488,8 +442,7 @@ public void setRegisterPeriod( .isBefore(lockerRegisterPeriodRequestDto.getRegisterEndAt())) { throw new BadRequestException( ErrorCode.INVALID_PERIOD, - MessageUtil.LOCKER_INVALID_REGISTER_PERIOD - ); + MessageUtil.LOCKER_INVALID_REGISTER_PERIOD); } // 신청 시작일 설정 @@ -542,8 +495,7 @@ public void returnExpiredLockers(User user) { user.getEmail(), user.getName(), LockerLogAction.RETURN, - MessageUtil.LOCKER_EXPIRED_ALL_RETURNED - ); + MessageUtil.LOCKER_EXPIRED_ALL_RETURNED); lockerLogRepository.save(lockerLog); } } @@ -566,8 +518,7 @@ private void createLockerByLockerLocationAndEndLockerNumber(LockerLocation locke true, null, lockerLocationSecondFloor, - null - ); + null); Set roles = user.getRoles(); validatorBucket @@ -585,8 +536,7 @@ private void createLockerByLockerLocationAndEndLockerNumber(LockerLocation locke user.getEmail(), user.getName(), LockerLogAction.ENABLE, - MessageUtil.LOCKER_FIRST_CREATED - ); + MessageUtil.LOCKER_FIRST_CREATED); lockerLogRepository.save(lockerLog); } } @@ -595,8 +545,7 @@ private void setOrUpdateTextField(String key, String value) { commonService.findByKeyInTextField(key) .ifPresentOrElse( textField -> commonService.updateTextField(key, value), - () -> commonService.createTextField(key, value) - ); + () -> commonService.createTextField(key, value)); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/ExtendLockerExpiredAtValidator.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/ExtendLockerExpiredAtValidator.java index da66efc48..28fb77c33 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/ExtendLockerExpiredAtValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/ExtendLockerExpiredAtValidator.java @@ -13,16 +13,14 @@ public class ExtendLockerExpiredAtValidator extends AbstractValidator { private ExtendLockerExpiredAtValidator( LocalDateTime src, - LocalDateTime dst - ) { + LocalDateTime dst) { this.src = src; this.dst = dst; } public static ExtendLockerExpiredAtValidator of( LocalDateTime src, - LocalDateTime dst - ) { + LocalDateTime dst) { return new ExtendLockerExpiredAtValidator(src, dst); } @@ -31,8 +29,7 @@ public void validate() { if (src.isEqual(dst)) { throw new BadRequestException( ErrorCode.INVALID_EXPIRE_DATE, - MessageUtil.LOCKER_ALREADY_EXTENDED - ); + MessageUtil.LOCKER_ALREADY_EXTENDED); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerAccessValidator.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerAccessValidator.java index da22b9087..37b94a59c 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerAccessValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerAccessValidator.java @@ -21,8 +21,7 @@ public void validate() { if (!flag) { throw new BadRequestException( ErrorCode.FLAG_NOT_AVAILABLE, - MessageUtil.LOCKER_REGISTER_NOT_ALLOWED - ); + MessageUtil.LOCKER_REGISTER_NOT_ALLOWED); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerExpiredAtValidator.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerExpiredAtValidator.java index a008cbc0a..41212c6b5 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerExpiredAtValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerExpiredAtValidator.java @@ -13,16 +13,14 @@ public class LockerExpiredAtValidator extends AbstractValidator { private LockerExpiredAtValidator( LocalDateTime src, - LocalDateTime dst - ) { + LocalDateTime dst) { this.src = src; this.dst = dst; } public static LockerExpiredAtValidator of( LocalDateTime src, - LocalDateTime dst - ) { + LocalDateTime dst) { return new LockerExpiredAtValidator(src, dst); } @@ -32,8 +30,7 @@ public void validate() { if (src.isAfter(dst)) { throw new BadRequestException( ErrorCode.INVALID_EXPIRE_DATE, - MessageUtil.LOCKER_INVALID_EXPIRE_DATE - ); + MessageUtil.LOCKER_INVALID_EXPIRE_DATE); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerInUseValidator.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerInUseValidator.java index 6a9d93686..b71aff0ea 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerInUseValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerInUseValidator.java @@ -21,8 +21,7 @@ public void validate() { if (isInUse) { throw new BadRequestException( ErrorCode.CANNOT_PERFORMED, - MessageUtil.LOCKER_USED - ); + MessageUtil.LOCKER_USED); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerIsActiveValidator.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerIsActiveValidator.java index ff9c03b80..ed7fcb7bf 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerIsActiveValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerIsActiveValidator.java @@ -20,8 +20,7 @@ public void validate() { if (this.isActive) { throw new BadRequestException( ErrorCode.CANNOT_PERFORMED, - "이미 사용 가능한 사물함입니다." - ); + "이미 사용 가능한 사물함입니다."); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerIsDeactivatedValidator.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerIsDeactivatedValidator.java index 96edf9e9b..acc9332b0 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerIsDeactivatedValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerIsDeactivatedValidator.java @@ -20,8 +20,7 @@ public void validate() { if (!this.isActive) { throw new BadRequestException( ErrorCode.CANNOT_PERFORMED, - "사물함이 사용 불가능한 상태입니다." - ); + "사물함이 사용 불가능한 상태입니다."); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerTimePassedValidator.java b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerTimePassedValidator.java index cc5211f7b..f1b8daacd 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerTimePassedValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/asset/locker/util/LockerTimePassedValidator.java @@ -26,20 +26,18 @@ public void validate() { if (duration.getSeconds() < StaticValue.JWT_ACCESS_THRESHOLD) { LocalDateTime allowedTime = this.updatedAt.plusSeconds(StaticValue.JWT_ACCESS_THRESHOLD); - String message = - "24시간 이내에 사물함 신청 내역이 있습니다." + - allowedTime.getYear() + "-" + - allowedTime.getMonthValue() + "-" + - allowedTime.getDayOfMonth() + " " + - allowedTime.getHour() + ":" + - allowedTime.getMinute() + ":" + - allowedTime.getSecond() + - " 이후에 다시 시도해주세요."; + String message = "24시간 이내에 사물함 신청 내역이 있습니다." + + allowedTime.getYear() + "-" + + allowedTime.getMonthValue() + "-" + + allowedTime.getDayOfMonth() + " " + + allowedTime.getHour() + ":" + + allowedTime.getMinute() + ":" + + allowedTime.getSecond() + + " 이후에 다시 시도해주세요."; throw new BadRequestException( ErrorCode.TIME_NOT_PASSED, - message - ); + message); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/campus/circle/entity/Circle.java b/app-main/src/main/java/net/causw/app/main/domain/campus/circle/entity/Circle.java index e0afd9f70..922ed6188 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/campus/circle/entity/Circle.java +++ b/app-main/src/main/java/net/causw/app/main/domain/campus/circle/entity/Circle.java @@ -77,8 +77,7 @@ public static Circle of( Integer recruitMembers, User leader, LocalDateTime recruitEndDate, - Boolean isRecruit - ) { + Boolean isRecruit) { Circle circle = Circle.builder() .name(name) .description(description) @@ -96,8 +95,7 @@ public static Circle of( CircleMainImage circleMainImage = CircleMainImage.of( circle, - uuidFile - ); + uuidFile); circle.setCircleMainImage(circleMainImage); diff --git a/app-main/src/main/java/net/causw/app/main/domain/campus/circle/entity/CircleMember.java b/app-main/src/main/java/net/causw/app/main/domain/campus/circle/entity/CircleMember.java index aee3b7ef5..65d97e255 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/campus/circle/entity/CircleMember.java +++ b/app-main/src/main/java/net/causw/app/main/domain/campus/circle/entity/CircleMember.java @@ -1,8 +1,8 @@ package net.causw.app.main.domain.campus.circle.entity; +import net.causw.app.main.domain.campus.circle.enums.CircleMemberStatus; import net.causw.app.main.domain.community.form.entity.Form; import net.causw.app.main.domain.community.form.entity.Reply; -import net.causw.app.main.domain.campus.circle.enums.CircleMemberStatus; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.shared.entity.BaseEntity; @@ -60,8 +60,7 @@ public static CircleMember of( Circle circle, User user, Form form, - Reply reply - ) { + Reply reply) { return CircleMember.builder() .status(CircleMemberStatus.AWAIT) .circle(circle) diff --git a/app-main/src/main/java/net/causw/app/main/domain/campus/circle/repository/CircleMemberRepository.java b/app-main/src/main/java/net/causw/app/main/domain/campus/circle/repository/CircleMemberRepository.java index eb9f2b0fe..617bcdc83 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/campus/circle/repository/CircleMemberRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/campus/circle/repository/CircleMemberRepository.java @@ -24,5 +24,6 @@ public interface CircleMemberRepository extends JpaRepository findCircleByUserId(String userId) { .filter(circleMember -> circleMember.getStatus().equals(CircleMemberStatus.MEMBER)) .collect(Collectors.toMap( circleMember -> circleMember.getCircle().getId(), - circleMember -> circleMember - )); + circleMember -> circleMember)); } public List getCircleListByUserId(String userId) { @@ -69,8 +68,7 @@ public CircleMember create(User user, Circle circle, Reply reply) { circle, user, reply.getForm(), - reply - )); + reply)); } public Optional updateStatus(String applicationId, CircleMemberStatus targetStatus) { @@ -79,7 +77,6 @@ public Optional updateStatus(String applicationId, CircleMemberSta circleMember.setStatus(targetStatus); return this.circleMemberRepository.save(circleMember); - } - ); + }); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/campus/circle/service/CircleService.java b/app-main/src/main/java/net/causw/app/main/domain/campus/circle/service/CircleService.java index 41c83bcaa..24342908d 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/campus/circle/service/CircleService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/campus/circle/service/CircleService.java @@ -19,26 +19,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import net.causw.app.main.core.aop.annotation.MeasureTime; -import net.causw.app.main.domain.asset.file.entity.UuidFile; -import net.causw.app.main.domain.asset.file.entity.joinEntity.CircleMainImage; -import net.causw.app.main.domain.community.board.entity.Board; -import net.causw.app.main.domain.community.board.repository.BoardRepository; -import net.causw.app.main.domain.community.form.entity.Form; -import net.causw.app.main.domain.community.form.entity.FormQuestion; -import net.causw.app.main.domain.community.form.entity.FormQuestionOption; -import net.causw.app.main.domain.community.form.entity.Reply; -import net.causw.app.main.domain.community.form.entity.ReplyQuestion; -import net.causw.app.main.domain.community.form.enums.QuestionType; -import net.causw.app.main.domain.community.form.enums.RegisteredSemester; -import net.causw.app.main.domain.community.form.repository.FormRepository; -import net.causw.app.main.domain.community.form.repository.QuestionRepository; -import net.causw.app.main.domain.community.form.repository.ReplyRepository; -import net.causw.app.main.domain.community.post.entity.Post; -import net.causw.app.main.domain.community.post.repository.PostRepository; -import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFee; -import net.causw.app.main.domain.finance.usercouncilfee.repository.UserCouncilFeeRepository; -import net.causw.app.main.domain.integration.export.service.CircleExcelService; import net.causw.app.main.api.dto.board.BoardOfCircleResponseDto; import net.causw.app.main.api.dto.circle.CircleBoardsResponseDto; import net.causw.app.main.api.dto.circle.CircleCreateRequestDto; @@ -58,19 +38,36 @@ import net.causw.app.main.api.dto.user.UserResponseDto; import net.causw.app.main.api.dto.util.dtoMapper.CircleDtoMapper; import net.causw.app.main.api.dto.util.dtoMapper.FormDtoMapper; +import net.causw.app.main.core.aop.annotation.MeasureTime; +import net.causw.app.main.domain.asset.file.entity.UuidFile; +import net.causw.app.main.domain.asset.file.entity.joinEntity.CircleMainImage; +import net.causw.app.main.domain.asset.file.enums.FilePath; +import net.causw.app.main.domain.asset.file.repository.CircleMainImageRepository; +import net.causw.app.main.domain.asset.file.service.UuidFileService; import net.causw.app.main.domain.campus.circle.entity.Circle; import net.causw.app.main.domain.campus.circle.entity.CircleMember; import net.causw.app.main.domain.campus.circle.enums.CircleMemberStatus; -import net.causw.app.main.domain.asset.file.enums.FilePath; -import net.causw.app.main.shared.StatusPolicy; -import net.causw.app.main.domain.finance.usercouncilfee.policy.UserCouncilFeePolicy; import net.causw.app.main.domain.campus.circle.repository.CircleMemberRepository; import net.causw.app.main.domain.campus.circle.repository.CircleRepository; -import net.causw.app.main.domain.asset.file.repository.CircleMainImageRepository; -import net.causw.app.main.domain.asset.file.service.UuidFileService; import net.causw.app.main.domain.campus.circle.util.CircleMemberStatusValidator; -import net.causw.app.main.shared.util.ConstraintValidator; -import net.causw.app.main.shared.util.TargetIsDeletedValidator; +import net.causw.app.main.domain.community.board.entity.Board; +import net.causw.app.main.domain.community.board.repository.BoardRepository; +import net.causw.app.main.domain.community.form.entity.Form; +import net.causw.app.main.domain.community.form.entity.FormQuestion; +import net.causw.app.main.domain.community.form.entity.FormQuestionOption; +import net.causw.app.main.domain.community.form.entity.Reply; +import net.causw.app.main.domain.community.form.entity.ReplyQuestion; +import net.causw.app.main.domain.community.form.enums.QuestionType; +import net.causw.app.main.domain.community.form.enums.RegisteredSemester; +import net.causw.app.main.domain.community.form.repository.FormRepository; +import net.causw.app.main.domain.community.form.repository.QuestionRepository; +import net.causw.app.main.domain.community.form.repository.ReplyRepository; +import net.causw.app.main.domain.community.post.entity.Post; +import net.causw.app.main.domain.community.post.repository.PostRepository; +import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFee; +import net.causw.app.main.domain.finance.usercouncilfee.policy.UserCouncilFeePolicy; +import net.causw.app.main.domain.finance.usercouncilfee.repository.UserCouncilFeeRepository; +import net.causw.app.main.domain.integration.export.service.CircleExcelService; import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.enums.user.Role; @@ -81,7 +78,10 @@ import net.causw.app.main.domain.user.account.util.UserRoleIsNoneValidator; import net.causw.app.main.domain.user.account.util.UserRoleValidator; import net.causw.app.main.domain.user.account.util.UserStateValidator; +import net.causw.app.main.shared.StatusPolicy; import net.causw.app.main.shared.ValidatorBucket; +import net.causw.app.main.shared.util.ConstraintValidator; +import net.causw.app.main.shared.util.TargetIsDeletedValidator; import net.causw.app.main.shared.util.UserEqualValidator; import net.causw.global.constant.MessageUtil; import net.causw.global.constant.StaticValue; @@ -131,8 +131,7 @@ public List findAll(User user) { .filter(circleMember -> circleMember.getStatus().equals(CircleMemberStatus.MEMBER)) .collect(Collectors.toMap( circleMember -> circleMember.getCircle().getId(), - circleMember -> circleMember - )); + circleMember -> circleMember)); return circleRepository.findAll() .stream() @@ -141,20 +140,17 @@ public List findAll(User user) { return this.toCirclesResponseDtoExtended( circle, getCircleNumMember(circle.getId()), - LocalDateTime.now() - ); + LocalDateTime.now()); } else { if (joinedCircleMap.containsKey(circle.getId())) { return this.toCirclesResponseDtoExtended( circle, getCircleNumMember(circle.getId()), - joinedCircleMap.get(circle.getId()).getUpdatedAt() - ); + joinedCircleMap.get(circle.getId()).getUpdatedAt()); } else { return this.toCirclesResponseDto( circle, - getCircleNumMember(circle.getId()) - ); + getCircleNumMember(circle.getId())); } } }).collect(Collectors.toList()); @@ -163,8 +159,7 @@ public List findAll(User user) { @Transactional(readOnly = true) public CircleBoardsResponseDto findBoards( User user, - String circleId - ) { + String circleId) { Set roles = user.getRoles(); Circle circle = getCircle(circleId); @@ -179,15 +174,12 @@ public CircleBoardsResponseDto findBoards( .orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.CIRCLE_APPLY_INVALID - ) - ); + MessageUtil.CIRCLE_APPLY_INVALID)); ValidatorBucket.of() .consistOf(CircleMemberStatusValidator.of( circleMember.getStatus(), - List.of(CircleMemberStatus.MEMBER) - )) + List.of(CircleMemberStatus.MEMBER))) .validate(); } @@ -201,14 +193,12 @@ public CircleBoardsResponseDto findBoards( board, roles, post, - postRepository.countAllCommentByPost_Id(post.getId()) - )).orElse( + postRepository.countAllCommentByPost_Id(post.getId()))) + .orElse( this.toBoardOfCircleResponseDto( board, - roles - )) - ).collect(Collectors.toList()) - ); + roles))) + .collect(Collectors.toList())); } @Transactional(readOnly = true) @@ -220,8 +210,7 @@ public Long getNumMember(String id) { public List getUserList( User user, String circleId, - CircleMemberStatus status - ) { + CircleMemberStatus status) { Set roles = user.getRoles(); Circle circle = getCircle(circleId); @@ -246,10 +235,8 @@ public List getUserList( userRepository.findById(circleMember.getUser().getId()).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - ) - ) - )).collect(Collectors.toList()); + MessageUtil.USER_NOT_FOUND)))) + .collect(Collectors.toList()); } @Transactional(readOnly = true) @@ -265,10 +252,8 @@ public List getMemberList(String circleId) { userRepository.findById(circleMember.getUser().getId()).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - ) - ) - )).collect(Collectors.toList()); + MessageUtil.USER_NOT_FOUND)))) + .collect(Collectors.toList()); } @Transactional @@ -276,12 +261,9 @@ public void create(CircleCreateRequestDto circleCreateRequestDto, MultipartFile User leader = userRepository.findById(circleCreateRequestDto.getLeaderId()) .orElseThrow(() -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.NEW_CIRCLE_LEADER_NOT_FOUND) - ); + MessageUtil.NEW_CIRCLE_LEADER_NOT_FOUND)); - UuidFile uuidFile = (mainImage == null) ? - null : - uuidFileService.saveFile(mainImage, FilePath.CIRCLE_PROFILE); + UuidFile uuidFile = (mainImage == null) ? null : uuidFileService.saveFile(mainImage, FilePath.CIRCLE_PROFILE); Circle circle = Circle.of( circleCreateRequestDto.getName(), @@ -292,8 +274,7 @@ public void create(CircleCreateRequestDto circleCreateRequestDto, MultipartFile circleCreateRequestDto.getRecruitMembers(), leader, circleCreateRequestDto.getRecruitEndDate(), - circleCreateRequestDto.getIsRecruit() - ); + circleCreateRequestDto.getIsRecruit()); /* Check if the request user is president or admin * Then, validate the circle name whether it is duplicated or not @@ -302,10 +283,8 @@ public void create(CircleCreateRequestDto circleCreateRequestDto, MultipartFile name -> { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.CIRCLE_DUPLICATE_NAME - ); - } - ); + MessageUtil.CIRCLE_DUPLICATE_NAME); + }); // Grant role to the LEADER leader = updateRole(leader, Role.LEADER_CIRCLE); @@ -326,8 +305,7 @@ public void create(CircleCreateRequestDto circleCreateRequestDto, MultipartFile "동아리 공지 게시판", false, false, - circle - ); + circle); boardRepository.save(noticeBoard); // Apply the leader automatically to the circle @@ -335,8 +313,7 @@ public void create(CircleCreateRequestDto circleCreateRequestDto, MultipartFile circle, leader, null, - null - )); + null)); updateCircleMemberStatus(circleMember.getId(), CircleMemberStatus.MEMBER); } @@ -346,8 +323,7 @@ public CircleResponseDto update( User user, String circleId, CircleUpdateRequestDto circleUpdateRequestDto, - MultipartFile mainImage - ) { + MultipartFile mainImage) { Circle circle = getCircle(circleId); Set roles = user.getRoles(); @@ -356,10 +332,8 @@ public CircleResponseDto update( name -> { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.CIRCLE_DUPLICATE_NAME - ); - } - ); + MessageUtil.CIRCLE_DUPLICATE_NAME); + }); } ValidatorBucket validatorBucket = ValidatorBucket.of(); @@ -371,15 +345,13 @@ public CircleResponseDto update( .consistOf(ConstraintValidator.of(circle, this.validator)) .consistOf(UserRoleValidator.of( roles, - Set.of(Role.LEADER_CIRCLE) - )); + Set.of(Role.LEADER_CIRCLE))); if (roles.contains(Role.LEADER_CIRCLE)) { validatorBucket .consistOf(UserEqualValidator.of( getCircleLeader(circle).getId(), - user.getId() - )); + user.getId())); } validatorBucket @@ -396,16 +368,13 @@ public CircleResponseDto update( if (circleMainImage == null) { circleMainImage = CircleMainImage.of( circle, - uuidFileService.saveFile(mainImage, FilePath.CIRCLE_PROFILE) - ); + uuidFileService.saveFile(mainImage, FilePath.CIRCLE_PROFILE)); } else { circleMainImage.setUuidFile( uuidFileService.updateFile( circle.getCircleMainImage().getUuidFile(), mainImage, - FilePath.CIRCLE_PROFILE - ) - ); + FilePath.CIRCLE_PROFILE)); } } @@ -416,8 +385,7 @@ public CircleResponseDto update( circleUpdateRequestDto.getCircleTax(), circleUpdateRequestDto.getRecruitMembers(), circleUpdateRequestDto.getRecruitEndDate(), - circleUpdateRequestDto.getIsRecruit() - ); + circleUpdateRequestDto.getIsRecruit()); return this.toCircleResponseDto(circleRepository.save(circle)); } @@ -425,8 +393,7 @@ public CircleResponseDto update( @Transactional public CircleResponseDto delete( User user, - String circleId - ) { + String circleId) { Circle circle = getCircle(circleId); Set roles = user.getRoles(); @@ -438,22 +405,19 @@ public CircleResponseDto delete( .consistOf(TargetIsDeletedValidator.of(circle.getIsDeleted(), StaticValue.DOMAIN_CIRCLE)) .consistOf(UserRoleValidator.of( roles, - Set.of(Role.LEADER_CIRCLE) - )); + Set.of(Role.LEADER_CIRCLE))); if (roles.contains(Role.LEADER_CIRCLE)) { User leader = circle.getLeader().orElse(null); if (leader == null) { throw new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.CIRCLE_WITHOUT_LEADER - ); + MessageUtil.CIRCLE_WITHOUT_LEADER); } validatorBucket .consistOf(UserEqualValidator.of( leader.getId(), - user.getId() - )); + user.getId())); } validatorBucket @@ -471,9 +435,7 @@ public CircleResponseDto delete( CircleResponseDto circleResponseDto = this.toCircleResponseDto(deleteCircle(circleId).orElseThrow( () -> new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.INTERNAL_SERVER_ERROR - ) - )); + MessageUtil.INTERNAL_SERVER_ERROR))); deleteAllCircleBoard(circleId); @@ -505,8 +467,7 @@ public void userApply(User user, String circleId, FormReplyRequestDto formReplyR circle, user, null, - null - )); + null)); if (circleMember.getStatus().equals(CircleMemberStatus.REJECT)) { circleMember.setStatus(CircleMemberStatus.AWAIT); @@ -515,8 +476,7 @@ public void userApply(User user, String circleId, FormReplyRequestDto formReplyR Reply reply = this.replyForm( this.getForm(circle), formReplyRequestDto, - user - ); + user); circleMember.setAppliedForm(reply.getForm()); circleMember.setAppliedReply(reply); @@ -541,9 +501,7 @@ public CircleMemberResponseDto leaveUser(User user, String circleId) { .orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.CIRCLE_APPLY_INVALID - ) - ); + MessageUtil.CIRCLE_APPLY_INVALID)); ValidatorBucket.of() .consistOf(UserStateValidator.of(user.getState())) @@ -551,27 +509,23 @@ public CircleMemberResponseDto leaveUser(User user, String circleId) { .consistOf(TargetIsDeletedValidator.of(circleMember.getCircle().getIsDeleted(), StaticValue.DOMAIN_CIRCLE)) .consistOf(CircleMemberStatusValidator.of( circleMember.getStatus(), - List.of(CircleMemberStatus.MEMBER) - )) + List.of(CircleMemberStatus.MEMBER))) .consistOf(UserNotEqualValidator.of( getCircleLeader(circle).getId(), - user.getId()) - ) + user.getId())) .validate(); return this.toCircleMemberResponseDto( updateCircleMemberStatus(circleMember.getId(), CircleMemberStatus.LEAVE), circle, - user - ); + user); } @Transactional public CircleMemberResponseDto dropUser( User requestUser, String userId, - String circleId - ) { + String circleId) { Set roles = requestUser.getRoles(); User user = getUser(userId); @@ -581,9 +535,7 @@ public CircleMemberResponseDto dropUser( CircleMember circleMember = circleMemberRepository.findByUser_IdAndCircle_Id(userId, circleId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.CIRCLE_APPLY_INVALID - ) - ); + MessageUtil.CIRCLE_APPLY_INVALID)); ValidatorBucket validatorBucket = ValidatorBucket.of(); validatorBucket @@ -597,15 +549,13 @@ public CircleMemberResponseDto dropUser( validatorBucket .consistOf(UserEqualValidator.of( getCircleLeader(circle).getId(), - requestUser.getId() - )); + requestUser.getId())); } validatorBucket .consistOf(CircleMemberStatusValidator.of( circleMember.getStatus(), - List.of(CircleMemberStatus.MEMBER) - )) + List.of(CircleMemberStatus.MEMBER))) .consistOf(UserNotEqualValidator.of( getCircleLeader(circle).getId(), userId)) @@ -614,8 +564,7 @@ public CircleMemberResponseDto dropUser( return this.toCircleMemberResponseDto( updateCircleMemberStatus(circleMember.getId(), CircleMemberStatus.DROP), circle, - user - ); + user); } @Transactional @@ -623,8 +572,7 @@ public CircleMemberResponseDto acceptUser(User requestUser, String applicationId return this.updateUserApplication( requestUser, applicationId, - CircleMemberStatus.MEMBER - ); + CircleMemberStatus.MEMBER); } @Transactional @@ -632,23 +580,19 @@ public CircleMemberResponseDto rejectUser(User requestUser, String applicationId return updateUserApplication( requestUser, applicationId, - CircleMemberStatus.REJECT - ); + CircleMemberStatus.REJECT); } private CircleMemberResponseDto updateUserApplication( User requestUser, String applicationId, - CircleMemberStatus targetStatus - ) { + CircleMemberStatus targetStatus) { Set roles = requestUser.getRoles(); CircleMember circleMember = circleMemberRepository.findById(applicationId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_APPLY_NOT_FOUND - ) - ); + MessageUtil.USER_APPLY_NOT_FOUND)); User user = getUser(circleMember.getUser().getId()); @@ -670,15 +614,13 @@ private CircleMemberResponseDto updateUserApplication( validatorBucket .consistOf(CircleMemberStatusValidator.of( circleMember.getStatus(), - List.of(CircleMemberStatus.AWAIT) - )) + List.of(CircleMemberStatus.AWAIT))) .validate(); return this.toCircleMemberResponseDto( updateCircleMemberStatus(applicationId, targetStatus), circleMember.getCircle(), - user - ); + user); } @Transactional @@ -693,9 +635,7 @@ public CircleMemberResponseDto restoreUser(User loginUser, String circleId, Stri .orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.CIRCLE_APPLY_INVALID - ) - ); + MessageUtil.CIRCLE_APPLY_INVALID)); ValidatorBucket validatorBucket = ValidatorBucket.of(); validatorBucket @@ -706,19 +646,17 @@ public CircleMemberResponseDto restoreUser(User loginUser, String circleId, Stri Set.of(Role.LEADER_CIRCLE))) .consistOf(UserEqualValidator.of( loginUser.getId(), - getCircleLeader(circle).getId() - )); + getCircleLeader(circle).getId())); validatorBucket .consistOf(CircleMemberStatusValidator.of( restoreTargetMember.getStatus(), - List.of(CircleMemberStatus.DROP) - )).validate(); + List.of(CircleMemberStatus.DROP))) + .validate(); return this.toCircleMemberResponseDto( updateCircleMemberStatus(restoreTargetMember.getId(), CircleMemberStatus.MEMBER), circle, - targetUser - ); + targetUser); } @Transactional(readOnly = true) @@ -729,24 +667,19 @@ public void exportCircleMembersToExcel(String circleId, HttpServletResponse resp LinkedHashMap> sheetNameDataMap = new LinkedHashMap<>(); sheetNameDataMap.put( "활성 동아리원", - getExportCircleMemberToExcelResponseDtoListByMemberStatus(circleId, CircleMemberStatus.MEMBER) - ); + getExportCircleMemberToExcelResponseDtoListByMemberStatus(circleId, CircleMemberStatus.MEMBER)); sheetNameDataMap.put( "가입 대기 동아리원", - getExportCircleMemberToExcelResponseDtoListByMemberStatus(circleId, CircleMemberStatus.AWAIT) - ); + getExportCircleMemberToExcelResponseDtoListByMemberStatus(circleId, CircleMemberStatus.AWAIT)); sheetNameDataMap.put( "거절 동아리원", - getExportCircleMemberToExcelResponseDtoListByMemberStatus(circleId, CircleMemberStatus.REJECT) - ); + getExportCircleMemberToExcelResponseDtoListByMemberStatus(circleId, CircleMemberStatus.REJECT)); sheetNameDataMap.put( "탈퇴 동아리원", - getExportCircleMemberToExcelResponseDtoListByMemberStatus(circleId, CircleMemberStatus.LEAVE) - ); + getExportCircleMemberToExcelResponseDtoListByMemberStatus(circleId, CircleMemberStatus.LEAVE)); sheetNameDataMap.put( "추방 동아리원", - getExportCircleMemberToExcelResponseDtoListByMemberStatus(circleId, CircleMemberStatus.DROP) - ); + getExportCircleMemberToExcelResponseDtoListByMemberStatus(circleId, CircleMemberStatus.DROP)); String fileName = circleName + "_부원명단"; @@ -768,8 +701,7 @@ public void exportCircleMembersToExcel(String circleId, HttpServletResponse resp "학생회비 납부 차수", "적용 학생회비 학기", "잔여 학생회비 적용 학기", - "학생회비 환불 여부" - ); + "학생회비 환불 여부"); circleExcelService.generateExcel(response, fileName, headerStringList, sheetNameDataMap); } @@ -781,9 +713,7 @@ public void createApplicationForm(User writer, String circleId, FormCreateReques .orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.CIRCLE_APPLY_INVALID - ) - ); + MessageUtil.CIRCLE_APPLY_INVALID)); ValidatorBucket.of() .consistOf(UserEqualValidator.of( @@ -791,18 +721,16 @@ public void createApplicationForm(User writer, String circleId, FormCreateReques writer.getId())) .consistOf(CircleMemberStatusValidator.of( circleMember.getStatus(), - List.of(CircleMemberStatus.MEMBER) - )) + List.of(CircleMemberStatus.MEMBER))) .validate(); List
priorFormList = formRepository.findAllByCircleAndIsDeleted(circle, false); if (!priorFormList.isEmpty()) { priorFormList.forEach(form -> { - form.setIsClosed(true); - form.setIsDeleted(true); - } - ); + form.setIsClosed(true); + form.setIsDeleted(true); + }); formRepository.saveAll(priorFormList); } @@ -823,9 +751,7 @@ public Boolean isCircleApplicationFormExist(String circleId) { public FormResponseDto getCircleApplicationForm(String circleId) { return this.toFormResponseDto( this.getForm( - getCircle(circleId) - ) - ); + getCircle(circleId))); } public Page getAllCircleApplicationFormList(User user, String circleId, Pageable pageable) { @@ -839,8 +765,7 @@ public Page getAllCircleApplicationFormList(User user, String c .consistOf(TargetIsDeletedValidator.of(circle.getIsDeleted(), StaticValue.DOMAIN_CIRCLE)) .consistOf(UserEqualValidator.of( getCircleLeader(circle).getId(), - user.getId() - )) + user.getId())) .validate(); return formRepository.findAllByCircle(circle, pageable) @@ -852,9 +777,7 @@ private Circle getCircle(String circleId) { return circleRepository.findById(circleId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.SMALL_CLUB_NOT_FOUND - ) - ); + MessageUtil.SMALL_CLUB_NOT_FOUND)); } private Optional deleteCircle(String id) { @@ -862,8 +785,7 @@ private Optional deleteCircle(String id) { srcCircle -> { srcCircle.delete(); return circleRepository.save(srcCircle); - } - ); + }); } private Long getCircleNumMember(String circleId) { @@ -876,13 +798,10 @@ private CircleMember updateCircleMemberStatus(String applicationId, CircleMember circleMember -> { circleMember.setStatus(targetStatus); return circleMemberRepository.save(circleMember); - } - ).orElseThrow( - () -> new BadRequestException( - ErrorCode.INTERNAL_SERVER, - MessageUtil.INTERNAL_SERVER_ERROR - ) - ); + }).orElseThrow( + () -> new BadRequestException( + ErrorCode.INTERNAL_SERVER, + MessageUtil.INTERNAL_SERVER_ERROR)); } // Entity or Entity Information CRUD - User @@ -890,9 +809,7 @@ private User getUser(String userId) { return userRepository.findById(userId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - ) - ); + MessageUtil.USER_NOT_FOUND)); } private User getCircleLeader(Circle circle) { @@ -901,16 +818,13 @@ private User getCircleLeader(Circle circle) { if (leader == null) { throw new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.CIRCLE_WITHOUT_LEADER - ); + MessageUtil.CIRCLE_WITHOUT_LEADER); } return userRepository.findById(leader.getId()).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - ) - ); + MessageUtil.USER_NOT_FOUND)); } private User updateRole(User targetUser, Role newRole) { @@ -941,8 +855,7 @@ private Form getForm(Circle circle) { if (formList.size() != 1) { throw new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.INTERNAL_SERVER_ERROR - ); + MessageUtil.INTERNAL_SERVER_ERROR); } return formList.get(0); @@ -958,10 +871,9 @@ private List deleteAllCircleBoard(String circleId) { return boardRepository.save(srcBoard); }).orElseThrow( - () -> new InternalServerException( - ErrorCode.INTERNAL_SERVER, - MessageUtil.INTERNAL_SERVER_ERROR - )); + () -> new InternalServerException( + ErrorCode.INTERNAL_SERVER, + MessageUtil.INTERNAL_SERVER_ERROR)); } return boardList; } @@ -974,8 +886,7 @@ private Form generateForm(FormCreateRequestDto formCreateRequestDto, Circle circ Form form = Form.createCircleApplicationForm( formCreateRequestDto, formQuestionList, - circle - ); + circle); formQuestionList.forEach(question -> question.setForm(form)); @@ -989,8 +900,7 @@ private static void validFormInfo(FormCreateRequestDto formCreateRequestDto) { if (formCreateRequestDto.getIsNeedCouncilFeePaid() == null) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.IS_NEED_COUNCIL_FEE_REQUIRED - ); + MessageUtil.IS_NEED_COUNCIL_FEE_REQUIRED); } // enrolledRegisteredSemesterList가 null이거나 비어있는 경우 예외 처리 @@ -998,20 +908,17 @@ private static void validFormInfo(FormCreateRequestDto formCreateRequestDto) { formCreateRequestDto.getEnrolledRegisteredSemesterList().isEmpty()) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_REGISTERED_SEMESTER_INFO - ); + MessageUtil.INVALID_REGISTERED_SEMESTER_INFO); } } // isAllowedLeaveOfAbsence가 false이고 isAllowedLeaveOfAbsence가 false인 경우 예외 처리 if (formCreateRequestDto.getIsAllowedLeaveOfAbsence() && (formCreateRequestDto.getLeaveOfAbsenceRegisteredSemesterList() == null || - formCreateRequestDto.getLeaveOfAbsenceRegisteredSemesterList().isEmpty()) - ) { + formCreateRequestDto.getLeaveOfAbsenceRegisteredSemesterList().isEmpty())) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_REGISTERED_SEMESTER_INFO - ); + MessageUtil.INVALID_REGISTERED_SEMESTER_INFO); } } @@ -1022,8 +929,7 @@ private List generateFormQuestionList(FormCreateRequestDto formCre || formCreateRequestDto.getQuestionCreateRequestDtoList().isEmpty()) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.EMPTY_QUESTION_INFO - ); + MessageUtil.EMPTY_QUESTION_INFO); } AtomicReference questionNumber = new AtomicReference<>(1); @@ -1038,12 +944,10 @@ private List generateFormQuestionList(FormCreateRequestDto formCre if (questionCreateRequestDto.getQuestionType().equals(QuestionType.OBJECTIVE)) { if (questionCreateRequestDto.getIsMultiple() == null || (questionCreateRequestDto.getOptionCreateRequestDtoList() == null || - questionCreateRequestDto.getOptionCreateRequestDtoList().isEmpty()) - ) { + questionCreateRequestDto.getOptionCreateRequestDtoList().isEmpty())) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_QUESTION_INFO - ); + MessageUtil.INVALID_QUESTION_INFO); } List formQuestionOptionList = getFormQuestionOptionList( @@ -1052,20 +956,18 @@ private List generateFormQuestionList(FormCreateRequestDto formCre formQuestion = FormQuestion.createObjectiveQuestion( questionNumber.getAndSet(questionNumber.get() + 1), questionCreateRequestDto, - formQuestionOptionList - ); + formQuestionOptionList); formQuestionOptionList.forEach(option -> option.setFormQuestion(formQuestion)); } else { // 주관식일 때 formQuestion = FormQuestion.createSubjectQuestion( questionNumber.getAndSet(questionNumber.get() + 1), - questionCreateRequestDto - ); + questionCreateRequestDto); } return formQuestion; - } - ).toList(); + }) + .toList(); } @NotNull @@ -1076,8 +978,7 @@ private static List getFormQuestionOptionList( || questionCreateRequestDto.getOptionCreateRequestDtoList().isEmpty()) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.EMPTY_OPTION_INFO - ); + MessageUtil.EMPTY_OPTION_INFO); } AtomicReference optionNumber = new AtomicReference<>(1); @@ -1088,21 +989,18 @@ private static List getFormQuestionOptionList( optionCreateRequestDto -> FormQuestionOption.of( optionNumber.getAndSet(optionNumber.get() + 1), optionCreateRequestDto.getOptionText(), - null - ) - ).toList(); + null)) + .toList(); } private Reply replyForm( Form form, FormReplyRequestDto formReplyRequestDto, - User writer - ) { + User writer) { if (form.getIsClosed()) { throw new BadRequestException( ErrorCode.NOT_ALLOWED_TO_REPLY_FORM, - MessageUtil.FORM_CLOSED - ); + MessageUtil.FORM_CLOSED); } this.validateToReply(writer, form); @@ -1118,15 +1016,13 @@ private Reply replyForm( if (questionReplyRequestDto.getQuestionReply() != null) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_REPLY_INFO - ); + MessageUtil.INVALID_REPLY_INFO); } if (!formQuestion.getIsMultiple() && questionReplyRequestDto.getSelectedOptionList().size() > 1) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_REPLY_INFO - ); + MessageUtil.INVALID_REPLY_INFO); } // 객관식일 시: 유효한 옵션 번호 선택했는지 검사 @@ -1139,8 +1035,7 @@ private Reply replyForm( if (!formQuestionOptionNumberList.contains(optionNumber)) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_REPLY_INFO - ); + MessageUtil.INVALID_REPLY_INFO); } }); } @@ -1149,20 +1044,18 @@ private Reply replyForm( if (questionReplyRequestDto.getSelectedOptionList() != null) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_REPLY_INFO - ); + MessageUtil.INVALID_REPLY_INFO); } } ReplyQuestion replyQuestion = ReplyQuestion.of( formQuestion, - formQuestion.getQuestionType().equals(QuestionType.SUBJECTIVE) ? - questionReplyRequestDto.getQuestionReply() + formQuestion.getQuestionType().equals(QuestionType.SUBJECTIVE) + ? questionReplyRequestDto.getQuestionReply() : null, - formQuestion.getQuestionType().equals(QuestionType.OBJECTIVE) ? - questionReplyRequestDto.getSelectedOptionList() - : null - ); + formQuestion.getQuestionType().equals(QuestionType.OBJECTIVE) + ? questionReplyRequestDto.getSelectedOptionList() + : null); replyQuestionList.add(replyQuestion); } @@ -1171,8 +1064,7 @@ private Reply replyForm( if (replyQuestionList.size() != form.getFormQuestionList().size()) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.REPLY_SIZE_INVALID - ); + MessageUtil.REPLY_SIZE_INVALID); } // 모든 문항에 대해 답변 정확히 하나 있는지 검사(답변 유효성 검사) @@ -1186,8 +1078,7 @@ private Reply replyForm( if (questionReplyCount != 1) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_REPLY_INFO - ); + MessageUtil.INVALID_REPLY_INFO); } }); @@ -1212,23 +1103,19 @@ private void validateToReply(User writer, Form form) { if (!allowedAcademicStatus.contains(writer.getAcademicStatus())) { throw new BadRequestException( ErrorCode.NOT_ALLOWED_TO_REPLY_FORM, - MessageUtil.NOT_ALLOWED_TO_REPLY_FORM - ); + MessageUtil.NOT_ALLOWED_TO_REPLY_FORM); } else { if (allowedAcademicStatus.contains(AcademicStatus.ENROLLED) - && writer.getAcademicStatus().equals(AcademicStatus.ENROLLED) - ) { + && writer.getAcademicStatus().equals(AcademicStatus.ENROLLED)) { EnumSet allowedRegisteredSemester = form.getEnrolledRegisteredSemester(); if (!allowedRegisteredSemester .stream() .map(RegisteredSemester::getSemester) .collect(Collectors.toSet()) - .contains(writer.getCurrentCompletedSemester()) - ) { + .contains(writer.getCurrentCompletedSemester())) { throw new BadRequestException( ErrorCode.NOT_ALLOWED_TO_REPLY_FORM, - MessageUtil.NOT_ALLOWED_TO_REPLY_FORM - ); + MessageUtil.NOT_ALLOWED_TO_REPLY_FORM); } if (form.getIsNeedCouncilFeePaid()) { @@ -1236,33 +1123,27 @@ private void validateToReply(User writer, Form form) { UserCouncilFee userCouncilFee = userCouncilFeeRepository.findByUser(writer).orElseThrow( () -> new BadRequestException( ErrorCode.NOT_ALLOWED_TO_REPLY_FORM, - MessageUtil.NOT_ALLOWED_TO_REPLY_FORM - ) - ); + MessageUtil.NOT_ALLOWED_TO_REPLY_FORM)); if (!UserCouncilFeePolicy.isAppliedCurrentSemesterWithUser(userCouncilFee)) { throw new BadRequestException( ErrorCode.NOT_ALLOWED_TO_REPLY_FORM, - MessageUtil.NOT_ALLOWED_TO_REPLY_FORM - ); + MessageUtil.NOT_ALLOWED_TO_REPLY_FORM); } } } if (allowedAcademicStatus.contains(AcademicStatus.LEAVE_OF_ABSENCE) - && writer.getAcademicStatus().equals(AcademicStatus.LEAVE_OF_ABSENCE) - ) { + && writer.getAcademicStatus().equals(AcademicStatus.LEAVE_OF_ABSENCE)) { EnumSet allowedRegisteredSemester = form.getLeaveOfAbsenceRegisteredSemester(); if (!allowedRegisteredSemester .stream() .map(RegisteredSemester::getSemester) .collect(Collectors.toSet()) - .contains(writer.getCurrentCompletedSemester()) - ) { + .contains(writer.getCurrentCompletedSemester())) { throw new BadRequestException( ErrorCode.NOT_ALLOWED_TO_REPLY_FORM, - MessageUtil.NOT_ALLOWED_TO_REPLY_FORM - ); + MessageUtil.NOT_ALLOWED_TO_REPLY_FORM); } } } @@ -1272,9 +1153,7 @@ private FormQuestion getQuestion(String questionId) { return questionRepository.findById(questionId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.QUESTION_NOT_FOUND - ) - ); + MessageUtil.QUESTION_NOT_FOUND)); } // ValidatorBucket Constructor @@ -1301,22 +1180,20 @@ private List getExportCircleMemberToExcelR return circleMemberRepository.findByCircle_IdAndStatus(circleId, circleMemberStatus) .stream() .map(circleMember -> { - User srcUser = circleMember.getUser(); - UserCouncilFee userCouncilFee = userCouncilFeeRepository.findByUser(srcUser) - .orElse(null); - - if (userCouncilFee == null) { - return this.toExportCircleMemberToExcelResponseDtoReduced(srcUser); - } + User srcUser = circleMember.getUser(); + UserCouncilFee userCouncilFee = userCouncilFeeRepository.findByUser(srcUser) + .orElse(null); - return this.toExportCircleMemberToExcelResponseDto( - srcUser, - userCouncilFee, - UserCouncilFeePolicy.getRemainingAppliedSemestersWithUser(userCouncilFee), - UserCouncilFeePolicy.isAppliedCurrentSemesterWithUser(userCouncilFee) - ); + if (userCouncilFee == null) { + return this.toExportCircleMemberToExcelResponseDtoReduced(srcUser); } - ).toList(); + + return this.toExportCircleMemberToExcelResponseDto( + srcUser, + userCouncilFee, + UserCouncilFeePolicy.getRemainingAppliedSemestersWithUser(userCouncilFee), + UserCouncilFeePolicy.isAppliedCurrentSemesterWithUser(userCouncilFee)); + }).toList(); } // Dto Mapper @@ -1344,8 +1221,7 @@ private CirclesResponseDto toCirclesResponseDtoExtended(Circle circle, Long numM private BoardOfCircleResponseDto toBoardOfCircleResponseDto(Board board, Set userRoles) { return CircleDtoMapper.INSTANCE.toBoardOfCircleResponseDto( board, - BoardOfCircleResponseDto.isWriteable(board, userRoles) - ); + BoardOfCircleResponseDto.isWriteable(board, userRoles)); } private BoardOfCircleResponseDto toBoardOfCircleResponseDtoExtended(Board board, Set userRoles, Post post, @@ -1354,8 +1230,7 @@ private BoardOfCircleResponseDto toBoardOfCircleResponseDtoExtended(Board board, board, BoardOfCircleResponseDto.isWriteable(board, userRoles), post, - numComment - ); + numComment); } private CircleBoardsResponseDto toCircleBoardsResponseDto(Circle circle, Long numMember, @@ -1373,8 +1248,7 @@ private CircleMemberResponseDto toCircleMemberResponseDto(CircleMember circleMem return this.toCircleMemberResponseDto( circleMember, this.toCircleResponseDto(circle), - this.toUserResponseDto(user) - ); + this.toUserResponseDto(user)); } private DuplicatedCheckResponseDto toDuplicatedCheckResponseDto(Boolean isDuplicated) { @@ -1385,8 +1259,7 @@ private ExportCircleMemberToExcelResponseDto toExportCircleMemberToExcelResponse User user, UserCouncilFee userCouncilFee, Integer restOfSemester, - Boolean isAppliedThisSemester - ) { + Boolean isAppliedThisSemester) { return CircleDtoMapper.INSTANCE.toExportCircleMemberToExcelResponseDto(user, userCouncilFee, restOfSemester, isAppliedThisSemester, userCouncilFee.getNumOfPaidSemester() - restOfSemester); } @@ -1400,8 +1273,7 @@ private FormResponseDto toFormResponseDto(Form form) { form, form.getFormQuestionList().stream() .map(this::toQuestionResponseDto) - .collect(Collectors.toList()) - ); + .collect(Collectors.toList())); } private QuestionResponseDto toQuestionResponseDto(FormQuestion formQuestion) { @@ -1409,8 +1281,7 @@ private QuestionResponseDto toQuestionResponseDto(FormQuestion formQuestion) { formQuestion, formQuestion.getFormQuestionOptionList().stream() .map(this::toOptionResponseDto) - .collect(Collectors.toList()) - ); + .collect(Collectors.toList())); } private OptionResponseDto toOptionResponseDto(FormQuestionOption formQuestionOption) { diff --git a/app-main/src/main/java/net/causw/app/main/domain/campus/circle/util/CircleMemberStatusValidator.java b/app-main/src/main/java/net/causw/app/main/domain/campus/circle/util/CircleMemberStatusValidator.java index 589bca37d..38a69cfc8 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/campus/circle/util/CircleMemberStatusValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/campus/circle/util/CircleMemberStatusValidator.java @@ -35,28 +35,23 @@ public void validate() { case MEMBER: throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - "이미 동아리에 가입한 사용자 입니다." - ); + "이미 동아리에 가입한 사용자 입니다."); case LEAVE: throw new BadRequestException( ErrorCode.APPLY_NOT_EXIST, - "동아리를 떠난 사용자 입니다." - ); + "동아리를 떠난 사용자 입니다."); case AWAIT: throw new BadRequestException( ErrorCode.AWAITING_STATUS, - "동아리 가입 대기 중인 사용자 입니다." - ); + "동아리 가입 대기 중인 사용자 입니다."); case REJECT: throw new UnauthorizedException( ErrorCode.BLOCKED_USER, - "동아리 가입 거절된 사용자 입니다." - ); + "동아리 가입 거절된 사용자 입니다."); case DROP: throw new UnauthorizedException( ErrorCode.BLOCKED_USER, - "동아리에서 추방된 사용자 입니다." - ); + "동아리에서 추방된 사용자 입니다."); default: break; } diff --git a/app-main/src/main/java/net/causw/app/main/domain/campus/event/entity/Event.java b/app-main/src/main/java/net/causw/app/main/domain/campus/event/entity/Event.java index bf6b8000e..98714d775 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/campus/event/entity/Event.java +++ b/app-main/src/main/java/net/causw/app/main/domain/campus/event/entity/Event.java @@ -41,8 +41,7 @@ public class Event extends BaseEntity { public static Event of( String url, UuidFile eventImageUuidFile, - Boolean isDeleted - ) { + Boolean isDeleted) { Event event = Event.builder() .url(url) .isDeleted(isDeleted) @@ -50,8 +49,7 @@ public static Event of( EventAttachImage eventAttachImage = EventAttachImage.of( event, - eventImageUuidFile - ); + eventImageUuidFile); event.setEventImageUuidFile(eventAttachImage); diff --git a/app-main/src/main/java/net/causw/app/main/domain/campus/event/service/EventService.java b/app-main/src/main/java/net/causw/app/main/domain/campus/event/service/EventService.java index a5f1fc6ae..402099459 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/campus/event/service/EventService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/campus/event/service/EventService.java @@ -6,18 +6,18 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import net.causw.app.main.core.aop.annotation.MeasureTime; -import net.causw.app.main.domain.asset.file.entity.UuidFile; -import net.causw.app.main.domain.asset.file.entity.joinEntity.EventAttachImage; import net.causw.app.main.api.dto.event.EventCreateRequestDto; import net.causw.app.main.api.dto.event.EventResponseDto; import net.causw.app.main.api.dto.event.EventUpdateRequestDto; import net.causw.app.main.api.dto.event.EventsResponseDto; import net.causw.app.main.api.dto.util.dtoMapper.EventDtoMapper; -import net.causw.app.main.domain.campus.event.entity.Event; +import net.causw.app.main.core.aop.annotation.MeasureTime; +import net.causw.app.main.domain.asset.file.entity.UuidFile; +import net.causw.app.main.domain.asset.file.entity.joinEntity.EventAttachImage; import net.causw.app.main.domain.asset.file.enums.FilePath; -import net.causw.app.main.domain.campus.event.repository.EventRepository; import net.causw.app.main.domain.asset.file.service.UuidFileService; +import net.causw.app.main.domain.campus.event.entity.Event; +import net.causw.app.main.domain.campus.event.repository.EventRepository; import net.causw.global.constant.MessageUtil; import net.causw.global.constant.StaticValue; import net.causw.global.exception.BadRequestException; @@ -40,8 +40,7 @@ public EventsResponseDto findEvents() { return EventDtoMapper.INSTANCE.toEventsResponseDto( events.size(), - events - ); + events); } @Transactional @@ -49,8 +48,7 @@ public EventResponseDto createEvent(EventCreateRequestDto eventCreateRequestDto, if (eventRepository.findByIsDeletedIsFalseOrderByCreatedAtDesc().size() >= StaticValue.MAX_NUM_EVENT) { throw new BadRequestException( ErrorCode.CANNOT_PERFORMED, - MessageUtil.EVENT_MAX_CREATED - ); + MessageUtil.EVENT_MAX_CREATED); } UuidFile uuidFile = uuidFileService.saveFile(eventImage, FilePath.EVENT); @@ -60,10 +58,7 @@ public EventResponseDto createEvent(EventCreateRequestDto eventCreateRequestDto, Event.of( eventCreateRequestDto.getUrl(), uuidFile, - false - ) - ) - ); + false))); } @Transactional @@ -77,17 +72,14 @@ public EventResponseDto updateEvent(String eventId, EventUpdateRequestDto eventU uuidFileService.updateFile( event.getEventAttachImage().getUuidFile(), eventImage, - FilePath.EVENT - ) - ); + FilePath.EVENT)); } EventAttachImage eventAttachImage = event.getEventAttachImage(); event.update( eventUpdateRequestDto.getUrl(), - eventAttachImage - ); + eventAttachImage); return EventDtoMapper.INSTANCE.toEventResponseDto(eventRepository.save(event)); } @@ -102,9 +94,7 @@ private Event getEvent(String eventId) { return eventRepository.findById(eventId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.EVENT_NOT_FOUND - ) - ); + MessageUtil.EVENT_NOT_FOUND)); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/campus/schedule/entity/Calendar.java b/app-main/src/main/java/net/causw/app/main/domain/campus/schedule/entity/Calendar.java index aa4194532..1f5f53bda 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/campus/schedule/entity/Calendar.java +++ b/app-main/src/main/java/net/causw/app/main/domain/campus/schedule/entity/Calendar.java @@ -36,8 +36,7 @@ public class Calendar extends BaseEntity { public static Calendar of( Integer year, Integer month, - UuidFile uuidFile - ) { + UuidFile uuidFile) { Calendar calendar = Calendar.builder() .year(year) .month(month) @@ -45,8 +44,7 @@ public static Calendar of( CalendarAttachImage calendarAttachImage = CalendarAttachImage.of( calendar, - uuidFile - ); + uuidFile); calendar.setCalendarAttachImage(calendarAttachImage); diff --git a/app-main/src/main/java/net/causw/app/main/domain/campus/schedule/service/CalendarService.java b/app-main/src/main/java/net/causw/app/main/domain/campus/schedule/service/CalendarService.java index 2acd1ee0b..58cd7af6d 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/campus/schedule/service/CalendarService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/campus/schedule/service/CalendarService.java @@ -6,19 +6,19 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import net.causw.app.main.core.aop.annotation.MeasureTime; -import net.causw.app.main.domain.asset.file.entity.UuidFile; -import net.causw.app.main.domain.asset.file.entity.joinEntity.CalendarAttachImage; import net.causw.app.main.api.dto.calendar.CalendarCreateRequestDto; import net.causw.app.main.api.dto.calendar.CalendarResponseDto; import net.causw.app.main.api.dto.calendar.CalendarUpdateRequestDto; import net.causw.app.main.api.dto.calendar.CalendarsResponseDto; import net.causw.app.main.api.dto.util.dtoMapper.CalendarDtoMapper; -import net.causw.app.main.domain.campus.schedule.entity.Calendar; +import net.causw.app.main.core.aop.annotation.MeasureTime; +import net.causw.app.main.domain.asset.file.entity.UuidFile; +import net.causw.app.main.domain.asset.file.entity.joinEntity.CalendarAttachImage; import net.causw.app.main.domain.asset.file.enums.FilePath; -import net.causw.app.main.domain.campus.schedule.repository.CalendarRepository; import net.causw.app.main.domain.asset.file.repository.CalendarAttachImageRepository; import net.causw.app.main.domain.asset.file.service.UuidFileService; +import net.causw.app.main.domain.campus.schedule.entity.Calendar; +import net.causw.app.main.domain.campus.schedule.repository.CalendarRepository; import net.causw.global.constant.MessageUtil; import net.causw.global.exception.BadRequestException; import net.causw.global.exception.ErrorCode; @@ -41,8 +41,7 @@ public CalendarsResponseDto findCalendarByYear(Integer year) { return CalendarDtoMapper.INSTANCE.toCalendarsResponseDto( calendars.size(), - calendars - ); + calendars); } @Transactional(readOnly = true) @@ -51,9 +50,7 @@ public CalendarResponseDto findCalendar(String calendarId) { calendarRepository.findById(calendarId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.CALENDAR_NOT_FOUND - ) - )); + MessageUtil.CALENDAR_NOT_FOUND))); } @Transactional(readOnly = true) @@ -62,8 +59,7 @@ public CalendarResponseDto findCalendar() { .map(CalendarDtoMapper.INSTANCE::toCalendarResponseDto) .orElseThrow(() -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.CALENDAR_NOT_FOUND - )); + MessageUtil.CALENDAR_NOT_FOUND)); } @Transactional @@ -74,8 +70,7 @@ public CalendarResponseDto createCalendar(CalendarCreateRequestDto calendarCreat .ifPresent(calendar -> { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.CALENDAR_ALREADY_EXIST - ); + MessageUtil.CALENDAR_ALREADY_EXIST); }); return CalendarDtoMapper.INSTANCE.toCalendarResponseDto( @@ -83,10 +78,7 @@ public CalendarResponseDto createCalendar(CalendarCreateRequestDto calendarCreat Calendar.of( calendarCreateRequestDto.getYear(), calendarCreateRequestDto.getMonth(), - uuidFile - ) - ) - ); + uuidFile))); } @Transactional @@ -95,9 +87,7 @@ public CalendarResponseDto updateCalendar(String calendarId, CalendarUpdateReque Calendar calendar = calendarRepository.findById(calendarId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.CALENDAR_NOT_FOUND - ) - ); + MessageUtil.CALENDAR_NOT_FOUND)); // 이미지가 없을 경우 기존 이미지를 사용하고, 이미지가 있을 경우 새로운 이미지로 교체 (Calendar의 이미지는 not null임) if (!(image == null || image.isEmpty())) { @@ -105,9 +95,7 @@ public CalendarResponseDto updateCalendar(String calendarId, CalendarUpdateReque uuidFileService.updateFile( calendar.getCalendarAttachImage().getUuidFile(), image, - FilePath.CALENDAR - ) - ); + FilePath.CALENDAR)); } CalendarAttachImage calendarAttachImage = calendar.getCalendarAttachImage(); @@ -115,8 +103,7 @@ public CalendarResponseDto updateCalendar(String calendarId, CalendarUpdateReque calendar.update( calendarUpdateRequestDto.getYear(), calendarUpdateRequestDto.getMonth(), - calendarAttachImage - ); + calendarAttachImage); return CalendarDtoMapper.INSTANCE.toCalendarResponseDto(calendarRepository.save(calendar)); } @@ -130,9 +117,7 @@ public CalendarResponseDto deleteCalendar(String calendarId) { Calendar calendar = calendarRepository.findById(calendarId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.CALENDAR_NOT_FOUND - ) - ); + MessageUtil.CALENDAR_NOT_FOUND)); calendarAttachImageRepository.delete(calendar.getCalendarAttachImage()); uuidFileService.deleteFile(calendar.getCalendarAttachImage().uuidFile); diff --git a/app-main/src/main/java/net/causw/app/main/domain/campus/semester/entity/Semester.java b/app-main/src/main/java/net/causw/app/main/domain/campus/semester/entity/Semester.java index 675644197..4646b6c6f 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/campus/semester/entity/Semester.java +++ b/app-main/src/main/java/net/causw/app/main/domain/campus/semester/entity/Semester.java @@ -52,8 +52,7 @@ public void updateIsCurrent(Boolean isCurrent) { public static Semester of( Integer semesterYear, SemesterType semesterType, - User updateUser - ) { + User updateUser) { LocalDate startDate, endDate; if (semesterType == SemesterType.FIRST) { startDate = LocalDate.of(semesterYear, 3, 1); diff --git a/app-main/src/main/java/net/causw/app/main/domain/campus/semester/service/SemesterService.java b/app-main/src/main/java/net/causw/app/main/domain/campus/semester/service/SemesterService.java index 0a1295320..d3a18fb7c 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/campus/semester/service/SemesterService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/campus/semester/service/SemesterService.java @@ -5,17 +5,17 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import net.causw.app.main.core.aop.annotation.MeasureTime; -import net.causw.app.main.domain.finance.usercouncilfee.entity.CouncilFeeFakeUser; -import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFee; -import net.causw.app.main.domain.finance.usercouncilfee.repository.CouncilFeeFakeUserRepository; -import net.causw.app.main.domain.finance.usercouncilfee.repository.UserCouncilFeeRepository; import net.causw.app.main.api.dto.semester.CreateSemesterRequestDto; import net.causw.app.main.api.dto.semester.CurrentSemesterResponseDto; import net.causw.app.main.api.dto.util.dtoMapper.SemesterDtoMapper; +import net.causw.app.main.core.aop.annotation.MeasureTime; import net.causw.app.main.domain.campus.semester.entity.Semester; import net.causw.app.main.domain.campus.semester.enums.SemesterType; import net.causw.app.main.domain.campus.semester.repository.SemesterRepository; +import net.causw.app.main.domain.finance.usercouncilfee.entity.CouncilFeeFakeUser; +import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFee; +import net.causw.app.main.domain.finance.usercouncilfee.repository.CouncilFeeFakeUserRepository; +import net.causw.app.main.domain.finance.usercouncilfee.repository.UserCouncilFeeRepository; import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.repository.user.UserRepository; @@ -72,8 +72,7 @@ public void createSemester(CreateSemesterRequestDto createSemesterRequestDto, Us Semester semester = Semester.of( createSemesterRequestDto.getSemesterYear(), createSemesterRequestDto.getSemesterType(), - user - ); + user); semesterRepository.save(semester); } @@ -84,23 +83,21 @@ public void createNextSemester(User user) { priorSemester.updateIsCurrent(false); - Semester newSemester = (priorSemester.getSemesterType().equals(SemesterType.FIRST)) ? - Semester.of(priorSemester.getSemesterYear(), SemesterType.SECOND, user) : - Semester.of(priorSemester.getSemesterYear() + 1, SemesterType.FIRST, user); + Semester newSemester = (priorSemester.getSemesterType().equals(SemesterType.FIRST)) + ? Semester.of(priorSemester.getSemesterYear(), SemesterType.SECOND, user) + : Semester.of(priorSemester.getSemesterYear() + 1, SemesterType.FIRST, user); semesterRepository.save(priorSemester); semesterRepository.save(newSemester); // 신학기 시작으로 학적상태가 재학 또는 휴학인 학생들을 미결정으로 변경 List userList = userRepository.findByAcademicStatusInOrAcademicStatusIsNull( - List.of( - AcademicStatus.ENROLLED, - AcademicStatus.LEAVE_OF_ABSENCE - )) + List.of( + AcademicStatus.ENROLLED, + AcademicStatus.LEAVE_OF_ABSENCE)) .stream() .peek( - (u) -> u.setAcademicStatus(AcademicStatus.UNDETERMINED) - ) + (u) -> u.setAcademicStatus(AcademicStatus.UNDETERMINED)) .toList(); userRepository.saveAll(userList); @@ -112,8 +109,7 @@ public void createNextSemester(User user) { .filter(councilFeeFakeUser -> councilFeeFakeUser.getAcademicStatus().equals(AcademicStatus.ENROLLED)) .peek(councilFeeFakeUser -> { validAcademicStatusAndCurrentCompletedSemester(councilFeeFakeUser.getAcademicStatus(), - councilFeeFakeUser.getCurrentCompletedSemester() + 1 - ); + councilFeeFakeUser.getCurrentCompletedSemester() + 1); councilFeeFakeUser.setCurrentCompletedSemester( councilFeeFakeUser.getCurrentCompletedSemester() + 1); }) diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/board/entity/Board.java b/app-main/src/main/java/net/causw/app/main/domain/community/board/entity/Board.java index c81c35238..f8a8a14f4 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/board/entity/Board.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/board/entity/Board.java @@ -8,8 +8,8 @@ import org.hibernate.annotations.ColumnDefault; -import net.causw.app.main.domain.community.post.entity.Post; import net.causw.app.main.domain.campus.circle.entity.Circle; +import net.causw.app.main.domain.community.post.entity.Post; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.domain.user.account.enums.user.RoleGroup; import net.causw.app.main.shared.entity.BaseEntity; @@ -85,8 +85,7 @@ public static Board of( String description, String category, Boolean isAnonymousAllowed, - Circle circle - ) { + Circle circle) { Set roleSet = Arrays.stream(Role.values()) // 일반 게시판 생성시 글쓰기 권한 '모두 허용' .map(Role::getValue) .collect(Collectors.toSet()); @@ -118,8 +117,7 @@ public static Board createNoticeBoard( String category, Boolean isAnonymousAllowed, Boolean isAlumni, - Circle circle - ) { + Circle circle) { Set roleSet = RoleGroup.EXECUTIVES.getRoles().stream() // 집행부(관리자, 학생회장, 부학생회장) 글쓰기 권한 보장 .map(Role::getValue) .collect(Collectors.toSet()); @@ -129,8 +127,7 @@ public static Board createNoticeBoard( createRoleList.stream() // 공지 게시판 생성시 글쓰기 권한 '선택적 허용' .map(Role::of) .map(Role::getValue) - .collect(Collectors.toSet()) - ); + .collect(Collectors.toSet())); } roleSet.remove(Role.NONE.getValue()); // 비회원 글쓰기 권한 제한 diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/board/entity/BoardApply.java b/app-main/src/main/java/net/causw/app/main/domain/community/board/entity/BoardApply.java index 2c42f0ffa..a33eb2778 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/board/entity/BoardApply.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/board/entity/BoardApply.java @@ -62,8 +62,7 @@ public static BoardApply of( String description, String category, Boolean isAnonymousAllowed, - Circle circle - ) { + Circle circle) { // description 비어있을 경우 처리 if (description == null) { description = ""; diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/board/entity/FavoriteBoard.java b/app-main/src/main/java/net/causw/app/main/domain/community/board/entity/FavoriteBoard.java index 6375f9df9..4abd99ef4 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/board/entity/FavoriteBoard.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/board/entity/FavoriteBoard.java @@ -30,8 +30,7 @@ public class FavoriteBoard extends BaseEntity { public static FavoriteBoard of( User user, - Board board - ) { + Board board) { return FavoriteBoard.builder() .user(user) .board(board) diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/board/service/BoardService.java b/app-main/src/main/java/net/causw/app/main/domain/community/board/service/BoardService.java index 3b0df63ef..474816fae 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/board/service/BoardService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/board/service/BoardService.java @@ -13,15 +13,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.event.TransactionalEventListener; -import net.causw.app.main.core.aop.annotation.MeasureTime; -import net.causw.app.main.domain.community.board.entity.Board; -import net.causw.app.main.domain.community.board.entity.BoardApply; -import net.causw.app.main.domain.community.board.entity.BoardApplyStatus; -import net.causw.app.main.domain.community.board.repository.BoardApplyRepository; -import net.causw.app.main.domain.community.board.repository.BoardRepository; -import net.causw.app.main.domain.community.post.repository.PostRepository; -import net.causw.app.main.domain.community.post.service.PostEntityService; -import net.causw.app.main.domain.community.post.service.PostService; import net.causw.app.main.api.dto.board.BoardAppliesResponseDto; import net.causw.app.main.api.dto.board.BoardApplyRequestDto; import net.causw.app.main.api.dto.board.BoardApplyResponseDto; @@ -39,16 +30,22 @@ import net.causw.app.main.api.dto.util.dtoMapper.CircleDtoMapper; import net.causw.app.main.api.dto.util.dtoMapper.PostDtoMapper; import net.causw.app.main.api.dto.util.dtoMapper.UserDtoMapper; +import net.causw.app.main.core.aop.annotation.MeasureTime; import net.causw.app.main.domain.campus.circle.entity.Circle; import net.causw.app.main.domain.campus.circle.entity.CircleMember; -import net.causw.app.main.domain.notification.notification.entity.UserBoardSubscribe; import net.causw.app.main.domain.campus.circle.enums.CircleMemberStatus; import net.causw.app.main.domain.campus.circle.repository.CircleMemberRepository; import net.causw.app.main.domain.campus.circle.repository.CircleRepository; +import net.causw.app.main.domain.community.board.entity.Board; +import net.causw.app.main.domain.community.board.entity.BoardApply; +import net.causw.app.main.domain.community.board.entity.BoardApplyStatus; +import net.causw.app.main.domain.community.board.repository.BoardApplyRepository; +import net.causw.app.main.domain.community.board.repository.BoardRepository; +import net.causw.app.main.domain.community.post.repository.PostRepository; +import net.causw.app.main.domain.community.post.service.PostEntityService; +import net.causw.app.main.domain.community.post.service.PostService; +import net.causw.app.main.domain.notification.notification.entity.UserBoardSubscribe; import net.causw.app.main.domain.notification.notification.repository.UserBoardSubscribeRepository; -import net.causw.app.main.shared.util.ConstraintValidator; -import net.causw.app.main.shared.util.TargetIsDeletedValidator; -import net.causw.app.main.shared.util.TargetIsNotDeletedValidator; import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; import net.causw.app.main.domain.user.academic.event.AcademicStatusChangeEvent; import net.causw.app.main.domain.user.academic.event.CertifiedUserCreatedEvent; @@ -62,6 +59,9 @@ import net.causw.app.main.domain.user.account.util.UserStateValidator; import net.causw.app.main.domain.user.relation.service.UserBlockEntityService; import net.causw.app.main.shared.ValidatorBucket; +import net.causw.app.main.shared.util.ConstraintValidator; +import net.causw.app.main.shared.util.TargetIsDeletedValidator; +import net.causw.app.main.shared.util.TargetIsNotDeletedValidator; import net.causw.app.main.shared.util.UserEqualValidator; import net.causw.global.constant.MessageUtil; import net.causw.global.constant.StaticValue; @@ -90,8 +90,7 @@ public class BoardService { @Transactional(readOnly = true) public List findAllBoard( - User user - ) { + User user) { Set roles = user.getRoles(); AcademicStatus academicStatus = user.getAcademicStatus(); @@ -123,8 +122,8 @@ public List findAllBoard( .collect(Collectors.toList()); return Stream.concat( - this.boardRepository.findByCircle_IdIsNullAndIsDeletedOrderByCreatedAtAsc(false).stream(), - this.boardRepository.findByCircle_IdInAndIsDeletedFalseOrderByCreatedAtAsc(circleIdList).stream()) + this.boardRepository.findByCircle_IdIsNullAndIsDeletedOrderByCreatedAtAsc(false).stream(), + this.boardRepository.findByCircle_IdInAndIsDeletedFalseOrderByCreatedAtAsc(circleIdList).stream()) .map(board -> toBoardResponseDto(board, roles)) .collect(Collectors.toList()); } @@ -133,8 +132,7 @@ public List findAllBoard( @Transactional(readOnly = true) public List mainBoard( - User user - ) { + User user) { Set roles = user.getRoles(); AcademicStatus academicStatus = user.getAcademicStatus(); @@ -163,9 +161,8 @@ public List mainBoard( .collect(Collectors.toList()); boards = Stream.concat( - boardRepository.findByCircle_IdIsNullAndIsDeletedOrderByCreatedAtAsc(false).stream(), - boardRepository.findByCircle_IdInAndIsDeletedFalseOrderByCreatedAtAsc(circleIdList).stream() - ) + boardRepository.findByCircle_IdIsNullAndIsDeletedOrderByCreatedAtAsc(false).stream(), + boardRepository.findByCircle_IdInAndIsDeletedFalseOrderByCreatedAtAsc(circleIdList).stream()) .collect(Collectors.toList()); } } @@ -175,12 +172,11 @@ public List mainBoard( return boards.stream() .map(board -> { List recentPosts = postEntityService.findPostsByBoardWithFilters( - board.getId(), - false, - blockedUserIds, - null, - PageRequest.of(0, 2) - ) + board.getId(), + false, + blockedUserIds, + null, + PageRequest.of(0, 2)) .getContent() .stream() .map(post -> { @@ -203,8 +199,7 @@ public List mainBoard( @Transactional(readOnly = true) public BoardNameCheckResponseDto checkBoardName( - BoardNameCheckRequestDto boardNameCheckRequestDto - ) { + BoardNameCheckRequestDto boardNameCheckRequestDto) { String boardName = boardNameCheckRequestDto.getName(); return BoardDtoMapper.INSTANCE.toBoardNameCheckResponseDto(boardRepository.existsByName(boardName)); @@ -213,13 +208,11 @@ public BoardNameCheckResponseDto checkBoardName( @Transactional public void applyBoard( User creator, - BoardApplyRequestDto boardApplyRequestDto - ) { + BoardApplyRequestDto boardApplyRequestDto) { if (boardRepository.existsByName(boardApplyRequestDto.getBoardName())) { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.BOARD_NAME_ALREADY_EXISTS - ); + MessageUtil.BOARD_NAME_ALREADY_EXISTS); } BoardApply newBoardApply = BoardApply.of( @@ -228,8 +221,7 @@ public void applyBoard( boardApplyRequestDto.getDescription(), StaticValue.BOARD_NAME_APP_FREE, boardApplyRequestDto.getIsAnonymousAllowed(), - getCircle(boardApplyRequestDto.getCircleId()) - ); + getCircle(boardApplyRequestDto.getCircleId())); boardApplyRepository.save(newBoardApply); } @@ -237,20 +229,17 @@ public void applyBoard( @Transactional public BoardResponseDto createNoticeBoard( User creator, - BoardCreateRequestDto boardCreateRequestDto - ) { + BoardCreateRequestDto boardCreateRequestDto) { if (boardRepository.existsByName(boardCreateRequestDto.getBoardName())) { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.BOARD_NAME_ALREADY_EXISTS - ); + MessageUtil.BOARD_NAME_ALREADY_EXISTS); } if (!StaticValue.BOARD_NAME_APP_NOTICE.equals(boardCreateRequestDto.getBoardCategory())) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_BOARD_CATEGORY - ); + MessageUtil.INVALID_BOARD_CATEGORY); } Board newBoard = boardRepository.save( @@ -261,8 +250,7 @@ public BoardResponseDto createNoticeBoard( boardCreateRequestDto.getBoardCategory(), boardCreateRequestDto.getIsAnonymousAllowed(), boardCreateRequestDto.getIsAlumni(), - getCircle(boardCreateRequestDto.getCircleId()) - )); + getCircle(boardCreateRequestDto.getCircleId()))); createBoardSubscribe(newBoard.getId()); @@ -284,8 +272,7 @@ public BoardApplyResponseDto findBoardApplyByApplyId(String applyId) { BoardApply boardApply = this.boardApplyRepository.findById(applyId) .orElseThrow(() -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.APPLY_NOT_FOUND - )); + MessageUtil.APPLY_NOT_FOUND)); return toBoardApplyResponseDto(boardApply); } @@ -295,29 +282,25 @@ public BoardApplyResponseDto accept(String boardApplyId) { BoardApply boardApply = this.boardApplyRepository.findById(boardApplyId) .orElseThrow(() -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.APPLY_NOT_FOUND - )); + MessageUtil.APPLY_NOT_FOUND)); if (boardApply.getAcceptStatus() == BoardApplyStatus.ACCEPTED) { // 해당 신청이 이미 승인된 경우 throw new BadRequestException( ErrorCode.CANNOT_PERFORMED, - MessageUtil.APPLY_ALREADY_ACCEPTED - ); + MessageUtil.APPLY_ALREADY_ACCEPTED); } if (boardApply.getAcceptStatus() == BoardApplyStatus.REJECT) { // 해당 신청이 이미 거부된 경우 throw new BadRequestException( ErrorCode.CANNOT_PERFORMED, - MessageUtil.APPLY_ALREADY_REJECTED - ); + MessageUtil.APPLY_ALREADY_REJECTED); } // 게시판명 중복 체크 if (boardRepository.existsByName(boardApply.getBoardName())) { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.BOARD_NAME_ALREADY_EXISTS - ); + MessageUtil.BOARD_NAME_ALREADY_EXISTS); } boardApply.updateAcceptStatus(BoardApplyStatus.ACCEPTED); // 해당 boardApply의 상태를 ACCEPTED로 변경 @@ -330,8 +313,7 @@ public BoardApplyResponseDto accept(String boardApplyId) { boardApply.getIsAnonymousAllowed(), Optional.ofNullable(boardApply.getCircle()) .map(circle -> getCircle(circle.getId())) - .orElse(null) - ); + .orElse(null)); this.boardRepository.save(newBoard); @@ -343,21 +325,18 @@ public BoardApplyResponseDto reject(String boardApplyId) { BoardApply boardApply = this.boardApplyRepository.findById(boardApplyId) .orElseThrow(() -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.APPLY_NOT_FOUND - )); + MessageUtil.APPLY_NOT_FOUND)); if (boardApply.getAcceptStatus() == BoardApplyStatus.ACCEPTED) { // 해당 신청이 이미 승인된 경우 throw new BadRequestException( ErrorCode.CANNOT_PERFORMED, - MessageUtil.APPLY_ALREADY_ACCEPTED - ); + MessageUtil.APPLY_ALREADY_ACCEPTED); } if (boardApply.getAcceptStatus() == BoardApplyStatus.REJECT) { // 해당 신청이 이미 거부된 경우 throw new BadRequestException( ErrorCode.CANNOT_PERFORMED, - MessageUtil.APPLY_ALREADY_REJECTED - ); + MessageUtil.APPLY_ALREADY_REJECTED); } boardApply.updateAcceptStatus(BoardApplyStatus.REJECT); // 해당 boardApply의 상태를 REJECT로 변경 @@ -370,8 +349,7 @@ public BoardApplyResponseDto reject(String boardApplyId) { public BoardResponseDto updateBoard( User updater, String boardId, - BoardUpdateRequestDto boardUpdateRequestDto - ) { + BoardUpdateRequestDto boardUpdateRequestDto) { Set roles = updater.getRoles(); Board board = getBoard(boardId); @@ -381,8 +359,7 @@ public BoardResponseDto updateBoard( boardUpdateRequestDto.getName(), boardUpdateRequestDto.getDescription(), String.join(",", boardUpdateRequestDto.getCreateRoleList()), - boardUpdateRequestDto.getCategory() - ); + boardUpdateRequestDto.getCategory()); validatorBucket .consistOf(ConstraintValidator.of(board, this.validator)) @@ -394,8 +371,7 @@ public BoardResponseDto updateBoard( @Transactional public BoardResponseDto deleteBoard( User deleter, - String boardId - ) { + String boardId) { Set roles = deleter.getRoles(); Board board = getBoard(boardId); @@ -404,8 +380,7 @@ public BoardResponseDto deleteBoard( validatorBucket .consistOf(UserRoleValidator.of( roles, - Set.of() - )); + Set.of())); } validatorBucket.validate(); @@ -420,8 +395,7 @@ public BoardResponseDto deleteBoard( @Transactional public BoardResponseDto restoreBoard( User restorer, - String boardId - ) { + String boardId) { Set roles = restorer.getRoles(); Board board = getBoard(boardId); @@ -446,23 +420,18 @@ public BoardResponseDto restoreBoard( circle.getLeader().map(User::getId).orElseThrow( () -> new UnauthorizedException( ErrorCode.API_NOT_ALLOWED, - MessageUtil.NOT_CIRCLE_LEADER - ) - ), - restorer.getId() - )); + MessageUtil.NOT_CIRCLE_LEADER)), + restorer.getId())); } }, () -> validatorBucket - .consistOf(UserRoleValidator.of(roles, Set.of())) - ); + .consistOf(UserRoleValidator.of(roles, Set.of()))); if (board.getCategory().equals(StaticValue.BOARD_NAME_APP_NOTICE)) { validatorBucket .consistOf(UserRoleValidator.of( roles, - Set.of() - )); + Set.of())); } validatorBucket.validate(); @@ -493,16 +462,12 @@ private ValidatorBucket initializeValidatorBucket(User user, Board board) { circle.getLeader().map(User::getId).orElseThrow( () -> new UnauthorizedException( ErrorCode.API_NOT_ALLOWED, - MessageUtil.NOT_CIRCLE_LEADER - ) - ), - user.getId() - )); + MessageUtil.NOT_CIRCLE_LEADER)), + user.getId())); } }, () -> validatorBucket - .consistOf(UserRoleValidator.of(roles, Set.of())) - ); + .consistOf(UserRoleValidator.of(roles, Set.of()))); return validatorBucket; } @@ -518,8 +483,7 @@ private BoardResponseDto toBoardResponseDto(Board board, Set userRoles) { roles, writable, circleId, - circleName - ); + circleName); } private BoardApplyResponseDto toBoardApplyResponseDto(BoardApply boardApply) { @@ -531,26 +495,21 @@ private BoardApplyResponseDto toBoardApplyResponseDto(BoardApply boardApply) { return BoardDtoMapper.INSTANCE.toBoardApplyResponseDto( boardApply, userResponseDto, - circleResponseDto - ); + circleResponseDto); } private User getUser(String userId) { return userRepository.findById(userId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - ) - ); + MessageUtil.USER_NOT_FOUND)); } private Board getBoard(String boardId) { return boardRepository.findById(boardId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.BOARD_NOT_FOUND - ) - ); + MessageUtil.BOARD_NOT_FOUND)); } private Circle getCircle(String circleId) { @@ -561,9 +520,7 @@ private Circle getCircle(String circleId) { return circleRepository.findById(circleId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.SMALL_CLUB_NOT_FOUND - ) - ); + MessageUtil.SMALL_CLUB_NOT_FOUND)); } @Transactional @@ -574,7 +531,7 @@ public void createBoardSubscribe(String boardId) { List certifiedUsers = userRepository.findAllByState(UserState.ACTIVE).stream() .filter(user -> !AcademicStatus.UNDETERMINED.equals(user.getAcademicStatus()) // 학적 인증이 완료된 일반 사용자 || RoleGroup.EXECUTIVES_AND_PROFESSOR.getRoles().stream() // 집행부/교수 역할의 사용자 - .anyMatch(user.getRoles()::contains)) + .anyMatch(user.getRoles()::contains)) .toList(); // 구독 생성 diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/ceremony/entity/Ceremony.java b/app-main/src/main/java/net/causw/app/main/domain/community/ceremony/entity/Ceremony.java index 67f391e03..1a34b833d 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/ceremony/entity/Ceremony.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/ceremony/entity/Ceremony.java @@ -95,8 +95,7 @@ public static Ceremony of( LocalDate startDate, LocalDate endDate, boolean isSetAll, - List targetAdmissionYears - ) { + List targetAdmissionYears) { Set targetYearsSet = targetAdmissionYears != null ? new HashSet<>(targetAdmissionYears) : new HashSet<>(); @@ -120,8 +119,7 @@ public static Ceremony createWithImages( LocalDate endDate, boolean isSetAll, List targetAdmissionYears, - List ceremonyAttachImageUuidFileList - ) { + List ceremonyAttachImageUuidFileList) { Ceremony ceremony = Ceremony.of( user, ceremonyCategory, @@ -129,8 +127,7 @@ public static Ceremony createWithImages( startDate, endDate, isSetAll, - targetAdmissionYears - ); + targetAdmissionYears); List ceremonyAttachImageList = ceremonyAttachImageUuidFileList.stream() .map(uuidFile -> CeremonyAttachImage.of(ceremony, uuidFile)) .toList(); diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/ceremony/enums/CeremonyContext.java b/app-main/src/main/java/net/causw/app/main/domain/community/ceremony/enums/CeremonyContext.java index 124a3f6e0..2a042f570 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/ceremony/enums/CeremonyContext.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/ceremony/enums/CeremonyContext.java @@ -30,8 +30,7 @@ public static CeremonyContext fromString(String context) { if (context == null || context.isEmpty()) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.CEREMONY_INVALID_CONTEXT_VALUE - ); + MessageUtil.CEREMONY_INVALID_CONTEXT_VALUE); } for (CeremonyContext ceremonyContext : CeremonyContext.values()) { @@ -42,7 +41,6 @@ public static CeremonyContext fromString(String context) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.CEREMONY_INVALID_CONTEXT_VALUE - ); + MessageUtil.CEREMONY_INVALID_CONTEXT_VALUE); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/ceremony/service/CeremonyService.java b/app-main/src/main/java/net/causw/app/main/domain/community/ceremony/service/CeremonyService.java index 7676df3ea..747bdbebf 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/ceremony/service/CeremonyService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/ceremony/service/CeremonyService.java @@ -11,7 +11,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import net.causw.app.main.domain.asset.file.entity.UuidFile; import net.causw.app.main.api.dto.ceremony.CeremonyNotificationSettingResponseDto; import net.causw.app.main.api.dto.ceremony.CeremonyResponseDto; import net.causw.app.main.api.dto.ceremony.CreateCeremonyNotificationSettingDto; @@ -20,15 +19,16 @@ import net.causw.app.main.api.dto.notification.CeremonyListNotificationDto; import net.causw.app.main.api.dto.util.dtoMapper.CeremonyDtoMapper; import net.causw.app.main.api.dto.util.dtoMapper.NotificationDtoMapper; +import net.causw.app.main.domain.asset.file.entity.UuidFile; +import net.causw.app.main.domain.asset.file.enums.FilePath; +import net.causw.app.main.domain.asset.file.service.UuidFileService; import net.causw.app.main.domain.community.ceremony.entity.Ceremony; -import net.causw.app.main.domain.notification.notification.entity.CeremonyNotificationSetting; import net.causw.app.main.domain.community.ceremony.enums.CeremonyContext; import net.causw.app.main.domain.community.ceremony.enums.CeremonyState; -import net.causw.app.main.domain.asset.file.enums.FilePath; import net.causw.app.main.domain.community.ceremony.repository.CeremonyRepository; +import net.causw.app.main.domain.notification.notification.entity.CeremonyNotificationSetting; import net.causw.app.main.domain.notification.notification.repository.CeremonyNotificationSettingRepository; import net.causw.app.main.domain.notification.notification.service.CeremonyNotificationService; -import net.causw.app.main.domain.asset.file.service.UuidFileService; import net.causw.app.main.domain.user.academic.event.CertifiedUserCreatedEvent; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.enums.user.Role; @@ -55,17 +55,16 @@ public class CeremonyService { @Transactional public CeremonyResponseDto createCeremony( User user, - @Valid CreateCeremonyRequestDto createCeremonyRequestDTO, - List imageFileList - ) { + @Valid + CreateCeremonyRequestDto createCeremonyRequestDTO, + List imageFileList) { // 전체 알림 전송이 false인 경우, 대상 학번이 입력되었는지 검증 if (!createCeremonyRequestDTO.getIsSetAll()) { if (createCeremonyRequestDTO.getTargetAdmissionYears() == null || createCeremonyRequestDTO.getTargetAdmissionYears().isEmpty()) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.CEREMONY_TARGET_ADMISSION_YEARS_REQUIRED - ); + MessageUtil.CEREMONY_TARGET_ADMISSION_YEARS_REQUIRED); } // 학번 형식 (숫자 2자리) 검증 @@ -73,8 +72,7 @@ public CeremonyResponseDto createCeremony( if (!admissionYear.matches("^[0-9]{2}$")) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.CEREMONY_INVALID_ADMISSION_YEAR_FORMAT - ); + MessageUtil.CEREMONY_INVALID_ADMISSION_YEAR_FORMAT); } } } @@ -96,8 +94,7 @@ public CeremonyResponseDto createCeremony( createCeremonyRequestDTO.getEndDate(), createCeremonyRequestDTO.getIsSetAll(), targetAdmissionYears, - uuidFileList - ); + uuidFileList); ceremonyRepository.save(ceremony); return CeremonyDtoMapper.INSTANCE.toDetailedCeremonyResponseDto(ceremony); @@ -124,26 +121,22 @@ public CeremonyResponseDto getCeremony(String ceremonyId, CeremonyContext contex Ceremony ceremony = ceremonyRepository.findById(ceremonyId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.CEREMONY_NOT_FOUND - ) - ); + MessageUtil.CEREMONY_NOT_FOUND)); // context에 따라 다르게 처리 switch (context) { - case MY: // 내 경조사 목록 + case MY: // 내 경조사 목록 if (!ceremony.getUser().getId().equals(user.getId())) { throw new BadRequestException( ErrorCode.API_NOT_ACCESSIBLE, - MessageUtil.CEREMONY_ACCESS_MY_ONLY - ); + MessageUtil.CEREMONY_ACCESS_MY_ONLY); } return CeremonyDtoMapper.INSTANCE.toDetailedCeremonyResponseDto(ceremony); - case ADMIN: // 관리자용 경조사 관리 페이지 + case ADMIN: // 관리자용 경조사 관리 페이지 if (!user.getRoles().contains(Role.ADMIN)) { throw new BadRequestException( ErrorCode.API_NOT_ACCESSIBLE, - MessageUtil.CEREMONY_ACCESS_ADMIN_ONLY - ); + MessageUtil.CEREMONY_ACCESS_ADMIN_ONLY); } return CeremonyDtoMapper.INSTANCE.toDetailedCeremonyResponseDto(ceremony); case GENERAL: @@ -157,9 +150,7 @@ public CeremonyResponseDto updateUserCeremonyStatus(UpdateCeremonyStateRequestDt Ceremony ceremony = ceremonyRepository.findById(updateDto.getCeremonyId()).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.CEREMONY_NOT_FOUND - ) - ); + MessageUtil.CEREMONY_NOT_FOUND)); ceremony.updateCeremonyState(updateDto.getTargetCeremonyState()); if (updateDto.getTargetCeremonyState() == CeremonyState.ACCEPT) { @@ -181,9 +172,7 @@ public CeremonyResponseDto closeUserCeremonyStatus(User user, String ceremonyId) Ceremony ceremony = ceremonyRepository.findByIdAndUser(ceremonyId, user).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.CEREMONY_NOT_FOUND - ) - ); + MessageUtil.CEREMONY_NOT_FOUND)); ceremony.updateCeremonyState(CeremonyState.CLOSE); @@ -197,13 +186,11 @@ public CeremonyNotificationSettingResponseDto createCeremonyNotificationSettings CreateCeremonyNotificationSettingDto createCeremonyNotificationSettingDTO) { Set admissionYears = validateAdmissionYears(createCeremonyNotificationSettingDTO); - CeremonyNotificationSetting ceremonyNotificationSetting = - CeremonyNotificationSetting.of( - admissionYears, - createCeremonyNotificationSettingDTO.isSetAll(), - createCeremonyNotificationSettingDTO.isNotificationActive(), - user - ); + CeremonyNotificationSetting ceremonyNotificationSetting = CeremonyNotificationSetting.of( + admissionYears, + createCeremonyNotificationSettingDTO.isSetAll(), + createCeremonyNotificationSettingDTO.isNotificationActive(), + user); ceremonyNotificationSettingRepository.save(ceremonyNotificationSetting); return CeremonyDtoMapper.INSTANCE.toCeremonyNotificationSettingResponseDto(ceremonyNotificationSetting); @@ -214,8 +201,7 @@ public void createDefaultCeremonyNotificationSetting(CertifiedUserCreatedEvent e User user = userRepository.findById(event.userId()) .orElseThrow(() -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - )); + MessageUtil.USER_NOT_FOUND)); ceremonyNotificationSettingRepository.findByUser(user) .orElseGet(() -> ceremonyNotificationSettingRepository.save( @@ -223,8 +209,7 @@ public void createDefaultCeremonyNotificationSetting(CertifiedUserCreatedEvent e new HashSet<>(), true, true, - user - ))); + user))); } @Transactional(readOnly = true) @@ -233,9 +218,7 @@ public CeremonyNotificationSettingResponseDto getCeremonyNotificationSetting(Use .orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.CEREMONY_NOTIFICATION_SETTING_NOT_FOUND - ) - ); + MessageUtil.CEREMONY_NOTIFICATION_SETTING_NOT_FOUND)); return CeremonyDtoMapper.INSTANCE.toCeremonyNotificationSettingResponseDto(ceremonyNotificationSetting); } @@ -246,9 +229,7 @@ public CeremonyNotificationSettingResponseDto updateUserSettings(User user, .orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.CEREMONY_NOTIFICATION_SETTING_NOT_FOUND - ) - ); + MessageUtil.CEREMONY_NOTIFICATION_SETTING_NOT_FOUND)); Set admissionYears = validateAdmissionYears(createCeremonyNotificationSettingDTO); @@ -275,8 +256,7 @@ private Set validateAdmissionYears(CreateCeremonyNotificationSettingDto if (dto.getSubscribedAdmissionYears() == null || dto.getSubscribedAdmissionYears().isEmpty()) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.CEREMONY_NOTIFICATION_SUBSCRIPTION_REQUIRED - ); + MessageUtil.CEREMONY_NOTIFICATION_SUBSCRIPTION_REQUIRED); } // 학번 형식 (2자리) 검증 @@ -284,8 +264,7 @@ private Set validateAdmissionYears(CreateCeremonyNotificationSettingDto if (!year.matches("^[0-9]{2}$")) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.CEREMONY_INVALID_ADMISSION_YEAR_FORMAT - ); + MessageUtil.CEREMONY_INVALID_ADMISSION_YEAR_FORMAT); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/comment/entity/ChildComment.java b/app-main/src/main/java/net/causw/app/main/domain/community/comment/entity/ChildComment.java index 1a163515c..b665ceb0f 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/comment/entity/ChildComment.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/comment/entity/ChildComment.java @@ -50,8 +50,7 @@ public static ChildComment of( Boolean isDeleted, Boolean isAnonymous, User writer, - Comment parentComment - ) { + Comment parentComment) { return ChildComment.builder() .content(content) .isDeleted(isDeleted) diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/comment/entity/Comment.java b/app-main/src/main/java/net/causw/app/main/domain/community/comment/entity/Comment.java index 3dba22feb..615b98a94 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/comment/entity/Comment.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/comment/entity/Comment.java @@ -58,8 +58,7 @@ public static Comment of( Boolean isDeleted, Boolean isAnonymous, User writer, - Post post - ) { + Post post) { return Comment.builder() .content(content) .isDeleted(isDeleted) diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/comment/repository/ChildCommentRepository.java b/app-main/src/main/java/net/causw/app/main/domain/community/comment/repository/ChildCommentRepository.java index 8970e948c..fc910b4f7 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/comment/repository/ChildCommentRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/comment/repository/ChildCommentRepository.java @@ -24,7 +24,8 @@ public interface ChildCommentRepository extends JpaRepository findByParentComment_Id(@Param("parentCommentId") String parentCommentId); + List findByParentComment_Id(@Param("parentCommentId") + String parentCommentId); @Query(""" SELECT DISTINCT p @@ -34,9 +35,10 @@ public interface ChildCommentRepository extends JpaRepository findPostsByUserId(@Param("userId") String userId, @Param("blockedUserIds") Set blockedUserIds, + """) + Page findPostsByUserId(@Param("userId") + String userId, @Param("blockedUserIds") + Set blockedUserIds, Pageable pageable); Optional findByIdAndIsDeletedFalse(String id); diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/comment/repository/CommentRepository.java b/app-main/src/main/java/net/causw/app/main/domain/community/comment/repository/CommentRepository.java index 8630f2f7d..c228df5e8 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/comment/repository/CommentRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/comment/repository/CommentRepository.java @@ -20,7 +20,8 @@ public interface CommentRepository extends JpaRepository { "LEFT JOIN FETCH c.writer w " + "WHERE c.post.id = :postId " + "ORDER BY c.createdAt") - Page findByPost_IdOrderByCreatedAt(@Param("postId") String postId, Pageable pageable); + Page findByPost_IdOrderByCreatedAt(@Param("postId") + String postId, Pageable pageable); Boolean existsByPostIdAndIsDeletedFalse(String postId); @@ -31,7 +32,8 @@ public interface CommentRepository extends JpaRepository { "left join tb_circle_member as cm on p.user_id = cm.user_id and c.id = cm.circle_id " + "where co.user_id = :user_id and p.is_deleted = false and b.is_deleted = false and co.is_deleted = false " + "and (c.id is null or (c.is_deleted = false and cm.status = 'MEMBER')) ORDER BY p.created_at DESC", nativeQuery = true) - Page findByUserId(@Param("user_id") String userId, Pageable pageable); + Page findByUserId(@Param("user_id") + String userId, Pageable pageable); @Query(""" SELECT DISTINCT p @@ -40,9 +42,10 @@ public interface CommentRepository extends JpaRepository { WHERE c.writer.id = :userId AND c.isDeleted = false AND (:#{#blockedUserIds.size()} = 0 OR p.writer.id NOT IN :blockedUserIds) ORDER BY p.createdAt DESC - """ - ) - Page findPostsByUserId(@Param("userId") String userId, @Param("blockedUserIds") Set blockedUserIds, + """) + Page findPostsByUserId(@Param("userId") + String userId, @Param("blockedUserIds") + Set blockedUserIds, Pageable pageable); Optional findByIdAndIsDeletedFalse(String commentId); diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/comment/service/ChildCommentEntityService.java b/app-main/src/main/java/net/causw/app/main/domain/community/comment/service/ChildCommentEntityService.java index 7c9a150f7..b4885b941 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/comment/service/ChildCommentEntityService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/comment/service/ChildCommentEntityService.java @@ -19,11 +19,8 @@ public class ChildCommentEntityService { public ChildComment findByIdNotDeleted(String childCommentId) { return childCommentRepository.findByIdAndIsDeletedFalse(childCommentId) - .orElseThrow(() -> - new NotFoundException( - ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.CHILD_COMMENT_NOT_FOUND - ) - ); + .orElseThrow(() -> new NotFoundException( + ErrorCode.ROW_DOES_NOT_EXIST, + MessageUtil.CHILD_COMMENT_NOT_FOUND)); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/comment/service/ChildCommentService.java b/app-main/src/main/java/net/causw/app/main/domain/community/comment/service/ChildCommentService.java index 4ea31fdae..8c50c5347 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/comment/service/ChildCommentService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/comment/service/ChildCommentService.java @@ -7,7 +7,16 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import net.causw.app.main.api.dto.comment.ChildCommentCreateRequestDto; +import net.causw.app.main.api.dto.comment.ChildCommentResponseDto; +import net.causw.app.main.api.dto.comment.ChildCommentUpdateRequestDto; +import net.causw.app.main.api.dto.util.dtoMapper.CommentDtoMapper; import net.causw.app.main.core.aop.annotation.MeasureTime; +import net.causw.app.main.domain.campus.circle.entity.Circle; +import net.causw.app.main.domain.campus.circle.entity.CircleMember; +import net.causw.app.main.domain.campus.circle.enums.CircleMemberStatus; +import net.causw.app.main.domain.campus.circle.repository.CircleMemberRepository; +import net.causw.app.main.domain.campus.circle.util.CircleMemberStatusValidator; import net.causw.app.main.domain.community.board.entity.Board; import net.causw.app.main.domain.community.comment.entity.ChildComment; import net.causw.app.main.domain.community.comment.entity.Comment; @@ -18,26 +27,17 @@ import net.causw.app.main.domain.community.post.entity.Post; import net.causw.app.main.domain.community.post.repository.PostRepository; import net.causw.app.main.domain.community.post.service.PostService; -import net.causw.app.main.api.dto.comment.ChildCommentCreateRequestDto; -import net.causw.app.main.api.dto.comment.ChildCommentResponseDto; -import net.causw.app.main.api.dto.comment.ChildCommentUpdateRequestDto; -import net.causw.app.main.api.dto.util.dtoMapper.CommentDtoMapper; -import net.causw.app.main.domain.campus.circle.entity.Circle; -import net.causw.app.main.domain.campus.circle.entity.CircleMember; -import net.causw.app.main.domain.campus.circle.enums.CircleMemberStatus; -import net.causw.app.main.shared.StatusPolicy; -import net.causw.app.main.domain.campus.circle.repository.CircleMemberRepository; import net.causw.app.main.domain.notification.notification.service.CommentNotificationService; -import net.causw.app.main.domain.campus.circle.util.CircleMemberStatusValidator; -import net.causw.app.main.shared.util.ConstraintValidator; -import net.causw.app.main.shared.util.ContentsAdminValidator; -import net.causw.app.main.shared.util.TargetIsDeletedValidator; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.domain.user.account.util.UserRoleIsNoneValidator; import net.causw.app.main.domain.user.account.util.UserStateIsDeletedValidator; import net.causw.app.main.domain.user.account.util.UserStateValidator; +import net.causw.app.main.shared.StatusPolicy; import net.causw.app.main.shared.ValidatorBucket; +import net.causw.app.main.shared.util.ConstraintValidator; +import net.causw.app.main.shared.util.ContentsAdminValidator; +import net.causw.app.main.shared.util.TargetIsDeletedValidator; import net.causw.app.main.shared.util.UserEqualValidator; import net.causw.global.constant.MessageUtil; import net.causw.global.constant.StaticValue; @@ -73,8 +73,7 @@ public ChildCommentResponseDto createChildComment(User creator, false, childCommentCreateRequestDto.getIsAnonymous(), creator, - parentComment - ); + parentComment); ValidatorBucket validatorBucket = initializeValidator(creator, post); validatorBucket @@ -85,8 +84,7 @@ public ChildCommentResponseDto createChildComment(User creator, ChildCommentResponseDto childCommentResponseDto = toChildCommentResponseDto( childCommentRepository.save(childComment), creator, - post.getBoard() - ); + post.getBoard()); //1. 여기선 그냥 댓글 달리면 알람을 보내게 하면됨 commentNotificationService.sendByCommentIsSubscribed(parentComment, childComment); @@ -98,8 +96,7 @@ public ChildCommentResponseDto createChildComment(User creator, public ChildCommentResponseDto updateChildComment( User updater, String childCommentId, - ChildCommentUpdateRequestDto childCommentUpdateRequestDto - ) { + ChildCommentUpdateRequestDto childCommentUpdateRequestDto) { Set roles = updater.getRoles(); ChildComment childComment = getChildComment(childCommentId); Post post = getPost(childComment.getParentComment().getPost().getId()); @@ -113,15 +110,13 @@ public ChildCommentResponseDto updateChildComment( roles, updater.getId(), childComment.getWriter().getId(), - List.of() - )); + List.of())); validatorBucket.validate(); return toChildCommentResponseDto( childCommentRepository.save(childComment), updater, - post.getBoard() - ); + post.getBoard()); } @Transactional @@ -145,14 +140,12 @@ public ChildCommentResponseDto deleteChildComment(User deleter, String childComm .consistOf(TargetIsDeletedValidator.of(circle.getIsDeleted(), StaticValue.DOMAIN_CIRCLE)) .consistOf(CircleMemberStatusValidator.of( member.getStatus(), - List.of(CircleMemberStatus.MEMBER) - )) + List.of(CircleMemberStatus.MEMBER))) .consistOf(ContentsAdminValidator.of( roles, deleter.getId(), childComment.getWriter().getId(), - List.of(Role.LEADER_CIRCLE) - )); + List.of(Role.LEADER_CIRCLE))); if (roles.contains(Role.LEADER_CIRCLE) && !childComment.getWriter() .getId() @@ -161,14 +154,12 @@ public ChildCommentResponseDto deleteChildComment(User deleter, String childComm if (leader == null) { throw new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.CIRCLE_WITHOUT_LEADER - ); + MessageUtil.CIRCLE_WITHOUT_LEADER); } validatorBucket .consistOf(UserEqualValidator.of( leader.getId(), - deleter.getId() - )); + deleter.getId())); } }, () -> validatorBucket @@ -176,8 +167,7 @@ public ChildCommentResponseDto deleteChildComment(User deleter, String childComm roles, deleter.getId(), childComment.getWriter().getId(), - List.of() - )) + List.of())) ); validatorBucket.validate(); @@ -187,8 +177,7 @@ public ChildCommentResponseDto deleteChildComment(User deleter, String childComm return toChildCommentResponseDto( childCommentRepository.save(childComment), deleter, - post.getBoard() - ); + post.getBoard()); } @Transactional @@ -246,8 +235,7 @@ private ValidatorBucket initializeValidator(User user, Post post) { .consistOf(TargetIsDeletedValidator.of(circle.getIsDeleted(), StaticValue.DOMAIN_CIRCLE)) .consistOf(CircleMemberStatusValidator.of( member.getStatus(), - List.of(CircleMemberStatus.MEMBER) - )); + List.of(CircleMemberStatus.MEMBER))); }); return validatorBucket; } @@ -260,8 +248,7 @@ private ChildCommentResponseDto toChildCommentResponseDto(ChildComment childComm StatusPolicy.isChildCommentOwner(childComment, user), StatusPolicy.isUpdatable(childComment, user), StatusPolicy.isDeletable(childComment, user, board), - false - ); + false); // 화면에 표시될 닉네임 설정 User writer = childComment.getWriter(); @@ -280,36 +267,28 @@ private Post getPost(String postId) { return postRepository.findById(postId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.POST_NOT_FOUND - ) - ); + MessageUtil.POST_NOT_FOUND)); } private Comment getComment(String commentId) { return commentRepository.findById(commentId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.COMMENT_NOT_FOUND - ) - ); + MessageUtil.COMMENT_NOT_FOUND)); } private ChildComment getChildComment(String childCommentId) { return childCommentRepository.findById(childCommentId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.COMMENT_NOT_FOUND - ) - ); + MessageUtil.COMMENT_NOT_FOUND)); } private CircleMember getCircleMember(String userId, String circleId) { return circleMemberRepository.findByUser_IdAndCircle_Id(userId, circleId).orElseThrow( () -> new UnauthorizedException( ErrorCode.NOT_MEMBER, - MessageUtil.CIRCLE_APPLY_INVALID - ) - ); + MessageUtil.CIRCLE_APPLY_INVALID)); } private void validateWriterNotDeleted(final ChildComment childComment) { @@ -319,4 +298,3 @@ private void validateWriterNotDeleted(final ChildComment childComment) { .validate(); } } - diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/comment/service/CommentEntityService.java b/app-main/src/main/java/net/causw/app/main/domain/community/comment/service/CommentEntityService.java index fd8a89b12..a50ad9d83 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/comment/service/CommentEntityService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/comment/service/CommentEntityService.java @@ -18,11 +18,8 @@ public class CommentEntityService { public Comment findByIdNotDeleted(String commentId) { - return commentRepository.findByIdAndIsDeletedFalse(commentId).orElseThrow(() -> - new NotFoundException( - ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.COMMENT_NOT_FOUND - ) - ); + return commentRepository.findByIdAndIsDeletedFalse(commentId).orElseThrow(() -> new NotFoundException( + ErrorCode.ROW_DOES_NOT_EXIST, + MessageUtil.COMMENT_NOT_FOUND)); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/comment/service/CommentService.java b/app-main/src/main/java/net/causw/app/main/domain/community/comment/service/CommentService.java index 4967b500f..fe20b823e 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/comment/service/CommentService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/comment/service/CommentService.java @@ -9,7 +9,18 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import net.causw.app.main.api.dto.comment.ChildCommentResponseDto; +import net.causw.app.main.api.dto.comment.CommentCreateRequestDto; +import net.causw.app.main.api.dto.comment.CommentResponseDto; +import net.causw.app.main.api.dto.comment.CommentSubscribeResponseDto; +import net.causw.app.main.api.dto.comment.CommentUpdateRequestDto; +import net.causw.app.main.api.dto.util.dtoMapper.CommentDtoMapper; import net.causw.app.main.core.aop.annotation.MeasureTime; +import net.causw.app.main.domain.campus.circle.entity.Circle; +import net.causw.app.main.domain.campus.circle.entity.CircleMember; +import net.causw.app.main.domain.campus.circle.enums.CircleMemberStatus; +import net.causw.app.main.domain.campus.circle.repository.CircleMemberRepository; +import net.causw.app.main.domain.campus.circle.util.CircleMemberStatusValidator; import net.causw.app.main.domain.community.board.entity.Board; import net.causw.app.main.domain.community.comment.entity.ChildComment; import net.causw.app.main.domain.community.comment.entity.Comment; @@ -21,32 +32,21 @@ import net.causw.app.main.domain.community.post.entity.Post; import net.causw.app.main.domain.community.post.repository.PostRepository; import net.causw.app.main.domain.community.post.service.PostService; -import net.causw.app.main.api.dto.comment.ChildCommentResponseDto; -import net.causw.app.main.api.dto.comment.CommentCreateRequestDto; -import net.causw.app.main.api.dto.comment.CommentResponseDto; -import net.causw.app.main.api.dto.comment.CommentSubscribeResponseDto; -import net.causw.app.main.api.dto.comment.CommentUpdateRequestDto; -import net.causw.app.main.api.dto.util.dtoMapper.CommentDtoMapper; -import net.causw.app.main.domain.campus.circle.entity.Circle; -import net.causw.app.main.domain.campus.circle.entity.CircleMember; import net.causw.app.main.domain.notification.notification.entity.UserCommentSubscribe; -import net.causw.app.main.domain.campus.circle.enums.CircleMemberStatus; -import net.causw.app.main.shared.StatusPolicy; -import net.causw.app.main.domain.campus.circle.repository.CircleMemberRepository; import net.causw.app.main.domain.notification.notification.repository.UserCommentSubscribeRepository; import net.causw.app.main.domain.notification.notification.service.PostNotificationService; -import net.causw.app.main.domain.campus.circle.util.CircleMemberStatusValidator; -import net.causw.app.main.shared.util.ConstraintValidator; -import net.causw.app.main.shared.util.ContentsAdminValidator; -import net.causw.app.main.shared.util.TargetIsDeletedValidator; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.domain.user.account.util.UserRoleIsNoneValidator; import net.causw.app.main.domain.user.account.util.UserStateIsDeletedValidator; import net.causw.app.main.domain.user.account.util.UserStateValidator; import net.causw.app.main.domain.user.relation.service.UserBlockEntityService; +import net.causw.app.main.shared.StatusPolicy; import net.causw.app.main.shared.ValidatorBucket; import net.causw.app.main.shared.pageable.PageableFactory; +import net.causw.app.main.shared.util.ConstraintValidator; +import net.causw.app.main.shared.util.ContentsAdminValidator; +import net.causw.app.main.shared.util.TargetIsDeletedValidator; import net.causw.app.main.shared.util.UserEqualValidator; import net.causw.global.constant.MessageUtil; import net.causw.global.constant.StaticValue; @@ -83,13 +83,11 @@ public CommentResponseDto createComment(User creator, CommentCreateRequestDto co post); ValidatorBucket validatorBucket = initializeValidator(creator, post); - validatorBucket. - consistOf(ConstraintValidator.of(comment, this.validator)); + validatorBucket.consistOf(ConstraintValidator.of(comment, this.validator)); validatorBucket.validate(); //1. comment의 구독 여부 저장 CommentResponseDto commentResponseDto = toCommentResponseDto( - commentRepository.save(comment), creator, post.getBoard() - , Set.of()); + commentRepository.save(comment), creator, post.getBoard(), Set.of()); createCommentSubscribe(creator, comment.getId()); @@ -110,8 +108,7 @@ public Page findAllComments(User user, String postId, Intege Page comments = commentRepository.findByPost_IdOrderByCreatedAt( postId, - pageableFactory.create(pageNum, StaticValue.DEFAULT_POST_PAGE_SIZE) - ); + pageableFactory.create(pageNum, StaticValue.DEFAULT_POST_PAGE_SIZE)); comments.forEach( comment -> comment.setChildCommentList(childCommentRepository.findByParentComment_Id(comment.getId()))); @@ -122,8 +119,7 @@ public Page findAllComments(User user, String postId, Intege public CommentResponseDto updateComment( User updater, String commentId, - CommentUpdateRequestDto commentUpdateRequestDto - ) { + CommentUpdateRequestDto commentUpdateRequestDto) { Set roles = updater.getRoles(); Comment comment = getComment(commentId); Post post = getPost(comment.getPost().getId()); @@ -136,8 +132,7 @@ public CommentResponseDto updateComment( roles, updater.getId(), comment.getWriter().getId(), - List.of() - )); + List.of())); validatorBucket.validate(); comment.update(commentUpdateRequestDto.getContent()); @@ -169,14 +164,12 @@ public CommentResponseDto deleteComment(User deleter, String commentId) { .consistOf(TargetIsDeletedValidator.of(circle.getIsDeleted(), StaticValue.DOMAIN_CIRCLE)) .consistOf(CircleMemberStatusValidator.of( member.getStatus(), - List.of(CircleMemberStatus.MEMBER) - )) + List.of(CircleMemberStatus.MEMBER))) .consistOf(ContentsAdminValidator.of( roles, deleter.getId(), comment.getWriter().getId(), - List.of(Role.LEADER_CIRCLE) - )); + List.of(Role.LEADER_CIRCLE))); if (roles.contains(Role.LEADER_CIRCLE) && !comment.getWriter().getId().equals(deleter.getId())) { validatorBucket @@ -186,10 +179,8 @@ public CommentResponseDto deleteComment(User deleter, String commentId) { ErrorCode.ROW_DOES_NOT_EXIST, MessageUtil.CIRCLE_WITHOUT_LEADER - ) - ), - deleter.getId() - )); + )), + deleter.getId())); } }, () -> validatorBucket @@ -197,9 +188,7 @@ public CommentResponseDto deleteComment(User deleter, String commentId) { roles, deleter.getId(), comment.getWriter().getId(), - List.of() - )) - ); + List.of()))); validatorBucket.validate(); comment.delete(); @@ -288,15 +277,13 @@ private CommentResponseDto toCommentResponseDto(Comment comment, User user, Boar StatusPolicy.isUpdatable(comment, user), StatusPolicy.isDeletable(comment, user, board), isCommentSubscribed(user, comment), - isBlockedContent - ); + isBlockedContent); // 화면에 표시될 닉네임 설정 User writer = comment.getWriter(); commentResponseDto.setDisplayWriterNickname( postService.getDisplayWriterNickname(writer, commentResponseDto.getIsAnonymous(), - commentResponseDto.getWriterNickname()) - ); + commentResponseDto.getWriterNickname())); if (comment.getIsAnonymous()) { commentResponseDto.updateAnonymousUserInfo(); @@ -316,8 +303,7 @@ private ChildCommentResponseDto toChildCommentResponseDto(ChildComment childComm StatusPolicy.isChildCommentOwner(childComment, user), StatusPolicy.isUpdatable(childComment, user), StatusPolicy.isDeletable(childComment, user, board), - isBlockedContent - ); + isBlockedContent); // 화면에 표시될 닉네임 설정 User writer = childComment.getWriter(); @@ -360,8 +346,7 @@ private ValidatorBucket initializeValidator(User user, Post post) { .consistOf(TargetIsDeletedValidator.of(circle.getIsDeleted(), StaticValue.DOMAIN_CIRCLE)) .consistOf(CircleMemberStatusValidator.of( member.getStatus(), - List.of(CircleMemberStatus.MEMBER) - )); + List.of(CircleMemberStatus.MEMBER))); }); return validatorBucket; } @@ -370,27 +355,21 @@ private Post getPost(String postId) { return postRepository.findById(postId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.POST_NOT_FOUND - ) - ); + MessageUtil.POST_NOT_FOUND)); } private Comment getComment(String commentId) { return commentRepository.findById(commentId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.COMMENT_NOT_FOUND - ) - ); + MessageUtil.COMMENT_NOT_FOUND)); } private CircleMember getCircleMember(String userId, String circleId) { return circleMemberRepository.findByUser_IdAndCircle_Id(userId, circleId).orElseThrow( () -> new UnauthorizedException( ErrorCode.NOT_MEMBER, - MessageUtil.CIRCLE_APPLY_INVALID - ) - ); + MessageUtil.CIRCLE_APPLY_INVALID)); } private Boolean isCommentSubscribed(User user, Comment comment) { @@ -407,8 +386,3 @@ private void validateWriterNotDeleted(final Comment comment) { } } - - - - - diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/comment/util/ChildCommentNotEqualValidator.java b/app-main/src/main/java/net/causw/app/main/domain/community/comment/util/ChildCommentNotEqualValidator.java index 590ddd3b6..669d862d9 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/comment/util/ChildCommentNotEqualValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/comment/util/ChildCommentNotEqualValidator.java @@ -24,8 +24,7 @@ public void validate() { if (this.srcChildCommentId.equals(this.targetChildCommentId)) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - "해당 답장에 답할 수 없습니다." - ); + "해당 답장에 답할 수 없습니다."); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/comment/util/PostNumberOfAttachmentsValidator.java b/app-main/src/main/java/net/causw/app/main/domain/community/comment/util/PostNumberOfAttachmentsValidator.java index 9cdcaa4e9..73da391d5 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/comment/util/PostNumberOfAttachmentsValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/comment/util/PostNumberOfAttachmentsValidator.java @@ -1,6 +1,6 @@ package net.causw.app.main.domain.community.comment.util; -import static net.causw.global.constant.StaticValue.*; +import static net.causw.global.constant.StaticValue.MAX_NUM_FILE_ATTACHMENTS; import java.util.List; @@ -26,8 +26,7 @@ public void validate() { if (multipartFileList != null && multipartFileList.size() > MAX_NUM_FILE_ATTACHMENTS) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - "4개 이상의 파일을 첨부할 수 없습니다." - ); + "4개 이상의 파일을 첨부할 수 없습니다."); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/Form.java b/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/Form.java index dc1cc1e47..ff0481059 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/Form.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/Form.java @@ -4,11 +4,11 @@ import java.util.EnumSet; import java.util.List; +import net.causw.app.main.api.dto.form.request.create.FormCreateRequestDto; +import net.causw.app.main.domain.campus.circle.entity.Circle; import net.causw.app.main.domain.community.form.enums.FormType; import net.causw.app.main.domain.community.form.enums.RegisteredSemester; import net.causw.app.main.domain.community.form.enums.RegisteredSemesterManager; -import net.causw.app.main.api.dto.form.request.create.FormCreateRequestDto; -import net.causw.app.main.domain.campus.circle.entity.Circle; import net.causw.app.main.shared.entity.BaseEntity; import jakarta.persistence.CascadeType; @@ -33,10 +33,9 @@ @Builder(access = AccessLevel.PROTECTED) @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) -@Table(name = "tb_form", - indexes = { - @Index(name = "circle_id_index", columnList = "circle_id") - }) +@Table(name = "tb_form", indexes = { + @Index(name = "circle_id_index", columnList = "circle_id") +}) public class Form extends BaseEntity { @Enumerated(EnumType.STRING) @@ -101,35 +100,29 @@ public EnumSet getLeaveOfAbsenceRegisteredSemester() { public static Form createPostForm( FormCreateRequestDto formCreateRequestDto, - List formQuestionList - ) { + List formQuestionList) { return Form.builder() .formType(FormType.POST_FORM) .title(formCreateRequestDto.getTitle()) .formQuestionList(formQuestionList) .isAllowedEnrolled(formCreateRequestDto.getIsAllowedEnrolled()) .EnrolledRegisteredSemester( - formCreateRequestDto.getIsAllowedEnrolled() ? - RegisteredSemesterManager.fromEnumList( - formCreateRequestDto.getEnrolledRegisteredSemesterList() - ).serialize() + formCreateRequestDto.getIsAllowedEnrolled() ? RegisteredSemesterManager.fromEnumList( + formCreateRequestDto.getEnrolledRegisteredSemesterList()).serialize() : null) .isNeedCouncilFeePaid( (formCreateRequestDto.getIsAllowedEnrolled() - && formCreateRequestDto.getIsNeedCouncilFeePaid() != null) ? - formCreateRequestDto.getIsNeedCouncilFeePaid() - : false - ) + && formCreateRequestDto.getIsNeedCouncilFeePaid() != null) + ? formCreateRequestDto.getIsNeedCouncilFeePaid() + : false) .isAllowedLeaveOfAbsence(formCreateRequestDto.getIsAllowedLeaveOfAbsence()) .LeaveOfAbsenceRegisteredSemester( (formCreateRequestDto.getIsAllowedLeaveOfAbsence() && !(formCreateRequestDto.getLeaveOfAbsenceRegisteredSemesterList() == null || - formCreateRequestDto.getLeaveOfAbsenceRegisteredSemesterList().isEmpty()) - ) ? - RegisteredSemesterManager.fromEnumList( - formCreateRequestDto.getLeaveOfAbsenceRegisteredSemesterList() - ).serialize() - : null) + formCreateRequestDto.getLeaveOfAbsenceRegisteredSemesterList().isEmpty())) + ? RegisteredSemesterManager.fromEnumList( + formCreateRequestDto.getLeaveOfAbsenceRegisteredSemesterList()).serialize() + : null) .isAllowedGraduation(formCreateRequestDto.getIsAllowedGraduation()) .build(); } @@ -137,8 +130,7 @@ public static Form createPostForm( public static Form createCircleApplicationForm( FormCreateRequestDto formCreateRequestDto, List formQuestionList, - Circle circle - ) { + Circle circle) { return Form.builder() .formType(FormType.CIRCLE_APPLICATION_FORM) .title(formCreateRequestDto.getTitle()) @@ -146,27 +138,22 @@ public static Form createCircleApplicationForm( .circle(circle) .isAllowedEnrolled(formCreateRequestDto.getIsAllowedEnrolled()) .EnrolledRegisteredSemester( - formCreateRequestDto.getIsAllowedEnrolled() ? - RegisteredSemesterManager.fromEnumList( - formCreateRequestDto.getEnrolledRegisteredSemesterList() - ).serialize() + formCreateRequestDto.getIsAllowedEnrolled() ? RegisteredSemesterManager.fromEnumList( + formCreateRequestDto.getEnrolledRegisteredSemesterList()).serialize() : null) .isNeedCouncilFeePaid( (formCreateRequestDto.getIsAllowedEnrolled() - && formCreateRequestDto.getIsNeedCouncilFeePaid() != null) ? - formCreateRequestDto.getIsNeedCouncilFeePaid() - : false - ) + && formCreateRequestDto.getIsNeedCouncilFeePaid() != null) + ? formCreateRequestDto.getIsNeedCouncilFeePaid() + : false) .isAllowedLeaveOfAbsence(formCreateRequestDto.getIsAllowedLeaveOfAbsence()) .LeaveOfAbsenceRegisteredSemester( (formCreateRequestDto.getIsAllowedLeaveOfAbsence() && !(formCreateRequestDto.getLeaveOfAbsenceRegisteredSemesterList() == null || - formCreateRequestDto.getLeaveOfAbsenceRegisteredSemesterList().isEmpty()) - ) ? - RegisteredSemesterManager.fromEnumList( - formCreateRequestDto.getLeaveOfAbsenceRegisteredSemesterList() - ).serialize() - : null) + formCreateRequestDto.getLeaveOfAbsenceRegisteredSemesterList().isEmpty())) + ? RegisteredSemesterManager.fromEnumList( + formCreateRequestDto.getLeaveOfAbsenceRegisteredSemesterList()).serialize() + : null) .isAllowedGraduation(formCreateRequestDto.getIsAllowedGraduation()) .build(); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/FormQuestion.java b/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/FormQuestion.java index 8c7269140..52b227268 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/FormQuestion.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/FormQuestion.java @@ -3,8 +3,8 @@ import java.util.ArrayList; import java.util.List; -import net.causw.app.main.domain.community.form.enums.QuestionType; import net.causw.app.main.api.dto.form.request.create.QuestionCreateRequestDto; +import net.causw.app.main.domain.community.form.enums.QuestionType; import net.causw.app.main.shared.entity.BaseEntity; import jakarta.persistence.CascadeType; @@ -30,10 +30,9 @@ @Builder(access = AccessLevel.PROTECTED) @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) -@Table(name = "tb_form_question", - indexes = { - @Index(name = "form_id_index", columnList = "form_id") - }) +@Table(name = "tb_form_question", indexes = { + @Index(name = "form_id_index", columnList = "form_id") +}) public class FormQuestion extends BaseEntity { @Column(name = "number", nullable = false) @@ -62,8 +61,7 @@ public class FormQuestion extends BaseEntity { public static FormQuestion createObjectiveQuestion( Integer number, QuestionCreateRequestDto questionCreateRequestDto, - List formQuestionOptionList - ) { + List formQuestionOptionList) { return FormQuestion.builder() .number(number) .questionType(questionCreateRequestDto.getQuestionType()) @@ -75,8 +73,7 @@ public static FormQuestion createObjectiveQuestion( public static FormQuestion createSubjectQuestion( Integer number, - QuestionCreateRequestDto questionCreateRequestDto - ) { + QuestionCreateRequestDto questionCreateRequestDto) { return FormQuestion.builder() .number(number) .questionType(questionCreateRequestDto.getQuestionType()) diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/FormQuestionOption.java b/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/FormQuestionOption.java index 1684a01b3..b0ebee7fb 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/FormQuestionOption.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/FormQuestionOption.java @@ -20,10 +20,9 @@ @Builder(access = AccessLevel.PROTECTED) @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) -@Table(name = "tb_form_question_option", - indexes = { - @Index(name = "form_question_id_index", columnList = "form_question_id") - }) +@Table(name = "tb_form_question_option", indexes = { + @Index(name = "form_question_id_index", columnList = "form_question_id") +}) public class FormQuestionOption extends BaseEntity { @Column(name = "number", nullable = false) diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/Reply.java b/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/Reply.java index 4355a9990..9f4dddaee 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/Reply.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/Reply.java @@ -42,8 +42,7 @@ public class Reply extends BaseEntity { public static Reply of( Form form, User user, - List replyQuestionList - ) { + List replyQuestionList) { return Reply.builder() .form(form) .user(user) diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/ReplyQuestion.java b/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/ReplyQuestion.java index ed84ca3f4..59ce0f113 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/ReplyQuestion.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/ReplyQuestion.java @@ -24,11 +24,10 @@ @Builder(access = AccessLevel.PROTECTED) @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) -@Table(name = "tb_reply_question", - indexes = { - @Index(name = "reply_id_index", columnList = "reply_id"), - @Index(name = "form_question_id_index", columnList = "form_question_id") - }) +@Table(name = "tb_reply_question", indexes = { + @Index(name = "reply_id_index", columnList = "reply_id"), + @Index(name = "form_question_id_index", columnList = "form_question_id") +}) public class ReplyQuestion extends BaseEntity { @Setter @@ -50,8 +49,7 @@ public class ReplyQuestion extends BaseEntity { public static ReplyQuestion of( FormQuestion formQuestion, String questionAnswer, - List selectedOptionList - ) { + List selectedOptionList) { return ReplyQuestion.builder() .formQuestion(formQuestion) .questionAnswer(questionAnswer) diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/ReplySelectedOptionManager.java b/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/ReplySelectedOptionManager.java index 76520f711..fc2e6a3d0 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/ReplySelectedOptionManager.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/form/entity/ReplySelectedOptionManager.java @@ -39,8 +39,7 @@ public void deserialize(String selectedOptionString) { } public static ReplySelectedOptionManager fromIntegerList( - List selectedOptionList - ) { + List selectedOptionList) { if (selectedOptionList == null || selectedOptionList.isEmpty()) { return new ReplySelectedOptionManager(); } @@ -49,8 +48,7 @@ public static ReplySelectedOptionManager fromIntegerList( } public static ReplySelectedOptionManager fromString( - String selectedOptionString - ) { + String selectedOptionString) { if (selectedOptionString == null || selectedOptionString.isBlank() || selectedOptionString.isEmpty()) { return new ReplySelectedOptionManager(); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/form/enums/RegisteredSemesterManager.java b/app-main/src/main/java/net/causw/app/main/domain/community/form/enums/RegisteredSemesterManager.java index 1626ffc8a..6c9cd0224 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/form/enums/RegisteredSemesterManager.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/form/enums/RegisteredSemesterManager.java @@ -39,8 +39,7 @@ public void deserialize(String registeredSemesterString) { } public static RegisteredSemesterManager fromEnumList( - List registeredSemesterList - ) { + List registeredSemesterList) { if (registeredSemesterList.isEmpty()) { return new RegisteredSemesterManager(); } @@ -48,8 +47,7 @@ public static RegisteredSemesterManager fromEnumList( } public static RegisteredSemesterManager fromString( - String registeredSemesterString - ) { + String registeredSemesterString) { if (registeredSemesterString == null) { return new RegisteredSemesterManager(); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/form/repository/FormRepository.java b/app-main/src/main/java/net/causw/app/main/domain/community/form/repository/FormRepository.java index e8b6fd089..01063c25a 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/form/repository/FormRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/form/repository/FormRepository.java @@ -9,13 +9,14 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import net.causw.app.main.domain.community.form.entity.Form; import net.causw.app.main.domain.campus.circle.entity.Circle; +import net.causw.app.main.domain.community.form.entity.Form; @Repository public interface FormRepository extends JpaRepository { @NotNull - Optional findByIdAndIsDeleted(@NotNull String id, Boolean isDeleted); + Optional findByIdAndIsDeleted(@NotNull + String id, Boolean isDeleted); List findAllByCircleAndIsDeletedAndIsClosed(Circle circle, Boolean isDeleted, Boolean isClosed); diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/form/repository/ReplyQuestionRepository.java b/app-main/src/main/java/net/causw/app/main/domain/community/form/repository/ReplyQuestionRepository.java index ceaa8ee83..d22e558e7 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/form/repository/ReplyQuestionRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/form/repository/ReplyQuestionRepository.java @@ -12,7 +12,8 @@ public interface ReplyQuestionRepository extends JpaRepository { @NotNull - Optional findById(@NotNull String id); + Optional findById(@NotNull + String id); List findAllByReplyForm(Form form); diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/form/service/FormService.java b/app-main/src/main/java/net/causw/app/main/domain/community/form/service/FormService.java index 11af415d1..80a8ac1bf 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/form/service/FormService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/form/service/FormService.java @@ -15,27 +15,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import net.causw.app.main.core.aop.annotation.MeasureTime; -import net.causw.app.main.domain.community.board.entity.Board; -import net.causw.app.main.domain.community.board.repository.BoardRepository; -import net.causw.app.main.domain.community.form.entity.Form; -import net.causw.app.main.domain.community.form.entity.FormQuestion; -import net.causw.app.main.domain.community.form.entity.FormQuestionOption; -import net.causw.app.main.domain.community.form.entity.Reply; -import net.causw.app.main.domain.community.form.entity.ReplyQuestion; -import net.causw.app.main.domain.community.form.enums.FormType; -import net.causw.app.main.domain.community.form.enums.QuestionType; -import net.causw.app.main.domain.community.form.enums.RegisteredSemester; -import net.causw.app.main.domain.community.form.repository.FormRepository; -import net.causw.app.main.domain.community.form.repository.OptionRepository; -import net.causw.app.main.domain.community.form.repository.QuestionRepository; -import net.causw.app.main.domain.community.form.repository.ReplyQuestionRepository; -import net.causw.app.main.domain.community.form.repository.ReplyRepository; -import net.causw.app.main.domain.community.post.entity.Post; -import net.causw.app.main.domain.community.post.repository.PostRepository; -import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFee; -import net.causw.app.main.domain.finance.usercouncilfee.repository.UserCouncilFeeRepository; -import net.causw.app.main.domain.integration.export.service.FormExcelService; import net.causw.app.main.api.dto.form.request.FormReplyRequestDto; import net.causw.app.main.api.dto.form.request.QuestionReplyRequestDto; import net.causw.app.main.api.dto.form.response.FormResponseDto; @@ -52,12 +31,33 @@ import net.causw.app.main.api.dto.form.response.reply.excel.ExcelReplyQuestionResponseDto; import net.causw.app.main.api.dto.form.response.reply.excel.ExcelReplyResponseDto; import net.causw.app.main.api.dto.util.dtoMapper.FormDtoMapper; +import net.causw.app.main.core.aop.annotation.MeasureTime; import net.causw.app.main.domain.campus.circle.entity.Circle; import net.causw.app.main.domain.campus.circle.entity.CircleMember; import net.causw.app.main.domain.campus.circle.enums.CircleMemberStatus; -import net.causw.app.main.domain.finance.usercouncilfee.policy.UserCouncilFeePolicy; import net.causw.app.main.domain.campus.circle.repository.CircleMemberRepository; import net.causw.app.main.domain.campus.circle.repository.CircleRepository; +import net.causw.app.main.domain.community.board.entity.Board; +import net.causw.app.main.domain.community.board.repository.BoardRepository; +import net.causw.app.main.domain.community.form.entity.Form; +import net.causw.app.main.domain.community.form.entity.FormQuestion; +import net.causw.app.main.domain.community.form.entity.FormQuestionOption; +import net.causw.app.main.domain.community.form.entity.Reply; +import net.causw.app.main.domain.community.form.entity.ReplyQuestion; +import net.causw.app.main.domain.community.form.enums.FormType; +import net.causw.app.main.domain.community.form.enums.QuestionType; +import net.causw.app.main.domain.community.form.enums.RegisteredSemester; +import net.causw.app.main.domain.community.form.repository.FormRepository; +import net.causw.app.main.domain.community.form.repository.OptionRepository; +import net.causw.app.main.domain.community.form.repository.QuestionRepository; +import net.causw.app.main.domain.community.form.repository.ReplyQuestionRepository; +import net.causw.app.main.domain.community.form.repository.ReplyRepository; +import net.causw.app.main.domain.community.post.entity.Post; +import net.causw.app.main.domain.community.post.repository.PostRepository; +import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFee; +import net.causw.app.main.domain.finance.usercouncilfee.policy.UserCouncilFeePolicy; +import net.causw.app.main.domain.finance.usercouncilfee.repository.UserCouncilFeeRepository; +import net.causw.app.main.domain.integration.export.service.FormExcelService; import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.enums.user.Role; @@ -94,8 +94,7 @@ public class FormService { public void setFormIsClosed( String formId, User user, - Boolean targetIsClosed - ) { + Boolean targetIsClosed) { Form form = getForm(formId); validateCanAccessFormResult(user, form); @@ -146,24 +145,21 @@ public FormResponseDto getFormById(User user, String formId) { public void replyForm( String formId, FormReplyRequestDto formReplyRequestDto, - User writer - ) { + User writer) { Form form = getForm(formId); // 동아리 신청서의 경우 본 API 통해서 답변 불가. Circle Controller 사용 필수 if (form.getFormType().equals(FormType.CIRCLE_APPLICATION_FORM)) { throw new BadRequestException( ErrorCode.NOT_ALLOWED_TO_REPLY_FORM, - MessageUtil.NOT_ALLOWED_TO_REPLY_FORM - ); + MessageUtil.NOT_ALLOWED_TO_REPLY_FORM); } // 제출 가능한지 검사 if (form.getIsClosed()) { throw new BadRequestException( ErrorCode.NOT_ALLOWED_TO_REPLY_FORM, - MessageUtil.FORM_CLOSED - ); + MessageUtil.FORM_CLOSED); } // writer가 해당 form이 있는 post에 접근 가능한지 검사 @@ -186,15 +182,13 @@ public void replyForm( if (questionReplyRequestDto.getQuestionReply() != null) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_REPLY_INFO - ); + MessageUtil.INVALID_REPLY_INFO); } if (!formQuestion.getIsMultiple() && questionReplyRequestDto.getSelectedOptionList().size() > 1) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_REPLY_INFO - ); + MessageUtil.INVALID_REPLY_INFO); } // 객관식일 시: 유효한 옵션 번호 선택했는지 검사 @@ -207,8 +201,7 @@ public void replyForm( if (!formQuestionOptionNumberList.contains(optionNumber)) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_REPLY_INFO - ); + MessageUtil.INVALID_REPLY_INFO); } }); } @@ -217,20 +210,18 @@ public void replyForm( if (questionReplyRequestDto.getSelectedOptionList() != null) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_REPLY_INFO - ); + MessageUtil.INVALID_REPLY_INFO); } } ReplyQuestion replyQuestion = ReplyQuestion.of( formQuestion, - formQuestion.getQuestionType().equals(QuestionType.SUBJECTIVE) ? - questionReplyRequestDto.getQuestionReply() + formQuestion.getQuestionType().equals(QuestionType.SUBJECTIVE) + ? questionReplyRequestDto.getQuestionReply() : null, - formQuestion.getQuestionType().equals(QuestionType.OBJECTIVE) ? - questionReplyRequestDto.getSelectedOptionList() - : null - ); + formQuestion.getQuestionType().equals(QuestionType.OBJECTIVE) + ? questionReplyRequestDto.getSelectedOptionList() + : null); replyQuestionList.add(replyQuestion); } @@ -239,8 +230,7 @@ public void replyForm( if (replyQuestionList.size() != form.getFormQuestionList().size()) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.REPLY_SIZE_INVALID - ); + MessageUtil.REPLY_SIZE_INVALID); } // 모든 문항에 대해 답변 정확히 하나 있는지 검사(답변 유효성 검사) @@ -254,8 +244,7 @@ public void replyForm( if (questionReplyCount != 1) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_REPLY_INFO - ); + MessageUtil.INVALID_REPLY_INFO); } }); @@ -292,17 +281,14 @@ public List findSummaryReply(String formId, User use formQuestion -> formQuestion, formQuestion -> replyQuestionList.stream() .filter(replyQuestion -> replyQuestion.getFormQuestion().equals(formQuestion)) - .collect(Collectors.toList()) - )); + .collect(Collectors.toList()))); List questionSummaryResponseDtoList = new ArrayList<>(); for (FormQuestion formQuestion : formQuestionList) { questionSummaryResponseDtoList.add( toQuestionSummaryResponseDto( formQuestion, - replyQuestionMap.get(formQuestion) - ) - ); + replyQuestionMap.get(formQuestion))); } return questionSummaryResponseDtoList; @@ -337,15 +323,13 @@ public void exportFormResult(String formId, User user, HttpServletResponse respo "납부 시점 학기", "납부한 학기 수", "잔여 학생회비 적용 학기", - "환불 여부" - )); + "환불 여부")); List questionStringList = excelReplyListResponseDto.getQuestionResponseDtoList() .stream() - .map(questionResponseDto -> ( - questionResponseDto.getQuestionNumber().toString() - + "." - + questionResponseDto.getQuestionText() - )).toList(); + .map(questionResponseDto -> (questionResponseDto.getQuestionNumber().toString() + + "." + + questionResponseDto.getQuestionText())) + .toList(); headerStringList.addAll(questionStringList); LinkedHashMap> sheetNameDataMap = new LinkedHashMap<>(); @@ -355,8 +339,7 @@ public void exportFormResult(String formId, User user, HttpServletResponse respo response, fileName, headerStringList, - sheetNameDataMap - ); + sheetNameDataMap); } // private methods @@ -365,8 +348,7 @@ private void validDuplicateReplyExist(User writer, Form form) { if (replyRepository.existsByFormAndUser(form, writer)) { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.ALREADY_REPLIED - ); + MessageUtil.ALREADY_REPLIED); } } @@ -384,23 +366,19 @@ private void validateToReply(User writer, Form form) { if (!allowedAcademicStatus.contains(writer.getAcademicStatus())) { throw new BadRequestException( ErrorCode.NOT_ALLOWED_TO_REPLY_FORM, - MessageUtil.NOT_ALLOWED_TO_REPLY_FORM - ); + MessageUtil.NOT_ALLOWED_TO_REPLY_FORM); } else { if (allowedAcademicStatus.contains(AcademicStatus.ENROLLED) - && writer.getAcademicStatus().equals(AcademicStatus.ENROLLED) - ) { + && writer.getAcademicStatus().equals(AcademicStatus.ENROLLED)) { EnumSet allowedRegisteredSemester = form.getEnrolledRegisteredSemester(); if (!allowedRegisteredSemester .stream() .map(RegisteredSemester::getSemester) .collect(Collectors.toSet()) - .contains(writer.getCurrentCompletedSemester()) - ) { + .contains(writer.getCurrentCompletedSemester())) { throw new BadRequestException( ErrorCode.NOT_ALLOWED_TO_REPLY_FORM, - MessageUtil.NOT_ALLOWED_TO_REPLY_FORM - ); + MessageUtil.NOT_ALLOWED_TO_REPLY_FORM); } if (form.getIsNeedCouncilFeePaid()) { @@ -408,33 +386,27 @@ private void validateToReply(User writer, Form form) { UserCouncilFee userCouncilFee = userCouncilFeeRepository.findByUser(writer).orElseThrow( () -> new BadRequestException( ErrorCode.NOT_ALLOWED_TO_REPLY_FORM, - MessageUtil.NOT_ALLOWED_TO_REPLY_FORM - ) - ); + MessageUtil.NOT_ALLOWED_TO_REPLY_FORM)); if (!UserCouncilFeePolicy.isAppliedCurrentSemesterWithUser(userCouncilFee)) { throw new BadRequestException( ErrorCode.NOT_ALLOWED_TO_REPLY_FORM, - MessageUtil.NOT_ALLOWED_TO_REPLY_FORM - ); + MessageUtil.NOT_ALLOWED_TO_REPLY_FORM); } } } if (allowedAcademicStatus.contains(AcademicStatus.LEAVE_OF_ABSENCE) - && writer.getAcademicStatus().equals(AcademicStatus.LEAVE_OF_ABSENCE) - ) { + && writer.getAcademicStatus().equals(AcademicStatus.LEAVE_OF_ABSENCE)) { EnumSet allowedRegisteredSemester = form.getLeaveOfAbsenceRegisteredSemester(); if (!allowedRegisteredSemester .stream() .map(RegisteredSemester::getSemester) .collect(Collectors.toSet()) - .contains(writer.getCurrentCompletedSemester()) - ) { + .contains(writer.getCurrentCompletedSemester())) { throw new BadRequestException( ErrorCode.NOT_ALLOWED_TO_REPLY_FORM, - MessageUtil.NOT_ALLOWED_TO_REPLY_FORM - ); + MessageUtil.NOT_ALLOWED_TO_REPLY_FORM); } } } @@ -446,31 +418,25 @@ private void validateCanAccessFormResult(User user, Form form) { if (!post.getWriter().equals(user)) { throw new UnauthorizedException( ErrorCode.API_NOT_ALLOWED, - MessageUtil.NOT_ALLOWED_TO_ACCESS_REPLY - ); + MessageUtil.NOT_ALLOWED_TO_ACCESS_REPLY); } } else { Circle circle = form.getCircle(); if (circle == null) { throw new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.INTERNAL_SERVER_ERROR - ); + MessageUtil.INTERNAL_SERVER_ERROR); } CircleMember circleMember = circleMemberRepository.findByUser_IdAndCircle_Id(user.getId(), circle.getId()) .orElseThrow( () -> new UnauthorizedException( ErrorCode.NOT_MEMBER, - MessageUtil.CIRCLE_APPLY_INVALID - ) - ); + MessageUtil.CIRCLE_APPLY_INVALID)); if (circleMember.getStatus().equals(CircleMemberStatus.MEMBER) || - !user.getRoles().contains(Role.LEADER_CIRCLE) - ) { + !user.getRoles().contains(Role.LEADER_CIRCLE)) { throw new UnauthorizedException( ErrorCode.API_NOT_ALLOWED, - MessageUtil.NOT_ALLOWED_TO_ACCESS_REPLY - ); + MessageUtil.NOT_ALLOWED_TO_ACCESS_REPLY); } } } @@ -479,36 +445,28 @@ private User getUser(String userId) { return userRepository.findById(userId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - ) - ); + MessageUtil.USER_NOT_FOUND)); } private Form getForm(String formId) { return formRepository.findByIdAndIsDeleted(formId, false).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.FORM_NOT_FOUND - ) - ); + MessageUtil.FORM_NOT_FOUND)); } private FormQuestion getQuestion(String questionId) { return questionRepository.findById(questionId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.QUESTION_NOT_FOUND - ) - ); + MessageUtil.QUESTION_NOT_FOUND)); } private FormQuestionOption getOption(String optionId) { return optionRepository.findById(optionId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.OPTION_NOT_FOUND - ) - ); + MessageUtil.OPTION_NOT_FOUND)); } @@ -516,27 +474,21 @@ private Circle getCircle(String circleId) { return circleRepository.findById(circleId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.SMALL_CLUB_NOT_FOUND - ) - ); + MessageUtil.SMALL_CLUB_NOT_FOUND)); } private Board getBoard(String boardId) { return boardRepository.findById(boardId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.BOARD_NOT_FOUND - ) - ); + MessageUtil.BOARD_NOT_FOUND)); } private CircleMember getCircleMember(String userId, String circleId) { return circleMemberRepository.findByUser_IdAndCircle_Id(userId, circleId).orElseThrow( () -> new UnauthorizedException( ErrorCode.NOT_MEMBER, - MessageUtil.CIRCLE_APPLY_INVALID - ) - ); + MessageUtil.CIRCLE_APPLY_INVALID)); } private User getCircleLeader(Circle circle) { @@ -544,8 +496,7 @@ private User getCircleLeader(Circle circle) { if (leader == null) { throw new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.CIRCLE_WITHOUT_LEADER - ); + MessageUtil.CIRCLE_WITHOUT_LEADER); } return leader; } @@ -565,8 +516,7 @@ private void validCanAccessPost(User writer, Form form) { if (circleMember.getStatus().equals(CircleMemberStatus.MEMBER)) { throw new UnauthorizedException( ErrorCode.API_NOT_ALLOWED, - MessageUtil.NOT_ALLOWED_TO_REPLY_FORM - ); + MessageUtil.NOT_ALLOWED_TO_REPLY_FORM); } } } @@ -575,9 +525,7 @@ private Post getPost(Form form) { return postRepository.findByForm(form).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.FORM_NOT_FOUND - ) - ); + MessageUtil.FORM_NOT_FOUND)); } // Dto Mapper @@ -599,10 +547,8 @@ private ReplyPageResponseDto toReplyPageResponseDto(Form form, Page reply return this.toReplyResponseDto( replyUser, questionReplyList, - reply.getCreatedAt() - ); - }) - ); + reply.getCreatedAt()); + })); } private FormResponseDto toFormResponseDto(Form form) { @@ -610,8 +556,7 @@ private FormResponseDto toFormResponseDto(Form form) { form, form.getFormQuestionList().stream() .map(this::toQuestionResponseDto) - .collect(Collectors.toList()) - ); + .collect(Collectors.toList())); } private QuestionResponseDto toQuestionResponseDto(FormQuestion formQuestion) { @@ -635,8 +580,7 @@ private ReplyResponseDto toReplyResponseDto(User user, List replyQuestionList - ) { + List replyQuestionList) { if (formQuestion.getQuestionType().equals(QuestionType.SUBJECTIVE)) { List answerList = replyQuestionList.stream() .map(ReplyQuestion::getQuestionAnswer) @@ -666,8 +609,7 @@ private QuestionSummaryResponseDto toQuestionSummaryResponseDto( answerList, null, (long)answerList.size(), - findIsMultiple(formQuestion) - ); + findIsMultiple(formQuestion)); } else { List answerList = formQuestion.getFormQuestionOptionList().stream() .map(formQuestionOption -> { @@ -684,8 +626,7 @@ private QuestionSummaryResponseDto toQuestionSummaryResponseDto( null, answerList, findNumOfReply(answerList), - findIsMultiple(formQuestion) - ); + findIsMultiple(formQuestion)); } } @@ -704,8 +645,7 @@ private Boolean findIsMultiple(FormQuestion formQuestion) { private OptionSummaryResponseDto toOptionSummaryResponseDto( FormQuestionOption formQuestionOption, - Long selectedCount - ) { + Long selectedCount) { return FormDtoMapper.INSTANCE.toOptionSummaryResponseDto(formQuestionOption, selectedCount); } @@ -727,11 +667,9 @@ private ExcelReplyListResponseDto toExcelReplyListResponseDto(Form form, List getReplyByUserAndCircle(String userId, String User user = userRepository.findById(userId) .orElseThrow(() -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - )); + MessageUtil.USER_NOT_FOUND)); List userReplyList = circleFormList.stream() .flatMap(form -> replyRepository.findByFormAndUser(form, user).stream()) @@ -764,8 +700,7 @@ public List getReplyByUserAndCircle(String userId, String if (userReplyList.isEmpty()) { throw new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_APPLY_NOT_FOUND - ); + MessageUtil.USER_APPLY_NOT_FOUND); } List optionResponseDtoList = circleFormList.stream() diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/homepage/service/HomePageService.java b/app-main/src/main/java/net/causw/app/main/domain/community/homepage/service/HomePageService.java index 2fec66be0..4b2d176b9 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/homepage/service/HomePageService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/homepage/service/HomePageService.java @@ -8,24 +8,24 @@ import org.springframework.stereotype.Service; +import net.causw.app.main.api.dto.board.BoardResponseDto; +import net.causw.app.main.api.dto.homepage.HomePageResponseDto; +import net.causw.app.main.api.dto.util.dtoMapper.BoardDtoMapper; +import net.causw.app.main.api.dto.util.dtoMapper.PostDtoMapper; import net.causw.app.main.core.aop.annotation.MeasureTime; +import net.causw.app.main.domain.campus.circle.entity.Circle; import net.causw.app.main.domain.community.board.entity.Board; import net.causw.app.main.domain.community.board.repository.BoardRepository; import net.causw.app.main.domain.community.post.entity.Post; +import net.causw.app.main.domain.community.post.repository.PostRepository; import net.causw.app.main.domain.community.reaction.repository.FavoritePostRepository; import net.causw.app.main.domain.community.reaction.repository.LikePostRepository; -import net.causw.app.main.domain.community.post.repository.PostRepository; -import net.causw.app.main.api.dto.board.BoardResponseDto; -import net.causw.app.main.api.dto.homepage.HomePageResponseDto; -import net.causw.app.main.api.dto.util.dtoMapper.BoardDtoMapper; -import net.causw.app.main.api.dto.util.dtoMapper.PostDtoMapper; -import net.causw.app.main.domain.campus.circle.entity.Circle; -import net.causw.app.main.shared.StatusPolicy; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.domain.user.account.repository.user.UserRepository; import net.causw.app.main.domain.user.account.util.UserRoleIsNoneValidator; import net.causw.app.main.domain.user.account.util.UserStateValidator; +import net.causw.app.main.shared.StatusPolicy; import net.causw.app.main.shared.ValidatorBucket; import net.causw.app.main.shared.pageable.PageableFactory; import net.causw.global.constant.MessageUtil; @@ -59,8 +59,7 @@ public List getHomePage(User user) { if (boards.isEmpty()) { throw new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.BOARD_NOT_FOUND - ); + MessageUtil.BOARD_NOT_FOUND); } return boards @@ -68,7 +67,7 @@ public List getHomePage(User user) { .map(board -> HomePageResponseDto.of( toBoardResponseDto(board, roles), postRepository.findAllByBoard_IdAndIsDeletedIsFalseOrderByCreatedAtDesc(board.getId(), - pageableFactory.create(0, StaticValue.HOME_POST_PAGE_SIZE)) + pageableFactory.create(0, StaticValue.HOME_POST_PAGE_SIZE)) .map(post -> PostDtoMapper.INSTANCE.toPostsResponseDto( post, postRepository.countAllCommentByPost_Id(post.getId()), @@ -76,9 +75,7 @@ public List getHomePage(User user) { getNumOfPostFavorites(post), !post.getPostAttachImageList().isEmpty() ? post.getPostAttachImageList().get(0) : null, StatusPolicy.isPostVote(post), - post.getForm() != null - ))) - ) + post.getForm() != null)))) .collect(Collectors.toList()); } @@ -89,8 +86,7 @@ public List getAlumniHomePage(User user) { if (boards.isEmpty()) { throw new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.BOARD_NOT_FOUND - ); + MessageUtil.BOARD_NOT_FOUND); } return boards @@ -98,7 +94,7 @@ public List getAlumniHomePage(User user) { .map(board -> HomePageResponseDto.of( toBoardResponseDto(board, roles), postRepository.findAllByBoard_IdAndIsDeletedIsFalseOrderByCreatedAtDesc(board.getId(), - pageableFactory.create(0, StaticValue.ALUMNI_HOME_POST_PAGE_SIZE)) + pageableFactory.create(0, StaticValue.ALUMNI_HOME_POST_PAGE_SIZE)) .map(post -> PostDtoMapper.INSTANCE.toPostsResponseDto( post, postRepository.countAllCommentByPost_Id(post.getId()), @@ -106,9 +102,7 @@ public List getAlumniHomePage(User user) { getNumOfPostFavorites(post), !post.getPostAttachImageList().isEmpty() ? post.getPostAttachImageList().get(0) : null, StatusPolicy.isPostVote(post), - post.getForm() != null - ))) - ) + post.getForm() != null)))) .collect(Collectors.toList()); } @@ -124,8 +118,7 @@ private BoardResponseDto toBoardResponseDto(Board board, Set userRoles) { roles, writable, circleId, - circleName - ); + circleName); } private Long getNumOfPostLikes(Post post) { diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/post/entity/Post.java b/app-main/src/main/java/net/causw/app/main/domain/community/post/entity/Post.java index 275b96e7e..82ab51530 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/post/entity/Post.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/post/entity/Post.java @@ -90,8 +90,7 @@ public static Post of( Board board, Form form, - List postAttachImageUuidFileList - ) { + List postAttachImageUuidFileList) { Post post = Post.builder() .title(title) .content(content) diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/post/repository/PostRepository.java b/app-main/src/main/java/net/causw/app/main/domain/community/post/repository/PostRepository.java index d5ff89fcc..b36bed636 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/post/repository/PostRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/post/repository/PostRepository.java @@ -36,12 +36,15 @@ p.writer.nickname LIKE CONCAT('%', :keyword, '%')) ORDER BY p.createdAt DESC """) Page findPostsByBoardWithFilters( - @Param("boardId") String boardId, - @Param("includeDeleted") boolean includeDeleted, - @Param("blockedUserIds") Set blockedUserIds, - @Param("keyword") String keyword, - Pageable pageable - ); + @Param("boardId") + String boardId, + @Param("includeDeleted") + boolean includeDeleted, + @Param("blockedUserIds") + Set blockedUserIds, + @Param("keyword") + String keyword, + Pageable pageable); // 특정 사용자가 작성한 게시글 검색 @Query("SELECT p " + @@ -53,17 +56,21 @@ Page findPostsByBoardWithFilters( "AND (c.id IS NULL " + "OR (cm.status = 'MEMBER' AND c.isDeleted = false)) " + "ORDER BY p.createdAt DESC") - Page findByUserId(@Param("user_id") String userId, Pageable pageable); + Page findByUserId(@Param("user_id") + String userId, Pageable pageable); // fetch join으로 Board까지 가져오기 @Query(value = "SELECT DISTINCT p FROM Post p JOIN FETCH p.board WHERE p.id = :id") - Optional findById(@Param("id") String id); + Optional findById(@Param("id") + String id); @Query("SELECT COUNT(c) FROM Comment c WHERE c.post.id = :postId AND c.isDeleted = false") - Long countCommentsByPostId(@Param("postId") String postId); + Long countCommentsByPostId(@Param("postId") + String postId); @Query("SELECT COUNT(cc) FROM ChildComment cc WHERE cc.parentComment.post.id = :postId AND cc.isDeleted = false") - Long countChildCommentsByPostId(@Param("postId") String postId); + Long countChildCommentsByPostId(@Param("postId") + String postId); // 게시글에 작성된 모든댓글(댓글 + 대댓글)의 수 반환 default Long countAllCommentByPost_Id(String postId) { @@ -81,7 +88,8 @@ default Long countAllCommentByPost_Id(String postId) { @Query("UPDATE Post p SET p.isDeleted = true " + "WHERE p.board.id = :boardId AND p.isDeleted = false") @Modifying - int deleteAllPostsByBoardId(@Param("boardId") String boardId); + int deleteAllPostsByBoardId(@Param("boardId") + String boardId); Optional findByIdAndIsDeletedFalse(String postId); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/post/repository/query/PostQueryRepository.java b/app-main/src/main/java/net/causw/app/main/domain/community/post/repository/query/PostQueryRepository.java index fd79f448d..b2d1f12d6 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/post/repository/query/PostQueryRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/post/repository/query/PostQueryRepository.java @@ -10,11 +10,11 @@ import org.springframework.stereotype.Repository; import net.causw.app.main.domain.asset.file.entity.joinEntity.QPostAttachImage; +import net.causw.app.main.domain.asset.file.enums.FileExtensionType; import net.causw.app.main.domain.community.comment.entity.QComment; import net.causw.app.main.domain.community.post.entity.QPost; import net.causw.app.main.domain.community.reaction.entity.QFavoritePost; import net.causw.app.main.domain.community.reaction.entity.QLikePost; -import net.causw.app.main.domain.asset.file.enums.FileExtensionType; import net.causw.app.main.domain.user.account.entity.user.QUser; import com.querydsl.core.types.SubQueryExpression; @@ -37,8 +37,7 @@ public Page findPostsByBoardWithFilters( boolean includeDeleted, Set blockedUserIds, String keyword, - Pageable pageable - ) { + Pageable pageable) { QPost post = QPost.post; QUser writer = new QUser("writer"); @@ -120,8 +119,7 @@ private static QPostQueryResult toPostQueryResult(QPost post, QUser writer) { .and(postAttachImage.uuidFile.createdAt.eq( JPAExpressions.select(postAttachImage.uuidFile.createdAt.min()) .from(postAttachImage) - .where(postAttachImage.post.eq(post)) - ))); + .where(postAttachImage.post.eq(post))))); return new QPostQueryResult( post.id, post.title, post.content, @@ -129,7 +127,6 @@ private static QPostQueryResult toPostQueryResult(QPost post, QUser writer) { post.isAnonymous, post.isQuestion, post.vote.isNotNull(), post.form.isNotNull(), post.isDeleted, writer.isNotNull(), writer.name, writer.nickname, writer.admissionYear, writer.state, post.createdAt, post.updatedAt, - thumbnailUrl - ); + thumbnailUrl); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/post/repository/query/PostQueryResult.java b/app-main/src/main/java/net/causw/app/main/domain/community/post/repository/query/PostQueryResult.java index 733698db4..0a407d2cf 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/post/repository/query/PostQueryResult.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/post/repository/query/PostQueryResult.java @@ -25,8 +25,7 @@ public record PostQueryResult( UserState writerUserState, LocalDateTime createdAt, LocalDateTime updatedAt, - String postAttachImage -) { + String postAttachImage) { @QueryProjection public PostQueryResult { } // canonical constructor diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/post/service/PostEntityService.java b/app-main/src/main/java/net/causw/app/main/domain/community/post/service/PostEntityService.java index dc796648b..5e6041a21 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/post/service/PostEntityService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/post/service/PostEntityService.java @@ -21,12 +21,9 @@ public class PostEntityService { public Post findByIdNotDeleted(String postId) { - return postRepository.findByIdAndIsDeletedFalse(postId).orElseThrow(() -> - new NotFoundException( - ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.POST_NOT_FOUND - ) - ); + return postRepository.findByIdAndIsDeletedFalse(postId).orElseThrow(() -> new NotFoundException( + ErrorCode.ROW_DOES_NOT_EXIST, + MessageUtil.POST_NOT_FOUND)); } /** @@ -43,8 +40,7 @@ public Page findPostsByBoardWithFilters( boolean includeDeleted, Set blockedUserIds, String keyword, - Pageable pageable - ) { + Pageable pageable) { return postRepository.findPostsByBoardWithFilters(boardId, includeDeleted, blockedUserIds, keyword, pageable); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/post/service/PostService.java b/app-main/src/main/java/net/causw/app/main/domain/community/post/service/PostService.java index c46ad3b21..55b1372a9 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/post/service/PostService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/post/service/PostService.java @@ -18,29 +18,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import net.causw.app.main.core.aop.annotation.MeasureTime; -import net.causw.app.main.domain.asset.file.entity.UuidFile; -import net.causw.app.main.domain.asset.file.entity.joinEntity.PostAttachImage; -import net.causw.app.main.domain.community.board.entity.Board; -import net.causw.app.main.domain.community.board.repository.BoardRepository; -import net.causw.app.main.domain.community.board.repository.FavoriteBoardRepository; -import net.causw.app.main.domain.community.comment.repository.CommentRepository; -import net.causw.app.main.domain.community.comment.util.PostNumberOfAttachmentsValidator; -import net.causw.app.main.domain.community.form.entity.Form; -import net.causw.app.main.domain.community.form.entity.FormQuestion; -import net.causw.app.main.domain.community.form.entity.FormQuestionOption; -import net.causw.app.main.domain.community.form.enums.QuestionType; -import net.causw.app.main.domain.community.form.repository.FormRepository; -import net.causw.app.main.domain.community.reaction.entity.FavoritePost; -import net.causw.app.main.domain.community.reaction.entity.LikePost; -import net.causw.app.main.domain.community.post.entity.Post; -import net.causw.app.main.domain.community.vote.entity.Vote; -import net.causw.app.main.domain.community.vote.entity.VoteOption; -import net.causw.app.main.domain.community.vote.entity.VoteRecord; -import net.causw.app.main.domain.community.reaction.repository.FavoritePostRepository; -import net.causw.app.main.domain.community.reaction.repository.LikePostRepository; -import net.causw.app.main.domain.community.post.repository.PostRepository; -import net.causw.app.main.domain.community.post.repository.query.PostQueryRepository; import net.causw.app.main.api.dto.form.request.create.FormCreateRequestDto; import net.causw.app.main.api.dto.form.request.create.QuestionCreateRequestDto; import net.causw.app.main.api.dto.form.response.FormResponseDto; @@ -62,25 +39,43 @@ import net.causw.app.main.api.dto.util.dtoMapper.VoteDtoMapper; import net.causw.app.main.api.dto.vote.VoteOptionResponseDto; import net.causw.app.main.api.dto.vote.VoteResponseDto; +import net.causw.app.main.core.aop.annotation.MeasureTime; +import net.causw.app.main.domain.asset.file.entity.UuidFile; +import net.causw.app.main.domain.asset.file.entity.joinEntity.PostAttachImage; +import net.causw.app.main.domain.asset.file.enums.FilePath; +import net.causw.app.main.domain.asset.file.repository.PostAttachImageRepository; +import net.causw.app.main.domain.asset.file.service.UuidFileService; import net.causw.app.main.domain.campus.circle.entity.Circle; import net.causw.app.main.domain.campus.circle.entity.CircleMember; -import net.causw.app.main.domain.notification.notification.entity.UserBoardSubscribe; -import net.causw.app.main.domain.notification.notification.entity.UserPostSubscribe; import net.causw.app.main.domain.campus.circle.enums.CircleMemberStatus; -import net.causw.app.main.domain.asset.file.enums.FilePath; -import net.causw.app.main.shared.StatusPolicy; import net.causw.app.main.domain.campus.circle.repository.CircleMemberRepository; +import net.causw.app.main.domain.campus.circle.util.CircleMemberStatusValidator; +import net.causw.app.main.domain.community.board.entity.Board; +import net.causw.app.main.domain.community.board.repository.BoardRepository; +import net.causw.app.main.domain.community.board.repository.FavoriteBoardRepository; +import net.causw.app.main.domain.community.comment.repository.CommentRepository; +import net.causw.app.main.domain.community.comment.util.PostNumberOfAttachmentsValidator; +import net.causw.app.main.domain.community.form.entity.Form; +import net.causw.app.main.domain.community.form.entity.FormQuestion; +import net.causw.app.main.domain.community.form.entity.FormQuestionOption; +import net.causw.app.main.domain.community.form.enums.QuestionType; +import net.causw.app.main.domain.community.form.repository.FormRepository; +import net.causw.app.main.domain.community.post.entity.Post; +import net.causw.app.main.domain.community.post.repository.PostRepository; +import net.causw.app.main.domain.community.post.repository.query.PostQueryRepository; +import net.causw.app.main.domain.community.reaction.entity.FavoritePost; +import net.causw.app.main.domain.community.reaction.entity.LikePost; +import net.causw.app.main.domain.community.reaction.repository.FavoritePostRepository; +import net.causw.app.main.domain.community.reaction.repository.LikePostRepository; +import net.causw.app.main.domain.community.vote.entity.Vote; +import net.causw.app.main.domain.community.vote.entity.VoteOption; +import net.causw.app.main.domain.community.vote.entity.VoteRecord; +import net.causw.app.main.domain.community.vote.repository.VoteRecordRepository; +import net.causw.app.main.domain.notification.notification.entity.UserBoardSubscribe; +import net.causw.app.main.domain.notification.notification.entity.UserPostSubscribe; import net.causw.app.main.domain.notification.notification.repository.UserBoardSubscribeRepository; import net.causw.app.main.domain.notification.notification.repository.UserPostSubscribeRepository; -import net.causw.app.main.domain.asset.file.repository.PostAttachImageRepository; -import net.causw.app.main.domain.community.vote.repository.VoteRecordRepository; import net.causw.app.main.domain.notification.notification.service.BoardNotificationService; -import net.causw.app.main.domain.asset.file.service.UuidFileService; -import net.causw.app.main.domain.campus.circle.util.CircleMemberStatusValidator; -import net.causw.app.main.shared.util.ConstraintValidator; -import net.causw.app.main.shared.util.ContentsAdminValidator; -import net.causw.app.main.shared.util.TargetIsDeletedValidator; -import net.causw.app.main.shared.util.TargetIsNotDeletedValidator; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.domain.user.account.enums.user.UserState; @@ -89,8 +84,13 @@ import net.causw.app.main.domain.user.account.util.UserStateIsDeletedValidator; import net.causw.app.main.domain.user.account.util.UserStateValidator; import net.causw.app.main.domain.user.relation.service.UserBlockEntityService; +import net.causw.app.main.shared.StatusPolicy; import net.causw.app.main.shared.ValidatorBucket; import net.causw.app.main.shared.pageable.PageableFactory; +import net.causw.app.main.shared.util.ConstraintValidator; +import net.causw.app.main.shared.util.ContentsAdminValidator; +import net.causw.app.main.shared.util.TargetIsDeletedValidator; +import net.causw.app.main.shared.util.TargetIsNotDeletedValidator; import net.causw.app.main.shared.util.UserEqualValidator; import net.causw.global.constant.MessageUtil; import net.causw.global.constant.StaticValue; @@ -153,10 +153,9 @@ public BoardPostsResponseDto findAllPost( User user, String boardId, String keyword, - Integer pageNum - ) { - Set roles = user.getRoles(); // 사용자의 역할 가져오기 - Board board = getBoard(boardId); // 게시판 정보 가져오기 + Integer pageNum) { + Set roles = user.getRoles(); // 사용자의 역할 가져오기 + Board board = getBoard(boardId); // 게시판 정보 가져오기 // 유효성 검사 초기화 및 실행 ValidatorBucket validatorBucket = initializeValidator(user, board); @@ -184,8 +183,7 @@ public BoardPostsResponseDto findAllPost( roles, isFavorite(user.getId(), board.getId()), isBoardSubscribed(user, board), - posts - ); + posts); } public BoardPostsResponseDto findAllAppNotice(User user, Integer pageNum) { @@ -193,9 +191,7 @@ public BoardPostsResponseDto findAllAppNotice(User user, Integer pageNum) { Board board = boardRepository.findAppNotice().orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.BOARD_NOT_FOUND - ) - ); + MessageUtil.BOARD_NOT_FOUND)); Set blockedUserIds = userBlockEntityService.findBlockeeUserIdsByBlocker(user); Pageable pageable = pageableFactory.create(pageNum, StaticValue.DEFAULT_POST_PAGE_SIZE); @@ -210,8 +206,7 @@ public BoardPostsResponseDto findAllAppNotice(User user, Integer pageNum) { roles, isFavorite(user.getId(), board.getId()), isBoardSubscribed(user, board), - posts - ); + posts); } //게시글이 생성될 때 발생할 일 @@ -226,9 +221,8 @@ public PostCreateResponseDto createPost(User creator, PostCreateRequestDto postC Board board = getBoard(postCreateRequestDto.getBoardId()); List createRoles = new ArrayList<>(Arrays.asList(board.getCreateRoles().split(","))); - List uuidFileList = (attachImageList == null || attachImageList.isEmpty()) ? - new ArrayList<>() : - uuidFileService.saveFileList(attachImageList, FilePath.POST); + List uuidFileList = (attachImageList == null || attachImageList.isEmpty()) ? new ArrayList<>() + : uuidFileService.saveFileList(attachImageList, FilePath.POST); Post post = Post.of( postCreateRequestDto.getTitle(), @@ -238,8 +232,7 @@ public PostCreateResponseDto createPost(User creator, PostCreateRequestDto postC postCreateRequestDto.getIsQuestion(), board, null, - uuidFileList - ); + uuidFileList); validateAnonymousAllowed(board, postCreateRequestDto.getIsAnonymous()); @@ -252,8 +245,7 @@ public PostCreateResponseDto createPost(User creator, PostCreateRequestDto postC roles, createRoles.stream() .map(Role::of) - .collect(Collectors.toSet()) - )); + .collect(Collectors.toSet()))); Optional circles = Optional.ofNullable(board.getCircle()); circles @@ -267,18 +259,15 @@ public PostCreateResponseDto createPost(User creator, PostCreateRequestDto postC .consistOf(TargetIsDeletedValidator.of(circle.getIsDeleted(), StaticValue.DOMAIN_CIRCLE)) .consistOf(CircleMemberStatusValidator.of( member.getStatus(), - List.of(CircleMemberStatus.MEMBER) - )); + List.of(CircleMemberStatus.MEMBER))); if (roles.contains(Role.LEADER_CIRCLE) && !createRoles.contains("COMMON")) { validatorBucket .consistOf(UserEqualValidator.of( getCircleLeader(circle).getId(), - creator.getId() - )); + creator.getId())); } - } - ); + }); validatorBucket .consistOf(ConstraintValidator.of(post, this.validator)) .validate(); @@ -297,16 +286,14 @@ public PostCreateResponseDto createPost(User creator, PostCreateRequestDto postC public PostCreateResponseDto createPostWithForm( User creator, PostCreateWithFormRequestDto postCreateWithFormRequestDto, - List attachImageList - ) { + List attachImageList) { Set roles = creator.getRoles(); Board board = getBoard(postCreateWithFormRequestDto.getBoardId()); List createRoles = new ArrayList<>(Arrays.asList(board.getCreateRoles().split(","))); - List uuidFileList = (attachImageList == null || attachImageList.isEmpty()) ? - new ArrayList<>() : - attachImageList.stream() + List uuidFileList = (attachImageList == null || attachImageList.isEmpty()) ? new ArrayList<>() + : attachImageList.stream() .map(multipartFile -> uuidFileService.saveFile(multipartFile, FilePath.POST)) .toList(); @@ -320,8 +307,7 @@ public PostCreateResponseDto createPostWithForm( postCreateWithFormRequestDto.getIsQuestion(), board, form, - uuidFileList - ); + uuidFileList); validateAnonymousAllowed(board, postCreateWithFormRequestDto.getIsAnonymous()); @@ -330,8 +316,7 @@ public PostCreateResponseDto createPostWithForm( validatorBucket .consistOf(UserRoleValidator.of( roles, - Set.of() - )); + Set.of())); } validatorBucket @@ -353,8 +338,7 @@ public PostCreateResponseDto createPostWithForm( } }) .filter(Objects::nonNull) // 유효한 역할만 수집 - .collect(Collectors.toSet()) - )) + .collect(Collectors.toSet()))) .validate(); Optional circles = Optional.ofNullable(board.getCircle()); @@ -369,18 +353,15 @@ public PostCreateResponseDto createPostWithForm( .consistOf(TargetIsDeletedValidator.of(circle.getIsDeleted(), StaticValue.DOMAIN_CIRCLE)) .consistOf(CircleMemberStatusValidator.of( member.getStatus(), - List.of(CircleMemberStatus.MEMBER) - )); + List.of(CircleMemberStatus.MEMBER))); if (roles.contains(Role.LEADER_CIRCLE) && !createRoles.contains("COMMON")) { validatorBucket .consistOf(UserEqualValidator.of( getCircleLeader(circle).getId(), - creator.getId() - )); + creator.getId())); } - } - ); + }); validatorBucket .consistOf(ConstraintValidator.of(post, this.validator)) .validate(); @@ -401,8 +382,7 @@ public void deletePost(User deleter, String postId) { && !post.getWriter().getId().equals(deleter.getId())) { throw new UnauthorizedException( ErrorCode.API_NOT_ALLOWED, - "접근 권한이 없습니다." - ); + "접근 권한이 없습니다."); } } validatorBucket @@ -422,20 +402,18 @@ public void deletePost(User deleter, String postId) { .consistOf(TargetIsDeletedValidator.of(circle.getIsDeleted(), StaticValue.DOMAIN_CIRCLE)) .consistOf(CircleMemberStatusValidator.of( member.getStatus(), - List.of(CircleMemberStatus.MEMBER) - )).consistOf(ContentsAdminValidator.of( + List.of(CircleMemberStatus.MEMBER))) + .consistOf(ContentsAdminValidator.of( roles, deleter.getId(), post.getWriter().getId(), - List.of(Role.LEADER_CIRCLE) - )); + List.of(Role.LEADER_CIRCLE))); if (roles.contains(Role.LEADER_CIRCLE) && !post.getWriter().getId().equals(deleter.getId())) { validatorBucket .consistOf(UserEqualValidator.of( getCircleLeader(circle).getId(), - deleter.getId() - )); + deleter.getId())); } }, () -> validatorBucket @@ -443,9 +421,7 @@ public void deletePost(User deleter, String postId) { roles, deleter.getId(), post.getWriter().getId(), - List.of()) - ) - ); + List.of()))); validatorBucket.validate(); post.setIsDeleted(true); @@ -456,8 +432,7 @@ public PostResponseDto updatePost( User updater, String postId, PostUpdateRequestDto postUpdateRequestDto, - List attachImageList - ) { + List attachImageList) { Set roles = updater.getRoles(); Post post = getPost(postId); @@ -466,8 +441,7 @@ public PostResponseDto updatePost( validatorBucket .consistOf(UserRoleValidator.of( roles, - Set.of() - )); + Set.of())); } validatorBucket .consistOf(PostNumberOfAttachmentsValidator.of(attachImageList)) @@ -477,8 +451,7 @@ public PostResponseDto updatePost( roles, updater.getId(), post.getWriter().getId(), - List.of() - )) + List.of())) .consistOf(ConstraintValidator.of(post, this.validator)); validatorBucket.validate(); @@ -487,9 +460,8 @@ public PostResponseDto updatePost( if (!attachImageList.isEmpty()) { postAttachImageList = uuidFileService.updateFileList( - post.getPostAttachImageList().stream().map(PostAttachImage::getUuidFile).collect(Collectors.toList()), - attachImageList, FilePath.POST - ).stream() + post.getPostAttachImageList().stream().map(PostAttachImage::getUuidFile).collect(Collectors.toList()), + attachImageList, FilePath.POST).stream() .map(uuidFile -> PostAttachImage.of(post, uuidFile)) .toList(); } else { @@ -505,8 +477,7 @@ public PostResponseDto updatePost( postUpdateRequestDto.getTitle(), postUpdateRequestDto.getContent(), null, - postAttachImageList - ); + postAttachImageList); return toPostResponseDtoExtended(post, updater); } @@ -516,8 +487,7 @@ public void updatePostWithForm( User updater, String postId, PostUpdateWithFormRequestDto postUpdateWithFormRequestDto, - List attachImageList - ) { + List attachImageList) { Set roles = updater.getRoles(); Post post = getPost(postId); @@ -526,8 +496,7 @@ public void updatePostWithForm( validatorBucket .consistOf(UserRoleValidator.of( roles, - Set.of() - )); + Set.of())); } validatorBucket .consistOf(PostNumberOfAttachmentsValidator.of(attachImageList)) @@ -537,8 +506,7 @@ public void updatePostWithForm( roles, updater.getId(), post.getWriter().getId(), - List.of() - )) + List.of())) .consistOf(ConstraintValidator.of(post, this.validator)); validatorBucket.validate(); @@ -547,9 +515,8 @@ public void updatePostWithForm( if (!attachImageList.isEmpty()) { postAttachImageList = uuidFileService.updateFileList( - post.getPostAttachImageList().stream().map(PostAttachImage::getUuidFile).collect(Collectors.toList()), - attachImageList, FilePath.POST - ).stream() + post.getPostAttachImageList().stream().map(PostAttachImage::getUuidFile).collect(Collectors.toList()), + attachImageList, FilePath.POST).stream() .map(uuidFile -> PostAttachImage.of(post, uuidFile)) .toList(); } else { @@ -567,8 +534,7 @@ public void updatePostWithForm( postUpdateWithFormRequestDto.getTitle(), postUpdateWithFormRequestDto.getContent(), form, - postAttachImageList - ); + postAttachImageList); } @Transactional @@ -581,8 +547,7 @@ public void restorePost(User restorer, String postId) { validatorBucket .consistOf(UserRoleValidator.of( roles, - Set.of() - )); + Set.of())); } validatorBucket .consistOf(UserStateValidator.of(restorer.getState())) @@ -602,21 +567,18 @@ public void restorePost(User restorer, String postId) { .consistOf(TargetIsDeletedValidator.of(circle.getIsDeleted(), StaticValue.DOMAIN_CIRCLE)) .consistOf(CircleMemberStatusValidator.of( member.getStatus(), - List.of(CircleMemberStatus.MEMBER) - )) + List.of(CircleMemberStatus.MEMBER))) .consistOf(ContentsAdminValidator.of( roles, restorer.getId(), post.getWriter().getId(), - List.of(Role.LEADER_CIRCLE) - )); + List.of(Role.LEADER_CIRCLE))); if (roles.contains(Role.LEADER_CIRCLE) && !post.getWriter().getId().equals(restorer.getId())) { validatorBucket .consistOf(UserEqualValidator.of( getCircleLeader(circle).getId(), - restorer.getId() - )); + restorer.getId())); } }, () -> validatorBucket @@ -624,17 +586,14 @@ public void restorePost(User restorer, String postId) { roles, restorer.getId(), post.getWriter().getId(), - List.of() - )) - ); + List.of()))); validatorBucket .consistOf(ContentsAdminValidator.of( roles, restorer.getId(), post.getWriter().getId(), - List.of(Role.LEADER_CIRCLE) - )) + List.of(Role.LEADER_CIRCLE))) .validate(); post.setIsDeleted(false); @@ -764,10 +723,8 @@ private ValidatorBucket initializeValidator(User user, Board board) { .consistOf(TargetIsDeletedValidator.of(circle.getIsDeleted(), StaticValue.DOMAIN_CIRCLE)) .consistOf(CircleMemberStatusValidator.of( member.getStatus(), - List.of(CircleMemberStatus.MEMBER) - )); - } - ); + List.of(CircleMemberStatus.MEMBER))); + }); return validatorBucket; } @@ -778,8 +735,7 @@ private Form generateForm(FormCreateRequestDto formCreateRequestDto) { Form form = Form.createPostForm( formCreateRequestDto, - formQuestionList - ); + formQuestionList); formQuestionList.forEach(question -> question.setForm(form)); @@ -793,8 +749,7 @@ private static void validFormInfo(FormCreateRequestDto formCreateRequestDto) { if (formCreateRequestDto.getIsNeedCouncilFeePaid() == null) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.IS_NEED_COUNCIL_FEE_REQUIRED - ); + MessageUtil.IS_NEED_COUNCIL_FEE_REQUIRED); } // enrolledRegisteredSemesterList가 null이거나 비어있는 경우 예외 처리 @@ -802,20 +757,17 @@ private static void validFormInfo(FormCreateRequestDto formCreateRequestDto) { formCreateRequestDto.getEnrolledRegisteredSemesterList().isEmpty()) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_REGISTERED_SEMESTER_INFO - ); + MessageUtil.INVALID_REGISTERED_SEMESTER_INFO); } } // isAllowedLeaveOfAbsence가 false이고 isAllowedLeaveOfAbsence가 false인 경우 예외 처리 if (formCreateRequestDto.getIsAllowedLeaveOfAbsence() && (formCreateRequestDto.getLeaveOfAbsenceRegisteredSemesterList() == null || - formCreateRequestDto.getLeaveOfAbsenceRegisteredSemesterList().isEmpty()) - ) { + formCreateRequestDto.getLeaveOfAbsenceRegisteredSemesterList().isEmpty())) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_REGISTERED_SEMESTER_INFO - ); + MessageUtil.INVALID_REGISTERED_SEMESTER_INFO); } } @@ -826,8 +778,7 @@ private List generateFormQuestionList(FormCreateRequestDto formCre || formCreateRequestDto.getQuestionCreateRequestDtoList().isEmpty()) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.EMPTY_QUESTION_INFO - ); + MessageUtil.EMPTY_QUESTION_INFO); } AtomicReference questionNumber = new AtomicReference<>(1); @@ -842,12 +793,10 @@ private List generateFormQuestionList(FormCreateRequestDto formCre if (questionCreateRequestDto.getQuestionType().equals(QuestionType.OBJECTIVE)) { if (questionCreateRequestDto.getIsMultiple() == null || (questionCreateRequestDto.getOptionCreateRequestDtoList() == null || - questionCreateRequestDto.getOptionCreateRequestDtoList().isEmpty()) - ) { + questionCreateRequestDto.getOptionCreateRequestDtoList().isEmpty())) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_QUESTION_INFO - ); + MessageUtil.INVALID_QUESTION_INFO); } List formQuestionOptionList = getFormQuestionOptionList( @@ -856,20 +805,18 @@ private List generateFormQuestionList(FormCreateRequestDto formCre formQuestion = FormQuestion.createObjectiveQuestion( questionNumber.getAndSet(questionNumber.get() + 1), questionCreateRequestDto, - formQuestionOptionList - ); + formQuestionOptionList); formQuestionOptionList.forEach(option -> option.setFormQuestion(formQuestion)); } else { // 주관식일 때 formQuestion = FormQuestion.createSubjectQuestion( questionNumber.getAndSet(questionNumber.get() + 1), - questionCreateRequestDto - ); + questionCreateRequestDto); } return formQuestion; - } - ).toList(); + }) + .toList(); } @NotNull @@ -880,8 +827,7 @@ private static List getFormQuestionOptionList( || questionCreateRequestDto.getOptionCreateRequestDtoList().isEmpty()) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.EMPTY_OPTION_INFO - ); + MessageUtil.EMPTY_OPTION_INFO); } AtomicReference optionNumber = new AtomicReference<>(1); @@ -892,9 +838,8 @@ private static List getFormQuestionOptionList( optionCreateRequestDto -> FormQuestionOption.of( optionNumber.getAndSet(optionNumber.get() + 1), optionCreateRequestDto.getOptionText(), - null - ) - ).toList(); + null)) + .toList(); } // DtoMapper methods @@ -914,8 +859,7 @@ private BoardPostsResponseDto toBoardPostsResponseDto(Board board, Set use writable, isFavorite, isBoardSubscribed, - post - ); + post); } private PostResponseDto toPostResponseDtoExtended(Post post, User user) { @@ -933,8 +877,7 @@ private PostResponseDto toPostResponseDtoExtended(Post post, User user) { StatusPolicy.isPostVote(post) ? toVoteResponseDto(post.getVote(), user) : null, StatusPolicy.isPostVote(post), StatusPolicy.isPostForm(post), - isPostSubscribed(user, post) - ); + isPostSubscribed(user, post)); // 화면에 표시할 작성자 닉네임 설정 User writer = post.getWriter(); @@ -983,27 +926,21 @@ private Post getPost(String postId) { return postRepository.findById(postId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.POST_NOT_FOUND - ) - ); + MessageUtil.POST_NOT_FOUND)); } private Board getBoard(String boardId) { return boardRepository.findById(boardId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.BOARD_NOT_FOUND - ) - ); + MessageUtil.BOARD_NOT_FOUND)); } private CircleMember getCircleMember(String userId, String circleId) { return circleMemberRepository.findByUser_IdAndCircle_Id(userId, circleId).orElseThrow( () -> new UnauthorizedException( ErrorCode.NOT_MEMBER, - MessageUtil.CIRCLE_APPLY_INVALID - ) - ); + MessageUtil.CIRCLE_APPLY_INVALID)); } private User getCircleLeader(Circle circle) { @@ -1011,8 +948,7 @@ private User getCircleLeader(Circle circle) { if (leader == null) { throw new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.CIRCLE_WITHOUT_LEADER - ); + MessageUtil.CIRCLE_WITHOUT_LEADER); } return leader; } @@ -1022,8 +958,7 @@ private FormResponseDto toFormResponseDto(Form form) { form, form.getFormQuestionList().stream() .map(this::toQuestionResponseDto) - .collect(Collectors.toList()) - ); + .collect(Collectors.toList())); } private QuestionResponseDto toQuestionResponseDto(FormQuestion formQuestion) { @@ -1031,8 +966,7 @@ private QuestionResponseDto toQuestionResponseDto(FormQuestion formQuestion) { formQuestion, formQuestion.getFormQuestionOptionList().stream() .map(this::toOptionResponseDto) - .collect(Collectors.toList()) - ); + .collect(Collectors.toList())); } private OptionResponseDto toOptionResponseDto(FormQuestionOption formQuestionOption) { @@ -1052,14 +986,11 @@ private VoteResponseDto toVoteResponseDto(Vote vote, User user) { Integer totalUserCount = uniqueUserIds.size(); return VoteDtoMapper.INSTANCE.toVoteResponseDto( vote, - voteOptionResponseDtoList - , StatusPolicy.isVoteOwner(vote, user) - , vote.isEnd() - , voteRecordRepository.existsByVoteOption_VoteAndUser(vote, user) - , voteOptionResponseDtoList.stream() + voteOptionResponseDtoList, StatusPolicy.isVoteOwner(vote, user), vote.isEnd(), + voteRecordRepository.existsByVoteOption_VoteAndUser(vote, user), voteOptionResponseDtoList.stream() .mapToInt(VoteOptionResponseDto::getVoteCount) - .sum() - , totalUserCount); + .sum(), + totalUserCount); } private VoteOptionResponseDto tovoteOptionResponseDto(VoteOption voteOption) { @@ -1090,8 +1021,7 @@ private void validateAnonymousAllowed(Board board, boolean isAnonymous) { if (!board.getIsAnonymousAllowed() && isAnonymous) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.ANONYMOUS_NOT_ALLOWED - ); + MessageUtil.ANONYMOUS_NOT_ALLOWED); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/reaction/entity/FavoritePost.java b/app-main/src/main/java/net/causw/app/main/domain/community/reaction/entity/FavoritePost.java index b52005665..fb277b7c2 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/reaction/entity/FavoritePost.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/reaction/entity/FavoritePost.java @@ -38,5 +38,3 @@ public static FavoritePost of(Post post, User user) { } } - - diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/reaction/repository/FavoritePostRepository.java b/app-main/src/main/java/net/causw/app/main/domain/community/reaction/repository/FavoritePostRepository.java index f758a692e..4ec65f1e7 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/reaction/repository/FavoritePostRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/reaction/repository/FavoritePostRepository.java @@ -24,8 +24,9 @@ public interface FavoritePostRepository extends JpaRepository findByUserId(@Param("userId") String userId, @Param("blockedUserIds") Set blockedUserIds, + """) + Page findByUserId(@Param("userId") + String userId, @Param("blockedUserIds") + Set blockedUserIds, Pageable pageable); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/reaction/repository/LikePostRepository.java b/app-main/src/main/java/net/causw/app/main/domain/community/reaction/repository/LikePostRepository.java index 4ebcd68e8..ec5948067 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/reaction/repository/LikePostRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/reaction/repository/LikePostRepository.java @@ -19,17 +19,17 @@ public interface LikePostRepository extends JpaRepository { Long countByPostId(String postId); - @Query( - """ - SELECT lp - FROM LikePost lp - JOIN lp.post p - WHERE lp.user.id = :userId - AND (:#{#blockedUserIds.size()} = 0 OR p.writer.id NOT IN :blockedUserIds) - ORDER BY p.createdAt DESC - """ - ) + @Query(""" + SELECT lp + FROM LikePost lp + JOIN lp.post p + WHERE lp.user.id = :userId + AND (:#{#blockedUserIds.size()} = 0 OR p.writer.id NOT IN :blockedUserIds) + ORDER BY p.createdAt DESC + """) @EntityGraph(attributePaths = {"post"}) - Page findByUserId(@Param("userId") String userId, @Param("blockedUserIds") Set blockedUserIds, + Page findByUserId(@Param("userId") + String userId, @Param("blockedUserIds") + Set blockedUserIds, Pageable pageable); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/report/entity/Report.java b/app-main/src/main/java/net/causw/app/main/domain/community/report/entity/Report.java index d054582f1..f51dd3963 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/report/entity/Report.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/report/entity/Report.java @@ -24,15 +24,9 @@ @Builder(access = AccessLevel.PROTECTED) @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) -@Table( - name = "tb_report", - uniqueConstraints = { - @UniqueConstraint( - name = "unique_user_content_report", - columnNames = {"reporter_id", "report_type", "target_id"} - ) - } -) +@Table(name = "tb_report", uniqueConstraints = { + @UniqueConstraint(name = "unique_user_content_report", columnNames = {"reporter_id", "report_type", "target_id"}) +}) public class Report extends BaseEntity { @ManyToOne(targetEntity = User.class) @@ -54,8 +48,7 @@ public static Report of( User reporter, ReportType reportType, String targetId, - ReportReason reportReason - ) { + ReportReason reportReason) { return Report.builder() .reporter(reporter) .reportType(reportType) diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/report/repository/ReportRepository.java b/app-main/src/main/java/net/causw/app/main/domain/community/report/repository/ReportRepository.java index a9ca402d2..8c398bf3b 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/report/repository/ReportRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/report/repository/ReportRepository.java @@ -18,41 +18,38 @@ public interface ReportRepository extends JpaRepository { boolean existsByReporterAndReportTypeAndTargetId(User reporter, ReportType reportType, String targetId); // 게시글 신고 목록 조회 (통합된 메서드) - @Query( - value = """ - SELECT - r.id AS reportId, - p.id AS postId, - p.title AS postTitle, - u.name AS writerName, - u.state AS writerState, - r.report_reason AS reportReason, - r.created_at AS reportCreatedAt, - b.name AS boardName, - b.id AS boardId - FROM tb_report r - JOIN tb_post p ON r.target_id = p.id - JOIN tb_user u ON p.user_id = u.id - JOIN tb_board b ON p.board_id = b.id - WHERE r.report_type = :reportType - AND (:userId IS NULL OR u.id = :userId) - ORDER BY r.created_at DESC - """, - countQuery = """ - SELECT COUNT(*) - FROM tb_report r - JOIN tb_post p ON r.target_id = p.id - JOIN tb_user u ON p.user_id = u.id - WHERE r.report_type = :reportType - AND (:userId IS NULL OR u.id = :userId) - """, - nativeQuery = true - ) + @Query(value = """ + SELECT + r.id AS reportId, + p.id AS postId, + p.title AS postTitle, + u.name AS writerName, + u.state AS writerState, + r.report_reason AS reportReason, + r.created_at AS reportCreatedAt, + b.name AS boardName, + b.id AS boardId + FROM tb_report r + JOIN tb_post p ON r.target_id = p.id + JOIN tb_user u ON p.user_id = u.id + JOIN tb_board b ON p.board_id = b.id + WHERE r.report_type = :reportType + AND (:userId IS NULL OR u.id = :userId) + ORDER BY r.created_at DESC + """, countQuery = """ + SELECT COUNT(*) + FROM tb_report r + JOIN tb_post p ON r.target_id = p.id + JOIN tb_user u ON p.user_id = u.id + WHERE r.report_type = :reportType + AND (:userId IS NULL OR u.id = :userId) + """, nativeQuery = true) Page findPostReportsWithDetails( - @Param("reportType") String reportType, - @Param("userId") String userId, - Pageable pageable - ); + @Param("reportType") + String reportType, + @Param("userId") + String userId, + Pageable pageable); // 신고된 사용자 목록 조회 @Query(value = """ @@ -69,72 +66,67 @@ Page findPostReportsWithDetails( ELSE 99 END, u.reportCount DESC - """ - ) + """) Page findReportedUsersByReportCount(Pageable pageable); // 댓글, 대댓글 신고 목록 조회(메모리 문제를 막기 위해 Native Query와 UNION ALL로 DB 내에서 처리하도록 함) - @Query( - value = """ - SELECT - reportId, contentId, content, postTitle, postId, boardId, writerName, writerState, reportReason, reportCreatedAt - FROM ( - SELECT - r.id AS reportId, - c.id AS contentId, - c.content AS content, - p.title AS postTitle, - p.id AS postId, - p.board_id AS boardId, - u.name AS writerName, - u.state AS writerState, - r.report_reason AS reportReason, - r.created_at AS reportCreatedAt - FROM tb_report r - JOIN tb_comment c ON r.target_id = c.id AND r.report_type = 'COMMENT' - JOIN tb_post p ON c.post_id = p.id - JOIN tb_user u ON c.user_id = u.id - WHERE (:userId IS NULL OR u.id = :userId) - UNION ALL - SELECT - r.id AS reportId, - cc.id AS contentId, - cc.content AS content, - p.title AS postTitle, - p.id AS postId, - p.board_id AS boardId, - u.name AS writerName, - u.state AS writerState, - r.report_reason AS reportReason, - r.created_at AS reportCreatedAt - FROM tb_report r - JOIN tb_child_comment cc ON r.target_id = cc.id AND r.report_type = 'CHILD_COMMENT' - JOIN tb_comment parent_c ON cc.parent_comment_id = parent_c.id - JOIN tb_post p ON parent_c.post_id = p.id - JOIN tb_user u ON cc.user_id = u.id - WHERE (:userId IS NULL OR u.id = :userId) - ) AS combined_reports - ORDER BY reportCreatedAt DESC - """, - countQuery = """ - SELECT COUNT(*) FROM ( - SELECT r.id - FROM tb_report r - JOIN tb_comment c ON r.target_id = c.id AND r.report_type = 'COMMENT' - JOIN tb_user u ON c.user_id = u.id - WHERE (:userId IS NULL OR u.id = :userId) - UNION ALL - SELECT r.id - FROM tb_report r - JOIN tb_child_comment cc ON r.target_id = cc.id AND r.report_type = 'CHILD_COMMENT' - JOIN tb_user u ON cc.user_id = u.id - WHERE (:userId IS NULL OR u.id = :userId) - ) AS T - """, - nativeQuery = true - ) + @Query(value = """ + SELECT + reportId, contentId, content, postTitle, postId, boardId, writerName, writerState, reportReason, reportCreatedAt + FROM ( + SELECT + r.id AS reportId, + c.id AS contentId, + c.content AS content, + p.title AS postTitle, + p.id AS postId, + p.board_id AS boardId, + u.name AS writerName, + u.state AS writerState, + r.report_reason AS reportReason, + r.created_at AS reportCreatedAt + FROM tb_report r + JOIN tb_comment c ON r.target_id = c.id AND r.report_type = 'COMMENT' + JOIN tb_post p ON c.post_id = p.id + JOIN tb_user u ON c.user_id = u.id + WHERE (:userId IS NULL OR u.id = :userId) + UNION ALL + SELECT + r.id AS reportId, + cc.id AS contentId, + cc.content AS content, + p.title AS postTitle, + p.id AS postId, + p.board_id AS boardId, + u.name AS writerName, + u.state AS writerState, + r.report_reason AS reportReason, + r.created_at AS reportCreatedAt + FROM tb_report r + JOIN tb_child_comment cc ON r.target_id = cc.id AND r.report_type = 'CHILD_COMMENT' + JOIN tb_comment parent_c ON cc.parent_comment_id = parent_c.id + JOIN tb_post p ON parent_c.post_id = p.id + JOIN tb_user u ON cc.user_id = u.id + WHERE (:userId IS NULL OR u.id = :userId) + ) AS combined_reports + ORDER BY reportCreatedAt DESC + """, countQuery = """ + SELECT COUNT(*) FROM ( + SELECT r.id + FROM tb_report r + JOIN tb_comment c ON r.target_id = c.id AND r.report_type = 'COMMENT' + JOIN tb_user u ON c.user_id = u.id + WHERE (:userId IS NULL OR u.id = :userId) + UNION ALL + SELECT r.id + FROM tb_report r + JOIN tb_child_comment cc ON r.target_id = cc.id AND r.report_type = 'CHILD_COMMENT' + JOIN tb_user u ON cc.user_id = u.id + WHERE (:userId IS NULL OR u.id = :userId) + ) AS T + """, nativeQuery = true) Page findCombinedCommentReports( - @Param("userId") String userId, - Pageable pageable - ); + @Param("userId") + String userId, + Pageable pageable); } \ No newline at end of file diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/report/service/ReportService.java b/app-main/src/main/java/net/causw/app/main/domain/community/report/service/ReportService.java index a8dd30dd8..7e469730e 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/report/service/ReportService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/report/service/ReportService.java @@ -5,18 +5,18 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import net.causw.app.main.domain.community.comment.entity.ChildComment; -import net.causw.app.main.domain.community.comment.entity.Comment; -import net.causw.app.main.domain.community.comment.repository.ChildCommentRepository; -import net.causw.app.main.domain.community.comment.repository.CommentRepository; -import net.causw.app.main.domain.community.post.entity.Post; -import net.causw.app.main.domain.community.post.repository.PostRepository; import net.causw.app.main.api.dto.report.ReportCreateRequestDto; import net.causw.app.main.api.dto.report.ReportCreateResponseDto; import net.causw.app.main.api.dto.report.ReportedCommentResponseDto; import net.causw.app.main.api.dto.report.ReportedPostResponseDto; import net.causw.app.main.api.dto.report.ReportedUserResponseDto; import net.causw.app.main.api.dto.util.dtoMapper.ReportDtoMapper; +import net.causw.app.main.domain.community.comment.entity.ChildComment; +import net.causw.app.main.domain.community.comment.entity.Comment; +import net.causw.app.main.domain.community.comment.repository.ChildCommentRepository; +import net.causw.app.main.domain.community.comment.repository.CommentRepository; +import net.causw.app.main.domain.community.post.entity.Post; +import net.causw.app.main.domain.community.post.repository.PostRepository; import net.causw.app.main.domain.community.report.entity.Report; import net.causw.app.main.domain.community.report.enums.ReportType; import net.causw.app.main.domain.community.report.repository.ReportRepository; @@ -53,8 +53,7 @@ public ReportCreateResponseDto createReport(User reporter, ReportCreateRequestDt if (alreadyReported) { throw new BadRequestException( ErrorCode.CANNOT_PERFORMED, - MessageUtil.REPORT_ALREADY_REPORTED - ); + MessageUtil.REPORT_ALREADY_REPORTED); } // 신고 대상 콘텐츠, 작성자 조회 @@ -64,16 +63,14 @@ public ReportCreateResponseDto createReport(User reporter, ReportCreateRequestDt if (reporter.getId().equals(contentWriter.getId())) { throw new BadRequestException( ErrorCode.CANNOT_PERFORMED, - MessageUtil.REPORT_CANNOT_SELF - ); + MessageUtil.REPORT_CANNOT_SELF); } Report report = Report.of( reporter, request.getReportType(), request.getTargetId(), - request.getReportReason() - ); + request.getReportReason()); reportRepository.save(report); // 신고 대상 사용자의 신고 횟수 증가 @@ -110,14 +107,12 @@ public Page getReportedUsers(Integer pageNum) { @Transactional(readOnly = true) public Page getReportedPostsByUser( String userId, - Integer pageNum - ) { + Integer pageNum) { Pageable pageable = pageableFactory.create(pageNum, StaticValue.DEFAULT_REPORT_PAGE_SIZE); if (!userRepository.existsById(userId)) { throw new NotFoundException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - ); + MessageUtil.USER_NOT_FOUND); } return reportRepository.findPostReportsWithDetails("POST", userId, pageable) @@ -128,14 +123,12 @@ public Page getReportedPostsByUser( @Transactional(readOnly = true) public Page getReportedCommentsByUser( String userId, - Integer pageNum - ) { + Integer pageNum) { Pageable pageable = pageableFactory.create(pageNum, StaticValue.DEFAULT_REPORT_PAGE_SIZE); if (!userRepository.existsById(userId)) { throw new NotFoundException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - ); + MessageUtil.USER_NOT_FOUND); } return reportRepository.findCombinedCommentReports(userId, pageable) @@ -149,24 +142,21 @@ private User getContentWriter(ReportType reportType, String targetId) { Post post = postRepository.findById(targetId) .orElseThrow(() -> new NotFoundException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.POST_NOT_FOUND - )); + MessageUtil.POST_NOT_FOUND)); yield post.getWriter(); } case COMMENT -> { Comment comment = commentRepository.findById(targetId) .orElseThrow(() -> new NotFoundException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.COMMENT_NOT_FOUND - )); + MessageUtil.COMMENT_NOT_FOUND)); yield comment.getWriter(); } case CHILD_COMMENT -> { ChildComment childComment = childCommentRepository.findById(targetId) .orElseThrow(() -> new NotFoundException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.CHILD_COMMENT_NOT_FOUND - )); + MessageUtil.CHILD_COMMENT_NOT_FOUND)); yield childComment.getWriter(); } }; diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/vote/entity/VoteRecord.java b/app-main/src/main/java/net/causw/app/main/domain/community/vote/entity/VoteRecord.java index 59ad2c87c..7dfba9dd9 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/vote/entity/VoteRecord.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/vote/entity/VoteRecord.java @@ -31,8 +31,7 @@ public class VoteRecord extends BaseEntity { private VoteOption voteOption; public static VoteRecord of(User user, VoteOption voteOption) { - return VoteRecord.builder(). - user(user) + return VoteRecord.builder().user(user) .voteOption(voteOption) .build(); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/vote/repository/VoteRepository.java b/app-main/src/main/java/net/causw/app/main/domain/community/vote/repository/VoteRepository.java index 8dd748ec3..605767eb0 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/vote/repository/VoteRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/vote/repository/VoteRepository.java @@ -4,5 +4,4 @@ import net.causw.app.main.domain.community.vote.entity.Vote; -public interface VoteRepository extends JpaRepository { -} +public interface VoteRepository extends JpaRepository {} diff --git a/app-main/src/main/java/net/causw/app/main/domain/community/vote/service/VoteService.java b/app-main/src/main/java/net/causw/app/main/domain/community/vote/service/VoteService.java index 49dd3ee8b..2147580ec 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/community/vote/service/VoteService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/community/vote/service/VoteService.java @@ -8,12 +8,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import net.causw.app.main.core.aop.annotation.MeasureTime; -import net.causw.app.main.domain.community.post.entity.Post; -import net.causw.app.main.domain.community.vote.entity.Vote; -import net.causw.app.main.domain.community.vote.entity.VoteOption; -import net.causw.app.main.domain.community.vote.entity.VoteRecord; -import net.causw.app.main.domain.community.post.repository.PostRepository; import net.causw.app.main.api.dto.user.UserResponseDto; import net.causw.app.main.api.dto.util.dtoMapper.UserDtoMapper; import net.causw.app.main.api.dto.util.dtoMapper.VoteDtoMapper; @@ -21,11 +15,17 @@ import net.causw.app.main.api.dto.vote.CreateVoteRequestDto; import net.causw.app.main.api.dto.vote.VoteOptionResponseDto; import net.causw.app.main.api.dto.vote.VoteResponseDto; -import net.causw.app.main.shared.StatusPolicy; +import net.causw.app.main.core.aop.annotation.MeasureTime; +import net.causw.app.main.domain.community.post.entity.Post; +import net.causw.app.main.domain.community.post.repository.PostRepository; +import net.causw.app.main.domain.community.vote.entity.Vote; +import net.causw.app.main.domain.community.vote.entity.VoteOption; +import net.causw.app.main.domain.community.vote.entity.VoteRecord; import net.causw.app.main.domain.community.vote.repository.VoteOptionRepository; import net.causw.app.main.domain.community.vote.repository.VoteRecordRepository; import net.causw.app.main.domain.community.vote.repository.VoteRepository; import net.causw.app.main.domain.user.account.entity.user.User; +import net.causw.app.main.shared.StatusPolicy; import net.causw.global.constant.MessageUtil; import net.causw.global.exception.BadRequestException; import net.causw.global.exception.ErrorCode; @@ -59,8 +59,7 @@ public VoteResponseDto createVote(CreateVoteRequestDto createVoteRequestDTO, Use createVoteRequestDTO.getAllowAnonymous(), createVoteRequestDTO.getAllowMultiple(), voteOptions, - post - ); + post); Vote savedVote = voteRepository.save(vote); post.updateVote(vote); voteOptions.forEach(voteOption -> voteOption.updateVote(savedVote)); @@ -77,7 +76,7 @@ public String castVote(CastVoteRequestDto castVoteRequestDto, User user) { } // 첫 번째 VoteOption을 이용해 Vote를 가져옴 (모든 옵션은 동일한 Vote에 속해야 함) VoteOption firstVoteOption = voteOptionRepository.findById( - castVoteRequestDto.getVoteOptionIdList().get(0)) + castVoteRequestDto.getVoteOptionIdList().get(0)) .orElseThrow(() -> new BadRequestException(ErrorCode.ROW_DOES_NOT_EXIST, MessageUtil.VOTE_OPTION_NOT_FOUND)); Vote vote = firstVoteOption.getVote(); @@ -155,14 +154,11 @@ private VoteResponseDto toVoteResponseDto(Vote vote, User user) { Integer totalUserCount = uniqueUserIds.size(); return VoteDtoMapper.INSTANCE.toVoteResponseDto( vote, - voteOptionResponseDtoList - , StatusPolicy.isVoteOwner(vote, user) - , vote.isEnd() - , voteRecordRepository.existsByVoteOption_VoteAndUser(vote, user) - , voteOptionResponseDtoList.stream() + voteOptionResponseDtoList, StatusPolicy.isVoteOwner(vote, user), vote.isEnd(), + voteRecordRepository.existsByVoteOption_VoteAndUser(vote, user), voteOptionResponseDtoList.stream() .mapToInt(VoteOptionResponseDto::getVoteCount) - .sum() - , totalUserCount); + .sum(), + totalUserCount); } private VoteOptionResponseDto tovoteOptionResponseDto(VoteOption voteOption) { diff --git a/app-main/src/main/java/net/causw/app/main/domain/etc/flag/entity/Flag.java b/app-main/src/main/java/net/causw/app/main/domain/etc/flag/entity/Flag.java index 0bdcefd80..8c4fe9226 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/etc/flag/entity/Flag.java +++ b/app-main/src/main/java/net/causw/app/main/domain/etc/flag/entity/Flag.java @@ -31,8 +31,7 @@ public class Flag extends BaseEntity { public static Flag of( String key, - Boolean value - ) { + Boolean value) { return Flag.builder() .key(key) .value(value) diff --git a/app-main/src/main/java/net/causw/app/main/domain/etc/textfield/entity/TextField.java b/app-main/src/main/java/net/causw/app/main/domain/etc/textfield/entity/TextField.java index 7802e3c34..a19a1e334 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/etc/textfield/entity/TextField.java +++ b/app-main/src/main/java/net/causw/app/main/domain/etc/textfield/entity/TextField.java @@ -28,8 +28,7 @@ public class TextField extends BaseEntity { public static TextField of( String key, - String value - ) { + String value) { return TextField.builder() .key(key) .value(value) diff --git a/app-main/src/main/java/net/causw/app/main/domain/etc/textfield/service/CommonService.java b/app-main/src/main/java/net/causw/app/main/domain/etc/textfield/service/CommonService.java index b551ec4d1..0fe01d081 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/etc/textfield/service/CommonService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/etc/textfield/service/CommonService.java @@ -6,8 +6,8 @@ import net.causw.app.main.core.aop.annotation.MeasureTime; import net.causw.app.main.domain.etc.flag.entity.Flag; -import net.causw.app.main.domain.etc.textfield.entity.TextField; import net.causw.app.main.domain.etc.flag.repository.FlagRepository; +import net.causw.app.main.domain.etc.textfield.entity.TextField; import net.causw.app.main.domain.etc.textfield.repository.TextFieldRepository; import jakarta.transaction.Transactional; @@ -33,8 +33,7 @@ public Optional updateTextField(String key, String value) { flag.setValue(value); return this.textFieldRepository.save(flag).getValue(); - } - ); + }); } public Boolean createFlag(String key, Boolean value) { @@ -48,8 +47,7 @@ public Boolean updateFlag(String key, Boolean value) { flag.setValue(value); return this.flagRepository.save(flag).getValue(); - } - ).orElse(false); + }).orElse(false); } public Optional findByKeyInTextField(String key) { diff --git a/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/entity/CouncilFeeFakeUser.java b/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/entity/CouncilFeeFakeUser.java index 215c88a0a..bb13b0ba4 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/entity/CouncilFeeFakeUser.java +++ b/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/entity/CouncilFeeFakeUser.java @@ -65,8 +65,7 @@ public void update( AcademicStatus academicStatus, Integer currentCompletedSemester, Integer graduationYear, - GraduationType graduationType - ) { + GraduationType graduationType) { this.name = name; this.studentId = studentId; this.phoneNumber = phoneNumber; @@ -87,8 +86,7 @@ public static CouncilFeeFakeUser of( AcademicStatus academicStatus, Integer currentCompletedSemester, Integer graduationYear, - GraduationType graduationType - ) { + GraduationType graduationType) { return CouncilFeeFakeUser.builder() .name(name) .studentId(studentId) diff --git a/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/entity/UserCouncilFee.java b/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/entity/UserCouncilFee.java index 5cdd93109..a5a297ec1 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/entity/UserCouncilFee.java +++ b/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/entity/UserCouncilFee.java @@ -53,8 +53,7 @@ public void update( Integer paidAt, Integer numOfPaidSemester, Boolean isRefunded, - Integer refundedAt - ) { + Integer refundedAt) { this.isJoinedService = isJoinedService; this.user = user; this.councilFeeFakeUser = councilFeeFakeUser; @@ -71,8 +70,7 @@ public static UserCouncilFee of( Integer paidAt, Integer numOfPaidSemester, Boolean isRefunded, - Integer refundedAt - ) { + Integer refundedAt) { return UserCouncilFee.builder() .isJoinedService(isJoinedService) .user(user) @@ -85,7 +83,6 @@ public static UserCouncilFee of( } public Integer getCurrentCompletedSemester() { - return user != null ? - user.getCurrentCompletedSemester() : councilFeeFakeUser.getCurrentCompletedSemester(); + return user != null ? user.getCurrentCompletedSemester() : councilFeeFakeUser.getCurrentCompletedSemester(); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/entity/UserCouncilFeeLog.java b/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/entity/UserCouncilFeeLog.java index 7b0b17fc1..f730bd5ce 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/entity/UserCouncilFeeLog.java +++ b/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/entity/UserCouncilFeeLog.java @@ -2,9 +2,9 @@ import java.time.LocalDate; -import net.causw.app.main.domain.finance.usercouncilfee.enums.CouncilFeeLogType; import net.causw.app.main.domain.campus.semester.entity.Semester; import net.causw.app.main.domain.campus.semester.enums.SemesterType; +import net.causw.app.main.domain.finance.usercouncilfee.enums.CouncilFeeLogType; import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.enums.user.Department; @@ -119,8 +119,7 @@ public static UserCouncilFeeLog fromUser( Semester semester, User targetUser, Integer restOfSemester, - Boolean isAppliedThisSemester - ) { + Boolean isAppliedThisSemester) { return UserCouncilFeeLog.builder() .controlledUserEmail(controlledUser.getEmail()) .controlledUserName(controlledUser.getName()) @@ -157,8 +156,7 @@ public static UserCouncilFeeLog fromCouncilFeeFakeUser( Semester semester, CouncilFeeFakeUser targetCouncilFeeFakeUser, Integer restOfSemester, - Boolean isAppliedThisSemester - ) { + Boolean isAppliedThisSemester) { return UserCouncilFeeLog.builder() .controlledUserEmail(controlledUser.getEmail()) .controlledUserName(controlledUser.getName()) diff --git a/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/policy/UserCouncilFeePolicy.java b/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/policy/UserCouncilFeePolicy.java index 85ef98e4d..460797789 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/policy/UserCouncilFeePolicy.java +++ b/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/policy/UserCouncilFeePolicy.java @@ -1,8 +1,8 @@ package net.causw.app.main.domain.finance.usercouncilfee.policy; -import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFee; import net.causw.app.main.domain.campus.semester.entity.Semester; import net.causw.app.main.domain.campus.semester.enums.SemesterType; +import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFee; import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; public class UserCouncilFeePolicy { @@ -40,8 +40,7 @@ public static int getRemainingAppliedSemestersWithFakeUser(UserCouncilFee userCo public static boolean isAppliedCurrentSemesterWithUser(UserCouncilFee userCouncilFee) { return isAppliedCurrentSemester( userCouncilFee, - userCouncilFee.getUser().getCurrentCompletedSemester() - ); + userCouncilFee.getUser().getCurrentCompletedSemester()); } /** @@ -53,8 +52,7 @@ public static boolean isAppliedCurrentSemesterWithUser(UserCouncilFee userCounci public static boolean isAppliedCurrentSemesterWithFakeUser(UserCouncilFee userCouncilFee) { return isAppliedCurrentSemester( userCouncilFee, - userCouncilFee.getCouncilFeeFakeUser().getCurrentCompletedSemester() - ); + userCouncilFee.getCouncilFeeFakeUser().getCurrentCompletedSemester()); } /** @@ -70,11 +68,10 @@ public static boolean isAppliedCurrentSemesterWithFakeUser(UserCouncilFee userCo */ public static int getStartSemesterToApply( Semester currentSemester, - Integer currentCompletedSemester, AcademicStatus currentAcademicStatus - ) { + Integer currentCompletedSemester, AcademicStatus currentAcademicStatus) { SemesterType currentSemesterType = currentSemester.getSemesterType(); - boolean duringSemester = - (currentSemesterType == SemesterType.FIRST) || (currentSemesterType == SemesterType.SECOND); + boolean duringSemester = (currentSemesterType == SemesterType.FIRST) + || (currentSemesterType == SemesterType.SECOND); if (currentAcademicStatus == AcademicStatus.ENROLLED && duringSemester) { return currentCompletedSemester; diff --git a/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/repository/CouncilFeeFakeUserRepository.java b/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/repository/CouncilFeeFakeUserRepository.java index bb4e69d6b..d264d3eb1 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/repository/CouncilFeeFakeUserRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/repository/CouncilFeeFakeUserRepository.java @@ -6,5 +6,4 @@ import net.causw.app.main.domain.finance.usercouncilfee.entity.CouncilFeeFakeUser; @Repository -public interface CouncilFeeFakeUserRepository extends JpaRepository { -} +public interface CouncilFeeFakeUserRepository extends JpaRepository {} diff --git a/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/repository/UserCouncilFeeLogRepository.java b/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/repository/UserCouncilFeeLogRepository.java index 89e6664ed..eee86c7ba 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/repository/UserCouncilFeeLogRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/repository/UserCouncilFeeLogRepository.java @@ -6,5 +6,4 @@ import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFeeLog; @Repository -public interface UserCouncilFeeLogRepository extends JpaRepository { -} +public interface UserCouncilFeeLogRepository extends JpaRepository {} diff --git a/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/service/UserCouncilFeeService.java b/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/service/UserCouncilFeeService.java index 612f9c150..0cd937bd9 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/service/UserCouncilFeeService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/finance/usercouncilfee/service/UserCouncilFeeService.java @@ -8,23 +8,23 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import net.causw.app.main.core.aop.annotation.MeasureTime; -import net.causw.app.main.domain.finance.usercouncilfee.entity.CouncilFeeFakeUser; -import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFee; -import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFeeLog; -import net.causw.app.main.domain.finance.usercouncilfee.enums.CouncilFeeLogType; -import net.causw.app.main.domain.finance.usercouncilfee.repository.UserCouncilFeeLogRepository; -import net.causw.app.main.domain.finance.usercouncilfee.repository.UserCouncilFeeRepository; -import net.causw.app.main.domain.integration.export.service.CouncilFeeExcelService; import net.causw.app.main.api.dto.userCouncilFee.CreateUserCouncilFeeWithFakeUserRequestDto; import net.causw.app.main.api.dto.userCouncilFee.CreateUserCouncilFeeWithUserRequestDto; import net.causw.app.main.api.dto.userCouncilFee.CurrentUserCouncilFeeResponseDto; import net.causw.app.main.api.dto.userCouncilFee.UserCouncilFeeListResponseDto; import net.causw.app.main.api.dto.userCouncilFee.UserCouncilFeeResponseDto; import net.causw.app.main.api.dto.util.dtoMapper.UserCouncilFeeDtoMapper; +import net.causw.app.main.core.aop.annotation.MeasureTime; import net.causw.app.main.domain.campus.semester.entity.Semester; -import net.causw.app.main.domain.finance.usercouncilfee.policy.UserCouncilFeePolicy; import net.causw.app.main.domain.campus.semester.service.SemesterService; +import net.causw.app.main.domain.finance.usercouncilfee.entity.CouncilFeeFakeUser; +import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFee; +import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFeeLog; +import net.causw.app.main.domain.finance.usercouncilfee.enums.CouncilFeeLogType; +import net.causw.app.main.domain.finance.usercouncilfee.policy.UserCouncilFeePolicy; +import net.causw.app.main.domain.finance.usercouncilfee.repository.UserCouncilFeeLogRepository; +import net.causw.app.main.domain.finance.usercouncilfee.repository.UserCouncilFeeRepository; +import net.causw.app.main.domain.integration.export.service.CouncilFeeExcelService; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.repository.user.UserRepository; import net.causw.global.constant.MessageUtil; @@ -49,8 +49,8 @@ public class UserCouncilFeeService { public void exportUserCouncilFeeToExcel(HttpServletResponse response) { Semester semester = semesterService.getCurrentSemesterEntity(); - String fileName = - semester.getSemesterYear().toString() + "-" + semester.getSemesterType().getValue() + "_학생회비_납부자_현황"; + String fileName = semester.getSemesterYear().toString() + "-" + semester.getSemesterType().getValue() + + "_학생회비_납부자_현황"; List headerStringList = List.of( "동문네트워크 서비스 가입 여부", @@ -71,8 +71,7 @@ public void exportUserCouncilFeeToExcel(HttpServletResponse response) { "학생회비 환불 여부", "학생회비 환불 시점", "잔여 학생회비 적용 학기", - "본 학기 학생회비 적용 여부" - ); + "본 학기 학생회비 적용 여부"); List userCouncilFeeResponseDtoList = userCouncilFeeRepository.findAll() .stream().map(this::toUserCouncilFeeResponseDto).toList(); @@ -84,16 +83,14 @@ public void exportUserCouncilFeeToExcel(HttpServletResponse response) { response, fileName, headerStringList, - sheetNameDataMap - ); + sheetNameDataMap); } public Page getUserCouncilFeeList(Pageable pageable) { return userCouncilFeeRepository.findAll(pageable) - .map(userCouncilFee -> (userCouncilFee.getIsJoinedService()) ? - toUserCouncilFeeListResponseDto(userCouncilFee, userCouncilFee.getUser()) : - toUserCouncilFeeListResponseDtoReduced(userCouncilFee, userCouncilFee.getCouncilFeeFakeUser()) - ); + .map(userCouncilFee -> (userCouncilFee.getIsJoinedService()) + ? toUserCouncilFeeListResponseDto(userCouncilFee, userCouncilFee.getUser()) + : toUserCouncilFeeListResponseDtoReduced(userCouncilFee, userCouncilFee.getCouncilFeeFakeUser())); } public UserCouncilFeeResponseDto getUserCouncilFeeInfo(String userCouncilFeeId) { @@ -131,8 +128,7 @@ public void createUserCouncilFeeWithUser(User user, int paidAt = UserCouncilFeePolicy.getStartSemesterToApply( currentSemester, targetUser.getCurrentCompletedSemester(), - targetUser.getAcademicStatus() - ); + targetUser.getAcademicStatus()); UserCouncilFee userCouncilFee = UserCouncilFee.of( true, targetUser, @@ -140,9 +136,8 @@ public void createUserCouncilFeeWithUser(User user, paidAt, createUserCouncilFeeWithUserRequestDto.getNumOfPaidSemester(), createUserCouncilFeeWithUserRequestDto.getIsRefunded(), - createUserCouncilFeeWithUserRequestDto.getRefundedAt() == null ? null : - createUserCouncilFeeWithUserRequestDto.getRefundedAt() - ); + createUserCouncilFeeWithUserRequestDto.getRefundedAt() == null ? null + : createUserCouncilFeeWithUserRequestDto.getRefundedAt()); userCouncilFeeRepository.save(userCouncilFee); createUserCouncilFeeLog(controlledUser, CouncilFeeLogType.CREATE, userCouncilFee, currentSemester); @@ -170,15 +165,13 @@ public void creatUserCouncilFeeWithFakeUser(User user, createUserCouncilFeeRequestDto.getAcademicStatus(), createUserCouncilFeeRequestDto.getCurrentCompletedSemester(), createUserCouncilFeeRequestDto.getGraduationYear(), - createUserCouncilFeeRequestDto.getGraduationType() - ); + createUserCouncilFeeRequestDto.getGraduationType()); Semester currentSemester = semesterService.getCurrentSemesterEntity(); int paidAt = UserCouncilFeePolicy.getStartSemesterToApply( currentSemester, councilFeeFakeUser.getCurrentCompletedSemester(), - councilFeeFakeUser.getAcademicStatus() - ); + councilFeeFakeUser.getAcademicStatus()); UserCouncilFee userCouncilFee = UserCouncilFee.of( false, null, @@ -186,8 +179,7 @@ public void creatUserCouncilFeeWithFakeUser(User user, paidAt, createUserCouncilFeeRequestDto.getNumOfPaidSemester(), createUserCouncilFeeRequestDto.getIsRefunded(), - createUserCouncilFeeRequestDto.getRefundedAt() - ); + createUserCouncilFeeRequestDto.getRefundedAt()); userCouncilFeeRepository.save(userCouncilFee); createUserCouncilFeeLog(controlledUser, CouncilFeeLogType.CREATE, userCouncilFee, currentSemester); @@ -218,8 +210,7 @@ public void updateUserCouncilFeeWithUser(User user, String userCouncilFeeId, createUserCouncilFeeWithUserRequestDto.getPaidAt(), createUserCouncilFeeWithUserRequestDto.getNumOfPaidSemester(), createUserCouncilFeeWithUserRequestDto.getIsRefunded(), - createUserCouncilFeeWithUserRequestDto.getRefundedAt() - ); + createUserCouncilFeeWithUserRequestDto.getRefundedAt()); userCouncilFeeRepository.save(userCouncilFee); createUserCouncilFeeLog( @@ -248,8 +239,7 @@ public void updateUserCouncilFeeWithFakeUser(User user, String userCouncilFeeId, createUserCouncilFeeWithFakeUserRequestDto.getAcademicStatus(), createUserCouncilFeeWithFakeUserRequestDto.getCurrentCompletedSemester(), createUserCouncilFeeWithFakeUserRequestDto.getGraduationYear(), - createUserCouncilFeeWithFakeUserRequestDto.getGraduationType() - ); + createUserCouncilFeeWithFakeUserRequestDto.getGraduationType()); userCouncilFee.update( false, null, @@ -257,8 +247,7 @@ public void updateUserCouncilFeeWithFakeUser(User user, String userCouncilFeeId, createUserCouncilFeeWithFakeUserRequestDto.getPaidAt(), createUserCouncilFeeWithFakeUserRequestDto.getNumOfPaidSemester(), createUserCouncilFeeWithFakeUserRequestDto.getIsRefunded(), - createUserCouncilFeeWithFakeUserRequestDto.getRefundedAt() - ); + createUserCouncilFeeWithFakeUserRequestDto.getRefundedAt()); userCouncilFeeRepository.save(userCouncilFee); createUserCouncilFeeLog( @@ -291,8 +280,7 @@ public String getUserIdByStudentId(String studentId) { public Boolean isCurrentSemesterApplied(String userId) { return isCurrentSemesterAppliedBySelf( userRepository.findById(userId) - .orElseThrow(() -> new BadRequestException(ErrorCode.ROW_DOES_NOT_EXIST, MessageUtil.USER_NOT_FOUND)) - ); + .orElseThrow(() -> new BadRequestException(ErrorCode.ROW_DOES_NOT_EXIST, MessageUtil.USER_NOT_FOUND))); } public Boolean isCurrentSemesterAppliedBySelf(User user) { @@ -323,8 +311,7 @@ public CurrentUserCouncilFeeResponseDto isCurrentSemesterAppliedBySelfInfo(User private void createUserCouncilFeeLog( User controlledUser, CouncilFeeLogType councilFeeLogType, - UserCouncilFee userCouncilFee, Semester currentSemester - ) { + UserCouncilFee userCouncilFee, Semester currentSemester) { UserCouncilFeeLog userCouncilFeeLog; if (userCouncilFee.getUser() != null) { @@ -335,8 +322,7 @@ private void createUserCouncilFeeLog( currentSemester, userCouncilFee.getUser(), UserCouncilFeePolicy.getRemainingAppliedSemestersWithUser(userCouncilFee), - UserCouncilFeePolicy.isAppliedCurrentSemesterWithUser(userCouncilFee) - ); + UserCouncilFeePolicy.isAppliedCurrentSemesterWithUser(userCouncilFee)); } else { userCouncilFeeLog = UserCouncilFeeLog.fromCouncilFeeFakeUser( controlledUser, @@ -345,8 +331,7 @@ private void createUserCouncilFeeLog( currentSemester, userCouncilFee.getCouncilFeeFakeUser(), UserCouncilFeePolicy.getRemainingAppliedSemestersWithFakeUser(userCouncilFee), - UserCouncilFeePolicy.isAppliedCurrentSemesterWithFakeUser(userCouncilFee) - ); + UserCouncilFeePolicy.isAppliedCurrentSemesterWithFakeUser(userCouncilFee)); } userCouncilFeeLogRepository.save(userCouncilFeeLog); @@ -379,15 +364,13 @@ private UserCouncilFeeResponseDto toUserCouncilFeeResponseDto(UserCouncilFee use userCouncilFee, userCouncilFee.getUser(), UserCouncilFeePolicy.getRemainingAppliedSemestersWithUser(userCouncilFee), - UserCouncilFeePolicy.isAppliedCurrentSemesterWithUser(userCouncilFee) - ); + UserCouncilFeePolicy.isAppliedCurrentSemesterWithUser(userCouncilFee)); } else { return UserCouncilFeeDtoMapper.INSTANCE.toUserCouncilFeeResponseDtoReduced( userCouncilFee, userCouncilFee.getCouncilFeeFakeUser(), UserCouncilFeePolicy.getRemainingAppliedSemestersWithFakeUser(userCouncilFee), - UserCouncilFeePolicy.isAppliedCurrentSemesterWithFakeUser(userCouncilFee) - ); + UserCouncilFeePolicy.isAppliedCurrentSemesterWithFakeUser(userCouncilFee)); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/entity/CrawledFileLink.java b/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/entity/CrawledFileLink.java index 91620f208..f7d941f81 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/entity/CrawledFileLink.java +++ b/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/entity/CrawledFileLink.java @@ -26,8 +26,7 @@ public class CrawledFileLink extends BaseEntity { public static CrawledFileLink of( String fileName, - String fileLink - ) { + String fileLink) { return CrawledFileLink.builder() .fileName(fileName) .fileLink(fileLink) diff --git a/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/entity/CrawledNotice.java b/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/entity/CrawledNotice.java index 8b05ffe08..88e4ae8e0 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/entity/CrawledNotice.java +++ b/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/entity/CrawledNotice.java @@ -72,8 +72,7 @@ public static CrawledNotice of( String author, String announceDate, String imageLink, - List crawledFileLinks - ) { + List crawledFileLinks) { // String -> LocalDate LocalDate parsedDate = LocalDate.parse(announceDate, DateTimeFormatter.ISO_LOCAL_DATE); // 새로운 공지에 대한 처리 diff --git a/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/enums/CrawlCategory.java b/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/enums/CrawlCategory.java index 60e5dff6f..dd33a6f20 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/enums/CrawlCategory.java +++ b/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/enums/CrawlCategory.java @@ -1,6 +1,6 @@ package net.causw.app.main.domain.integration.crawled.enums; public enum CrawlCategory { - CAU_SW_NOTICE, // 중앙대 소프트웨어학부 공지사항 - CAU_PORTAL_NOTICE // 중앙대 포탈 공지사항 + CAU_SW_NOTICE, // 중앙대 소프트웨어학부 공지사항 + CAU_PORTAL_NOTICE // 중앙대 포탈 공지사항 } diff --git a/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/service/CrawledToPostTransferService.java b/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/service/CrawledToPostTransferService.java index 058c00a50..e7883f0d8 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/service/CrawledToPostTransferService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/service/CrawledToPostTransferService.java @@ -99,8 +99,7 @@ private boolean processUpdatedNotice(CrawledNotice notice, Board board, User adm false, board, null, - new ArrayList<>() - ); + new ArrayList<>()); postRepository.save(newPost); // 새 게시글인 경우에만 알림 전송 @@ -167,4 +166,4 @@ private Post findExistingPostByTitle(Board board, String title) { return null; } -} \ No newline at end of file +} \ No newline at end of file diff --git a/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/service/CrawlingAndSavingService.java b/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/service/CrawlingAndSavingService.java index d69c88c4b..61e39db8e 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/service/CrawlingAndSavingService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/service/CrawlingAndSavingService.java @@ -65,4 +65,4 @@ private List processLatestNotices(List notices) { return noticesToSave; } -} \ No newline at end of file +} \ No newline at end of file diff --git a/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/service/JsoupCrawler.java b/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/service/JsoupCrawler.java index b14a254a6..0f995e662 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/service/JsoupCrawler.java +++ b/app-main/src/main/java/net/causw/app/main/domain/integration/crawled/service/JsoupCrawler.java @@ -130,8 +130,7 @@ private CrawledNotice parseNotice(Element row, String noticeUrl) { author, announceDate, imageLink, - fileLinks.isEmpty() ? null : fileLinks - ); + fileLinks.isEmpty() ? null : fileLinks); } private List extractDownloadLink(Document detailDoc) { diff --git a/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/CircleExcelService.java b/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/CircleExcelService.java index 2e4af1494..a0656f67b 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/CircleExcelService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/CircleExcelService.java @@ -6,8 +6,8 @@ import org.apache.poi.ss.usermodel.Sheet; import org.springframework.stereotype.Service; -import net.causw.app.main.core.aop.annotation.MeasureTime; import net.causw.app.main.api.dto.circle.ExportCircleMemberToExcelResponseDto; +import net.causw.app.main.core.aop.annotation.MeasureTime; @MeasureTime @Service @@ -20,79 +20,61 @@ public void createDataRows(Sheet sheet, for (ExportCircleMemberToExcelResponseDto exportCircleMemberToExcelResponseDto : exportCircleMemberToExcelResponseDtoList) { Row row = sheet.createRow(rowNum++); row.createCell(0).setCellValue( - exportCircleMemberToExcelResponseDto.getEmail() != null ? - exportCircleMemberToExcelResponseDto.getEmail() : "" - ); + exportCircleMemberToExcelResponseDto.getEmail() != null + ? exportCircleMemberToExcelResponseDto.getEmail() : ""); row.createCell(1).setCellValue( - exportCircleMemberToExcelResponseDto.getName() != null ? - exportCircleMemberToExcelResponseDto.getName() : "" - ); + exportCircleMemberToExcelResponseDto.getName() != null ? exportCircleMemberToExcelResponseDto.getName() + : ""); row.createCell(2).setCellValue( - exportCircleMemberToExcelResponseDto.getNickname() != null ? - exportCircleMemberToExcelResponseDto.getNickname() : "" - ); + exportCircleMemberToExcelResponseDto.getNickname() != null + ? exportCircleMemberToExcelResponseDto.getNickname() : ""); row.createCell(3).setCellValue( - exportCircleMemberToExcelResponseDto.getAdmissionYear() != null ? - exportCircleMemberToExcelResponseDto.getAdmissionYear().toString() : "" - ); + exportCircleMemberToExcelResponseDto.getAdmissionYear() != null + ? exportCircleMemberToExcelResponseDto.getAdmissionYear().toString() : ""); row.createCell(4).setCellValue( - exportCircleMemberToExcelResponseDto.getStudentId() != null ? - exportCircleMemberToExcelResponseDto.getStudentId() : "" - ); + exportCircleMemberToExcelResponseDto.getStudentId() != null + ? exportCircleMemberToExcelResponseDto.getStudentId() : ""); row.createCell(5).setCellValue( - exportCircleMemberToExcelResponseDto.getMajor() != null ? - exportCircleMemberToExcelResponseDto.getMajor() : "" - ); + exportCircleMemberToExcelResponseDto.getMajor() != null + ? exportCircleMemberToExcelResponseDto.getMajor() : ""); row.createCell(6).setCellValue( - exportCircleMemberToExcelResponseDto.getPhoneNumber() != null ? - exportCircleMemberToExcelResponseDto.getPhoneNumber() : "" - ); + exportCircleMemberToExcelResponseDto.getPhoneNumber() != null + ? exportCircleMemberToExcelResponseDto.getPhoneNumber() : ""); row.createCell(7).setCellValue( - exportCircleMemberToExcelResponseDto.getAcademicStatus() != null ? - exportCircleMemberToExcelResponseDto.getAcademicStatus().getValue() : "" - ); + exportCircleMemberToExcelResponseDto.getAcademicStatus() != null + ? exportCircleMemberToExcelResponseDto.getAcademicStatus().getValue() : ""); row.createCell(8).setCellValue( - exportCircleMemberToExcelResponseDto.getCurrentSemester() != null ? - exportCircleMemberToExcelResponseDto.getCurrentSemester().toString() : "" - ); + exportCircleMemberToExcelResponseDto.getCurrentSemester() != null + ? exportCircleMemberToExcelResponseDto.getCurrentSemester().toString() : ""); row.createCell(9).setCellValue( - exportCircleMemberToExcelResponseDto.getGraduationYear() != null ? - exportCircleMemberToExcelResponseDto.getGraduationYear().toString() : "" - ); + exportCircleMemberToExcelResponseDto.getGraduationYear() != null + ? exportCircleMemberToExcelResponseDto.getGraduationYear().toString() : ""); row.createCell(10).setCellValue( - exportCircleMemberToExcelResponseDto.getGraduationType() != null ? - exportCircleMemberToExcelResponseDto.getGraduationType().getValue() : "" - ); + exportCircleMemberToExcelResponseDto.getGraduationType() != null + ? exportCircleMemberToExcelResponseDto.getGraduationType().getValue() : ""); row.createCell(11).setCellValue( - exportCircleMemberToExcelResponseDto.getCreatedAt() != null ? - exportCircleMemberToExcelResponseDto.getCreatedAt().toString() : "" - ); + exportCircleMemberToExcelResponseDto.getCreatedAt() != null + ? exportCircleMemberToExcelResponseDto.getCreatedAt().toString() : ""); row.createCell(12).setCellValue( - exportCircleMemberToExcelResponseDto.getIsAppliedThisSemester() != null ? - exportCircleMemberToExcelResponseDto.getIsAppliedThisSemester() ? "O" : "X" - : "" - ); + exportCircleMemberToExcelResponseDto.getIsAppliedThisSemester() != null + ? exportCircleMemberToExcelResponseDto.getIsAppliedThisSemester() ? "O" : "X" + : ""); row.createCell(13).setCellValue( - exportCircleMemberToExcelResponseDto.getPaidAt() != null ? - exportCircleMemberToExcelResponseDto.getPaidAt().toString() : "" - ); + exportCircleMemberToExcelResponseDto.getPaidAt() != null + ? exportCircleMemberToExcelResponseDto.getPaidAt().toString() : ""); row.createCell(14).setCellValue( - exportCircleMemberToExcelResponseDto.getPaidSemester() != null ? - exportCircleMemberToExcelResponseDto.getPaidSemester().toString() : "" - ); + exportCircleMemberToExcelResponseDto.getPaidSemester() != null + ? exportCircleMemberToExcelResponseDto.getPaidSemester().toString() : ""); row.createCell(15).setCellValue( - exportCircleMemberToExcelResponseDto.getAppliedSemester() != null ? - exportCircleMemberToExcelResponseDto.getAppliedSemester().toString() : "" - ); + exportCircleMemberToExcelResponseDto.getAppliedSemester() != null + ? exportCircleMemberToExcelResponseDto.getAppliedSemester().toString() : ""); row.createCell(16).setCellValue( - exportCircleMemberToExcelResponseDto.getRestOfSemester() != null ? - exportCircleMemberToExcelResponseDto.getRestOfSemester().toString() : "" - ); + exportCircleMemberToExcelResponseDto.getRestOfSemester() != null + ? exportCircleMemberToExcelResponseDto.getRestOfSemester().toString() : ""); row.createCell(17).setCellValue( - exportCircleMemberToExcelResponseDto.getIsRefunded() != null ? - exportCircleMemberToExcelResponseDto.getIsRefunded() ? "O" : "X" - : "" - ); + exportCircleMemberToExcelResponseDto.getIsRefunded() != null + ? exportCircleMemberToExcelResponseDto.getIsRefunded() ? "O" : "X" + : ""); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/CouncilFeeExcelService.java b/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/CouncilFeeExcelService.java index c05c4f2cd..11fdbb9b1 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/CouncilFeeExcelService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/CouncilFeeExcelService.java @@ -9,8 +9,8 @@ import org.apache.poi.ss.usermodel.Sheet; import org.springframework.stereotype.Service; -import net.causw.app.main.core.aop.annotation.MeasureTime; import net.causw.app.main.api.dto.userCouncilFee.UserCouncilFeeResponseDto; +import net.causw.app.main.core.aop.annotation.MeasureTime; import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; import net.causw.app.main.domain.user.account.enums.user.GraduationType; @@ -18,8 +18,8 @@ @Service public class CouncilFeeExcelService extends ExcelAbstractService { - private static final Function> cellMappingFunction = - userCouncilFee -> List.of( + private static final Function> cellMappingFunction = userCouncilFee -> List + .of( Optional.ofNullable(userCouncilFee.getIsJoinedService()) .map(isRefunded -> isRefunded ? "O" : "X") .orElse(""), @@ -58,18 +58,16 @@ public class CouncilFeeExcelService extends ExcelAbstractService isRefunded) - .map(isRefunded -> - Optional.ofNullable(userCouncilFee.getRefundedAt()) - .map(String::valueOf) - .orElse("")) + .map(isRefunded -> Optional.ofNullable(userCouncilFee.getRefundedAt()) + .map(String::valueOf) + .orElse("")) .orElse(""), Optional.ofNullable(userCouncilFee.getRestOfSemester()) .map(String::valueOf) .orElse(""), Optional.ofNullable(userCouncilFee.getIsAppliedThisSemester()) .map(isRefunded -> isRefunded ? "O" : "X") - .orElse("") - ); + .orElse("")); @Override public void createDataRows(Sheet sheet, List dataList) { diff --git a/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/ExcelAbstractService.java b/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/ExcelAbstractService.java index 31fc76ba8..758c2d872 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/ExcelAbstractService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/ExcelAbstractService.java @@ -26,15 +26,13 @@ public void generateExcel( HttpServletResponse response, String fileName, List headerStringList, - LinkedHashMap> sheetNameDataMap - ) { + LinkedHashMap> sheetNameDataMap) { if (headerStringList == null || headerStringList.isEmpty()) { throw new InternalServerException(ErrorCode.INTERNAL_SERVER, MessageUtil.FAIL_TO_GENERATE_EXCEL_FILE); } try ( Workbook workbook = new XSSFWorkbook(); - ServletOutputStream outputStream = response.getOutputStream() - ) { + ServletOutputStream outputStream = response.getOutputStream()) { for (String sheetName : sheetNameDataMap.keySet()) { createSheet(workbook, sheetName, headerStringList, sheetNameDataMap.get(sheetName)); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/ExcelService.java b/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/ExcelService.java index 8a8587a20..7c22c156f 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/ExcelService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/ExcelService.java @@ -13,8 +13,7 @@ public interface ExcelService { void generateExcel(HttpServletResponse response, String fileName, List headerStringList, - LinkedHashMap> sheetNameDataMap - ); + LinkedHashMap> sheetNameDataMap); void createSheet(Workbook workbook, String sheetName, List headerStringList, List dataList); diff --git a/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/FormExcelService.java b/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/FormExcelService.java index 6ae4200b7..d469ad308 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/FormExcelService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/FormExcelService.java @@ -6,9 +6,9 @@ import org.apache.poi.ss.usermodel.Sheet; import org.springframework.stereotype.Service; -import net.causw.app.main.core.aop.annotation.MeasureTime; import net.causw.app.main.api.dto.form.response.reply.excel.ExcelReplyQuestionResponseDto; import net.causw.app.main.api.dto.form.response.reply.excel.ExcelReplyResponseDto; +import net.causw.app.main.core.aop.annotation.MeasureTime; import net.causw.global.constant.MessageUtil; import net.causw.global.exception.ErrorCode; import net.causw.global.exception.InternalServerException; @@ -27,148 +27,127 @@ public void createDataRows(Sheet sheet, List excelReplyRe int cellNum = 0; row.createCell(cellNum++).setCellValue( - excelReplyResponseDto.getCreatedAt() != null ? excelReplyResponseDto.getCreatedAt().toString() : "" - ); + excelReplyResponseDto.getCreatedAt() != null ? excelReplyResponseDto.getCreatedAt().toString() : ""); row.createCell(cellNum++).setCellValue( - excelReplyResponseDto.getReplyUserResponseDto() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getEmail() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getEmail() : "" - : "" - ); + excelReplyResponseDto.getReplyUserResponseDto() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getEmail() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getEmail() : "" + : ""); row.createCell(cellNum++).setCellValue( - excelReplyResponseDto.getReplyUserResponseDto() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getName() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getName() : "" - : "" - ); + excelReplyResponseDto.getReplyUserResponseDto() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getName() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getName() : "" + : ""); row.createCell(cellNum++).setCellValue( - excelReplyResponseDto.getReplyUserResponseDto() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getNickName() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getNickName() : "" - : "" - ); + excelReplyResponseDto.getReplyUserResponseDto() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getNickName() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getNickName() : "" + : ""); row.createCell(cellNum++).setCellValue( - excelReplyResponseDto.getReplyUserResponseDto() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getAdmissionYear() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getAdmissionYear().toString() : "" - : "" - ); + excelReplyResponseDto.getReplyUserResponseDto() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getAdmissionYear() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getAdmissionYear().toString() : "" + : ""); row.createCell(cellNum++).setCellValue( - excelReplyResponseDto.getReplyUserResponseDto() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getStudentId() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getStudentId() : "" - : "" - ); + excelReplyResponseDto.getReplyUserResponseDto() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getStudentId() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getStudentId() : "" + : ""); row.createCell(cellNum++).setCellValue( - excelReplyResponseDto.getReplyUserResponseDto() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getMajor() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getMajor() : "" - : "" - ); + excelReplyResponseDto.getReplyUserResponseDto() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getMajor() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getMajor() : "" + : ""); row.createCell(cellNum++).setCellValue( - excelReplyResponseDto.getReplyUserResponseDto() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getPhoneNumber() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getPhoneNumber() : "" - : "" - ); + excelReplyResponseDto.getReplyUserResponseDto() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getPhoneNumber() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getPhoneNumber() : "" + : ""); row.createCell(cellNum++).setCellValue( - excelReplyResponseDto.getReplyUserResponseDto() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getAcademicStatus() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getAcademicStatus().getValue() : "" - : "" - ); + excelReplyResponseDto.getReplyUserResponseDto() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getAcademicStatus() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getAcademicStatus().getValue() : "" + : ""); row.createCell(cellNum++).setCellValue( - excelReplyResponseDto.getReplyUserResponseDto() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getCurrentCompletedSemester() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getCurrentCompletedSemester().toString() : "" - : "" - ); + excelReplyResponseDto.getReplyUserResponseDto() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getCurrentCompletedSemester() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getCurrentCompletedSemester().toString() : "" + : ""); row.createCell(cellNum++).setCellValue( - excelReplyResponseDto.getReplyUserResponseDto() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getGraduationYear() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getGraduationYear().toString() : "" - : "" - ); + excelReplyResponseDto.getReplyUserResponseDto() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getGraduationYear() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getGraduationYear().toString() : "" + : ""); row.createCell(cellNum++).setCellValue( - excelReplyResponseDto.getReplyUserResponseDto() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getGraduationType() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getGraduationType().getValue() : "" - : "" - ); + excelReplyResponseDto.getReplyUserResponseDto() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getGraduationType() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getGraduationType().getValue() : "" + : ""); row.createCell(cellNum++).setCellValue( - excelReplyResponseDto.getReplyUserResponseDto() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getCreatedAt() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getCreatedAt().toString() : "" - : "" - ); + excelReplyResponseDto.getReplyUserResponseDto() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getCreatedAt() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getCreatedAt().toString() : "" + : ""); row.createCell(cellNum++).setCellValue( - excelReplyResponseDto.getReplyUserResponseDto() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getIsAppliedThisSemester() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getIsAppliedThisSemester() ? "O" : "X" + excelReplyResponseDto.getReplyUserResponseDto() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getIsAppliedThisSemester() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getIsAppliedThisSemester() ? "O" : "X" : "" - : "" - ); + : ""); row.createCell(cellNum++).setCellValue( - excelReplyResponseDto.getReplyUserResponseDto() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getPaidAt() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getPaidAt().toString() : "" - : "" - ); + excelReplyResponseDto.getReplyUserResponseDto() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getPaidAt() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getPaidAt().toString() : "" + : ""); row.createCell(cellNum++).setCellValue( - excelReplyResponseDto.getReplyUserResponseDto() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getNumOfPaidSemester() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getNumOfPaidSemester().toString() : "" - : "" - ); + excelReplyResponseDto.getReplyUserResponseDto() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getNumOfPaidSemester() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getNumOfPaidSemester().toString() : "" + : ""); row.createCell(cellNum++).setCellValue( - excelReplyResponseDto.getReplyUserResponseDto() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getRestOfSemester() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getRestOfSemester().toString() : "" - : "" - ); + excelReplyResponseDto.getReplyUserResponseDto() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getRestOfSemester() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getRestOfSemester().toString() : "" + : ""); row.createCell(cellNum++).setCellValue( - excelReplyResponseDto.getReplyUserResponseDto() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getIsRefunded() != null ? - excelReplyResponseDto.getReplyUserResponseDto().getIsRefunded() ? "O" : "X" + excelReplyResponseDto.getReplyUserResponseDto() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getIsRefunded() != null + ? excelReplyResponseDto.getReplyUserResponseDto().getIsRefunded() ? "O" : "X" : "" - : "" - ); + : ""); - for (ExcelReplyQuestionResponseDto excelReplyQuestionResponseDto : excelReplyResponseDto.getExcelReplyQuestionResponseDtoList()) { + for (ExcelReplyQuestionResponseDto excelReplyQuestionResponseDto : excelReplyResponseDto + .getExcelReplyQuestionResponseDtoList()) { if (excelReplyQuestionResponseDto.getQuestionAnswer() != null && - excelReplyQuestionResponseDto.getSelectedOptionTextList().isEmpty() - ) { + excelReplyQuestionResponseDto.getSelectedOptionTextList().isEmpty()) { row.createCell(cellNum++).setCellValue( - excelReplyQuestionResponseDto.getQuestionAnswer() - ); + excelReplyQuestionResponseDto.getQuestionAnswer()); } else if (excelReplyQuestionResponseDto.getQuestionAnswer() == null && - !excelReplyQuestionResponseDto.getSelectedOptionTextList().isEmpty() - ) { + !excelReplyQuestionResponseDto.getSelectedOptionTextList().isEmpty()) { String selectedOptionTextList = String.join("\n", excelReplyQuestionResponseDto.getSelectedOptionTextList()); row.createCell(cellNum++).setCellValue(selectedOptionTextList); } else { throw new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.INTERNAL_SERVER_ERROR - ); + MessageUtil.INTERNAL_SERVER_ERROR); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/UserAcademicRecordExcelService.java b/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/UserAcademicRecordExcelService.java index 299f2558d..a7c73f5a5 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/UserAcademicRecordExcelService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/UserAcademicRecordExcelService.java @@ -6,9 +6,9 @@ import org.apache.poi.ss.usermodel.Sheet; import org.springframework.stereotype.Service; -import net.causw.app.main.core.aop.annotation.MeasureTime; import net.causw.app.main.api.dto.userAcademicRecordApplication.UserAcademicRecordApplicationResponseDto; import net.causw.app.main.api.dto.userAcademicRecordApplication.UserAcademicRecordInfoResponseDto; +import net.causw.app.main.core.aop.annotation.MeasureTime; @MeasureTime @Service @@ -20,47 +20,40 @@ public void createDataRows(Sheet sheet, List for (UserAcademicRecordInfoResponseDto userAcademicRecordInfoResponseDto : dataList) { Row row = sheet.createRow(rowNum++); row.createCell(0).setCellValue( - (userAcademicRecordInfoResponseDto.getUserName() != null) ? - (userAcademicRecordInfoResponseDto.getUserName()) : "" - ); + (userAcademicRecordInfoResponseDto.getUserName() != null) + ? (userAcademicRecordInfoResponseDto.getUserName()) : ""); row.createCell(1).setCellValue( - (userAcademicRecordInfoResponseDto.getStudentId() != null) ? - (userAcademicRecordInfoResponseDto.getStudentId()) : "" - ); + (userAcademicRecordInfoResponseDto.getStudentId() != null) + ? (userAcademicRecordInfoResponseDto.getStudentId()) : ""); row.createCell(2).setCellValue( - (userAcademicRecordInfoResponseDto.getAcademicStatus() != null) ? - (userAcademicRecordInfoResponseDto.getAcademicStatus().getValue()) : "" - ); + (userAcademicRecordInfoResponseDto.getAcademicStatus() != null) + ? (userAcademicRecordInfoResponseDto.getAcademicStatus().getValue()) : ""); row.createCell(3).setCellValue( - (userAcademicRecordInfoResponseDto.getCurrentCompleteSemester() != null) ? - (userAcademicRecordInfoResponseDto.getCurrentCompleteSemester().toString()) : "" - ); + (userAcademicRecordInfoResponseDto.getCurrentCompleteSemester() != null) + ? (userAcademicRecordInfoResponseDto.getCurrentCompleteSemester().toString()) : ""); row.createCell(4).setCellValue( - (userAcademicRecordInfoResponseDto.getNote() != null) ? - (userAcademicRecordInfoResponseDto.getNote()) : "" - ); + (userAcademicRecordInfoResponseDto.getNote() != null) ? (userAcademicRecordInfoResponseDto.getNote()) + : ""); - List userAcademicRecordApplicationListResponseDtoList = userAcademicRecordInfoResponseDto.getUserAcademicRecordApplicationResponseDtoList(); + List userAcademicRecordApplicationListResponseDtoList = userAcademicRecordInfoResponseDto + .getUserAcademicRecordApplicationResponseDtoList(); for (UserAcademicRecordApplicationResponseDto userAcademicRecordApplicationResponseDto : userAcademicRecordApplicationListResponseDtoList) { row.createCell(5).setCellValue( - (userAcademicRecordApplicationResponseDto.getTargetAcademicStatus() != null) ? - (userAcademicRecordApplicationResponseDto.getTargetAcademicStatus().getValue()) : "" - ); + (userAcademicRecordApplicationResponseDto.getTargetAcademicStatus() != null) + ? (userAcademicRecordApplicationResponseDto.getTargetAcademicStatus().getValue()) : ""); row.createCell(6).setCellValue( - (userAcademicRecordApplicationResponseDto.getUserNote() != null) ? - (userAcademicRecordApplicationResponseDto.getUserNote()) : "" - ); + (userAcademicRecordApplicationResponseDto.getUserNote() != null) + ? (userAcademicRecordApplicationResponseDto.getUserNote()) : ""); row.createCell(7).setCellValue( - (userAcademicRecordApplicationResponseDto.getChangeDate() != null) ? - (userAcademicRecordApplicationResponseDto.getChangeDate().toString()) : "" - ); + (userAcademicRecordApplicationResponseDto.getChangeDate() != null) + ? (userAcademicRecordApplicationResponseDto.getChangeDate().toString()) : ""); row = sheet.createRow(rowNum++); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/UserExcelService.java b/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/UserExcelService.java index c05c4f07d..99dcb454e 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/UserExcelService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/integration/export/service/UserExcelService.java @@ -10,8 +10,8 @@ import org.apache.poi.ss.usermodel.Sheet; import org.springframework.stereotype.Service; -import net.causw.app.main.core.aop.annotation.MeasureTime; import net.causw.app.main.api.dto.user.UserResponseDto; +import net.causw.app.main.core.aop.annotation.MeasureTime; import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; import net.causw.app.main.domain.user.account.enums.user.GraduationType; import net.causw.app.main.domain.user.account.enums.user.Role; @@ -21,48 +21,46 @@ @Service public class UserExcelService extends ExcelAbstractService { - private static final Function> cellMappingFunction = - user -> List.of( - Optional.ofNullable(user.getEmail()).orElse(""), - Optional.ofNullable(user.getName()).orElse(""), - Optional.ofNullable(user.getStudentId()).orElse(""), - Optional.ofNullable(user.getAdmissionYear()) - .map(String::valueOf) - .orElse(""), - Optional.ofNullable(user.getRoles()) - .map(roles -> roles.stream() - .map(Role::getDescription) - .collect(Collectors.joining(","))) - .orElse(""), - Optional.ofNullable(user.getState()) - .map(UserState::getDescription) - .orElse(""), - Optional.ofNullable(user.getNickname()).orElse(""), - Optional.ofNullable(user.getMajor()).orElse(""), - Optional.ofNullable(user.getAcademicStatus()) - .map(AcademicStatus::getValue) - .orElse(""), - Optional.ofNullable(user.getCurrentCompletedSemester()) - .map(String::valueOf) - .orElse(""), - Optional.ofNullable(user.getGraduationYear()) - .map(String::valueOf) - .orElse(""), - Optional.ofNullable(user.getGraduationType()) - .map(GraduationType::getValue) - .orElse(""), - Optional.ofNullable(user.getPhoneNumber()).orElse(""), - Optional.ofNullable(user.getCircleNameIfLeader()) - .map(circles -> String.join(",", circles)) - .orElse(""), - Optional.ofNullable(user.getRejectionOrDropReason()).orElse(""), - Optional.ofNullable(user.getCreatedAt()) - .map(String::valueOf) - .orElse(""), - Optional.ofNullable(user.getUpdatedAt()) - .map(String::valueOf) - .orElse("") - ); + private static final Function> cellMappingFunction = user -> List.of( + Optional.ofNullable(user.getEmail()).orElse(""), + Optional.ofNullable(user.getName()).orElse(""), + Optional.ofNullable(user.getStudentId()).orElse(""), + Optional.ofNullable(user.getAdmissionYear()) + .map(String::valueOf) + .orElse(""), + Optional.ofNullable(user.getRoles()) + .map(roles -> roles.stream() + .map(Role::getDescription) + .collect(Collectors.joining(","))) + .orElse(""), + Optional.ofNullable(user.getState()) + .map(UserState::getDescription) + .orElse(""), + Optional.ofNullable(user.getNickname()).orElse(""), + Optional.ofNullable(user.getMajor()).orElse(""), + Optional.ofNullable(user.getAcademicStatus()) + .map(AcademicStatus::getValue) + .orElse(""), + Optional.ofNullable(user.getCurrentCompletedSemester()) + .map(String::valueOf) + .orElse(""), + Optional.ofNullable(user.getGraduationYear()) + .map(String::valueOf) + .orElse(""), + Optional.ofNullable(user.getGraduationType()) + .map(GraduationType::getValue) + .orElse(""), + Optional.ofNullable(user.getPhoneNumber()).orElse(""), + Optional.ofNullable(user.getCircleNameIfLeader()) + .map(circles -> String.join(",", circles)) + .orElse(""), + Optional.ofNullable(user.getRejectionOrDropReason()).orElse(""), + Optional.ofNullable(user.getCreatedAt()) + .map(String::valueOf) + .orElse(""), + Optional.ofNullable(user.getUpdatedAt()) + .map(String::valueOf) + .orElse("")); @Override public void createDataRows(Sheet sheet, List dataList) { diff --git a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/CeremonyNotificationSetting.java b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/CeremonyNotificationSetting.java index bf728a26e..0410f5453 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/CeremonyNotificationSetting.java +++ b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/CeremonyNotificationSetting.java @@ -40,7 +40,7 @@ public class CeremonyNotificationSetting extends BaseEntity { private boolean isNotificationActive = true; @Column(name = "is_set_all", nullable = false) - private boolean isSetAll = true; // 경조사 알림은 기본적으로 모든 학번에게 알림을 받음 + private boolean isSetAll = true; // 경조사 알림은 기본적으로 모든 학번에게 알림을 받음 @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id", nullable = false) @@ -50,8 +50,7 @@ public static CeremonyNotificationSetting of( Set subscribedAdmissionYears, boolean isSetAll, boolean receivePushNotification, - User user - ) { + User user) { return CeremonyNotificationSetting.builder() .subscribedAdmissionYears(subscribedAdmissionYears) .isSetAll(isSetAll) diff --git a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/Notification.java b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/Notification.java index 61b77605a..54293d8cc 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/Notification.java +++ b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/Notification.java @@ -52,8 +52,7 @@ public static Notification of( String body, NoticeType noticeType, String targetId, - String targetParentId - ) { + String targetParentId) { return Notification.builder() .user(user) .title(title) diff --git a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/NotificationLog.java b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/NotificationLog.java index 2f33c8028..0759c8f8c 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/NotificationLog.java +++ b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/NotificationLog.java @@ -36,8 +36,7 @@ public class NotificationLog extends BaseEntity { public static NotificationLog of( User user, - Notification notification - ) { + Notification notification) { return NotificationLog.builder() .user(user) .notification(notification) diff --git a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/UserBoardSubscribe.java b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/UserBoardSubscribe.java index e20aa9bbb..fda406d93 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/UserBoardSubscribe.java +++ b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/UserBoardSubscribe.java @@ -42,8 +42,7 @@ public void setIsSubscribed(Boolean subscribed) { public static UserBoardSubscribe of( User user, Board board, - Boolean isSubscribed - ) { + Boolean isSubscribed) { return UserBoardSubscribe.builder() .user(user) .board(board) diff --git a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/UserCommentSubscribe.java b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/UserCommentSubscribe.java index 048369761..369539a33 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/UserCommentSubscribe.java +++ b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/UserCommentSubscribe.java @@ -42,8 +42,7 @@ public void setIsSubscribed(Boolean subscribed) { public static UserCommentSubscribe of( User user, Comment comment, - Boolean isSubscribed - ) { + Boolean isSubscribed) { return UserCommentSubscribe.builder() .user(user) .comment(comment) diff --git a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/UserPostSubscribe.java b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/UserPostSubscribe.java index 17fcf36c0..13155640e 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/UserPostSubscribe.java +++ b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/entity/UserPostSubscribe.java @@ -42,8 +42,7 @@ public void setIsSubscribed(Boolean subscribed) { public static UserPostSubscribe of( User user, Post post, - Boolean isSubscribed - ) { + Boolean isSubscribed) { return UserPostSubscribe.builder() .user(user) .post(post) diff --git a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/enums/NoticeType.java b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/enums/NoticeType.java index 623c74963..e8f20a960 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/enums/NoticeType.java +++ b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/enums/NoticeType.java @@ -7,7 +7,9 @@ @AllArgsConstructor public enum NoticeType { POST("게시물 알림"), - COMMENT("댓글 알림"), CEREMONY("경조사 알림"), BOARD("보드 알림"); + COMMENT("댓글 알림"), + CEREMONY("경조사 알림"), + BOARD("보드 알림"); private final String type; } diff --git a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/CeremonyNotificationSettingRepository.java b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/CeremonyNotificationSettingRepository.java index 88018e6a1..46bd0a908 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/CeremonyNotificationSettingRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/CeremonyNotificationSettingRepository.java @@ -23,21 +23,21 @@ public interface CeremonyNotificationSettingRepository extends JpaRepository findByAdmissionYearOrSetAll( - @Param("admissionYear") Integer admissionYear, - @Param("blockerUserIds") Set blockerUserIds - ); + @Param("admissionYear") + Integer admissionYear, + @Param("blockerUserIds") + Set blockerUserIds); @Query(""" SELECT DISTINCT c FROM CeremonyNotificationSetting c WHERE EXISTS (SELECT 1 FROM c.subscribedAdmissionYears s WHERE s IN :admissionYears) OR c.isSetAll = true AND (:#{#blockerUserIds.size()} = 0 OR c.user.id NOT IN :blockerUserIds) - """ - ) + """) List findByAdmissionYearsIn( - @Param("admissionYears") List admissionYears, - @Param("blockerUserIds") Set blockerUserIds - ); + @Param("admissionYears") + List admissionYears, + @Param("blockerUserIds") + Set blockerUserIds); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/NotificationLogRepository.java b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/NotificationLogRepository.java index 805278fbd..8acd5377b 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/NotificationLogRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/NotificationLogRepository.java @@ -20,8 +20,10 @@ public interface NotificationLogRepository extends JpaRepository findByUserAndNotificationTypes(@Param("user") User user, - @Param("types") List types, Pageable pageable); + Page findByUserAndNotificationTypes(@Param("user") + User user, + @Param("types") + List types, Pageable pageable); @Query("SELECT nl FROM NotificationLog nl " + "JOIN FETCH nl.notification n " + @@ -29,14 +31,17 @@ Page findByUserAndNotificationTypes(@Param("user") User user, "AND nl.isRead = false " + "AND n.noticeType IN :types " + "ORDER BY nl.createdAt DESC") - List findByUserAndIsReadFalseNotificationTypes(@Param("user") User user, - @Param("types") List types, Pageable pageable); + List findByUserAndIsReadFalseNotificationTypes(@Param("user") + User user, + @Param("types") + List types, Pageable pageable); Optional findByIdAndUser(String id, User user); @Query("SELECT nl FROM NotificationLog nl " + "WHERE nl.user = :user " + "AND nl.isRead = false") - List findUnreadLogsUpToLimit(@Param("user") User user, Pageable pageable); + List findUnreadLogsUpToLimit(@Param("user") + User user, Pageable pageable); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/NotificationRepository.java b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/NotificationRepository.java index 44aa71c34..1e46791cc 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/NotificationRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/NotificationRepository.java @@ -13,13 +13,13 @@ @Repository public interface NotificationRepository extends JpaRepository { - @Query( - value = "SELECT * " + - "FROM tb_notification " + - "WHERE user_id = :userId OR is_global = true " + - "ORDER BY created_at DESC " + - "LIMIT 4", nativeQuery = true) - List findUserNotice(@Param("userId") String userId); + @Query(value = "SELECT * " + + "FROM tb_notification " + + "WHERE user_id = :userId OR is_global = true " + + "ORDER BY created_at DESC " + + "LIMIT 4", nativeQuery = true) + List findUserNotice(@Param("userId") + String userId); List findByUserAndNoticeTypeIn(User user, List noticeTypes); diff --git a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/UserBoardSubscribeRepository.java b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/UserBoardSubscribeRepository.java index f5cada079..9d9c9d370 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/UserBoardSubscribeRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/UserBoardSubscribeRepository.java @@ -23,16 +23,16 @@ public interface UserBoardSubscribeRepository extends JpaRepository findByBoardAndIsSubscribedTrue(Board board); @EntityGraph(attributePaths = {"user"}) - @Query( - """ - SELECT ubs FROM UserBoardSubscribe ubs - WHERE ubs.board = :board AND ubs.isSubscribed = true - AND (:#{#blockerUserIds.size()} = 0 OR ubs.user.id NOT IN :blockerUserIds) - """ - ) + @Query(""" + SELECT ubs FROM UserBoardSubscribe ubs + WHERE ubs.board = :board AND ubs.isSubscribed = true + AND (:#{#blockerUserIds.size()} = 0 OR ubs.user.id NOT IN :blockerUserIds) + """) List findByBoardAndIsSubscribedTrueExcludingBlockerUsers( - @Param("board") Board board, - @Param("blockerUserIds") Set blockerUserIds); + @Param("board") + Board board, + @Param("blockerUserIds") + Set blockerUserIds); @EntityGraph(attributePaths = {"board"}) List findByUserAndIsSubscribedTrue(User user); diff --git a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/UserCommentSubscribeRepository.java b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/UserCommentSubscribeRepository.java index b9bcfdddc..565579531 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/UserCommentSubscribeRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/UserCommentSubscribeRepository.java @@ -22,9 +22,10 @@ public interface UserCommentSubscribeRepository extends JpaRepository findByCommentAndIsSubscribedTrueExcludingBlockerUsers( - @Param("comment") Comment comment, - @Param("blockerUserIds") Set blockerUserIds - ); + @Param("comment") + Comment comment, + @Param("blockerUserIds") + Set blockerUserIds); Optional findByUserAndComment(User user, Comment comment); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/UserPostSubscribeRepository.java b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/UserPostSubscribeRepository.java index c3eebc487..9bec68450 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/UserPostSubscribeRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/repository/UserPostSubscribeRepository.java @@ -22,9 +22,10 @@ public interface UserPostSubscribeRepository extends JpaRepository findByPostAndIsSubscribedTrueExcludingBlockers( - @Param("post") Post post, - @Param("blockerUserIds") Set blockerUserIds - ); + @Param("post") + Post post, + @Param("blockerUserIds") + Set blockerUserIds); Optional findByUserAndPost(User user, Post post); diff --git a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/BoardNotificationService.java b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/BoardNotificationService.java index 7ee345e09..48f35730e 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/BoardNotificationService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/BoardNotificationService.java @@ -8,9 +8,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import net.causw.app.main.api.dto.notification.BoardNotificationDto; import net.causw.app.main.domain.community.board.entity.Board; import net.causw.app.main.domain.community.post.entity.Post; -import net.causw.app.main.api.dto.notification.BoardNotificationDto; import net.causw.app.main.domain.notification.notification.entity.Notification; import net.causw.app.main.domain.notification.notification.entity.NotificationLog; import net.causw.app.main.domain.notification.notification.entity.UserBoardSubscribe; @@ -75,8 +75,8 @@ public void sendByBoardIsSubscribed(Board board, Post post) { List userBoardSubscribeList = userBoardSubscribes .stream() .filter(subscribe -> board.getIsAlumni() // 동문회 허용 게시판인 경우 졸업생에게 게시판 알림 - || subscribe.getUser().getAcademicStatus() != AcademicStatus.GRADUATED - ).toList(); + || subscribe.getUser().getAcademicStatus() != AcademicStatus.GRADUATED) + .toList(); BoardNotificationDto boardNotificationDto = BoardNotificationDto.of(board, post); @@ -88,12 +88,11 @@ public void sendByBoardIsSubscribed(Board board, Post post) { userBoardSubscribeList.stream() .map(UserBoardSubscribe::getUser) .forEach(user -> { - fcmUtils.cleanInvalidFcmTokens(user); - Set copy = new HashSet<>(user.getFcmTokens()); - copy.forEach( - token -> send(user, token, boardNotificationDto.getTitle(), boardNotificationDto.getBody())); - saveNotificationLog(user, notification); - } - ); + fcmUtils.cleanInvalidFcmTokens(user); + Set copy = new HashSet<>(user.getFcmTokens()); + copy.forEach( + token -> send(user, token, boardNotificationDto.getTitle(), boardNotificationDto.getBody())); + saveNotificationLog(user, notification); + }); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/CeremonyNotificationService.java b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/CeremonyNotificationService.java index f5c0a090f..0b58b9dd8 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/CeremonyNotificationService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/CeremonyNotificationService.java @@ -11,11 +11,11 @@ import net.causw.app.main.api.dto.notification.CeremonyNotificationDto; import net.causw.app.main.domain.community.ceremony.entity.Ceremony; +import net.causw.app.main.domain.community.ceremony.repository.CeremonyRepository; import net.causw.app.main.domain.notification.notification.entity.CeremonyNotificationSetting; import net.causw.app.main.domain.notification.notification.entity.Notification; import net.causw.app.main.domain.notification.notification.entity.NotificationLog; import net.causw.app.main.domain.notification.notification.enums.NoticeType; -import net.causw.app.main.domain.community.ceremony.repository.CeremonyRepository; import net.causw.app.main.domain.notification.notification.repository.CeremonyNotificationSettingRepository; import net.causw.app.main.domain.notification.notification.repository.NotificationLogRepository; import net.causw.app.main.domain.notification.notification.repository.NotificationRepository; @@ -72,9 +72,7 @@ public void sendByAdmissionYear(Integer admissionYear, String ceremonyId) { Ceremony ceremony = ceremonyRepository.findById(ceremonyId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.CEREMONY_NOT_FOUND - ) - ); + MessageUtil.CEREMONY_NOT_FOUND)); List ceremonyNotificationSettings; @@ -86,8 +84,7 @@ public void sendByAdmissionYear(Integer admissionYear, String ceremonyId) { // 모든 학번에게 알림 ceremonyNotificationSettings = ceremonyNotificationSettingRepository.findByAdmissionYearOrSetAll( admissionYear, - blockerUserIdsByBlockee - ); + blockerUserIdsByBlockee); } else { // 특정 학번에게만 알림 // 1차 필터링 @@ -130,8 +127,7 @@ public void sendByAdmissionYear(Integer admissionYear, String ceremonyId) { ceremonyNotificationDto.getBody(), NoticeType.CEREMONY, ceremony.getId(), - null - ); + null); saveNotification(notification); diff --git a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/CommentNotificationService.java b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/CommentNotificationService.java index 84cd6b96c..d6a6d3636 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/CommentNotificationService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/CommentNotificationService.java @@ -11,9 +11,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import net.causw.app.main.api.dto.notification.CommentNotificationDto; import net.causw.app.main.domain.community.comment.entity.ChildComment; import net.causw.app.main.domain.community.comment.entity.Comment; -import net.causw.app.main.api.dto.notification.CommentNotificationDto; import net.causw.app.main.domain.notification.notification.entity.Notification; import net.causw.app.main.domain.notification.notification.entity.NotificationLog; import net.causw.app.main.domain.notification.notification.entity.UserCommentSubscribe; @@ -73,8 +73,9 @@ public void sendByCommentIsSubscribed(Comment comment, ChildComment childComment Set blockerUserIds = getBlockerUserIds(commentWriter, childCommentWriter); - List userCommentSubscribeList = userCommentSubscribeRepository.findByCommentAndIsSubscribedTrueExcludingBlockerUsers( - comment, blockerUserIds); + List userCommentSubscribeList = userCommentSubscribeRepository + .findByCommentAndIsSubscribedTrueExcludingBlockerUsers( + comment, blockerUserIds); CommentNotificationDto commentNotificationDto = CommentNotificationDto.of(comment, childComment); Notification notification = Notification.of(childCommentWriter, commentNotificationDto.getTitle(), @@ -102,11 +103,10 @@ public void sendByCommentIsSubscribed(Comment comment, ChildComment childComment * @return 차단한 유저 ids Set */ private Set getBlockerUserIds(User commentWriter, User childCommentWriter) { - Set blockeeUserIds = - Stream.of(commentWriter, childCommentWriter) - .filter(Objects::nonNull) - .map(BaseEntity::getId) - .collect(Collectors.toSet()); + Set blockeeUserIds = Stream.of(commentWriter, childCommentWriter) + .filter(Objects::nonNull) + .map(BaseEntity::getId) + .collect(Collectors.toSet()); return userBlockEntityService.findBlockerUserIdsByUserIds(blockeeUserIds); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/NotificationLogService.java b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/NotificationLogService.java index 77f0c9ab7..f470b2242 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/NotificationLogService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/NotificationLogService.java @@ -35,13 +35,10 @@ public Page getGeneralNotification(User user, Integer p Page notificationLogs = notificationLogRepository.findByUserAndNotificationTypes(user, types, pageableFactory.create(pageNum, StaticValue.DEFAULT_NOTIFICATION_PAGE_SIZE)); - return notificationLogs.map(log -> - NotificationDtoMapper.INSTANCE.toNotificationResponseDto( - log.getId(), - log.getNotification(), - log.getIsRead() - ) - ); + return notificationLogs.map(log -> NotificationDtoMapper.INSTANCE.toNotificationResponseDto( + log.getId(), + log.getNotification(), + log.getIsRead())); } @Transactional(readOnly = true) @@ -62,13 +59,10 @@ public Page getCeremonyNotification(User user, Integer Page notificationLogs = notificationLogRepository.findByUserAndNotificationTypes(user, types, pageableFactory.create(pageNum, StaticValue.DEFAULT_NOTIFICATION_PAGE_SIZE)); - return notificationLogs.map(log -> - NotificationDtoMapper.INSTANCE.toNotificationResponseDto( - log.getId(), - log.getNotification(), - log.getIsRead() - ) - ); + return notificationLogs.map(log -> NotificationDtoMapper.INSTANCE.toNotificationResponseDto( + log.getId(), + log.getNotification(), + log.getIsRead())); } @Transactional(readOnly = true) @@ -88,9 +82,7 @@ public void readNotification(User user, String id) { NotificationLog notificationLog = notificationLogRepository.findByIdAndUser(id, user).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.NOTIFICATION_LOG_NOT_FOUND - ) - ); + MessageUtil.NOTIFICATION_LOG_NOT_FOUND)); notificationLog.setIsRead(true); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/PostNotificationService.java b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/PostNotificationService.java index 753eee12a..561442b24 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/PostNotificationService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/notification/notification/service/PostNotificationService.java @@ -11,9 +11,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import net.causw.app.main.api.dto.notification.PostNotificationDto; import net.causw.app.main.domain.community.comment.entity.Comment; import net.causw.app.main.domain.community.post.entity.Post; -import net.causw.app.main.api.dto.notification.PostNotificationDto; import net.causw.app.main.domain.notification.notification.entity.Notification; import net.causw.app.main.domain.notification.notification.entity.NotificationLog; import net.causw.app.main.domain.notification.notification.entity.UserPostSubscribe; @@ -71,8 +71,9 @@ public void sendByPostIsSubscribed(Post post, Comment comment) { User postWriter = post.getWriter(); User commentWriter = comment.getWriter(); Set blockerUserIds = getBlockerUserIds(postWriter, commentWriter); - List userPostSubscribeList = userPostSubscribeRepository.findByPostAndIsSubscribedTrueExcludingBlockers( - post, blockerUserIds); + List userPostSubscribeList = userPostSubscribeRepository + .findByPostAndIsSubscribedTrueExcludingBlockers( + post, blockerUserIds); PostNotificationDto postNotificationDto = PostNotificationDto.of(post, comment); @@ -92,11 +93,10 @@ public void sendByPostIsSubscribed(Post post, Comment comment) { } private Set getBlockerUserIds(User postWriter, User commentWriter) { - Set blockeeUserIds = - Stream.of(postWriter, commentWriter) - .filter(Objects::nonNull) - .map(BaseEntity::getId) - .collect(Collectors.toSet()); + Set blockeeUserIds = Stream.of(postWriter, commentWriter) + .filter(Objects::nonNull) + .map(BaseEntity::getId) + .collect(Collectors.toSet()); return userBlockEntityService.findBlockerUserIdsByUserIds(blockeeUserIds); } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/academic/entity/userAcademicRecord/UserAcademicRecordApplication.java b/app-main/src/main/java/net/causw/app/main/domain/user/academic/entity/userAcademicRecord/UserAcademicRecordApplication.java index 604a99bc0..3d5560ed2 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/academic/entity/userAcademicRecord/UserAcademicRecordApplication.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/academic/entity/userAcademicRecord/UserAcademicRecordApplication.java @@ -32,11 +32,9 @@ @Entity @AllArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PROTECTED) -@Table( - name = "tb_user_academic_record_application", - indexes = { - @Index(name = "user_id_index", columnList = "user_id") - }) +@Table(name = "tb_user_academic_record_application", indexes = { + @Index(name = "user_id_index", columnList = "user_id") +}) public class UserAcademicRecordApplication extends BaseEntity { @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @@ -72,8 +70,7 @@ public static UserAcademicRecordApplication create( AcademicRecordRequestStatus academicRecordRequestStatus, AcademicStatus academicStatus, Integer targetCompletedSemester, - String note - ) { + String note) { return UserAcademicRecordApplication.builder() .user(user) .academicRecordRequestStatus(academicRecordRequestStatus) @@ -89,8 +86,7 @@ public static UserAcademicRecordApplication createWithImage( AcademicStatus academicStatus, Integer targetCompletedSemester, String note, - List userAcademicRecordAttachImageUuidFileList - ) { + List userAcademicRecordAttachImageUuidFileList) { UserAcademicRecordApplication userAcademicRecordApplication = UserAcademicRecordApplication.builder() .user(user) .academicRecordRequestStatus(academicRecordRequestStatus) @@ -99,7 +95,8 @@ public static UserAcademicRecordApplication createWithImage( .note(note) .build(); - List userAcademicRecordApplicationAttachImageList = userAcademicRecordAttachImageUuidFileList.stream() + List userAcademicRecordApplicationAttachImageList = userAcademicRecordAttachImageUuidFileList + .stream() .map(uuidFile -> UserAcademicRecordApplicationAttachImage.of(userAcademicRecordApplication, uuidFile)) .toList(); diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/academic/entity/userAcademicRecord/UserAcademicRecordLog.java b/app-main/src/main/java/net/causw/app/main/domain/user/academic/entity/userAcademicRecord/UserAcademicRecordLog.java index 33e7130f7..c93fbe424 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/academic/entity/userAcademicRecord/UserAcademicRecordLog.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/academic/entity/userAcademicRecord/UserAcademicRecordLog.java @@ -1,6 +1,5 @@ package net.causw.app.main.domain.user.academic.entity.userAcademicRecord; - import java.util.ArrayList; import java.util.List; @@ -79,8 +78,7 @@ public class UserAcademicRecordLog extends BaseEntity { public static UserAcademicRecordLog createWithApplication( User controlledUser, - UserAcademicRecordApplication targetUserAcademicRecordApplication - ) { + UserAcademicRecordApplication targetUserAcademicRecordApplication) { User targetUser = targetUserAcademicRecordApplication.getUser(); UserAcademicRecordLog userAcademicRecordLog = UserAcademicRecordLog.builder() @@ -96,13 +94,12 @@ public static UserAcademicRecordLog createWithApplication( .rejectMessage(targetUserAcademicRecordApplication.getRejectMessage()) .build(); - List userAcademicRecordLogAttachImageList = - targetUserAcademicRecordApplication.getUserAcademicRecordAttachImageList() - .stream() - .map(userAcademicRecordApplicationAttachImage -> - UserAcademicRecordLogAttachImage.of( - userAcademicRecordLog, userAcademicRecordApplicationAttachImage.getUuidFile())) - .toList(); + List userAcademicRecordLogAttachImageList = targetUserAcademicRecordApplication + .getUserAcademicRecordAttachImageList() + .stream() + .map(userAcademicRecordApplicationAttachImage -> UserAcademicRecordLogAttachImage.of( + userAcademicRecordLog, userAcademicRecordApplicationAttachImage.getUuidFile())) + .toList(); userAcademicRecordLog.setUserAcademicRecordLogAttachImageList(userAcademicRecordLogAttachImageList); @@ -112,8 +109,7 @@ public static UserAcademicRecordLog createWithApplication( public static UserAcademicRecordLog createWithApplication( User controlledUser, UserAcademicRecordApplication targetUserAcademicRecordApplication, - String note - ) { + String note) { User targetUser = targetUserAcademicRecordApplication.getUser(); UserAcademicRecordLog userAcademicRecordLog = UserAcademicRecordLog.builder() @@ -129,13 +125,12 @@ public static UserAcademicRecordLog createWithApplication( .rejectMessage(targetUserAcademicRecordApplication.getRejectMessage()) .build(); - List userAcademicRecordLogAttachImageList = - targetUserAcademicRecordApplication.getUserAcademicRecordAttachImageList() - .stream() - .map(userAcademicRecordApplicationAttachImage -> - UserAcademicRecordLogAttachImage.of( - userAcademicRecordLog, userAcademicRecordApplicationAttachImage.getUuidFile())) - .toList(); + List userAcademicRecordLogAttachImageList = targetUserAcademicRecordApplication + .getUserAcademicRecordAttachImageList() + .stream() + .map(userAcademicRecordApplicationAttachImage -> UserAcademicRecordLogAttachImage.of( + userAcademicRecordLog, userAcademicRecordApplicationAttachImage.getUuidFile())) + .toList(); userAcademicRecordLog.setUserAcademicRecordLogAttachImageList(userAcademicRecordLogAttachImageList); @@ -146,8 +141,7 @@ public static UserAcademicRecordLog create( User controlledUser, User targetUser, AcademicStatus targetAcademicRecordStatus, - String note - ) { + String note) { return UserAcademicRecordLog.builder() .controlledUserEmail(controlledUser.getEmail()) .controlledUserName(controlledUser.getName()) @@ -166,8 +160,7 @@ public static UserAcademicRecordLog createWithGraduation( AcademicStatus targetAcademicRecordStatus, Integer graduationYear, GraduationType graduationType, - String note - ) { + String note) { return UserAcademicRecordLog.builder() .controlledUserEmail(controlledUser.getEmail()) .controlledUserName(controlledUser.getName()) diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/academic/repository/userAcademicRecord/UserAcademicRecordApplicationRepository.java b/app-main/src/main/java/net/causw/app/main/domain/user/academic/repository/userAcademicRecord/UserAcademicRecordApplicationRepository.java index 996e7f4b4..ff28ed480 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/academic/repository/userAcademicRecord/UserAcademicRecordApplicationRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/academic/repository/userAcademicRecord/UserAcademicRecordApplicationRepository.java @@ -20,13 +20,11 @@ Page findAllByAcademicRecordRequestStatus(Pageabl List findAllByAcademicRecordRequestStatusAndUser( AcademicRecordRequestStatus academicRecordRequestStatus, - User user - ); + User user); Optional findDistinctTopByAcademicRecordRequestStatusAndUserOrderByCreatedAtDesc( AcademicRecordRequestStatus academicRecordRequestStatus, - User user - ); + User user); List findByUserId(String userId); diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/academic/service/UserAcademicRecordApplicationService.java b/app-main/src/main/java/net/causw/app/main/domain/user/academic/service/UserAcademicRecordApplicationService.java index 289f8466d..c89e00b2c 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/academic/service/UserAcademicRecordApplicationService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/academic/service/UserAcademicRecordApplicationService.java @@ -11,9 +11,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import net.causw.app.main.core.aop.annotation.MeasureTime; -import net.causw.app.main.domain.asset.file.entity.UuidFile; -import net.causw.app.main.domain.integration.export.service.UserAcademicRecordExcelService; import net.causw.app.main.api.dto.semester.CurrentSemesterResponseDto; import net.causw.app.main.api.dto.user.UserAcademicStatusNoteUpdateDto; import net.causw.app.main.api.dto.userAcademicRecordApplication.CreateUserAcademicRecordApplicationRequestDto; @@ -27,10 +24,13 @@ import net.causw.app.main.api.dto.userAcademicRecordApplication.UserAcademicRecordListResponseDto; import net.causw.app.main.api.dto.util.dtoMapper.SemesterDtoMapper; import net.causw.app.main.api.dto.util.dtoMapper.UserAcademicRecordDtoMapper; -import net.causw.app.main.domain.campus.semester.entity.Semester; +import net.causw.app.main.core.aop.annotation.MeasureTime; +import net.causw.app.main.domain.asset.file.entity.UuidFile; import net.causw.app.main.domain.asset.file.enums.FilePath; -import net.causw.app.main.domain.campus.semester.service.SemesterService; import net.causw.app.main.domain.asset.file.service.UuidFileService; +import net.causw.app.main.domain.campus.semester.entity.Semester; +import net.causw.app.main.domain.campus.semester.service.SemesterService; +import net.causw.app.main.domain.integration.export.service.UserAcademicRecordExcelService; import net.causw.app.main.domain.user.academic.entity.userAcademicRecord.UserAcademicRecordApplication; import net.causw.app.main.domain.user.academic.entity.userAcademicRecord.UserAcademicRecordLog; import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicRecordRequestStatus; @@ -75,8 +75,7 @@ public void exportUserAcademicRecordListToExcel(HttpServletResponse response) { "비고", "변환 타겟 학적 상태", "유저 작성 특이사항(단, 관리자 임의 수정 시 \"관리자 수정\"이라 기입)", - "변경 날짜" - ); + "변경 날짜"); LinkedHashMap> sheetDataMap = new LinkedHashMap<>(); @@ -85,12 +84,12 @@ public void exportUserAcademicRecordListToExcel(HttpServletResponse response) { List userList = userRepository.findAll(); for (User user : userList) { - List userAcademicRecordLogList = userAcademicRecordLogRepository.findAllByTargetUserEmailAndTargetUserName( - user.getEmail(), - user.getName()); + List userAcademicRecordLogList = userAcademicRecordLogRepository + .findAllByTargetUserEmailAndTargetUserName( + user.getEmail(), + user.getName()); userAcademicRecordInfoResponseDtoList.add( - toUserAcademicRecordInfoResponseDto(user, userAcademicRecordLogList) - ); + toUserAcademicRecordInfoResponseDto(user, userAcademicRecordLogList)); } sheetDataMap.put("학적상태명단", userAcademicRecordInfoResponseDtoList); @@ -105,7 +104,7 @@ public Page getAllUserAcademicRecordPage(Page public Page getAllUserAwaitingAcademicRecordPage(Pageable pageable) { return userAcademicRecordApplicationRepository.findAllByAcademicRecordRequestStatus(pageable, - AcademicRecordRequestStatus.AWAIT) + AcademicRecordRequestStatus.AWAIT) .map(this::toUserAcademicRecordApplicationListResponseDto); } @@ -154,8 +153,7 @@ public UserAcademicRecordInfoResponseDto updateUserAcademicStatus(User controlle controllerUser, targetUser, updateUserAcademicStatusRequestDto.getTargetAcademicStatus(), - MessageUtil.ADMIN_UPDATE_ACADEMIC_RECORD_MESSAGE - ); + MessageUtil.ADMIN_UPDATE_ACADEMIC_RECORD_MESSAGE); userRepository.save(targetUser); userAcademicRecordLogRepository.save(userAcademicRecordLog); @@ -166,8 +164,7 @@ public UserAcademicRecordInfoResponseDto updateUserAcademicStatus(User controlle @Transactional public UserAcademicRecordApplicationResponseDto updateUserAcademicRecordApplicationStatus( User controllerUser, - UpdateUserAcademicRecordApplicationStateRequestDto updateUserAcademicRecordApplicationStateRequestDto - ) { + UpdateUserAcademicRecordApplicationStateRequestDto updateUserAcademicRecordApplicationStateRequestDto) { User targetUser = getUser(updateUserAcademicRecordApplicationStateRequestDto.getTargetUserId()); UserAcademicRecordApplication userAcademicRecordApplication = getUserAcademicRecordApplication( updateUserAcademicRecordApplicationStateRequestDto.getApplicationId()); @@ -175,11 +172,11 @@ public UserAcademicRecordApplicationResponseDto updateUserAcademicRecordApplicat if (!userAcademicRecordApplication.getUser().equals(targetUser)) { throw new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_ACADEMIC_RECORD_APPLICATION_AND_USER_NOT_MATCH - ); + MessageUtil.USER_ACADEMIC_RECORD_APPLICATION_AND_USER_NOT_MATCH); } - AcademicRecordRequestStatus targetAcademicRecordRequestStatus = updateUserAcademicRecordApplicationStateRequestDto.getTargetAcademicRecordRequestStatus(); + AcademicRecordRequestStatus targetAcademicRecordRequestStatus = updateUserAcademicRecordApplicationStateRequestDto + .getTargetAcademicRecordRequestStatus(); if (targetAcademicRecordRequestStatus == AcademicRecordRequestStatus.REJECT) { // 거절 사유 저장 @@ -204,8 +201,7 @@ public UserAcademicRecordApplicationResponseDto updateUserAcademicRecordApplicat UserAcademicRecordLog userAcademicRecordLog = UserAcademicRecordLog.createWithApplication( controllerUser, - userAcademicRecordApplication - ); + userAcademicRecordApplication); userAcademicRecordLogRepository.save(userAcademicRecordLog); return toUserAcademicRecordApplicationResponseDto(userAcademicRecordLog); @@ -215,8 +211,7 @@ public UserAcademicRecordApplicationResponseDto updateUserAcademicRecordApplicat public UserAcademicRecordApplicationResponseDto createUserAcademicRecordApplication( String userId, CreateUserAcademicRecordApplicationRequestDto createUserAcademicRecordApplicationRequestDto, - List imageFileList - ) { + List imageFileList) { validCreateUserAcademicRecordApplicationRequestDto(createUserAcademicRecordApplicationRequestDto, imageFileList); @@ -239,15 +234,13 @@ public UserAcademicRecordApplicationResponseDto createUserAcademicRecordApplicat createUserAcademicRecordApplicationRequestDto.getTargetAcademicStatus(), createUserAcademicRecordApplicationRequestDto.getTargetCompletedSemester(), createUserAcademicRecordApplicationRequestDto.getNote(), - uuidFileList - ); + uuidFileList); userAcademicRecordApplicationRepository.save(userAcademicRecordApplication); userAcademicRecordLog = UserAcademicRecordLog.createWithApplication( user, userAcademicRecordApplication, - StaticValue.USER_APPLIED + createUserAcademicRecordApplicationRequestDto.getNote() - ); + StaticValue.USER_APPLIED + createUserAcademicRecordApplicationRequestDto.getNote()); } else if (targetAcademicStatus == AcademicStatus.GRADUATED) { // 졸업생의 학적 최초 인증 이벤트 발행 @@ -274,8 +267,7 @@ public UserAcademicRecordApplicationResponseDto createUserAcademicRecordApplicat createUserAcademicRecordApplicationRequestDto.getTargetAcademicStatus(), createUserAcademicRecordApplicationRequestDto.getGraduationYear(), createUserAcademicRecordApplicationRequestDto.getGraduationType(), - StaticValue.USER_APPLIED - ); + StaticValue.USER_APPLIED); } else if (targetAcademicStatus == AcademicStatus.LEAVE_OF_ABSENCE) { // 휴학생의 학적 최초 인증 이벤트 발행 @@ -291,14 +283,12 @@ public UserAcademicRecordApplicationResponseDto createUserAcademicRecordApplicat user, user, createUserAcademicRecordApplicationRequestDto.getTargetAcademicStatus(), - StaticValue.USER_APPLIED - ); + StaticValue.USER_APPLIED); } else { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_TARGET_ACADEMIC_STATUS - ); + MessageUtil.INVALID_TARGET_ACADEMIC_STATUS); } userAcademicRecordLogRepository.save(userAcademicRecordLog); @@ -325,33 +315,32 @@ public CurrentUserAcademicRecordApplicationResponseDto getCurrentUserAcademicRec return toCurrentUserAcademicRecordResponseDto( semester, userAcademicRecordApplication, - userAcademicRecordApplication.getAcademicRecordRequestStatus().equals(AcademicRecordRequestStatus.REJECT) - ); + userAcademicRecordApplication.getAcademicRecordRequestStatus().equals(AcademicRecordRequestStatus.REJECT)); } - /* - FIXME: FE 미사용으로 주석 처리 - - @Transactional - public UserAcademicRecordApplicationResponseDto updateUserAcademicRecordApplication( - User user, - CreateUserAcademicRecordApplicationRequestDto createUserAcademicRecordApplicationRequestDto, - List imageFileList - ) { - // User 엔티티가 영속성 컨텍스트에 없는 경우, merge로 다시 연결 - user = getUser(user.getId()); - - UserAcademicRecordApplication priorUserAcademicRecordApplication = getRecentAwaitOrRejectUserAcademicRecordApplication(user); - - if (!priorUserAcademicRecordApplication.getAcademicRecordRequestStatus().equals(AcademicRecordRequestStatus.REJECT)) { - priorUserAcademicRecordApplication.setAcademicRecordRequestStatus(AcademicRecordRequestStatus.CLOSE); - priorUserAcademicRecordApplication.setRejectMessage(StaticValue.USER_CLOSED); - } - - return createUserAcademicRecordApplication(user, createUserAcademicRecordApplicationRequestDto, imageFileList); - } - - */ + /* + FIXME: FE 미사용으로 주석 처리 + + @Transactional + public UserAcademicRecordApplicationResponseDto updateUserAcademicRecordApplication( + User user, + CreateUserAcademicRecordApplicationRequestDto createUserAcademicRecordApplicationRequestDto, + List imageFileList + ) { + // User 엔티티가 영속성 컨텍스트에 없는 경우, merge로 다시 연결 + user = getUser(user.getId()); + + UserAcademicRecordApplication priorUserAcademicRecordApplication = getRecentAwaitOrRejectUserAcademicRecordApplication(user); + + if (!priorUserAcademicRecordApplication.getAcademicRecordRequestStatus().equals(AcademicRecordRequestStatus.REJECT)) { + priorUserAcademicRecordApplication.setAcademicRecordRequestStatus(AcademicRecordRequestStatus.CLOSE); + priorUserAcademicRecordApplication.setRejectMessage(StaticValue.USER_CLOSED); + } + + return createUserAcademicRecordApplication(user, createUserAcademicRecordApplicationRequestDto, imageFileList); + } + + */ @Transactional protected void closeAwaitUserAcademicRecordApplications(User user) { @@ -373,8 +362,7 @@ protected void closeAwaitUserAcademicRecordApplications(User user) { UserAcademicRecordLog userAcademicRecordLog = UserAcademicRecordLog.createWithApplication( user, academicRecordApplication, - StaticValue.USER_CLOSED - ); + StaticValue.USER_CLOSED); closedApplicationLogList.add(userAcademicRecordLog); }); @@ -390,30 +378,26 @@ private User getUser(String userId) { private UserAcademicRecordInfoResponseDto getUserAcademicRecordInfoResponseDto(User user) { return toUserAcademicRecordInfoResponseDto( user, - getUserAcademicRecordLogList(user) - ); + getUserAcademicRecordLogList(user)); } private List getUserAcademicRecordLogList(User user) { return userAcademicRecordLogRepository.findAllByTargetUserEmailAndTargetUserName( user.getEmail(), - user.getName() - ); + user.getName()); } private UserAcademicRecordApplication getUserAcademicRecordApplication(String applicationId) { return userAcademicRecordApplicationRepository.findById(applicationId) .orElseThrow(() -> new BadRequestException(ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_ACADEMIC_RECORD_APPLICATION_NOT_FOUND - )); + MessageUtil.USER_ACADEMIC_RECORD_APPLICATION_NOT_FOUND)); } private UserAcademicRecordApplication getRecentAwaitOrRejectUserAcademicRecordApplication(User user) { - List awaitUserAcademicRecordApplicationList = - userAcademicRecordApplicationRepository.findAllByAcademicRecordRequestStatusAndUser( + List awaitUserAcademicRecordApplicationList = userAcademicRecordApplicationRepository + .findAllByAcademicRecordRequestStatusAndUser( AcademicRecordRequestStatus.AWAIT, - user - ); + user); UserAcademicRecordApplication userAcademicRecordApplication; @@ -424,11 +408,9 @@ private UserAcademicRecordApplication getRecentAwaitOrRejectUserAcademicRecordAp userAcademicRecordApplication = userAcademicRecordApplicationRepository .findDistinctTopByAcademicRecordRequestStatusAndUserOrderByCreatedAtDesc( AcademicRecordRequestStatus.REJECT, - user - ).orElseThrow(() -> - new BadRequestException(ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_ACADEMIC_RECORD_APPLICATION_NOT_FOUND) - ); + user) + .orElseThrow(() -> new BadRequestException(ErrorCode.ROW_DOES_NOT_EXIST, + MessageUtil.USER_ACADEMIC_RECORD_APPLICATION_NOT_FOUND)); } else { userAcademicRecordApplication = awaitUserAcademicRecordApplicationList.get(0); } @@ -458,13 +440,11 @@ else if (updateUserAcademicStatusRequestDto.getTargetAcademicStatus().equals(Aca private void validCreateUserAcademicRecordApplicationRequestDto( CreateUserAcademicRecordApplicationRequestDto createUserAcademicRecordApplicationRequestDto, - List imageFileList - ) { + List imageFileList) { // 대상 사용자의 변경 타겟 학적 상태가 재학인 경우, 현재 학기가 필수 입력 값이며 1 이상이여야 하고, 이미지 파일이 필수 입력 값 if (createUserAcademicRecordApplicationRequestDto.getTargetAcademicStatus().equals(AcademicStatus.ENROLLED)) { if (createUserAcademicRecordApplicationRequestDto.getTargetCompletedSemester() == null || - createUserAcademicRecordApplicationRequestDto.getTargetCompletedSemester() < 1 - ) { + createUserAcademicRecordApplicationRequestDto.getTargetCompletedSemester() < 1) { throw new BadRequestException(ErrorCode.INVALID_PARAMETER, MessageUtil.TARGET_CURRENT_COMPLETED_SEMESTER_NOT_EXIST); } @@ -497,12 +477,12 @@ private UserAcademicRecordApplicationListResponseDto toUserAcademicRecordApplica private UserAcademicRecordInfoResponseDto toUserAcademicRecordInfoResponseDto(User user, List userAcademicRecordLogList) { - UserAcademicRecordInfoResponseDto responseDto = UserAcademicRecordDtoMapper.INSTANCE.toUserAcademicRecordInfoResponseDto( - user, - userAcademicRecordLogList.stream() - .map(this::toUserAcademicRecordApplicationResponseDto) - .toList() - ); + UserAcademicRecordInfoResponseDto responseDto = UserAcademicRecordDtoMapper.INSTANCE + .toUserAcademicRecordInfoResponseDto( + user, + userAcademicRecordLogList.stream() + .map(this::toUserAcademicRecordApplicationResponseDto) + .toList()); // 따옴표 제거 if (responseDto.getNote() != null) { diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/user/DepartmentResolver.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/user/DepartmentResolver.java index eb1c28c6b..da91f6255 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/user/DepartmentResolver.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/user/DepartmentResolver.java @@ -19,8 +19,7 @@ public class DepartmentResolver { new DepartmentPeriod(Department.SCHOOL_OF_SW, 2018, StaticValue.CAU_AI_START_YEAR - 1), new DepartmentPeriod(Department.SCHOOL_OF_CSE, 2003, 2017), new DepartmentPeriod(Department.DEPT_OF_CSE, 1993, 2002), - new DepartmentPeriod(Department.DEPT_OF_CS, StaticValue.CAU_SW_START_YEAR, 1992) - ); + new DepartmentPeriod(Department.DEPT_OF_CS, StaticValue.CAU_SW_START_YEAR, 1992)); public static Department resolveByAdmissionYearOrDepartmentName(Integer admissionYear, String departmentName) { // AI 학과 개설 이전 입학생은 입학년도로 학과/학부 결정 @@ -41,22 +40,19 @@ public static Department resolveByAdmissionYearOrDepartment(Integer admissionYea if (request == null) { throw new BadRequestException( ErrorCode.INVALID_REQUEST_DEPARTMENT, - MessageUtil.DEPARTMENT_EXPLICITLY_REQUIRED - ); + MessageUtil.DEPARTMENT_EXPLICITLY_REQUIRED); } return request; } public static Department resolveByAdmissionYear(int admissionYear) { return departmentPeriods.stream() - .filter(period -> - admissionYear >= period.startYear() && admissionYear <= period.endYear()) + .filter(period -> admissionYear >= period.startYear() && admissionYear <= period.endYear()) .findFirst() .map(DepartmentPeriod::department) .orElseThrow(() -> new BadRequestException( ErrorCode.INVALID_REQUEST_DEPARTMENT, - MessageUtil.INVALID_ADMISSION_YEAR - )); + MessageUtil.INVALID_ADMISSION_YEAR)); } private record DepartmentPeriod(Department department, Integer startYear, Integer endYear) { diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/user/User.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/user/User.java index 9f04e2a4c..4991ce3fd 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/user/User.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/user/User.java @@ -1,6 +1,6 @@ package net.causw.app.main.domain.user.account.entity.user; -import static net.causw.global.constant.StaticValue.*; +import static net.causw.global.constant.StaticValue.NO_PHONE_NUMBER_MESSAGE; import java.util.HashSet; import java.util.List; @@ -9,12 +9,12 @@ import org.hibernate.annotations.BatchSize; -import net.causw.app.main.domain.asset.file.entity.joinEntity.UserProfileImage; -import net.causw.app.main.domain.community.vote.entity.VoteRecord; import net.causw.app.main.api.dto.user.GraduatedUserCommand; import net.causw.app.main.api.dto.user.UserCreateRequestDto; -import net.causw.app.main.domain.campus.circle.entity.CircleMember; +import net.causw.app.main.domain.asset.file.entity.joinEntity.UserProfileImage; import net.causw.app.main.domain.asset.locker.entity.Locker; +import net.causw.app.main.domain.campus.circle.entity.CircleMember; +import net.causw.app.main.domain.community.vote.entity.VoteRecord; import net.causw.app.main.domain.notification.notification.entity.CeremonyNotificationSetting; import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; import net.causw.app.main.domain.user.account.enums.user.Department; @@ -132,10 +132,7 @@ public class User extends BaseEntity { private Boolean isV2 = true; @ElementCollection(fetch = FetchType.EAGER) - @CollectionTable( - name = "tb_user_fcm_token", - joinColumns = @JoinColumn(name = "user_id") - ) + @CollectionTable(name = "tb_user_fcm_token", joinColumns = @JoinColumn(name = "user_id")) @Column(name = "fcm_token_value") private Set fcmTokens = new HashSet<>(); @@ -159,8 +156,7 @@ public void delete() { public static User from( UserCreateRequestDto userCreateRequestDto, - String encodedPassword - ) { + String encodedPassword) { return User.builder() .email(userCreateRequestDto.getEmail()) .name(userCreateRequestDto.getName()) @@ -174,8 +170,7 @@ public static User from( .department( DepartmentResolver.resolveByAdmissionYearOrDepartment( userCreateRequestDto.getAdmissionYear(), - userCreateRequestDto.getDepartment() - )) + userCreateRequestDto.getDepartment())) .academicStatus(AcademicStatus.UNDETERMINED) .phoneNumber(userCreateRequestDto.getPhoneNumber()) .isV2(true) @@ -184,8 +179,7 @@ public static User from( public static User createGraduate( GraduatedUserCommand graduatedUserCommand, - String encodedPassword - ) { + String encodedPassword) { return User.builder() .email(graduatedUserCommand.email()) .name(graduatedUserCommand.name()) @@ -214,8 +208,7 @@ public void updateProfile(String nickname, UserProfileImage userProfileImage, St public void updateDetails( String email, String name, String phoneNumber, String encodedPassword, String studentId, Integer admissionYear, String nickname, - String major, Department department - ) { + String major, Department department) { this.email = email; this.name = name; this.phoneNumber = phoneNumber; diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/user/UserAdmissionLog.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/user/UserAdmissionLog.java index 9560cb836..5853e7ced 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/user/UserAdmissionLog.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/user/UserAdmissionLog.java @@ -62,8 +62,7 @@ public static UserAdmissionLog of( UserAdmissionLogAction action, List userAdmissionLogAttachImageUuidFileList, String description, - String rejectReason - ) { + String rejectReason) { UserAdmissionLog userAdmissionLog = UserAdmissionLog.builder() .userEmail(userEmail) .userName(userName) @@ -74,7 +73,8 @@ public static UserAdmissionLog of( .rejectReason(rejectReason) .build(); - List userAdmissionLogAttachImageList = userAdmissionLogAttachImageUuidFileList.stream() + List userAdmissionLogAttachImageList = userAdmissionLogAttachImageUuidFileList + .stream() .map(uuidFile -> UserAdmissionLogAttachImage.of(userAdmissionLog, uuidFile)) .toList(); diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/userInfo/SocialLinksConverter.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/userInfo/SocialLinksConverter.java index 33a161fdd..eaf34395d 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/userInfo/SocialLinksConverter.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/userInfo/SocialLinksConverter.java @@ -38,8 +38,7 @@ public List convertToEntityAttribute(String dbData) { } try { - return objectMapper.readValue(dbData, new TypeReference>() { - }); + return objectMapper.readValue(dbData, new TypeReference>() {}); } catch (JsonProcessingException e) { log.error("socialLink-convert-to-attribute-error", e); return new ArrayList<>(); diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/userInfo/UserCareer.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/userInfo/UserCareer.java index a33c86b3d..102b448b2 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/userInfo/UserCareer.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/userInfo/UserCareer.java @@ -45,8 +45,7 @@ public static UserCareer of( UserInfo userInfo, Integer startYear, Integer startMonth, Integer endYear, Integer endMonth, - String description - ) { + String description) { return UserCareer.builder() .userInfo(userInfo) .startYear(startYear) @@ -60,8 +59,7 @@ public static UserCareer of( public void update( Integer startYear, Integer startMonth, Integer endYear, Integer endMonth, - String description - ) { + String description) { this.startYear = startYear; this.startMonth = startMonth; this.endYear = endYear; diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/userInfo/UserInfo.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/userInfo/UserInfo.java index dcfdcfdba..4dc5a45c7 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/userInfo/UserInfo.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/entity/userInfo/UserInfo.java @@ -64,13 +64,11 @@ public void update( String description, String job, List socialLinks, - boolean isPhoneNumberVisible - ) { + boolean isPhoneNumberVisible) { if (socialLinks.size() > 10) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_SOCIAL_LINK - ); + MessageUtil.INVALID_SOCIAL_LINK); } this.description = description; diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/enums/user/Department.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/enums/user/Department.java index d386a541f..de30fb845 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/enums/user/Department.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/enums/user/Department.java @@ -27,7 +27,6 @@ public static Department of(String name) { .findFirst() .orElseThrow(() -> new BadRequestException( ErrorCode.INVALID_REQUEST_DEPARTMENT, - String.format("name '%s' is invalid : not supported", name) - )); + String.format("name '%s' is invalid : not supported", name))); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/enums/user/Role.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/enums/user/Role.java index 965962c2c..2d995718d 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/enums/user/Role.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/enums/user/Role.java @@ -28,8 +28,10 @@ public enum Role { NONE("NONE", "없음"), // Deprecated Roles - @Deprecated LEADER_CIRCLE("LEADER_CIRCLE", "동아리장"), - @Deprecated PROFESSOR("PROFESSOR", "교수"); + @Deprecated + LEADER_CIRCLE("LEADER_CIRCLE", "동아리장"), + @Deprecated + PROFESSOR("PROFESSOR", "교수"); private final String value; private final String description; @@ -41,9 +43,7 @@ public static Role of(String value) { .orElseThrow( () -> new BadRequestException( ErrorCode.INVALID_REQUEST_ROLE, - String.format("'%s' is invalid : not supported", value) - ) - ); + String.format("'%s' is invalid : not supported", value))); } public String authority() { @@ -61,8 +61,7 @@ public static List getPrivilegedRoles() { LEADER_3, LEADER_4, LEADER_ALUMNI, - ALUMNI_MANAGER - ); + ALUMNI_MANAGER); } @Component("Role") diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/enums/user/RoleGroup.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/enums/user/RoleGroup.java index ee14591e3..307cb82ef 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/enums/user/RoleGroup.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/enums/user/RoleGroup.java @@ -13,15 +13,13 @@ public enum RoleGroup { EXECUTIVES(Set.of( // 핵심 집행부 Role.ADMIN, Role.PRESIDENT, - Role.VICE_PRESIDENT - )), + Role.VICE_PRESIDENT)), EXECUTIVES_AND_PROFESSOR(Set.of( // 집행부 + 교수 Role.ADMIN, Role.PRESIDENT, Role.VICE_PRESIDENT, - Role.PROFESSOR - )), + Role.PROFESSOR)), EXECUTIVES_AND_LEADER_ALUMNI(Set.of( // 집행부 + 동문회장 Role.ADMIN, @@ -36,13 +34,11 @@ public enum RoleGroup { Role.ADMIN, Role.PRESIDENT, Role.VICE_PRESIDENT, - Role.LEADER_CIRCLE - )), + Role.LEADER_CIRCLE)), CAN_LEAVE(Set.of( // 탈퇴 가능 권한 Role.COMMON, - Role.PROFESSOR - )), + Role.PROFESSOR)), OPERATIONS_TEAM(Set.of( // 운영진 Role.ADMIN, @@ -55,8 +51,7 @@ public enum RoleGroup { Role.LEADER_3, Role.LEADER_4, Role.LEADER_ALUMNI, - Role.ALUMNI_MANAGER - )); + Role.ALUMNI_MANAGER)); private final Set roles; diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/enums/user/UserState.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/enums/user/UserState.java index d06471dd6..bbc77227b 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/enums/user/UserState.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/enums/user/UserState.java @@ -28,8 +28,6 @@ public static UserState of(String value) { .orElseThrow( () -> new BadRequestException( ErrorCode.INVALID_REQUEST_USER_STATE, - String.format("'%s' is invalid : not supported", value) - ) - ); + String.format("'%s' is invalid : not supported", value))); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/policy/RolePolicy.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/policy/RolePolicy.java index 37167b19c..b48d10daa 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/policy/RolePolicy.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/policy/RolePolicy.java @@ -1,7 +1,20 @@ package net.causw.app.main.domain.user.account.policy; -import static java.util.Map.*; -import static net.causw.app.main.domain.user.account.enums.user.Role.*; +import static java.util.Map.entry; +import static net.causw.app.main.domain.user.account.enums.user.Role.ADMIN; +import static net.causw.app.main.domain.user.account.enums.user.Role.ALUMNI_MANAGER; +import static net.causw.app.main.domain.user.account.enums.user.Role.COMMON; +import static net.causw.app.main.domain.user.account.enums.user.Role.COUNCIL; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_1; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_2; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_3; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_4; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_ALUMNI; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_CIRCLE; +import static net.causw.app.main.domain.user.account.enums.user.Role.NONE; +import static net.causw.app.main.domain.user.account.enums.user.Role.PRESIDENT; +import static net.causw.app.main.domain.user.account.enums.user.Role.PROFESSOR; +import static net.causw.app.main.domain.user.account.enums.user.Role.VICE_PRESIDENT; import java.util.EnumSet; import java.util.Map; @@ -31,8 +44,7 @@ public class RolePolicy { entry(NONE, false), entry(LEADER_CIRCLE, false), - entry(PROFESSOR, false) - ); + entry(PROFESSOR, false)); /** * 권한 우선순위 정책 @@ -54,8 +66,7 @@ public class RolePolicy { entry(NONE, 100), entry(LEADER_CIRCLE, 5), - entry(PROFESSOR, 6) - ); + entry(PROFESSOR, 6)); /** * 권한 설정 가능 대상 정책 (부여 및 위임 공통) @@ -66,8 +77,7 @@ public class RolePolicy { // 부학생회장과 학생회 권한이 같이 삭제되므로 대상이 일반, 학생회장, 부학생회장 권한까지 설정 가능함. PRESIDENT, Set.of(VICE_PRESIDENT, COUNCIL, COMMON), // 일반 권한의 경우 모두 권한에 설정 가능함. - COMMON, EnumSet.allOf(Role.class) - ); + COMMON, EnumSet.allOf(Role.class)); /** * 권한 위임 정책 @@ -91,8 +101,7 @@ public class RolePolicy { LEADER_4, LEADER_ALUMNI, ALUMNI_MANAGER, - COMMON - ), + COMMON), PRESIDENT, Set.of( VICE_PRESIDENT, @@ -103,9 +112,7 @@ public class RolePolicy { LEADER_4, LEADER_ALUMNI, ALUMNI_MANAGER, - COMMON - ) - ); + COMMON)); /** * 대리 위임 정책 @@ -122,8 +129,7 @@ public class RolePolicy { LEADER_3, LEADER_4, LEADER_ALUMNI, - ALUMNI_MANAGER - ), + ALUMNI_MANAGER), PRESIDENT, Set.of( VICE_PRESIDENT, @@ -133,9 +139,7 @@ public class RolePolicy { LEADER_3, LEADER_4, LEADER_ALUMNI, - ALUMNI_MANAGER - ) - ); + ALUMNI_MANAGER)); // --- Getter Methods --- diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/repository/user/UserAdmissionLogRepository.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/repository/user/UserAdmissionLogRepository.java index 958394c24..b20483b95 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/repository/user/UserAdmissionLogRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/repository/user/UserAdmissionLogRepository.java @@ -6,5 +6,4 @@ import net.causw.app.main.domain.user.account.entity.user.UserAdmissionLog; @Repository -public interface UserAdmissionLogRepository extends JpaRepository { -} +public interface UserAdmissionLogRepository extends JpaRepository {} diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/repository/user/UserAdmissionRepository.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/repository/user/UserAdmissionRepository.java index 7a8d149a5..5ae9afd89 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/repository/user/UserAdmissionRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/repository/user/UserAdmissionRepository.java @@ -20,20 +20,23 @@ public interface UserAdmissionRepository extends JpaRepository findAll(@Param("user_state") String userState, Pageable pageable); - - @Query(value = - "SELECT ua.id AS id, ua.user_id,uai.uuid_file_id AS user_admission_attach_image ,ua.description,ua.updated_at,ua.created_at, u.name, u.state " - + - "FROM tb_user_admission AS ua " + - "LEFT JOIN tb_user AS u ON ua.user_id = u.id " + - "LEFT JOIN tb_user_admission_attach_image_uuid_file AS uai ON ua.id = uai.user_admission_id " + - "WHERE u.state = :user_state AND (:name IS NULL OR u.name LIKE %:name%) ORDER BY ua.created_at DESC", nativeQuery = true) - Page findAllWithStateAneName(@Param("user_state") String userState, @Param("name") String name, + Page findAll(@Param("user_state") + String userState, Pageable pageable); + + @Query(value = "SELECT ua.id AS id, ua.user_id,uai.uuid_file_id AS user_admission_attach_image ,ua.description,ua.updated_at,ua.created_at, u.name, u.state " + + + "FROM tb_user_admission AS ua " + + "LEFT JOIN tb_user AS u ON ua.user_id = u.id " + + "LEFT JOIN tb_user_admission_attach_image_uuid_file AS uai ON ua.id = uai.user_admission_id " + + "WHERE u.state = :user_state AND (:name IS NULL OR u.name LIKE %:name%) ORDER BY ua.created_at DESC", nativeQuery = true) + Page findAllWithStateAneName(@Param("user_state") + String userState, @Param("name") + String name, Pageable pageable); @NotNull - Page findAll(@NotNull Pageable pageable); + Page findAll(@NotNull + Pageable pageable); Page findAllByUserName(String name, Pageable pageable); diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/repository/user/UserRepository.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/repository/user/UserRepository.java index a7f5a1151..491025687 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/repository/user/UserRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/repository/user/UserRepository.java @@ -27,7 +27,8 @@ Optional findByEmailAndNameAndStudentIdAndPhoneNumber(String email, String String phoneNumber); @NotNull - Page findAll(@NotNull Pageable pageable); + Page findAll(@NotNull + Pageable pageable); Optional findByEmailAndNameAndStudentId(String email, String name, String studentId); @@ -49,28 +50,36 @@ List findByStudentIdAndStateAndAcademicStatus(String studentId, UserState AcademicStatus academicStatus); @Query("SELECT u FROM User u WHERE :role MEMBER OF u.roles AND u.state = :state") - List findByRoleAndState(@Param("role") Role role, @Param("state") UserState state); + List findByRoleAndState(@Param("role") + Role role, @Param("state") + UserState state); @Query(value = "SELECT * " + "FROM tb_user AS u " + "WHERE u.state = :state AND (:name IS NULL OR u.name LIKE %:name%) ORDER BY u.created_at DESC", nativeQuery = true) - Page findByStateAndName(@Param("state") String state, @Param("name") String name, Pageable pageable); + Page findByStateAndName(@Param("state") + String state, @Param("name") + String name, Pageable pageable); @Query(value = "SELECT * " + "FROM tb_user AS u " + "WHERE u.state IN :state AND (COALESCE(:name, '') = '' OR u.name LIKE CONCAT('%', :name, '%')) ORDER BY u.created_at DESC", nativeQuery = true) - Page findByStateInAndNameContaining(@Param("state") List states, @Param("name") String name, + Page findByStateInAndNameContaining(@Param("state") + List states, @Param("name") + String name, Pageable pageable); @Query(value = "SELECT * FROM" + " tb_user AS u " + "WHERE u.academic_status IN :statuses OR u.academic_status IS NULL", nativeQuery = true) - List findByAcademicStatusInOrAcademicStatusIsNull(@Param("statuses") List statuses); + List findByAcademicStatusInOrAcademicStatusIsNull(@Param("statuses") + List statuses); Optional findByStudentId(String studentId); Optional findByPhoneNumber( - @Pattern(regexp = "^01(?:0|1|[6-9])(\\d{3}|\\d{4})\\d{4}$", message = "전화번호 형식에 맞지 않습니다.") String phoneNumber); + @Pattern(regexp = "^01(?:0|1|[6-9])(\\d{3}|\\d{4})\\d{4}$", message = "전화번호 형식에 맞지 않습니다.") + String phoneNumber); Boolean existsByStudentId(String studentId); diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/repository/userInfo/UserInfoQueryRepositoryImpl.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/repository/userInfo/UserInfoQueryRepositoryImpl.java index 06016e6b4..9c9d94e87 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/repository/userInfo/UserInfoQueryRepositoryImpl.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/repository/userInfo/UserInfoQueryRepositoryImpl.java @@ -7,9 +7,9 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Repository; +import net.causw.app.main.api.dto.userInfo.UserInfoSearchConditionDto; import net.causw.app.main.domain.asset.file.entity.QUuidFile; import net.causw.app.main.domain.asset.file.entity.joinEntity.QUserProfileImage; -import net.causw.app.main.api.dto.userInfo.UserInfoSearchConditionDto; import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; import net.causw.app.main.domain.user.account.entity.user.QUser; import net.causw.app.main.domain.user.account.entity.userInfo.QUserCareer; @@ -73,8 +73,7 @@ public Page searchUserInfo(UserInfoSearchConditionDto userInfoSearchCo */ private BooleanBuilder buildSearchPredicate( UserInfoSearchConditionDto userInfoSearchCondition, - QUserInfo userInfo - ) { + QUserInfo userInfo) { BooleanBuilder predicate = new BooleanBuilder(); String keyword = userInfoSearchCondition.keyword(); @@ -94,9 +93,7 @@ private BooleanBuilder buildSearchPredicate( // 입학 년도 검색 Integer admissionYearStart = userInfoSearchCondition.admissionYearStart(); Integer admissionYearEnd = userInfoSearchCondition.admissionYearEnd(); - if ( - admissionYearStart != null && admissionYearEnd != null - ) { + if (admissionYearStart != null && admissionYearEnd != null) { BooleanBuilder admissionYearPredicate = new BooleanBuilder(); admissionYearPredicate.and(userInfo.user.admissionYear.between(admissionYearStart, admissionYearEnd)); diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/service/FindPrivilegedUsersUseCaseService.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/service/FindPrivilegedUsersUseCaseService.java index 0716784cb..1ac7cd6ad 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/service/FindPrivilegedUsersUseCaseService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/service/FindPrivilegedUsersUseCaseService.java @@ -103,8 +103,7 @@ public UserPrivilegedResponseDto execute(User requestUser) { usersByRole.getOrDefault(Role.LEADER_4, List.of()), usersByRole.getOrDefault(Role.LEADER_CIRCLE, List.of()), usersByRole.getOrDefault(Role.LEADER_ALUMNI, List.of()), - usersByRole.getOrDefault(Role.ALUMNI_MANAGER, List.of()) - ); + usersByRole.getOrDefault(Role.ALUMNI_MANAGER, List.of())); } private void validateRequestUser(User requester) { @@ -122,8 +121,7 @@ private void validateRequestUser(User requester) { */ private void validateCircleLeaderUsersWithOutCircle( List leaderUserIds, - Map> circlesByLeaderId - ) { + Map> circlesByLeaderId) { List leadersWithoutCircle = leaderUserIds.stream() .filter(leaderId -> !circlesByLeaderId.containsKey(leaderId) || circlesByLeaderId.get(leaderId).isEmpty()) .toList(); @@ -131,8 +129,7 @@ private void validateCircleLeaderUsersWithOutCircle( if (!leadersWithoutCircle.isEmpty()) { throw new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.NO_ASSIGNED_CIRCLE_FOR_LEADER - ); + MessageUtil.NO_ASSIGNED_CIRCLE_FOR_LEADER); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/service/GetUserInfoUseCaseService.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/service/GetUserInfoUseCaseService.java index efb9754bb..f03229c9b 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/service/GetUserInfoUseCaseService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/service/GetUserInfoUseCaseService.java @@ -28,8 +28,7 @@ public UserInfoResponseDto execute(String userId) { if (user.getState() != UserState.ACTIVE) { throw new BadRequestException( ErrorCode.INVALID_REQUEST_USER_STATE, - MessageUtil.USER_INFO_NOT_ACCESSIBLE - ); + MessageUtil.USER_INFO_NOT_ACCESSIBLE); } UserInfo userInfo = userInfoService.getUserInfoByUser(user); diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/service/RegisterGraduatedUsersUseCaseService.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/service/RegisterGraduatedUsersUseCaseService.java index bcf3142b8..ef2de7c63 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/service/RegisterGraduatedUsersUseCaseService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/service/RegisterGraduatedUsersUseCaseService.java @@ -80,8 +80,7 @@ private static void validateCsvFileSize(MultipartFile csvFile) { if (csvFile.getSize() > StaticValue.CSV_FILE_SIZE) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - "CSV " + MessageUtil.FILE_SIZE_EXCEEDED - ); + "CSV " + MessageUtil.FILE_SIZE_EXCEEDED); } } @@ -102,32 +101,28 @@ private void validateCsvRecordDuplicates(List records) { if (!email.isEmpty() && !emailSet.add(email)) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - rowLabel + MessageUtil.EMAIL_ALREADY_EXIST - ); + rowLabel + MessageUtil.EMAIL_ALREADY_EXIST); } String phoneNumber = record.get(PHONE_NUMBER_COLUMN).trim(); if (!phoneNumber.isEmpty() && !phoneNumberSet.add(phoneNumber)) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - rowLabel + MessageUtil.PHONE_NUMBER_ALREADY_EXIST - ); + rowLabel + MessageUtil.PHONE_NUMBER_ALREADY_EXIST); } String studentId = record.get(STUDENT_ID_COLUMN).trim(); if (!studentId.isEmpty() && !studentIdSet.add(studentId)) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - rowLabel + MessageUtil.STUDENT_ID_ALREADY_EXIST - ); + rowLabel + MessageUtil.STUDENT_ID_ALREADY_EXIST); } } } private List parse(MultipartFile csvFile) { try (Reader reader = new InputStreamReader(csvFile.getInputStream()); - CSVParser csvParser = CSVParser.parse(reader, CSVFormat.DEFAULT) - ) { + CSVParser csvParser = CSVParser.parse(reader, CSVFormat.DEFAULT)) { return StreamSupport.stream(csvParser.spliterator(), false) .skip(1) // 헤더 제외 .toList(); @@ -135,8 +130,7 @@ private List parse(MultipartFile csvFile) { } catch (IOException e) { throw new InternalServerException( ErrorCode.INTERNAL_SERVER, - "CSV " + MessageUtil.FILE_READ_FAIL - ); + "CSV " + MessageUtil.FILE_READ_FAIL); } } @@ -145,8 +139,7 @@ private GraduatedUserRegisterRequestDto toDto(CSVRecord record) { if (!isPrivacyPolicyAccepted) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.PRIVACY_POLICY_REQUIRED - ); + MessageUtil.PRIVACY_POLICY_REQUIRED); } String name = record.get(NAME_COLUMN).trim(); @@ -156,8 +149,7 @@ private GraduatedUserRegisterRequestDto toDto(CSVRecord record) { Integer graduationYear = Integer.parseInt(record.get(GRADUATION_YEAR_COLUMN).trim()); Department department = DepartmentResolver.resolveByAdmissionYearOrDepartmentName( admissionYear, - record.get(DEPARTMENT_COLUMN).trim() - ); + record.get(DEPARTMENT_COLUMN).trim()); String phoneNumber = record.get(PHONE_NUMBER_COLUMN).trim(); String studentId = record.get(STUDENT_ID_COLUMN).trim(); diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/service/SearchUserInfoListUseCaseService.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/service/SearchUserInfoListUseCaseService.java index d38c884f8..f369bd3e5 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/service/SearchUserInfoListUseCaseService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/service/SearchUserInfoListUseCaseService.java @@ -1,6 +1,6 @@ package net.causw.app.main.domain.user.account.service; -import static net.causw.global.constant.StaticValue.*; +import static net.causw.global.constant.StaticValue.DEFAULT_PAGE_SIZE; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UpdateUserInfoUseCaseService.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UpdateUserInfoUseCaseService.java index 53b864f61..38d3ca480 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UpdateUserInfoUseCaseService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UpdateUserInfoUseCaseService.java @@ -40,8 +40,7 @@ public class UpdateUserInfoUseCaseService { public UserInfoResponseDto execute( String userId, UserInfoUpdateRequestDto request, - MultipartFile profileImage - ) { + MultipartFile profileImage) { User user = userEntityService.findUserByUserId(userId); // 사용자 정보 갱신(전화번호, 프로필 이미지) @@ -86,8 +85,7 @@ private void updateUserCareer(List userCareerDtoList, UserInfo us UserCareer userCareer = userCareerRepository.findById(userCareerDto.getId()) .orElseThrow(() -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_CAREER_NOT_FOUND - )); + MessageUtil.USER_CAREER_NOT_FOUND)); userCareer.update( userCareerDto.getStartYear(), userCareerDto.getStartMonth(), @@ -123,8 +121,7 @@ private void validateUserCareerDate(UserCareerDto userCareerDto) { if (isInvalidStartMonth || isInvalidStartYear) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_CAREER_DATE - ); + MessageUtil.INVALID_CAREER_DATE); } // 종료일이 있는 경우에만 검증 (null은 현재 재직 중으로 판단) @@ -136,8 +133,7 @@ private void validateUserCareerDate(UserCareerDto userCareerDto) { if (isInvalidEndMonth || isInvalidEndYear || isEndBeforeStart) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.INVALID_CAREER_DATE - ); + MessageUtil.INVALID_CAREER_DATE); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UserEntityService.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UserEntityService.java index b0acbc4a1..006baa1b1 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UserEntityService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UserEntityService.java @@ -34,7 +34,6 @@ public User findUserByUserId(String userId) { return userRepository.findById(userId) .orElseThrow(() -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - )); + MessageUtil.USER_NOT_FOUND)); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UserInfoService.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UserInfoService.java index 2935973e5..271d5a3ca 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UserInfoService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UserInfoService.java @@ -29,10 +29,8 @@ public class UserInfoService { public UserInfo getUserInfoByUser(User user) { return userInfoRepository.findByUserId(user.getId()) .orElseThrow(() -> new NotFoundException( - ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - ) - ); + ErrorCode.ROW_DOES_NOT_EXIST, + MessageUtil.USER_NOT_FOUND)); } public Page searchUserInfo(Pageable pageable, UserInfoSearchConditionDto userInfoSearchCondition) { diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UserRoleService.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UserRoleService.java index cbe1bfd0b..69fca7140 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UserRoleService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UserRoleService.java @@ -11,13 +11,13 @@ import net.causw.app.main.api.dto.user.UserResponseDto; import net.causw.app.main.api.dto.user.UserUpdateRoleRequestDto; import net.causw.app.main.api.dto.util.dtoMapper.UserDtoMapper; -import net.causw.app.main.domain.user.account.policy.RolePolicy; -import net.causw.app.main.domain.user.account.util.DelegatableRoleValidator; -import net.causw.app.main.domain.user.account.util.GrantableRoleValidator; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.domain.user.account.enums.user.UserState; +import net.causw.app.main.domain.user.account.policy.RolePolicy; import net.causw.app.main.domain.user.account.repository.user.UserRepository; +import net.causw.app.main.domain.user.account.util.DelegatableRoleValidator; +import net.causw.app.main.domain.user.account.util.GrantableRoleValidator; import net.causw.global.constant.MessageUtil; import net.causw.global.exception.BadRequestException; import net.causw.global.exception.ErrorCode; @@ -41,15 +41,12 @@ public class UserRoleService { public UserResponseDto delegateRole( User delegator, String delegateeId, - UserUpdateRoleRequestDto userUpdateRoleRequestDto - ) { + UserUpdateRoleRequestDto userUpdateRoleRequestDto) { // 피위임자의 Id로 피위임자 조회 User delegatee = userRepository.findById(delegateeId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - ) - ); + MessageUtil.USER_NOT_FOUND)); // 권한을 모두 조회 Set delegatorRoles = delegator.getRoles(); @@ -60,8 +57,7 @@ public UserResponseDto delegateRole( DelegatableRoleValidator.of( delegatorRoles, delegatedRole, - delegateeRoles - ).validate(); + delegateeRoles).validate(); // 학생회장 권한 위임 시 부학생 및 학생회 권한 삭제 if (delegatedRole.equals(Role.PRESIDENT)) { @@ -98,23 +94,18 @@ public UserResponseDto grantRole( User grantor, // 부여자 String delegatorId, // 위임자 String granteeId, // 수혜자 - UserUpdateRoleRequestDto userUpdateRoleRequestDto - ) { + UserUpdateRoleRequestDto userUpdateRoleRequestDto) { // 위임자의 Id로 위임자 조회 User delegator = StringUtils.isBlank(delegatorId) ? null : userRepository.findById(delegatorId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - ) - ); + MessageUtil.USER_NOT_FOUND)); // 수혜자의 Id로 수혜자 조회 User grantee = userRepository.findById(granteeId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - ) - ); + MessageUtil.USER_NOT_FOUND)); // 권한을 모두 조회 Role grantedRole = userUpdateRoleRequestDto.getRole(); @@ -124,8 +115,7 @@ public UserResponseDto grantRole( grantor.getRoles(), delegator, grantedRole, - grantee - ).validate(); + grantee).validate(); // 학생회장 권한 부여 시 부학생 및 학생회 권한 삭제 if (grantedRole.equals(Role.PRESIDENT)) { diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UserService.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UserService.java index ffe12a95e..6846750f3 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UserService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/service/UserService.java @@ -24,24 +24,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import net.causw.app.main.core.aop.annotation.MeasureTime; -import net.causw.app.main.core.security.JwtTokenProvider; -import net.causw.app.main.domain.asset.file.entity.UuidFile; -import net.causw.app.main.domain.asset.file.entity.joinEntity.UserAcademicRecordApplicationAttachImage; -import net.causw.app.main.domain.asset.file.entity.joinEntity.UserAdmissionAttachImage; -import net.causw.app.main.domain.asset.file.entity.joinEntity.UserProfileImage; -import net.causw.app.main.domain.community.board.entity.Board; -import net.causw.app.main.domain.community.board.repository.BoardRepository; -import net.causw.app.main.domain.community.comment.repository.ChildCommentRepository; -import net.causw.app.main.domain.community.comment.repository.CommentRepository; -import net.causw.app.main.domain.community.reaction.entity.FavoritePost; -import net.causw.app.main.domain.community.reaction.entity.LikePost; -import net.causw.app.main.domain.community.post.entity.Post; -import net.causw.app.main.domain.community.reaction.repository.FavoritePostRepository; -import net.causw.app.main.domain.community.reaction.repository.LikePostRepository; -import net.causw.app.main.domain.community.post.repository.PostRepository; -import net.causw.app.main.domain.community.post.service.PostService; -import net.causw.app.main.domain.integration.export.service.UserExcelService; import net.causw.app.main.api.dto.board.BoardResponseDto; import net.causw.app.main.api.dto.circle.CircleResponseDto; import net.causw.app.main.api.dto.duplicate.DuplicatedCheckResponseDto; @@ -69,22 +51,38 @@ import net.causw.app.main.api.dto.util.dtoMapper.CircleDtoMapper; import net.causw.app.main.api.dto.util.dtoMapper.PostDtoMapper; import net.causw.app.main.api.dto.util.dtoMapper.UserDtoMapper; +import net.causw.app.main.core.aop.annotation.MeasureTime; +import net.causw.app.main.core.security.JwtTokenProvider; +import net.causw.app.main.domain.asset.file.entity.UuidFile; +import net.causw.app.main.domain.asset.file.entity.joinEntity.UserAcademicRecordApplicationAttachImage; +import net.causw.app.main.domain.asset.file.entity.joinEntity.UserAdmissionAttachImage; +import net.causw.app.main.domain.asset.file.entity.joinEntity.UserProfileImage; +import net.causw.app.main.domain.asset.file.enums.FilePath; +import net.causw.app.main.domain.asset.file.repository.UserAcademicRecordApplicationAttachImageRepository; +import net.causw.app.main.domain.asset.file.repository.UserProfileImageRepository; +import net.causw.app.main.domain.asset.file.service.UuidFileService; +import net.causw.app.main.domain.asset.locker.entity.LockerLog; +import net.causw.app.main.domain.asset.locker.enums.LockerLogAction; +import net.causw.app.main.domain.asset.locker.repository.LockerLogRepository; +import net.causw.app.main.domain.asset.locker.repository.LockerRepository; import net.causw.app.main.domain.campus.circle.entity.Circle; import net.causw.app.main.domain.campus.circle.entity.CircleMember; -import net.causw.app.main.domain.asset.locker.entity.LockerLog; import net.causw.app.main.domain.campus.circle.enums.CircleMemberStatus; -import net.causw.app.main.domain.asset.locker.enums.LockerLogAction; -import net.causw.app.main.domain.asset.file.enums.FilePath; -import net.causw.app.main.shared.StatusPolicy; import net.causw.app.main.domain.campus.circle.repository.CircleMemberRepository; import net.causw.app.main.domain.campus.circle.repository.CircleRepository; import net.causw.app.main.domain.campus.circle.repository.query.CircleQueryRepository; -import net.causw.app.main.domain.asset.locker.repository.LockerLogRepository; -import net.causw.app.main.domain.asset.locker.repository.LockerRepository; -import net.causw.app.main.domain.asset.file.repository.UserAcademicRecordApplicationAttachImageRepository; -import net.causw.app.main.domain.asset.file.repository.UserProfileImageRepository; -import net.causw.app.main.domain.asset.file.service.UuidFileService; -import net.causw.app.main.shared.util.ConstraintValidator; +import net.causw.app.main.domain.community.board.entity.Board; +import net.causw.app.main.domain.community.board.repository.BoardRepository; +import net.causw.app.main.domain.community.comment.repository.ChildCommentRepository; +import net.causw.app.main.domain.community.comment.repository.CommentRepository; +import net.causw.app.main.domain.community.post.entity.Post; +import net.causw.app.main.domain.community.post.repository.PostRepository; +import net.causw.app.main.domain.community.post.service.PostService; +import net.causw.app.main.domain.community.reaction.entity.FavoritePost; +import net.causw.app.main.domain.community.reaction.entity.LikePost; +import net.causw.app.main.domain.community.reaction.repository.FavoritePostRepository; +import net.causw.app.main.domain.community.reaction.repository.LikePostRepository; +import net.causw.app.main.domain.integration.export.service.UserExcelService; import net.causw.app.main.domain.user.academic.entity.userAcademicRecord.UserAcademicRecordApplication; import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; import net.causw.app.main.domain.user.academic.event.CertifiedUserCreatedEvent; @@ -111,11 +109,13 @@ import net.causw.app.main.domain.user.account.util.UserStateIsNotDropAndActiveValidator; import net.causw.app.main.domain.user.account.util.UserStateValidator; import net.causw.app.main.domain.user.relation.service.UserBlockEntityService; +import net.causw.app.main.shared.StatusPolicy; import net.causw.app.main.shared.ValidatorBucket; import net.causw.app.main.shared.infra.firebase.FcmUtils; import net.causw.app.main.shared.infra.mail.GoogleMailSender; import net.causw.app.main.shared.infra.redis.RedisUtils; import net.causw.app.main.shared.pageable.PageableFactory; +import net.causw.app.main.shared.util.ConstraintValidator; import net.causw.global.constant.MessageUtil; import net.causw.global.constant.StaticValue; import net.causw.global.exception.BadRequestException; @@ -175,13 +175,11 @@ public class UserService { @Transactional public void findPassword( - UserFindPasswordRequestDto userFindPasswordRequestDto - ) { + UserFindPasswordRequestDto userFindPasswordRequestDto) { User requestUser = userRepository.findByEmailAndName( userFindPasswordRequestDto.getEmail().trim(), - userFindPasswordRequestDto.getName().trim() - ).orElseThrow(() -> - new NotFoundException(ErrorCode.ROW_DOES_NOT_EXIST, MessageUtil.USER_NOT_FOUND)); + userFindPasswordRequestDto.getName().trim()) + .orElseThrow(() -> new NotFoundException(ErrorCode.ROW_DOES_NOT_EXIST, MessageUtil.USER_NOT_FOUND)); if (!requestUser.getPhoneNumber().equals(userFindPasswordRequestDto.getPhoneNumber())) { throw new NotFoundException(ErrorCode.ROW_DOES_NOT_EXIST, MessageUtil.USER_NOT_FOUND); @@ -215,16 +213,14 @@ public UserResponseDto findByUserId(String targetUserId, User requestUser) { if (ownCircles.isEmpty()) { throw new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.NO_ASSIGNED_CIRCLE_FOR_LEADER - ); + MessageUtil.NO_ASSIGNED_CIRCLE_FOR_LEADER); } boolean isMemberOfAnyCircle = ownCircles.stream() - .anyMatch(circleEntity -> - this.circleMemberRepository.findByUser_IdAndCircle_Id(targetUserId, circleEntity.getId()) - .map(circleMemberEntity -> circleMemberEntity.getStatus() == CircleMemberStatus.MEMBER) - .orElse(false) - ); + .anyMatch(circleEntity -> this.circleMemberRepository + .findByUser_IdAndCircle_Id(targetUserId, circleEntity.getId()) + .map(circleMemberEntity -> circleMemberEntity.getStatus() == CircleMemberStatus.MEMBER) + .orElse(false)); if (!isMemberOfAnyCircle) { throw new BadRequestException(ErrorCode.NOT_MEMBER, MessageUtil.CIRCLE_MEMBER_NOT_FOUND); @@ -232,11 +228,9 @@ public UserResponseDto findByUserId(String targetUserId, User requestUser) { } User entity = this.userRepository.findById(targetUserId) - .orElseThrow(() -> - new BadRequestException( - ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - )); + .orElseThrow(() -> new BadRequestException( + ErrorCode.ROW_DOES_NOT_EXIST, + MessageUtil.USER_NOT_FOUND)); return UserDtoMapper.INSTANCE.toUserResponseDto(entity, null, null); } @@ -253,15 +247,13 @@ public UserResponseDto findCurrentUser(User requestUser) { if (ownCircles.isEmpty()) { throw new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.NO_ASSIGNED_CIRCLE_FOR_LEADER - ); + MessageUtil.NO_ASSIGNED_CIRCLE_FOR_LEADER); } return UserDtoMapper.INSTANCE.toUserResponseDto( requestUser, ownCircles.stream().map(Circle::getId).collect(Collectors.toList()), - ownCircles.stream().map(Circle::getName).collect(Collectors.toList()) - ); + ownCircles.stream().map(Circle::getName).collect(Collectors.toList())); } return UserDtoMapper.INSTANCE.toUserResponseDto(requestUser, null, null); } @@ -278,17 +270,15 @@ public UserPostsResponseDto findPosts(User requestUser, Integer pageNum) { return UserDtoMapper.INSTANCE.toUserPostsResponseDto( requestUser, this.postRepository.findByUserId(requestUser.getId(), - this.pageableFactory.create(pageNum, StaticValue.DEFAULT_POST_PAGE_SIZE) - ).map(post -> PostDtoMapper.INSTANCE.toPostsResponseDto( - post, - getNumOfComment(post), - getNumOfPostLikes(post), - getNumOfPostFavorites(post), - !post.getPostAttachImageList().isEmpty() ? post.getPostAttachImageList().get(0) : null, - StatusPolicy.isPostVote(post), - StatusPolicy.isPostForm(post) - )) - ); + this.pageableFactory.create(pageNum, StaticValue.DEFAULT_POST_PAGE_SIZE)) + .map(post -> PostDtoMapper.INSTANCE.toPostsResponseDto( + post, + getNumOfComment(post), + getNumOfPostLikes(post), + getNumOfPostFavorites(post), + !post.getPostAttachImageList().isEmpty() ? post.getPostAttachImageList().get(0) : null, + StatusPolicy.isPostVote(post), + StatusPolicy.isPostForm(post)))); } @Transactional(readOnly = true) @@ -318,15 +308,13 @@ public UserPostsResponseDto findFavoritePosts(User requestUser, Integer pageNum) getNumOfPostFavorites(post), !post.getPostAttachImageList().isEmpty() ? post.getPostAttachImageList().get(0) : null, StatusPolicy.isPostVote(post), - StatusPolicy.isPostForm(post) - ); + StatusPolicy.isPostForm(post)); // 화면에 표시될 작성자 닉네임 설정 String displayNickname = postService.getDisplayWriterNickname( post.getWriter(), post.getIsAnonymous(), - post.getWriter() != null ? post.getWriter().getNickname() : null - ); + post.getWriter() != null ? post.getWriter().getNickname() : null); dto.setDisplayWriterNickname(displayNickname); if (dto.getIsAnonymous()) { @@ -334,8 +322,7 @@ public UserPostsResponseDto findFavoritePosts(User requestUser, Integer pageNum) } return dto; - }) - ); + })); } /** @@ -370,20 +357,17 @@ public UserPostsResponseDto findLikePosts(User requestUser, Integer pageNum) { getNumOfPostFavorites(post), !post.getPostAttachImageList().isEmpty() ? post.getPostAttachImageList().get(0) : null, StatusPolicy.isPostVote(post), - StatusPolicy.isPostForm(post) - ); + StatusPolicy.isPostForm(post)); // 화면에 표시될 작성자 닉네임 설정 String displayNickname = postService.getDisplayWriterNickname( post.getWriter(), post.getIsAnonymous(), - post.getWriter() != null ? post.getWriter().getNickname() : null - ); + post.getWriter() != null ? post.getWriter().getNickname() : null); dto.setDisplayWriterNickname(displayNickname); return dto; - }) - ); + })); } @Transactional(readOnly = true) @@ -425,20 +409,17 @@ public UserPostsResponseDto findCommentedPosts(User requestUser, Integer pageNum getNumOfPostFavorites(post), !post.getPostAttachImageList().isEmpty() ? post.getPostAttachImageList().get(0) : null, StatusPolicy.isPostVote(post), - StatusPolicy.isPostForm(post) - ); + StatusPolicy.isPostForm(post)); // 화면에 표시될 작성자 닉네임 설정 String displayNickname = postService.getDisplayWriterNickname( post.getWriter(), post.getIsAnonymous(), - post.getWriter() != null ? post.getWriter().getNickname() : null - ); + post.getWriter() != null ? post.getWriter().getNickname() : null); dto.setDisplayWriterNickname(displayNickname); return dto; - }) - ); + })); } @Transactional(readOnly = true) @@ -453,13 +434,12 @@ public UserCommentsResponseDto findComments(User requestUser, Integer pageNum) { return UserDtoMapper.INSTANCE.toUserCommentsResponseDto( requestUser, this.commentRepository.findByUserId(requestUser.getId(), - this.pageableFactory.create(pageNum, StaticValue.DEFAULT_COMMENT_PAGE_SIZE)) + this.pageableFactory.create(pageNum, StaticValue.DEFAULT_COMMENT_PAGE_SIZE)) .map(comment -> { Post post = this.postRepository.findById(comment.getPost().getId()) .orElseThrow(() -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.POST_NOT_FOUND - )); + MessageUtil.POST_NOT_FOUND)); return UserDtoMapper.INSTANCE.toCommentsOfUserResponseDto( comment, post.getBoard().getId(), @@ -467,10 +447,8 @@ public UserCommentsResponseDto findComments(User requestUser, Integer pageNum) { post.getId(), post.getTitle(), post.getBoard().getCircle() != null ? post.getBoard().getCircle().getId() : null, - post.getBoard().getCircle() != null ? post.getBoard().getCircle().getName() : null - ); - }) - ); + post.getBoard().getCircle() != null ? post.getBoard().getCircle().getName() : null); + })); } @Transactional(readOnly = true) @@ -481,8 +459,7 @@ public List findByName(User requestUser, String name) { .consistOf(UserStateValidator.of(requestUser.getState())) .consistOf(UserRoleIsNoneValidator.of(roles)) .consistOf(UserRoleValidator.of(roles, - Set.of(Role.LEADER_CIRCLE - ))) + Set.of(Role.LEADER_CIRCLE))) .validate(); if (roles.contains(Role.LEADER_CIRCLE)) { @@ -490,19 +467,17 @@ public List findByName(User requestUser, String name) { if (ownCircles.isEmpty()) { throw new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.NO_ASSIGNED_CIRCLE_FOR_LEADER - ); + MessageUtil.NO_ASSIGNED_CIRCLE_FOR_LEADER); } return this.userRepository.findByName(name) .stream() .filter(user -> user.getState().equals(UserState.ACTIVE)) - .filter(user -> - ownCircles.stream() - .anyMatch(circle -> - this.circleMemberRepository.findByUser_IdAndCircle_Id(user.getId(), circle.getId()) - .map(circleMemberEntity -> circleMemberEntity.getStatus() == CircleMemberStatus.MEMBER) - .orElse(false))) + .filter(user -> ownCircles.stream() + .anyMatch( + circle -> this.circleMemberRepository.findByUser_IdAndCircle_Id(user.getId(), circle.getId()) + .map(circleMemberEntity -> circleMemberEntity.getStatus() == CircleMemberStatus.MEMBER) + .orElse(false))) .map(user -> UserDtoMapper.INSTANCE.toUserResponseDto( user, ownCircles.stream().map(Circle::getId).collect(Collectors.toList()), @@ -522,8 +497,7 @@ public Page findByState( User user, String state, String name, - Integer pageNum - ) { + Integer pageNum) { Set roles = user.getRoles(); ValidatorBucket.of() @@ -539,14 +513,12 @@ public Page findByState( usersPage = userRepository.findByStateInAndNameContaining( statesToSearch, name, - PageRequest.of(pageNum, StaticValue.USER_LIST_PAGE_SIZE) - ); + PageRequest.of(pageNum, StaticValue.USER_LIST_PAGE_SIZE)); } else { usersPage = userRepository.findByStateAndName( state, name, - PageRequest.of(pageNum, StaticValue.USER_LIST_PAGE_SIZE) - ); + PageRequest.of(pageNum, StaticValue.USER_LIST_PAGE_SIZE)); } return usersPage.map(srcUser -> { @@ -560,8 +532,7 @@ public Page findByState( return UserDtoMapper.INSTANCE.toUserResponseDto( srcUser, ownCircles.stream().map(Circle::getId).collect(Collectors.toList()), - ownCircles.stream().map(Circle::getName).collect(Collectors.toList()) - ); + ownCircles.stream().map(Circle::getName).collect(Collectors.toList())); } else { return UserDtoMapper.INSTANCE.toUserResponseDto(srcUser, null, null); } @@ -621,8 +592,7 @@ public UserResponseDto signUp(UserCreateRequestDto dto) { dto.getAdmissionYear(), dto.getNickname(), dto.getMajor(), - dto.getDepartment() - ); + dto.getDepartment()); user.markAsAwait(); validateUser(dto, user); userRepository.save(user); @@ -666,8 +636,7 @@ else if (state == UserState.ACTIVE) { dto.getAdmissionYear(), dto.getNickname(), dto.getMajor(), - dto.getDepartment() - ); + dto.getDepartment()); ghostuser.markAsAwait(); validateUser(dto, ghostuser); userRepository.save(ghostuser); @@ -723,8 +692,7 @@ public void registerGraduatedUser(GraduatedUserRegisterRequestDto dto) { dto.admissionYear(), dto.nickname(), null, - dto.department() - ); + dto.department()); user.markAsCertifiedGraduate(dto.graduationYear()); return user; @@ -735,8 +703,7 @@ public void registerGraduatedUser(GraduatedUserRegisterRequestDto dto) { } else { // 이미 인증된 계정이 존재하는 경우 throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.USER_ALREADY_REGISTERD - ); + MessageUtil.USER_ALREADY_REGISTERD); } }) .orElseGet(() -> { @@ -763,9 +730,7 @@ public UserSignInResponseDto signIn(UserSignInRequestDto userSignInRequestDto) { User user = userRepository.findByEmail(userSignInRequestDto.getEmail()).orElseThrow( () -> new UnauthorizedException( ErrorCode.INVALID_SIGNIN, - MessageUtil.EMAIL_INVALID - ) - ); + MessageUtil.EMAIL_INVALID)); /* Validate the input password and user state * The sign-in process is rejected if the user is in BLOCKED, WAIT, or INACTIVE state. @@ -787,8 +752,7 @@ public UserSignInResponseDto signIn(UserSignInRequestDto userSignInRequestDto) { return UserDtoMapper.INSTANCE.toUserSignInResponseDto( jwtTokenProvider.createAccessToken(user.getId(), user.getRoles(), user.getState()), - refreshToken - ); + refreshToken); } /** @@ -810,8 +774,7 @@ public DuplicatedCheckResponseDto isDuplicatedEmail(String email) { else if (state == UserState.DROP) { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.USER_DROPPED_CONTACT_EMAIL - ); + MessageUtil.USER_DROPPED_CONTACT_EMAIL); } } return UserDtoMapper.INSTANCE.toDuplicatedCheckResponseDto(false); @@ -838,8 +801,7 @@ public DuplicatedCheckResponseDto isDuplicatedNickname(String nickname) { else if (state == UserState.DROP) { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.USER_DROPPED_CONTACT_EMAIL - ); + MessageUtil.USER_DROPPED_CONTACT_EMAIL); } } return UserDtoMapper.INSTANCE.toDuplicatedCheckResponseDto(false); @@ -858,8 +820,7 @@ public DuplicatedCheckResponseDto isDuplicatedStudentId(String studentId) { else if (state == UserState.DROP) { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.USER_DROPPED_CONTACT_EMAIL - ); + MessageUtil.USER_DROPPED_CONTACT_EMAIL); } } return UserDtoMapper.INSTANCE.toDuplicatedCheckResponseDto(false); @@ -884,8 +845,7 @@ public DuplicatedCheckResponseDto isDuplicatedPhoneNumber(String phoneNumber) { else if (state == UserState.DROP) { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.USER_DROPPED_CONTACT_EMAIL - ); + MessageUtil.USER_DROPPED_CONTACT_EMAIL); } } return UserDtoMapper.INSTANCE.toDuplicatedCheckResponseDto(false); @@ -896,21 +856,17 @@ public UserResponseDto update(User user, UserUpdateRequestDto userUpdateRequestD User srcUser = userRepository.findById(user.getId()).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - ) - ); + MessageUtil.USER_NOT_FOUND)); // 닉네임이 변경되었을 때 중복 체크 if (srcUser.getNickname() == null - || !srcUser.getNickname().equals(userUpdateRequestDto.getNickname()) - ) { + || !srcUser.getNickname().equals(userUpdateRequestDto.getNickname())) { validateNicknameUniqueness(userUpdateRequestDto.getNickname(), srcUser); } // 전화번호가 변경되었을 때 중복 체크 if (srcUser.getPhoneNumber() == null - || !srcUser.getPhoneNumber().equals(userUpdateRequestDto.getPhoneNumber()) - ) { + || !srcUser.getPhoneNumber().equals(userUpdateRequestDto.getPhoneNumber())) { validatePhoneNumberUniqueness(userUpdateRequestDto.getPhoneNumber(), srcUser); } @@ -920,16 +876,13 @@ public UserResponseDto update(User user, UserUpdateRequestDto userUpdateRequestD if (srcUser.getUserProfileImage() == null) { userProfileImage = UserProfileImage.of( user, - uuidFileService.saveFile(profileImage, FilePath.USER_PROFILE) - ); + uuidFileService.saveFile(profileImage, FilePath.USER_PROFILE)); } else { userProfileImage.setUuidFile( uuidFileService.updateFile( srcUser.getUserProfileImage().getUuidFile(), profileImage, - FilePath.USER_PROFILE - ) - ); + FilePath.USER_PROFILE)); } } @@ -945,8 +898,7 @@ public UserResponseDto update(User user, UserUpdateRequestDto userUpdateRequestD @Transactional public UserResponseDto updatePassword( User user, - UserUpdatePasswordRequestDto userUpdatePasswordRequestDto - ) { + UserUpdatePasswordRequestDto userUpdatePasswordRequestDto) { Set roles = user.getRoles(); ValidatorBucket.of() @@ -955,8 +907,7 @@ public UserResponseDto updatePassword( .consistOf(PasswordCorrectValidator.of( this.passwordEncoder, user.getPassword(), - userUpdatePasswordRequestDto.getOriginPassword()) - ) + userUpdatePasswordRequestDto.getOriginPassword())) .consistOf(PasswordFormatValidator.of(userUpdatePasswordRequestDto.getUpdatedPassword())) .validate(); @@ -993,8 +944,7 @@ public UserResponseDto eraseUserData(User requestuser, String userId) { deleteUser.getEmail(), deleteUser.getName(), LockerLogAction.RETURN, - "사용자 탈퇴" - ); + "사용자 탈퇴"); this.lockerLogRepository.save(lockerLog); @@ -1002,13 +952,12 @@ public UserResponseDto eraseUserData(User requestuser, String userId) { // 가입된 동아리가 있다면 탈퇴 this.circleMemberRepository.findByUser_Id(deleteUser.getId()) - .forEach(circleMember -> - this.updateStatus(circleMember.getId(), CircleMemberStatus.LEAVE) - ); + .forEach(circleMember -> this.updateStatus(circleMember.getId(), CircleMemberStatus.LEAVE)); // FIXME: 영구삭제 시 UuidFile, User FK 제약 조건 위반 발생 - List userAcademicRecordApplicationList = userAcademicRecordApplicationRepository.findByUserId( - deleteUser.getId()); + List userAcademicRecordApplicationList = userAcademicRecordApplicationRepository + .findByUserId( + deleteUser.getId()); if (!userAcademicRecordApplicationList.isEmpty()) { // 재학 인증 신청 이미지 파일이 있다면 삭제 @@ -1016,10 +965,11 @@ public UserResponseDto eraseUserData(User requestuser, String userId) { userAcademicRecordApplicationList .stream() .flatMap( - userAcademicRecordApplication -> userAcademicRecordApplication.getUserAcademicRecordAttachImageList() + userAcademicRecordApplication -> userAcademicRecordApplication + .getUserAcademicRecordAttachImageList() .stream() - .map(UserAcademicRecordApplicationAttachImage::getUuidFile)).toList() - ); + .map(UserAcademicRecordApplicationAttachImage::getUuidFile)) + .toList()); // 재학 인증 신청 기록이 있다면 삭제 userAcademicRecordApplicationRepository.deleteAll(userAcademicRecordApplicationList); @@ -1050,8 +1000,7 @@ public UserResponseDto leave(User user) { user.getEmail(), user.getName(), LockerLogAction.RETURN, - "사용자 탈퇴" - ); + "사용자 탈퇴"); this.lockerLogRepository.save(lockerLog); @@ -1062,15 +1011,12 @@ public UserResponseDto leave(User user) { // Leave from circle where user joined this.circleMemberRepository.findByUser_Id(user.getId()) - .forEach(circleMember -> - this.updateStatus(circleMember.getId(), CircleMemberStatus.LEAVE) - ); + .forEach(circleMember -> this.updateStatus(circleMember.getId(), CircleMemberStatus.LEAVE)); User entity = this.updateState(user.getId(), UserState.INACTIVE) .orElseThrow(() -> new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.INTERNAL_SERVER_ERROR - )); + MessageUtil.INTERNAL_SERVER_ERROR)); return UserDtoMapper.INSTANCE.toUserResponseDto(entity, null, null); } @@ -1091,8 +1037,7 @@ private Optional updateStatus(String applicationId, CircleMemberSt circleMember -> { circleMember.setStatus(targetStatus); return this.circleMemberRepository.save(circleMember); - } - ); + }); } private Optional updateState(String id, UserState state) { @@ -1102,8 +1047,7 @@ private Optional updateState(String id, UserState state) { this.userRepository.save(srcUser); return srcUser; - } - ); + }); } @Transactional @@ -1113,9 +1057,7 @@ public UserResponseDto dropUser(User requestUser, String userId, String dropReas User droppedUser = this.userRepository.findById(userId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - ) - ); + MessageUtil.USER_NOT_FOUND)); String droppedUserEmail = droppedUser.getEmail(); String droppedUserName = droppedUser.getName(); @@ -1138,8 +1080,7 @@ public UserResponseDto dropUser(User requestUser, String userId, String dropReas droppedUserEmail, droppedUserName, LockerLogAction.RETURN, - "사용자 추방" - ); + "사용자 추방"); this.lockerLogRepository.save(lockerLog); }); @@ -1150,8 +1091,7 @@ public UserResponseDto dropUser(User requestUser, String userId, String dropReas droppedUser = this.updateState(userId, UserState.DROP) .orElseThrow(() -> new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.INTERNAL_SERVER_ERROR - )); + MessageUtil.INTERNAL_SERVER_ERROR)); userRepository.save(droppedUser); @@ -1258,17 +1198,14 @@ public UserAdmissionResponseDto findAdmissionById(User requestUser, String admis this.userAdmissionRepository.findById(admissionId) .orElseThrow(() -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_APPLY_NOT_FOUND - )) - ); + MessageUtil.USER_APPLY_NOT_FOUND))); } @Transactional(readOnly = true) public Page findAllAdmissions( User requestUser, String name, - Integer pageNum - ) { + Integer pageNum) { Set roles = requestUser.getRoles(); ValidatorBucket.of() @@ -1282,7 +1219,7 @@ public Page findAllAdmissions( .map(UserDtoMapper.INSTANCE::toUserAdmissionsResponseDto); } else { return this.userAdmissionRepository.findAllByUserName(name, - this.pageableFactory.create(pageNum, StaticValue.DEFAULT_PAGE_SIZE)) + this.pageableFactory.create(pageNum, StaticValue.DEFAULT_PAGE_SIZE)) .map(UserDtoMapper.INSTANCE::toUserAdmissionsResponseDto); } } @@ -1293,29 +1230,25 @@ public UserAdmissionResponseDto createAdmission(User user, if (!user.getEmail().equals(userAdmissionCreateRequestDto.getEmail())) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.EMAIL_INVALID - ); + MessageUtil.EMAIL_INVALID); } if (this.userAdmissionRepository.existsByUser_Id(user.getId())) { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.USER_ALREADY_APPLY - ); + MessageUtil.USER_ALREADY_APPLY); } if (!(user.getState().equals(UserState.AWAIT) || user.getState().equals(UserState.REJECT))) { throw new BadRequestException( ErrorCode.INVALID_REQUEST_USER_STATE, - MessageUtil.INVALID_USER_APPLICATION_USER_STATE - ); + MessageUtil.INVALID_USER_APPLICATION_USER_STATE); } if (userAdmissionAttachImageList.isEmpty()) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.USER_ADMISSION_MUST_HAVE_IMAGE - ); + MessageUtil.USER_ADMISSION_MUST_HAVE_IMAGE); } List uuidFileList = uuidFileService.saveFileList(userAdmissionAttachImageList, @@ -1324,8 +1257,7 @@ public UserAdmissionResponseDto createAdmission(User user, UserAdmission userAdmission = UserAdmission.of( user, uuidFileList, - userAdmissionCreateRequestDto.getDescription() - ); + userAdmissionCreateRequestDto.getDescription()); ValidatorBucket.of() .consistOf(UserStateIsNotDropAndActiveValidator.of(user.getState())) @@ -1335,9 +1267,7 @@ public UserAdmissionResponseDto createAdmission(User user, userRepository.save(updateState(user.getId(), UserState.AWAIT) .orElseThrow(() -> new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.ADMISSION_EXCEPTION - )) - ); + MessageUtil.ADMISSION_EXCEPTION))); return UserDtoMapper.INSTANCE.toUserAdmissionResponseDto(this.userAdmissionRepository.save(userAdmission)); } @@ -1346,9 +1276,7 @@ public UserAdmissionResponseDto getCurrentUserAdmission(User user) { UserAdmission userAdmission = userAdmissionRepository.findByUser_Id(user.getId()).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_APPLY_NOT_FOUND - ) - ); + MessageUtil.USER_APPLY_NOT_FOUND)); return UserDtoMapper.INSTANCE.toUserAdmissionResponseDto(userAdmission); } @@ -1356,13 +1284,11 @@ public UserAdmissionResponseDto getCurrentUserAdmission(User user) { @Transactional public UserAdmissionResponseDto accept( User requestUser, - String admissionId - ) { + String admissionId) { Set roles = requestUser.getRoles(); UserAdmission userAdmission = this.userAdmissionRepository.findById(admissionId).orElseThrow( - () -> new BadRequestException(ErrorCode.ROW_DOES_NOT_EXIST, MessageUtil.USER_APPLY_NOT_FOUND) - ); + () -> new BadRequestException(ErrorCode.ROW_DOES_NOT_EXIST, MessageUtil.USER_APPLY_NOT_FOUND)); ValidatorBucket.of() .consistOf(UserStateValidator.of(requestUser.getState())) @@ -1388,8 +1314,7 @@ public UserAdmissionResponseDto accept( .map(UserAdmissionAttachImage::getUuidFile) .toList(), userAdmission.getDescription(), - null - ); + null); this.userAdmissionLogRepository.save(userAdmissionLog); @@ -1401,22 +1326,18 @@ public UserAdmissionResponseDto accept( this.updateState(userAdmission.getUser().getId(), UserState.ACTIVE) .orElseThrow(() -> new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.ADMISSION_EXCEPTION - )) - ); + MessageUtil.ADMISSION_EXCEPTION))); } @Transactional public UserAdmissionResponseDto reject( User requestUser, String admissionId, - String rejectReason - ) { + String rejectReason) { Set roles = requestUser.getRoles(); UserAdmission userAdmission = this.userAdmissionRepository.findById(admissionId).orElseThrow( - () -> new BadRequestException(ErrorCode.ROW_DOES_NOT_EXIST, MessageUtil.USER_APPLY_NOT_FOUND) - ); + () -> new BadRequestException(ErrorCode.ROW_DOES_NOT_EXIST, MessageUtil.USER_APPLY_NOT_FOUND)); User targetUser = userAdmission.getUser(); @@ -1438,8 +1359,7 @@ public UserAdmissionResponseDto reject( .map(UserAdmissionAttachImage::getUuidFile) .toList(), userAdmission.getDescription(), - rejectReason - ); + rejectReason); userAdmissionLogRepository.save(userAdmissionLog); @@ -1450,27 +1370,23 @@ public UserAdmissionResponseDto reject( targetUser = this.updateState(targetUser.getId(), UserState.REJECT) .orElseThrow(() -> new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.ADMISSION_EXCEPTION - )); + MessageUtil.ADMISSION_EXCEPTION)); userRepository.save(targetUser); return UserDtoMapper.INSTANCE.toUserAdmissionResponseDto( userAdmissionLog, - targetUser - ); + targetUser); } @Transactional public UserResponseDto restore( User requestUser, - String userId - ) { + String userId) { Set roles = requestUser.getRoles(); User restoredUser = this.userRepository.findById(userId).orElseThrow( - () -> new BadRequestException(ErrorCode.ROW_DOES_NOT_EXIST, MessageUtil.USER_NOT_FOUND) - ); + () -> new BadRequestException(ErrorCode.ROW_DOES_NOT_EXIST, MessageUtil.USER_NOT_FOUND)); ValidatorBucket.of() .consistOf(UserRoleValidator.of(roles, Set.of())) .consistOf(UserStateIsDropOrIsInActiveValidator.of(restoredUser.getState())) @@ -1481,8 +1397,7 @@ public UserResponseDto restore( User entity = this.updateState(restoredUser.getId(), UserState.ACTIVE) .orElseThrow(() -> new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.INTERNAL_SERVER_ERROR - )); + MessageUtil.INTERNAL_SERVER_ERROR)); return UserDtoMapper.INSTANCE.toUserResponseDto(entity, null, null); } @@ -1490,8 +1405,7 @@ public UserResponseDto restore( public UserSignInResponseDto updateToken(String refreshToken) { // STEP1 : refreshToken으로 맵핑된 유저 찾기 User user = this.userRepository.findById(this.getUserIdFromRefreshToken(refreshToken)).orElseThrow( - () -> new BadRequestException(ErrorCode.ROW_DOES_NOT_EXIST, MessageUtil.INVALID_REFRESH_TOKEN) - ); + () -> new BadRequestException(ErrorCode.ROW_DOES_NOT_EXIST, MessageUtil.INVALID_REFRESH_TOKEN)); this.userRepository.findById(getUserIdFromRefreshToken(refreshToken)); @@ -1510,8 +1424,7 @@ private String getUserIdFromRefreshToken(String refreshToken) { return Optional.ofNullable(redisUtils.getRefreshTokenData(refreshToken)) .orElseThrow(() -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.INVALID_REFRESH_TOKEN - )); + MessageUtil.INVALID_REFRESH_TOKEN)); } public UserSignOutResponseDto signOut(User user, UserSignOutRequestDto userSignOutRequestDto) { @@ -1529,11 +1442,10 @@ public UserSignOutResponseDto signOut(User user, UserSignOutRequestDto userSignO public UserFindIdResponseDto findUserId(UserFindIdRequestDto userIdFindRequestDto) { User user = this.userRepository.findByPhoneNumberAndName( userIdFindRequestDto.getPhoneNumber().trim(), - userIdFindRequestDto.getName().trim() - ).orElseThrow(() -> new BadRequestException( - ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - )); + userIdFindRequestDto.getName().trim()).orElseThrow( + () -> new BadRequestException( + ErrorCode.ROW_DOES_NOT_EXIST, + MessageUtil.USER_NOT_FOUND)); return UserDtoMapper.INSTANCE.toUserfindIdResponseDto(user); } @@ -1546,8 +1458,7 @@ public List findByStudentId(String studentId) { if (userList.isEmpty()) { throw new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - ); + MessageUtil.USER_NOT_FOUND); } return userList.stream() @@ -1584,8 +1495,7 @@ public void exportUserListToExcel(HttpServletResponse response) { "동아리명 목록(동아리장일 경우)", "가입 거절/추방 사유", "동문네트워크 가입일", - "사용자 정보 최종 수정일" - ); + "사용자 정보 최종 수정일"); LinkedHashMap> sheetDataMap = new LinkedHashMap<>(); for (UserState state : UserState.values()) { @@ -1614,15 +1524,13 @@ public UserResponseDto updateUserIsV2(User user) { if (ownCircles.isEmpty()) { throw new InternalServerException( ErrorCode.INTERNAL_SERVER, - MessageUtil.NO_ASSIGNED_CIRCLE_FOR_LEADER - ); + MessageUtil.NO_ASSIGNED_CIRCLE_FOR_LEADER); } return UserDtoMapper.INSTANCE.toUserResponseDto( user, ownCircles.stream().map(Circle::getId).collect(Collectors.toList()), - ownCircles.stream().map(Circle::getName).collect(Collectors.toList()) - ); + ownCircles.stream().map(Circle::getName).collect(Collectors.toList())); } userRepository.save(user); @@ -1641,8 +1549,7 @@ public UserFcmTokenResponseDto registerFcmToken(User user, UserFcmCreateRequestD if (!transactionUser.getId().equals(userIdFromRedis)) { throw new BadRequestException( ErrorCode.INVALID_SIGNIN, - MessageUtil.INVALID_REFRESH_TOKEN - ); + MessageUtil.INVALID_REFRESH_TOKEN); } // 2. fcmToken 최신화 fcmUtils.cleanInvalidFcmTokens(transactionUser); @@ -1686,26 +1593,21 @@ private BoardResponseDto toBoardResponseDto(Board board, Role userRole) { roles, writable, circleId, - circleName - ); + circleName); } private User getUser(String userId) { return userRepository.findById(userId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - ) - ); + MessageUtil.USER_NOT_FOUND)); } private Board getBoard(String boardId) { return boardRepository.findById(boardId).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.BOARD_NOT_FOUND - ) - ); + MessageUtil.BOARD_NOT_FOUND)); } private Long getNumOfComment(Post post) { @@ -1751,8 +1653,7 @@ private void validateDuplicateBeforeAccept(User user) { if (!existingUser.getId().equals(user.getId()) && existingUser.getState() == UserState.ACTIVE) { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.EMAIL_ALREADY_EXIST - ); + MessageUtil.EMAIL_ALREADY_EXIST); } }); @@ -1760,8 +1661,7 @@ private void validateDuplicateBeforeAccept(User user) { if (!existingUser.getId().equals(user.getId()) && existingUser.getState() == UserState.ACTIVE) { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.NICKNAME_ALREADY_EXIST - ); + MessageUtil.NICKNAME_ALREADY_EXIST); } }); @@ -1769,8 +1669,7 @@ private void validateDuplicateBeforeAccept(User user) { if (!existingUser.getId().equals(user.getId()) && existingUser.getState() == UserState.ACTIVE) { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.PHONE_NUMBER_ALREADY_EXIST - ); + MessageUtil.PHONE_NUMBER_ALREADY_EXIST); } }); @@ -1779,8 +1678,7 @@ private void validateDuplicateBeforeAccept(User user) { if (!existingUser.getId().equals(user.getId()) && existingUser.getState() == UserState.ACTIVE) { throw new BadRequestException( ErrorCode.ROW_ALREADY_EXIST, - MessageUtil.STUDENT_ID_ALREADY_EXIST - ); + MessageUtil.STUDENT_ID_ALREADY_EXIST); } }); } @@ -1797,16 +1695,13 @@ public UserSignInResponseDto recoverUser(String email) { User user = userRepository.findByEmail(email).orElseThrow( () -> new BadRequestException( ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.USER_NOT_FOUND - ) - ); + MessageUtil.USER_NOT_FOUND)); // 사용자 상태가 INACTIVE인지 확인 if (user.getState() != UserState.INACTIVE) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - MessageUtil.USER_RECOVER_INVALID_STATE - ); + MessageUtil.USER_RECOVER_INVALID_STATE); } // 사용자 상태를 ACTIVE로 변경 @@ -1825,8 +1720,7 @@ public UserSignInResponseDto recoverUser(String email) { return UserDtoMapper.INSTANCE.toUserSignInResponseDto( jwtTokenProvider.createAccessToken(user.getId(), user.getRoles(), user.getState()), - refreshToken - ); + refreshToken); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/AdmissionYearValidator.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/AdmissionYearValidator.java index dd54feeaf..a5d24b157 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/AdmissionYearValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/AdmissionYearValidator.java @@ -24,8 +24,7 @@ public void validate() { if (!this.validateAdmissionYear()) { throw new BadRequestException( ErrorCode.INVALID_USER_DATA_REQUEST, - "입학년도를 다시 확인해주세요." - ); + "입학년도를 다시 확인해주세요."); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/DelegatableRoleValidator.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/DelegatableRoleValidator.java index aeab047c3..e09cb9e32 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/DelegatableRoleValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/DelegatableRoleValidator.java @@ -1,6 +1,8 @@ package net.causw.app.main.domain.user.account.util; -import static net.causw.app.main.domain.user.account.policy.RolePolicy.*; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.canAssign; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.getDelegatableRoles; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.isPrivilegeInverted; import java.util.Set; @@ -46,7 +48,6 @@ private boolean canDelegate() { private UnauthorizedException customUnauthorizedException() { return new UnauthorizedException( ErrorCode.ASSIGN_ROLE_NOT_ALLOWED, - MessageUtil.DELEGATE_ROLE_NOT_ALLOWED - ); + MessageUtil.DELEGATE_ROLE_NOT_ALLOWED); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/GrantableRoleValidator.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/GrantableRoleValidator.java index 47d6b59cb..ba8b57746 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/GrantableRoleValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/GrantableRoleValidator.java @@ -1,6 +1,9 @@ package net.causw.app.main.domain.user.account.util; -import static net.causw.app.main.domain.user.account.policy.RolePolicy.*; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.canAssign; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.getGrantableRoles; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.getProxyDelegatableRoles; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.isPrivilegeInverted; import java.util.Set; @@ -70,7 +73,6 @@ private boolean canProxyDelegate() { private UnauthorizedException customUnauthorizedException() { return new UnauthorizedException( ErrorCode.ASSIGN_ROLE_NOT_ALLOWED, - MessageUtil.GRANT_ROLE_NOT_ALLOWED - ); + MessageUtil.GRANT_ROLE_NOT_ALLOWED); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/PasswordCorrectValidator.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/PasswordCorrectValidator.java index 4055269eb..8d8304580 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/PasswordCorrectValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/PasswordCorrectValidator.java @@ -28,8 +28,7 @@ public void validate() { if (!passwordEncoder.matches(dstPassword, srcPassword)) { throw new UnauthorizedException( ErrorCode.INVALID_SIGNIN, - "비밀번호를 잘못 입력했습니다." - ); + "비밀번호를 잘못 입력했습니다."); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/PasswordFormatValidator.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/PasswordFormatValidator.java index b081b8007..07584ea44 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/PasswordFormatValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/PasswordFormatValidator.java @@ -24,8 +24,7 @@ public void validate() { if (!this.validatePassword()) { throw new BadRequestException( ErrorCode.INVALID_USER_DATA_REQUEST, - "비밀번호 형식이 잘못되었습니다." - ); + "비밀번호 형식이 잘못되었습니다."); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/PhoneNumberFormatValidator.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/PhoneNumberFormatValidator.java index 169e317f4..0ee40b849 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/PhoneNumberFormatValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/PhoneNumberFormatValidator.java @@ -24,8 +24,7 @@ public void validate() { if (!this.validatePhoneNumber()) { throw new BadRequestException( ErrorCode.INVALID_USER_DATA_REQUEST, - "전화번호 형식이 잘못되었습니다." - ); + "전화번호 형식이 잘못되었습니다."); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/StudentIdIsNullValidator.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/StudentIdIsNullValidator.java index a39ab40bf..0e40e8bc0 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/StudentIdIsNullValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/StudentIdIsNullValidator.java @@ -21,8 +21,7 @@ public void validate() { if (this.studentId == null) { throw new BadRequestException( ErrorCode.INVALID_STUDENT_ID, - "학번이 입력되지 않았습니다." - ); + "학번이 입력되지 않았습니다."); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserNameEqualValidator.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserNameEqualValidator.java index 8f644ffbc..ff73712c2 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserNameEqualValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserNameEqualValidator.java @@ -24,8 +24,7 @@ public void validate() { if (!this.srcUserName.equals(this.targetUserName)) { throw new BadRequestException( ErrorCode.INVALID_PARAMETER, - "답할 답장의 작성자가 아닙니다." - ); + "답할 답장의 작성자가 아닙니다."); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserNotEqualValidator.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserNotEqualValidator.java index 43def7f8b..613764668 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserNotEqualValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserNotEqualValidator.java @@ -24,8 +24,7 @@ public void validate() { if (this.srcUserId.equals(this.targetUserId)) { throw new BadRequestException( ErrorCode.CANNOT_PERFORMED, - "해당 사용자는 명령을 수행할 수 없습니다." - ); + "해당 사용자는 명령을 수행할 수 없습니다."); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserRoleIsNoneValidator.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserRoleIsNoneValidator.java index 5d52226e9..79cceeb46 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserRoleIsNoneValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserRoleIsNoneValidator.java @@ -23,8 +23,7 @@ public void validate() { if (this.requestUserRoles.contains(Role.NONE)) { throw new UnauthorizedException( ErrorCode.NEED_SIGN_IN, - "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요." - ); + "접근 권한이 없습니다. 다시 로그인 해주세요. 문제 반복시 관리자에게 문의해주세요."); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserRoleValidator.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserRoleValidator.java index 2b19d0559..3ac5b28f1 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserRoleValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserRoleValidator.java @@ -38,7 +38,6 @@ public void validate() { throw new UnauthorizedException( ErrorCode.API_NOT_ALLOWED, - MessageUtil.API_NOT_ACCESSIBLE - ); + MessageUtil.API_NOT_ACCESSIBLE); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserRoleWithoutAdminValidator.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserRoleWithoutAdminValidator.java index 760f4329e..b69b74388 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserRoleWithoutAdminValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserRoleWithoutAdminValidator.java @@ -32,7 +32,6 @@ public void validate() { throw new UnauthorizedException( ErrorCode.API_NOT_ALLOWED, - "접근 권한이 없습니다." - ); + "접근 권한이 없습니다."); } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateIsDeletedValidator.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateIsDeletedValidator.java index 421e9d94c..58107a551 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateIsDeletedValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateIsDeletedValidator.java @@ -22,8 +22,7 @@ public void validate() { if (this.userState.equals(UserState.DELETED)) { throw new UnauthorizedException( ErrorCode.DELETED_USER, - "삭제된 사용자 입니다." - ); + "삭제된 사용자 입니다."); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateIsDropOrIsInActiveValidator.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateIsDropOrIsInActiveValidator.java index ad96f9b5b..33f986f02 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateIsDropOrIsInActiveValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateIsDropOrIsInActiveValidator.java @@ -22,8 +22,7 @@ public void validate() { UserState.INACTIVE) || this.userState.equals(UserState.DELETED))) { throw new UnauthorizedException( ErrorCode.BLOCKED_USER, - "등록된 사용자가 아닙니다." - ); + "등록된 사용자가 아닙니다."); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateIsDropValidator.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateIsDropValidator.java index 7c85c1901..e9e1519bb 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateIsDropValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateIsDropValidator.java @@ -21,8 +21,7 @@ public void validate() { if (this.userState != UserState.DROP) { throw new UnauthorizedException( ErrorCode.BLOCKED_USER, - "추방된 사용자가 아닙니다." - ); + "추방된 사용자가 아닙니다."); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateIsNotDropAndActiveValidator.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateIsNotDropAndActiveValidator.java index 3e0019fe7..21dc1e4de 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateIsNotDropAndActiveValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateIsNotDropAndActiveValidator.java @@ -22,13 +22,11 @@ public void validate() { if (this.userState == UserState.DROP) { throw new UnauthorizedException( ErrorCode.BLOCKED_USER, - "추방된 사용자 입니다." - ); + "추방된 사용자 입니다."); } else if (this.userState == UserState.ACTIVE) { throw new UnauthorizedException( ErrorCode.API_NOT_ALLOWED, - "이미 등록된 사용자 입니다." - ); + "이미 등록된 사용자 입니다."); } } } \ No newline at end of file diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateValidator.java b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateValidator.java index 6bef15a06..81ba713f3 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateValidator.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/account/util/UserStateValidator.java @@ -23,22 +23,19 @@ public void validate() { if (this.userState == UserState.DROP) { throw new UnauthorizedException( ErrorCode.BLOCKED_USER, - MessageUtil.USER_DROPPED_CONTACT_EMAIL - ); + MessageUtil.USER_DROPPED_CONTACT_EMAIL); } if (this.userState == UserState.INACTIVE) { throw new UnauthorizedException( ErrorCode.INACTIVE_USER, - MessageUtil.USER_INACTIVE_CAN_REJOIN - ); + MessageUtil.USER_INACTIVE_CAN_REJOIN); } if (this.userState == UserState.DELETED) { throw new UnauthorizedException( ErrorCode.DELETED_USER, - MessageUtil.USER_DELETED - ); + MessageUtil.USER_DELETED); } } } diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/auth/service/SecurityService.java b/app-main/src/main/java/net/causw/app/main/domain/user/auth/service/SecurityService.java index dd52877f3..611d8296a 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/auth/service/SecurityService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/auth/service/SecurityService.java @@ -10,10 +10,10 @@ import org.springframework.stereotype.Service; import net.causw.app.main.core.aop.annotation.MeasureTime; -import net.causw.app.main.domain.user.auth.util.SecurityHelper; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.domain.user.account.enums.user.RoleGroup; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; +import net.causw.app.main.domain.user.auth.util.SecurityHelper; import net.causw.global.constant.MessageUtil; import lombok.RequiredArgsConstructor; diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/auth/userdetails/CustomUserDetailsService.java b/app-main/src/main/java/net/causw/app/main/domain/user/auth/userdetails/CustomUserDetailsService.java index 664e191e4..faac8aedb 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/auth/userdetails/CustomUserDetailsService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/auth/userdetails/CustomUserDetailsService.java @@ -33,14 +33,11 @@ public UserDetails loadUserByUsername(String email) throws UsernameNotFoundExcep public UserDetails loadUserByUserId(String userId) throws UsernameNotFoundException { User user = userQueryRepository.findByIdWithRoles(userId) .orElseThrow(() -> new BadRequestException( - ErrorCode.ROW_DOES_NOT_EXIST, - MessageUtil.LOGIN_USER_NOT_FOUND - ) - ); + ErrorCode.ROW_DOES_NOT_EXIST, + MessageUtil.LOGIN_USER_NOT_FOUND)); return CustomUserDetails.builder() .user(user) .build(); } } - diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/auth/util/SecurityHelper.java b/app-main/src/main/java/net/causw/app/main/domain/user/auth/util/SecurityHelper.java index f3373034b..afea8dae9 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/auth/util/SecurityHelper.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/auth/util/SecurityHelper.java @@ -4,11 +4,11 @@ import org.springframework.security.core.GrantedAuthority; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.domain.user.account.enums.user.RoleGroup; import net.causw.app.main.domain.user.account.enums.user.UserState; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; public class SecurityHelper { diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/relation/entity/userBlock/UserBlock.java b/app-main/src/main/java/net/causw/app/main/domain/user/relation/entity/userBlock/UserBlock.java index c893564d5..a05389dc8 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/relation/entity/userBlock/UserBlock.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/relation/entity/userBlock/UserBlock.java @@ -20,13 +20,10 @@ import lombok.NoArgsConstructor; @Entity -@Table(name = "tb_user_block", - uniqueConstraints = { - // 활성 차단은 동일 스코프로 중복 생성 방지 - @UniqueConstraint(name = "uq_block", - columnNames = {"blocker_id", "blockee_id"}) - } -) +@Table(name = "tb_user_block", uniqueConstraints = { + // 활성 차단은 동일 스코프로 중복 생성 방지 + @UniqueConstraint(name = "uq_block", columnNames = {"blocker_id", "blockee_id"}) +}) @Getter @Builder(access = AccessLevel.PROTECTED) @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -130,8 +127,7 @@ public static UserBlock createForComment( BlockScope.COMMENT, commentId, isAnonymous, - commentContent - ); + commentContent); } /** @@ -157,8 +153,7 @@ public static UserBlock createForChildComment( BlockScope.CHILD_COMMENT, childCommentId, isAnonymous, - childCommentContent - ); + childCommentContent); } /** @@ -184,8 +179,7 @@ public static UserBlock createForPost( BlockScope.POST, postId, isAnonymous, - postContent - ); + postContent); } /** diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/relation/relation/userBlock/UserBlockRepository.java b/app-main/src/main/java/net/causw/app/main/domain/user/relation/relation/userBlock/UserBlockRepository.java index a4b867e55..e32c309ef 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/relation/relation/userBlock/UserBlockRepository.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/relation/relation/userBlock/UserBlockRepository.java @@ -13,10 +13,12 @@ public interface UserBlockRepository extends JpaRepository { boolean existsByBlockerIdAndBlockeeId(String blockerId, String blockeeId); @Query("SELECT b.blockeeId FROM UserBlock b WHERE b.blockerId = :userId") - Set findBlockeeIdsByBlockerUserId(@Param("userId") String userId); + Set findBlockeeIdsByBlockerUserId(@Param("userId") + String userId); @Query("SELECT b.blockerId FROM UserBlock b WHERE b.blockeeId = :userId") - Set findBlockerIdsByBlockeeUserId(@Param("userId") String userId); + Set findBlockerIdsByBlockeeUserId(@Param("userId") + String userId); @Query("SELECT b.blockerId FROM UserBlock b WHERE b.blockeeId IN :userIds") Set findBlockerIdsByBlockeeUserIds(Set userIds); diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/relation/service/BlockByChildCommentUseCaseService.java b/app-main/src/main/java/net/causw/app/main/domain/user/relation/service/BlockByChildCommentUseCaseService.java index 2421127a2..1959032f8 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/relation/service/BlockByChildCommentUseCaseService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/relation/service/BlockByChildCommentUseCaseService.java @@ -3,11 +3,11 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; +import net.causw.app.main.api.dto.userBlock.response.CreateBlockByChildCommentResponseDto; import net.causw.app.main.domain.community.comment.entity.ChildComment; import net.causw.app.main.domain.community.comment.service.ChildCommentEntityService; -import net.causw.app.main.api.dto.userBlock.response.CreateBlockByChildCommentResponseDto; import net.causw.app.main.domain.user.account.entity.user.User; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.global.constant.MessageUtil; import net.causw.global.exception.BadRequestException; import net.causw.global.exception.ErrorCode; diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/relation/service/BlockByCommentUseCaseService.java b/app-main/src/main/java/net/causw/app/main/domain/user/relation/service/BlockByCommentUseCaseService.java index 777ba3992..4c9721e4e 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/relation/service/BlockByCommentUseCaseService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/relation/service/BlockByCommentUseCaseService.java @@ -3,11 +3,11 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; +import net.causw.app.main.api.dto.userBlock.response.CreateBlockByCommentResponseDto; import net.causw.app.main.domain.community.comment.entity.Comment; import net.causw.app.main.domain.community.comment.service.CommentEntityService; -import net.causw.app.main.api.dto.userBlock.response.CreateBlockByCommentResponseDto; import net.causw.app.main.domain.user.account.entity.user.User; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.global.constant.MessageUtil; import net.causw.global.exception.BadRequestException; import net.causw.global.exception.ErrorCode; diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/relation/service/BlockByPostUseCaseService.java b/app-main/src/main/java/net/causw/app/main/domain/user/relation/service/BlockByPostUseCaseService.java index cb264bb9d..de29f8cf8 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/relation/service/BlockByPostUseCaseService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/relation/service/BlockByPostUseCaseService.java @@ -3,11 +3,11 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; +import net.causw.app.main.api.dto.userBlock.response.CreateBlockByPostResponseDto; import net.causw.app.main.domain.community.post.entity.Post; import net.causw.app.main.domain.community.post.service.PostEntityService; -import net.causw.app.main.api.dto.userBlock.response.CreateBlockByPostResponseDto; import net.causw.app.main.domain.user.account.entity.user.User; +import net.causw.app.main.domain.user.auth.userdetails.CustomUserDetails; import net.causw.global.constant.MessageUtil; import net.causw.global.exception.BadRequestException; import net.causw.global.exception.ErrorCode; diff --git a/app-main/src/main/java/net/causw/app/main/domain/user/relation/service/UserBlockEntityService.java b/app-main/src/main/java/net/causw/app/main/domain/user/relation/service/UserBlockEntityService.java index 1197631a8..f7384b30c 100644 --- a/app-main/src/main/java/net/causw/app/main/domain/user/relation/service/UserBlockEntityService.java +++ b/app-main/src/main/java/net/causw/app/main/domain/user/relation/service/UserBlockEntityService.java @@ -43,8 +43,7 @@ public void createBlock(User user, Post post) { writer.getId(), post.getId(), post.getIsAnonymous(), - post.getTitle() + "\n내용: " + post.getContent() - ); + post.getTitle() + "\n내용: " + post.getContent()); userBlockRepository.save(userBlock); } @@ -62,8 +61,7 @@ public void createBlock(User user, Comment comment) { writer.getId(), comment.getId(), comment.getIsAnonymous(), - comment.getContent() - ); + comment.getContent()); userBlockRepository.save(userBlock); } @@ -81,8 +79,7 @@ public void createBlock(User user, ChildComment childComment) { writer.getId(), childComment.getId(), childComment.getIsAnonymous(), - childComment.getContent() - ); + childComment.getContent()); userBlockRepository.save(userBlock); } @@ -110,7 +107,8 @@ public Set findBlockerUserIdsByBlockee(User blockee) { * @param blockeeUserIds 차단당한 자들의 아이디 Set * @return 차단자 id Set */ - public Set findBlockerUserIdsByUserIds(@NotEmpty Set blockeeUserIds) { + public Set findBlockerUserIdsByUserIds(@NotEmpty + Set blockeeUserIds) { return userBlockRepository.findBlockerIdsByBlockeeUserIds(blockeeUserIds); } } diff --git a/app-main/src/main/java/net/causw/app/main/shared/infra/firebase/FcmUtils.java b/app-main/src/main/java/net/causw/app/main/shared/infra/firebase/FcmUtils.java index ea16612ae..51b6f77d3 100644 --- a/app-main/src/main/java/net/causw/app/main/shared/infra/firebase/FcmUtils.java +++ b/app-main/src/main/java/net/causw/app/main/shared/infra/firebase/FcmUtils.java @@ -60,27 +60,3 @@ public void removeFcmToken(User user, String fcmToken) { } } - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app-main/src/main/java/net/causw/app/main/shared/infra/mail/GoogleMailSender.java b/app-main/src/main/java/net/causw/app/main/shared/infra/mail/GoogleMailSender.java index 3f9e8eadb..662ec03e2 100644 --- a/app-main/src/main/java/net/causw/app/main/shared/infra/mail/GoogleMailSender.java +++ b/app-main/src/main/java/net/causw/app/main/shared/infra/mail/GoogleMailSender.java @@ -22,25 +22,23 @@ public class GoogleMailSender { public void sendNewPasswordMail( String to, - String password - ) { + String password) { String title = "[중앙대학교 소프트웨어학부 동문네트워크] 계정 임시 비밀번호 안내"; - String content = - "
" - + "
" - + "

계정 임시 비밀번호 발급

" - + "

안녕하세요,

" - + "

귀하의 계정에 대한 임시 비밀번호가 [" + password - + "]로 설정되었습니다.

" - + "

임시 비밀번호를 사용하여 동문네트워크에 로그인하신 후, 보안을 위해 새 비밀번호로 변경해 주시기 바랍니다.

" - + "

동문네트워크 웹사이트로 이동하기

" - + "
" - + "

중앙대학교 소프트웨어학부 동문네트워크

" - + "
" - + "

서울특별시 동작구 흑석로 84, 중앙대학교 소프트웨어학부 동문 네트워크

" - + "

문의 전화: 02-123-4567 | 이메일: caucsedongne@gmail.com

" - + "
" - + "
"; + String content = "
" + + "
" + + "

계정 임시 비밀번호 발급

" + + "

안녕하세요,

" + + "

귀하의 계정에 대한 임시 비밀번호가 [" + password + + "]로 설정되었습니다.

" + + "

임시 비밀번호를 사용하여 동문네트워크에 로그인하신 후, 보안을 위해 새 비밀번호로 변경해 주시기 바랍니다.

" + + "

동문네트워크 웹사이트로 이동하기

" + + "
" + + "

중앙대학교 소프트웨어학부 동문네트워크

" + + "
" + + "

서울특별시 동작구 흑석로 84, 중앙대학교 소프트웨어학부 동문 네트워크

" + + "

문의 전화: 02-123-4567 | 이메일: caucsedongne@gmail.com

" + + "
" + + "
"; this.sendMail(to, title, content); } @@ -48,8 +46,7 @@ public void sendNewPasswordMail( public void sendMail( String to, String title, - String content - ) { + String content) { try { MimeMessage message = javaMailSender.createMimeMessage(); MimeMessageHelper messageHelper = new MimeMessageHelper(message, false, "UTF-8"); diff --git a/app-main/src/main/java/net/causw/app/main/shared/infra/redis/RedisConfig.java b/app-main/src/main/java/net/causw/app/main/shared/infra/redis/RedisConfig.java index b26541c27..4dceb879c 100644 --- a/app-main/src/main/java/net/causw/app/main/shared/infra/redis/RedisConfig.java +++ b/app-main/src/main/java/net/causw/app/main/shared/infra/redis/RedisConfig.java @@ -54,7 +54,7 @@ public CacheManager cacheManager(RedisConnectionFactory connectionFactory) { .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer())) .serializeValuesWith( RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer())) - .entryTtl(Duration.ofMinutes(60)); // 캐시 TTL 설정, (기본값: 1시간, TTL 따로 지정안한 경우만 적용) + .entryTtl(Duration.ofMinutes(60)); // 캐시 TTL 설정, (기본값: 1시간, TTL 따로 지정안한 경우만 적용) return RedisCacheManager.builder(RedisCacheWriter.nonLockingRedisCacheWriter(connectionFactory)) .cacheDefaults(redisCacheConfiguration) diff --git a/app-main/src/main/java/net/causw/app/main/shared/util/ConstraintValidator.java b/app-main/src/main/java/net/causw/app/main/shared/util/ConstraintValidator.java index ab93ddc36..8164672e8 100644 --- a/app-main/src/main/java/net/causw/app/main/shared/util/ConstraintValidator.java +++ b/app-main/src/main/java/net/causw/app/main/shared/util/ConstraintValidator.java @@ -29,9 +29,7 @@ public void validate() { if (!violations.isEmpty()) { StringBuilder sb = new StringBuilder(); - violations.forEach(violation -> - sb.append(violation.getMessage()) - ); + violations.forEach(violation -> sb.append(violation.getMessage())); throw new ConstraintViolationException(sb.toString(), violations); } diff --git a/app-main/src/main/java/net/causw/app/main/shared/util/ContentsAdminValidator.java b/app-main/src/main/java/net/causw/app/main/shared/util/ContentsAdminValidator.java index cd95e29bf..6f89d9f8e 100644 --- a/app-main/src/main/java/net/causw/app/main/shared/util/ContentsAdminValidator.java +++ b/app-main/src/main/java/net/causw/app/main/shared/util/ContentsAdminValidator.java @@ -28,8 +28,7 @@ private ContentsAdminValidator( Set requestUserRoles, String requestUserId, String writerUserId, - List adminRoleList - ) { + List adminRoleList) { this.requestUserRoles = requestUserRoles; this.requestUserId = requestUserId; this.writerUserId = writerUserId; @@ -40,14 +39,12 @@ public static ContentsAdminValidator of( Set requestUserRoles, String requestUserId, String writerUserId, - List adminRoleList - ) { + List adminRoleList) { return new ContentsAdminValidator( requestUserRoles, requestUserId, writerUserId, - adminRoleList - ); + adminRoleList); } @Override @@ -69,7 +66,6 @@ public void validate() { throw new UnauthorizedException( ErrorCode.API_NOT_ALLOWED, - "접근 권한이 없습니다." - ); + "접근 권한이 없습니다."); } } \ No newline at end of file diff --git a/app-main/src/main/java/net/causw/app/main/shared/util/TargetIsDeletedValidator.java b/app-main/src/main/java/net/causw/app/main/shared/util/TargetIsDeletedValidator.java index 54bf09443..bcc42b512 100644 --- a/app-main/src/main/java/net/causw/app/main/shared/util/TargetIsDeletedValidator.java +++ b/app-main/src/main/java/net/causw/app/main/shared/util/TargetIsDeletedValidator.java @@ -24,8 +24,7 @@ public void validate() { if (this.isDeleted) { throw new BadRequestException( ErrorCode.TARGET_DELETED, - String.format("삭제된 %s 입니다.", this.domain) - ); + String.format("삭제된 %s 입니다.", this.domain)); } } } diff --git a/app-main/src/main/java/net/causw/app/main/shared/util/TargetIsNotDeletedValidator.java b/app-main/src/main/java/net/causw/app/main/shared/util/TargetIsNotDeletedValidator.java index 933250b5a..d8c64ad81 100644 --- a/app-main/src/main/java/net/causw/app/main/shared/util/TargetIsNotDeletedValidator.java +++ b/app-main/src/main/java/net/causw/app/main/shared/util/TargetIsNotDeletedValidator.java @@ -24,8 +24,7 @@ public void validate() { if (!this.isDeleted) { throw new BadRequestException( ErrorCode.TARGET_DELETED, - String.format("삭제되지 않은 %s 입니다.", this.domain) - ); + String.format("삭제되지 않은 %s 입니다.", this.domain)); } } } diff --git a/app-main/src/main/java/net/causw/app/main/shared/util/UserEqualValidator.java b/app-main/src/main/java/net/causw/app/main/shared/util/UserEqualValidator.java index 86c523c44..1686e221d 100644 --- a/app-main/src/main/java/net/causw/app/main/shared/util/UserEqualValidator.java +++ b/app-main/src/main/java/net/causw/app/main/shared/util/UserEqualValidator.java @@ -24,8 +24,7 @@ public void validate() { if (!this.srcUserId.equals(this.targetUserId)) { throw new UnauthorizedException( ErrorCode.API_NOT_ALLOWED, - "접근 권한이 없습니다." - ); + "접근 권한이 없습니다."); } } } \ No newline at end of file diff --git a/app-main/src/test/java/net/causw/app/main/domain/policy/RolePolicyTest.java b/app-main/src/test/java/net/causw/app/main/domain/policy/RolePolicyTest.java index ddc6d356b..c4704be1b 100644 --- a/app-main/src/test/java/net/causw/app/main/domain/policy/RolePolicyTest.java +++ b/app-main/src/test/java/net/causw/app/main/domain/policy/RolePolicyTest.java @@ -1,6 +1,6 @@ package net.causw.app.main.domain.policy; -import static org.assertj.core.api.AssertionsForClassTypes.*; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/app-main/src/test/java/net/causw/app/main/domain/policy/UserCouncilFeePolicyTest.java b/app-main/src/test/java/net/causw/app/main/domain/policy/UserCouncilFeePolicyTest.java index 9cdea3537..e41757c21 100644 --- a/app-main/src/test/java/net/causw/app/main/domain/policy/UserCouncilFeePolicyTest.java +++ b/app-main/src/test/java/net/causw/app/main/domain/policy/UserCouncilFeePolicyTest.java @@ -1,7 +1,9 @@ package net.causw.app.main.domain.policy; -import static net.causw.app.main.domain.finance.usercouncilfee.policy.UserCouncilFeePolicy.*; -import static org.assertj.core.api.Assertions.*; +import static net.causw.app.main.domain.finance.usercouncilfee.policy.UserCouncilFeePolicy.getRemainingAppliedSemestersWithUser; +import static net.causw.app.main.domain.finance.usercouncilfee.policy.UserCouncilFeePolicy.getStartSemesterToApply; +import static net.causw.app.main.domain.finance.usercouncilfee.policy.UserCouncilFeePolicy.isAppliedCurrentSemesterWithUser; +import static org.assertj.core.api.Assertions.assertThat; import java.util.stream.Stream; @@ -11,10 +13,10 @@ import org.junit.jupiter.params.provider.MethodSource; import net.causw.app.main.domain.campus.semester.entity.Semester; -import net.causw.app.main.domain.user.account.entity.user.User; -import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFee; import net.causw.app.main.domain.campus.semester.enums.SemesterType; +import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFee; import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; +import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.util.ObjectFixtures; public class UserCouncilFeePolicyTest { @@ -29,21 +31,17 @@ static Stream provideStartSemesterToApplyCases() { Arguments.of( "현재 학기중이고 재학생인 경우 현재 학기부터 적용", SemesterType.FIRST, AcademicStatus.ENROLLED, - user.getCurrentCompletedSemester() - ), + user.getCurrentCompletedSemester()), Arguments.of( "현재 방학중인 경우 다음 학기부터 적용", SemesterType.SUMMER, AcademicStatus.ENROLLED, - user.getCurrentCompletedSemester() + 1 - ), + user.getCurrentCompletedSemester() + 1), Arguments.of( "현재 휴학생인 경우 다음 학기부터 적용", SemesterType.FIRST, AcademicStatus.LEAVE_OF_ABSENCE, - user.getCurrentCompletedSemester() + 1 - ) - ); + user.getCurrentCompletedSemester() + 1)); } @ParameterizedTest(name = "{0}") @@ -70,27 +68,22 @@ static Stream provideRemainingAppliedSemestersCases() { Arguments.of( "학생회비 환불 받은 경우 잔여 학기 없음", createUserCouncilFee(1, 1, 8, true), - 0 - ), + 0), Arguments.of( "다음 학기부터 학생회비 적용되는 경우 잔여 학기는 납부한 학기 수", createUserCouncilFee(2, 3, 6, false), - 6 - ), + 6), Arguments.of( "이번 학기부터 학생회비 적용되는 경우 잔여 학기는 납부한 학기 수 - 1", createUserCouncilFee(3, 3, 6, false), - 5 - ), + 5), Arguments.of( "신입생때 납부한 초과학기 재학생의 경우 잔여 학기 없음", createUserCouncilFee(9, 1, 8, false), - 0 - ) - ); + 0)); } @ParameterizedTest(name = "{0}") @@ -112,21 +105,17 @@ static Stream provideIsAppliedCurrentSemesterCases() { Arguments.of( "현재 등록 완료 학기가 학생회비 적용 시작 학기 이전인 경우 학생회비 미적용", createUserCouncilFee(2, 3, 6, false), - false - ), + false), Arguments.of( "현재 등록 완료 학기가 학생회비 적용 시작 학기인 경우 학생회비 적용", createUserCouncilFee(3, 3, 6, false), - true - ), + true), Arguments.of( "잔여 학생회비 적용 학기가 없는 경우 학생회비 미적용", createUserCouncilFee(9, 1, 8, false), - false - ) - ); + false)); } @ParameterizedTest(name = "{0}") @@ -141,8 +130,7 @@ void test(String description, UserCouncilFee userCouncilFee, boolean expectedRes } private static UserCouncilFee createUserCouncilFee( - int currentCompletedSemester, int paidAt, int numOfPaidSemester, boolean isRefunded - ) { + int currentCompletedSemester, int paidAt, int numOfPaidSemester, boolean isRefunded) { User user = ObjectFixtures.getUser(); user.setCurrentCompletedSemester(currentCompletedSemester); @@ -153,7 +141,6 @@ private static UserCouncilFee createUserCouncilFee( paidAt, numOfPaidSemester, isRefunded, - isRefunded ? 2025 : null - ); + isRefunded ? 2025 : null); } } \ No newline at end of file diff --git a/app-main/src/test/java/net/causw/app/main/domain/validation/DelegatableRoleValidatorTest.java b/app-main/src/test/java/net/causw/app/main/domain/validation/DelegatableRoleValidatorTest.java index 8265ce67f..b1256e03f 100644 --- a/app-main/src/test/java/net/causw/app/main/domain/validation/DelegatableRoleValidatorTest.java +++ b/app-main/src/test/java/net/causw/app/main/domain/validation/DelegatableRoleValidatorTest.java @@ -1,10 +1,26 @@ package net.causw.app.main.domain.validation; import static java.util.Map.entry; -import static net.causw.app.main.domain.user.account.enums.user.Role.*; -import static net.causw.app.main.domain.user.account.policy.RolePolicy.*; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; +import static net.causw.app.main.domain.user.account.enums.user.Role.ADMIN; +import static net.causw.app.main.domain.user.account.enums.user.Role.COMMON; +import static net.causw.app.main.domain.user.account.enums.user.Role.COUNCIL; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_1; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_2; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_3; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_4; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_ALUMNI; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_CIRCLE; +import static net.causw.app.main.domain.user.account.enums.user.Role.NONE; +import static net.causw.app.main.domain.user.account.enums.user.Role.PRESIDENT; +import static net.causw.app.main.domain.user.account.enums.user.Role.PROFESSOR; +import static net.causw.app.main.domain.user.account.enums.user.Role.VICE_PRESIDENT; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.canAssign; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.getRolePriority; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.getRolesAssignableFor; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.isPrivilegeInverted; +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.ArgumentMatchers.any; import java.util.Map; import java.util.Set; @@ -17,10 +33,10 @@ import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; -import net.causw.app.main.domain.user.account.util.DelegatableRoleValidator; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.domain.user.account.policy.RolePolicy; +import net.causw.app.main.domain.user.account.util.DelegatableRoleValidator; import net.causw.app.main.util.ObjectFixtures; import net.causw.global.constant.MessageUtil; import net.causw.global.exception.ErrorCode; @@ -46,13 +62,11 @@ public class DelegatableRoleValidatorTest { entry(NONE, 100), entry(LEADER_CIRCLE, 5), - entry(PROFESSOR, 6) - ); + entry(PROFESSOR, 6)); private static final Map> MOCK_ROLES_ASSIGNABLE_FOR = Map.of( Role.PRESIDENT, Set.of(Role.VICE_PRESIDENT, Role.COUNCIL, Role.COMMON), - Role.VICE_PRESIDENT, Set.of(Role.PRESIDENT) - ); + Role.VICE_PRESIDENT, Set.of(Role.PRESIDENT)); private static final Set MOCK_DELEGATABLE_ROLES = Set.of(ADMIN, Role.PRESIDENT, Role.VICE_PRESIDENT); @@ -163,8 +177,8 @@ private void withMockedRolePolicy(Role delegatedRole, Runnable assertions) { rolePolicyMockedStatic.when(RolePolicy::getDelegatableRoles) .thenReturn(MOCK_DELEGATABLE_ROLES); - Stream.concat(delegator.getRoles().stream(), delegatee.getRoles().stream()).forEach(role -> - rolePolicyMockedStatic.when(() -> getRolePriority(role)) + Stream.concat(delegator.getRoles().stream(), delegatee.getRoles().stream()) + .forEach(role -> rolePolicyMockedStatic.when(() -> getRolePriority(role)) .thenReturn(MOCK_ROLE_PRIORITY.get(role))); rolePolicyMockedStatic.when(() -> canAssign(any(), any())) @@ -179,20 +193,16 @@ private void withMockedRolePolicy(Role delegatedRole, Runnable assertions) { private void assertValidatorSuccess(Role delegatedRole) { DelegatableRoleValidator validator = createValidator(delegatedRole); - withMockedRolePolicy(delegatedRole, () -> - assertThatCode(validator::validate) - .doesNotThrowAnyException() - ); + withMockedRolePolicy(delegatedRole, () -> assertThatCode(validator::validate) + .doesNotThrowAnyException()); } private void assertValidatorFail(Role delegatedRole) { DelegatableRoleValidator validator = createValidator(delegatedRole); - withMockedRolePolicy(delegatedRole, () -> - assertThatThrownBy(validator::validate) - .isInstanceOf(UnauthorizedException.class) - .hasMessageContaining(MessageUtil.DELEGATE_ROLE_NOT_ALLOWED) - .extracting("errorCode") - .isEqualTo(ErrorCode.ASSIGN_ROLE_NOT_ALLOWED) - ); + withMockedRolePolicy(delegatedRole, () -> assertThatThrownBy(validator::validate) + .isInstanceOf(UnauthorizedException.class) + .hasMessageContaining(MessageUtil.DELEGATE_ROLE_NOT_ALLOWED) + .extracting("errorCode") + .isEqualTo(ErrorCode.ASSIGN_ROLE_NOT_ALLOWED)); } } diff --git a/app-main/src/test/java/net/causw/app/main/domain/validation/GrantableRoleValidatorTest.java b/app-main/src/test/java/net/causw/app/main/domain/validation/GrantableRoleValidatorTest.java index 18713ab64..8bd333d12 100644 --- a/app-main/src/test/java/net/causw/app/main/domain/validation/GrantableRoleValidatorTest.java +++ b/app-main/src/test/java/net/causw/app/main/domain/validation/GrantableRoleValidatorTest.java @@ -1,10 +1,29 @@ package net.causw.app.main.domain.validation; import static java.util.Map.entry; -import static net.causw.app.main.domain.user.account.enums.user.Role.*; -import static net.causw.app.main.domain.user.account.policy.RolePolicy.*; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; +import static net.causw.app.main.domain.user.account.enums.user.Role.ADMIN; +import static net.causw.app.main.domain.user.account.enums.user.Role.COMMON; +import static net.causw.app.main.domain.user.account.enums.user.Role.COUNCIL; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_1; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_2; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_3; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_4; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_ALUMNI; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_CIRCLE; +import static net.causw.app.main.domain.user.account.enums.user.Role.NONE; +import static net.causw.app.main.domain.user.account.enums.user.Role.PRESIDENT; +import static net.causw.app.main.domain.user.account.enums.user.Role.PROFESSOR; +import static net.causw.app.main.domain.user.account.enums.user.Role.VICE_PRESIDENT; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.canAssign; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.getGrantableRoles; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.getProxyDelegatableRoles; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.getRolePriority; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.getRolesAssignableFor; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.isPrivilegeInverted; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.ArgumentMatchers.any; import java.util.EnumSet; import java.util.Map; @@ -18,11 +37,11 @@ import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; -import net.causw.app.main.domain.user.account.util.GrantableRoleValidator; +import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.enums.user.Role; -import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; import net.causw.app.main.domain.user.account.policy.RolePolicy; +import net.causw.app.main.domain.user.account.util.GrantableRoleValidator; import net.causw.app.main.util.ObjectFixtures; import net.causw.global.constant.MessageUtil; import net.causw.global.exception.ErrorCode; @@ -49,35 +68,27 @@ public class GrantableRoleValidatorTest { entry(NONE, 100), entry(LEADER_CIRCLE, 5), - entry(PROFESSOR, 6) - ); + entry(PROFESSOR, 6)); private static final Map> MOCK_ROLES_ASSIGNABLE_FOR = Map.of( Role.PRESIDENT, Set.of(Role.VICE_PRESIDENT, Role.COUNCIL, Role.COMMON), - Role.COMMON, EnumSet.allOf(Role.class) - ); + Role.COMMON, EnumSet.allOf(Role.class)); private static final Map> MOCK_GRANTABLE_ROLES = Map.of( ADMIN, Set.of( Role.PRESIDENT, LEADER_ALUMNI, - Role.COMMON - ), + Role.COMMON), Role.PRESIDENT, Set.of( - Role.COMMON - ) - ); + Role.COMMON)); private static final Map> MOCK_PROXY_DELEGATABLE_ROLES = Map.of( ADMIN, Set.of( - Role.PRESIDENT - ), + Role.PRESIDENT), Role.PRESIDENT, Set.of( - Role.VICE_PRESIDENT - ) - ); + Role.VICE_PRESIDENT)); // 부여 @Test @@ -252,8 +263,8 @@ private void withMockedRolePolicyForGrantable(Role grantedRole, Runnable asserti rolePolicyMockedStatic.when(() -> getRolesAssignableFor(grantedRole)) .thenReturn(MOCK_ROLES_ASSIGNABLE_FOR.getOrDefault(grantedRole, Set.of(Role.COMMON))); - Stream.concat(grantor.getRoles().stream(), grantee.getRoles().stream()).forEach(role -> - rolePolicyMockedStatic.when(() -> getRolePriority(role)) + Stream.concat(grantor.getRoles().stream(), grantee.getRoles().stream()) + .forEach(role -> rolePolicyMockedStatic.when(() -> getRolePriority(role)) .thenReturn(MOCK_ROLE_PRIORITY.get(role))); rolePolicyMockedStatic.when(() -> canAssign(any(), any())) @@ -268,20 +279,16 @@ private void withMockedRolePolicyForGrantable(Role grantedRole, Runnable asserti private void assertValidatorSuccess(Role grantedRole) { GrantableRoleValidator validator = createGrantableValidator(grantedRole); - withMockedRolePolicyForGrantable(grantedRole, () -> - assertThatCode(validator::validate) - .doesNotThrowAnyException() - ); + withMockedRolePolicyForGrantable(grantedRole, () -> assertThatCode(validator::validate) + .doesNotThrowAnyException()); } private void assertValidatorFail(Role grantedRole) { GrantableRoleValidator validator = createGrantableValidator(grantedRole); - withMockedRolePolicyForGrantable(grantedRole, () -> - assertThatThrownBy(validator::validate) - .isInstanceOf(UnauthorizedException.class) - .hasMessageContaining(MessageUtil.GRANT_ROLE_NOT_ALLOWED) - .extracting("errorCode") - .isEqualTo(ErrorCode.ASSIGN_ROLE_NOT_ALLOWED) - ); + withMockedRolePolicyForGrantable(grantedRole, () -> assertThatThrownBy(validator::validate) + .isInstanceOf(UnauthorizedException.class) + .hasMessageContaining(MessageUtil.GRANT_ROLE_NOT_ALLOWED) + .extracting("errorCode") + .isEqualTo(ErrorCode.ASSIGN_ROLE_NOT_ALLOWED)); } } diff --git a/app-main/src/test/java/net/causw/app/main/infrastructure/security/SecurityEndpointsTest.java b/app-main/src/test/java/net/causw/app/main/infrastructure/security/SecurityEndpointsTest.java index 16e4952ad..301d10521 100644 --- a/app-main/src/test/java/net/causw/app/main/infrastructure/security/SecurityEndpointsTest.java +++ b/app-main/src/test/java/net/causw/app/main/infrastructure/security/SecurityEndpointsTest.java @@ -1,7 +1,11 @@ package net.causw.app.main.infrastructure.security; -import static net.causw.app.main.core.security.SecurityEndpoints.*; -import static org.assertj.core.api.Assertions.*; +import static net.causw.app.main.core.security.SecurityEndpoints.ACTIVE_USER_ENDPOINTS; +import static net.causw.app.main.core.security.SecurityEndpoints.AUTHENTICATED_ENDPOINTS; +import static net.causw.app.main.core.security.SecurityEndpoints.CERTIFIED_USER_ENDPOINTS; +import static net.causw.app.main.core.security.SecurityEndpoints.PUBLIC_ENDPOINTS; +import static net.causw.app.main.core.security.SecurityEndpoints.SecurityEndpoint; +import static org.assertj.core.api.Assertions.assertThat; import java.util.HashMap; import java.util.HashSet; @@ -20,8 +24,7 @@ public class SecurityEndpointsTest { "PUBLIC", PUBLIC_ENDPOINTS, "AUTHENTICATED", AUTHENTICATED_ENDPOINTS, "ACTIVE_USER", ACTIVE_USER_ENDPOINTS, - "CERTIFIED_USER", CERTIFIED_USER_ENDPOINTS - ); + "CERTIFIED_USER", CERTIFIED_USER_ENDPOINTS); @ParameterizedTest @MethodSource("getEndpointGroups") diff --git a/app-main/src/test/java/net/causw/app/main/infrastructure/security/SecurityServiceTest.java b/app-main/src/test/java/net/causw/app/main/infrastructure/security/SecurityServiceTest.java index 623ff1492..d335fdcd2 100644 --- a/app-main/src/test/java/net/causw/app/main/infrastructure/security/SecurityServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/infrastructure/security/SecurityServiceTest.java @@ -1,8 +1,8 @@ package net.causw.app.main.infrastructure.security; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -14,12 +14,12 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.test.context.junit.jupiter.SpringExtension; +import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.domain.user.account.enums.user.RoleGroup; import net.causw.app.main.domain.user.account.enums.user.UserState; -import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; -import net.causw.app.main.domain.user.auth.util.SecurityHelper; import net.causw.app.main.domain.user.auth.service.SecurityService; +import net.causw.app.main.domain.user.auth.util.SecurityHelper; import net.causw.app.main.util.WithMockCustomUser; @ExtendWith({MockitoExtension.class, SpringExtension.class}) diff --git a/app-main/src/test/java/net/causw/app/main/infrastructure/security/WebSecurityConfigTest.java b/app-main/src/test/java/net/causw/app/main/infrastructure/security/WebSecurityConfigTest.java index 512abb744..16ce6b544 100644 --- a/app-main/src/test/java/net/causw/app/main/infrastructure/security/WebSecurityConfigTest.java +++ b/app-main/src/test/java/net/causw/app/main/infrastructure/security/WebSecurityConfigTest.java @@ -1,8 +1,8 @@ package net.causw.app.main.infrastructure.security; -import static net.causw.app.main.core.security.SecurityEndpoints.*; -import static org.assertj.core.api.Assertions.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static net.causw.app.main.core.security.SecurityEndpoints.SecurityEndpoint; +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import java.util.Arrays; import java.util.Objects; @@ -27,15 +27,15 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import net.causw.app.main.domain.user.account.enums.user.Role; -import net.causw.app.main.domain.user.account.enums.user.UserState; -import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; import net.causw.app.main.core.security.CustomAuthenticationEntryPoint; import net.causw.app.main.core.security.CustomAuthorizationManager; import net.causw.app.main.core.security.JwtTokenProvider; import net.causw.app.main.core.security.SecurityEndpoints; -import net.causw.app.main.domain.user.auth.service.SecurityService; import net.causw.app.main.core.security.WebSecurityConfig; +import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; +import net.causw.app.main.domain.user.account.enums.user.Role; +import net.causw.app.main.domain.user.account.enums.user.UserState; +import net.causw.app.main.domain.user.auth.service.SecurityService; import net.causw.app.main.util.DummyController; import net.causw.app.main.util.WithMockCustomUser; @@ -152,11 +152,10 @@ private HttpMethod[] getHttpMethods(SecurityEndpoint endpoint) { private HttpMethod[] getAllHttpMethodsWithoutRegistered(String pattern) { Set registeredMethods = Stream.of( - SecurityEndpoints.PUBLIC_ENDPOINTS, - SecurityEndpoints.AUTHENTICATED_ENDPOINTS, - SecurityEndpoints.ACTIVE_USER_ENDPOINTS, - SecurityEndpoints.CERTIFIED_USER_ENDPOINTS - ) + SecurityEndpoints.PUBLIC_ENDPOINTS, + SecurityEndpoints.AUTHENTICATED_ENDPOINTS, + SecurityEndpoints.ACTIVE_USER_ENDPOINTS, + SecurityEndpoints.CERTIFIED_USER_ENDPOINTS) .flatMap(Stream::of) .filter(endpoint -> pattern.equals(endpoint.pattern())) .map(SecurityEndpoint::httpMethod) diff --git a/app-main/src/test/java/net/causw/app/main/service/board/BoardServiceTest.java b/app-main/src/test/java/net/causw/app/main/service/board/BoardServiceTest.java index fc30473a2..dd3e07a21 100644 --- a/app-main/src/test/java/net/causw/app/main/service/board/BoardServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/board/BoardServiceTest.java @@ -1,8 +1,11 @@ package net.causw.app.main.service.board; -import static org.assertj.core.api.Assertions.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.BDDMockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.BDDMockito.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.never; +import static org.mockito.BDDMockito.then; import java.util.List; import java.util.Optional; @@ -16,15 +19,15 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import net.causw.app.main.domain.community.board.entity.Board; -import net.causw.app.main.domain.notification.notification.entity.UserBoardSubscribe; -import net.causw.app.main.domain.community.board.service.BoardService; -import net.causw.app.main.domain.user.account.entity.user.User; -import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; import net.causw.app.main.api.dto.board.BoardCreateRequestDto; import net.causw.app.main.api.dto.board.BoardResponseDto; +import net.causw.app.main.domain.community.board.entity.Board; import net.causw.app.main.domain.community.board.repository.BoardRepository; +import net.causw.app.main.domain.community.board.service.BoardService; +import net.causw.app.main.domain.notification.notification.entity.UserBoardSubscribe; import net.causw.app.main.domain.notification.notification.repository.UserBoardSubscribeRepository; +import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; +import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.repository.user.UserRepository; import net.causw.app.main.util.ObjectFixtures; import net.causw.global.constant.StaticValue; @@ -157,4 +160,3 @@ void getBoardSubscribeExcludeGraduated() { } } } - diff --git a/app-main/src/test/java/net/causw/app/main/service/calendar/CalendarServiceTest.java b/app-main/src/test/java/net/causw/app/main/service/calendar/CalendarServiceTest.java index ccb598090..eb2d1b306 100644 --- a/app-main/src/test/java/net/causw/app/main/service/calendar/CalendarServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/calendar/CalendarServiceTest.java @@ -1,7 +1,12 @@ package net.causw.app.main.service.calendar; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.BDDMockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.BDDMockito.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.never; +import static org.mockito.BDDMockito.times; +import static org.mockito.BDDMockito.verify; import java.util.Optional; @@ -14,15 +19,15 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import net.causw.app.main.api.dto.calendar.CalendarResponseDto; import net.causw.app.main.domain.asset.file.entity.UuidFile; import net.causw.app.main.domain.asset.file.entity.joinEntity.CalendarAttachImage; -import net.causw.app.main.domain.campus.schedule.entity.Calendar; import net.causw.app.main.domain.asset.file.enums.FilePath; -import net.causw.app.main.api.dto.calendar.CalendarResponseDto; -import net.causw.app.main.domain.campus.schedule.repository.CalendarRepository; import net.causw.app.main.domain.asset.file.repository.CalendarAttachImageRepository; -import net.causw.app.main.domain.campus.schedule.service.CalendarService; import net.causw.app.main.domain.asset.file.service.UuidFileService; +import net.causw.app.main.domain.campus.schedule.entity.Calendar; +import net.causw.app.main.domain.campus.schedule.repository.CalendarRepository; +import net.causw.app.main.domain.campus.schedule.service.CalendarService; import net.causw.global.constant.MessageUtil; import net.causw.global.exception.BadRequestException; @@ -56,8 +61,7 @@ void setUp() { "fileUrl", "rawFileName", "png", - FilePath.CALENDAR - ); + FilePath.CALENDAR); mockCalendar = Calendar.of(2025, 3, mockUuidFile); mockAttachImage = mockCalendar.getCalendarAttachImage(); diff --git a/app-main/src/test/java/net/causw/app/main/service/crawler/CrawledNoticeFixture.java b/app-main/src/test/java/net/causw/app/main/service/crawler/CrawledNoticeFixture.java index 5bdd616e8..48fb017fc 100644 --- a/app-main/src/test/java/net/causw/app/main/service/crawler/CrawledNoticeFixture.java +++ b/app-main/src/test/java/net/causw/app/main/service/crawler/CrawledNoticeFixture.java @@ -17,8 +17,7 @@ public static CrawledNotice newNotice() { "관리자", LocalDate.now().toString(), null, - Collections.emptyList() - ); + Collections.emptyList()); notice.setIsUpdated(true); return notice; } @@ -33,8 +32,7 @@ public static CrawledNotice updatedNotice() { "관리자", LocalDate.now().toString(), null, - Collections.emptyList() - ); + Collections.emptyList()); } // 기존 공지사항 (DB에 저장된 버전) @@ -47,11 +45,10 @@ public static CrawledNotice existingNotice() { "관리자", LocalDate.now().toString(), null, - Collections.emptyList() - ); + Collections.emptyList()); notice.setIsUpdated(false); // 기존 해시 설정 (다른 해시로 설정하여 변경 감지) notice.updateContent("기존 공지사항", "기존 내용입니다.", "oldContentHash"); return notice; } -} \ No newline at end of file +} \ No newline at end of file diff --git a/app-main/src/test/java/net/causw/app/main/service/crawler/CrawledToPostTransferServiceTest.java b/app-main/src/test/java/net/causw/app/main/service/crawler/CrawledToPostTransferServiceTest.java index fef3a20c3..09e66ed1d 100644 --- a/app-main/src/test/java/net/causw/app/main/service/crawler/CrawledToPostTransferServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/crawler/CrawledToPostTransferServiceTest.java @@ -1,7 +1,12 @@ package net.causw.app.main.service.crawler; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.BDDMockito.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.mock; +import static org.mockito.BDDMockito.never; +import static org.mockito.BDDMockito.verify; +import static org.mockito.BDDMockito.when; import java.util.Collections; import java.util.List; @@ -17,15 +22,15 @@ import org.mockito.quality.Strictness; import net.causw.app.main.domain.community.board.entity.Board; -import net.causw.app.main.domain.integration.crawled.entity.CrawledNotice; +import net.causw.app.main.domain.community.board.repository.BoardRepository; import net.causw.app.main.domain.community.post.entity.Post; +import net.causw.app.main.domain.community.post.repository.PostRepository; +import net.causw.app.main.domain.integration.crawled.entity.CrawledNotice; +import net.causw.app.main.domain.integration.crawled.repository.CrawledNoticeRepository; import net.causw.app.main.domain.integration.crawled.service.CrawledToPostTransferService; +import net.causw.app.main.domain.notification.notification.service.BoardNotificationService; import net.causw.app.main.domain.user.account.entity.user.User; -import net.causw.app.main.domain.community.board.repository.BoardRepository; -import net.causw.app.main.domain.integration.crawled.repository.CrawledNoticeRepository; -import net.causw.app.main.domain.community.post.repository.PostRepository; import net.causw.app.main.domain.user.account.repository.user.UserRepository; -import net.causw.app.main.domain.notification.notification.service.BoardNotificationService; import net.causw.global.constant.StaticValue; @ExtendWith(MockitoExtension.class) @@ -142,4 +147,4 @@ private Post createMockPost(String title) { when(post.getTitle()).thenReturn(title); return post; } -} \ No newline at end of file +} \ No newline at end of file diff --git a/app-main/src/test/java/net/causw/app/main/service/crawler/CrawlingAndSavingServiceTest.java b/app-main/src/test/java/net/causw/app/main/service/crawler/CrawlingAndSavingServiceTest.java index ca52452f7..2cc351a00 100644 --- a/app-main/src/test/java/net/causw/app/main/service/crawler/CrawlingAndSavingServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/crawler/CrawlingAndSavingServiceTest.java @@ -1,8 +1,10 @@ package net.causw.app.main.service.crawler; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.BDDMockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.never; +import static org.mockito.BDDMockito.verify; import java.util.List; import java.util.Optional; @@ -82,7 +84,7 @@ void crawlAndDetectUpdates_shouldNotSaveWhenContentSame() { existingNotice.updateContent( crawledNotice.getTitle(), crawledNotice.getContent(), - crawledNotice.getContentHash() // 크롤링된 것과 같은 해시 + crawledNotice.getContentHash() // 크롤링된 것과 같은 해시 ); existingNotice.setIsUpdated(false); @@ -97,4 +99,4 @@ void crawlAndDetectUpdates_shouldNotSaveWhenContentSame() { verify(crawledNoticeRepository, never()).saveAll(any()); assertThat(existingNotice.getIsUpdated()).isFalse(); } -} \ No newline at end of file +} \ No newline at end of file diff --git a/app-main/src/test/java/net/causw/app/main/service/crawler/JsoupCrawlerTest.java b/app-main/src/test/java/net/causw/app/main/service/crawler/JsoupCrawlerTest.java index 2b6bf89d9..49dd92089 100644 --- a/app-main/src/test/java/net/causw/app/main/service/crawler/JsoupCrawlerTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/crawler/JsoupCrawlerTest.java @@ -1,7 +1,13 @@ package net.causw.app.main.service.crawler; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.Mockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.Mockito.anyString; +import static org.mockito.Mockito.atLeast; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import java.io.IOException; import java.util.List; @@ -89,4 +95,4 @@ void crawl_shouldThrowException_whenNetworkError() throws IOException { } } } -} \ No newline at end of file +} \ No newline at end of file diff --git a/app-main/src/test/java/net/causw/app/main/service/event/EventServiceTest.java b/app-main/src/test/java/net/causw/app/main/service/event/EventServiceTest.java index 1fc92baae..c0bce3f1a 100644 --- a/app-main/src/test/java/net/causw/app/main/service/event/EventServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/event/EventServiceTest.java @@ -1,8 +1,11 @@ package net.causw.app.main.service.event; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.BDDMockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.never; +import static org.mockito.BDDMockito.verify; import java.util.List; import java.util.Optional; @@ -19,16 +22,16 @@ import org.springframework.mock.web.MockMultipartFile; import org.springframework.web.multipart.MultipartFile; -import net.causw.app.main.domain.asset.file.entity.UuidFile; -import net.causw.app.main.domain.campus.event.entity.Event; -import net.causw.app.main.domain.asset.file.enums.FilePath; import net.causw.app.main.api.dto.event.EventCreateRequestDto; import net.causw.app.main.api.dto.event.EventResponseDto; import net.causw.app.main.api.dto.event.EventUpdateRequestDto; import net.causw.app.main.api.dto.event.EventsResponseDto; +import net.causw.app.main.domain.asset.file.entity.UuidFile; +import net.causw.app.main.domain.asset.file.enums.FilePath; +import net.causw.app.main.domain.asset.file.service.UuidFileService; +import net.causw.app.main.domain.campus.event.entity.Event; import net.causw.app.main.domain.campus.event.repository.EventRepository; import net.causw.app.main.domain.campus.event.service.EventService; -import net.causw.app.main.domain.asset.file.service.UuidFileService; import net.causw.global.constant.MessageUtil; import net.causw.global.constant.StaticValue; import net.causw.global.exception.BadRequestException; @@ -60,12 +63,10 @@ void setUp() { "fileUrl", "rawFileName", "png", - FilePath.EVENT - ); + FilePath.EVENT); mockEvents = List.of( Event.of("url2", mockUuidFile, false), - Event.of("url1", mockUuidFile, false) - ); + Event.of("url1", mockUuidFile, false)); } @Test @@ -114,25 +115,21 @@ class EventCreateTest { void setUp() { mockEventCreateRequestDto = new EventCreateRequestDto("url1"); mockMultiFile = new MockMultipartFile( - "image1" - , "image" + ".png", + "image1", "image" + ".png", "png", - "file".getBytes() - ); + "file".getBytes()); mockUuidFile = UuidFile.of( "uuid", "fileKey", "fileUrl", mockMultiFile.getName(), mockMultiFile.getContentType(), - FilePath.CALENDAR - ); + FilePath.CALENDAR); mockEvent = Event.of( mockEventCreateRequestDto.getUrl(), mockUuidFile, - false - ); + false); } @Test @@ -168,8 +165,7 @@ void createEventFailed() { .mapToObj(i -> Event.of( mockEventCreateRequestDto.getUrl() + i, // 각 이벤트마다 URL 다르게 설정 mockUuidFile, - false - )) + false)) .toList(); given(eventRepository.findByIsDeletedIsFalseOrderByCreatedAtDesc()) .willReturn(mockEvents); @@ -210,8 +206,7 @@ void setUp() { "uuid", "fileKey", "fileUrl", previousMockMultipartFile.getName(), previousMockMultipartFile.getContentType(), - FilePath.CALENDAR - ); + FilePath.CALENDAR); mockEvent = Event.of(eventUpdateRequestDto.getUrl(), mockUuidFile, false); } @@ -228,8 +223,7 @@ void updateEventSuccess() { "updatedFileUrl", toBeUpdateMockMultipartFile.getName(), toBeUpdateMockMultipartFile.getContentType(), - FilePath.EVENT - ); + FilePath.EVENT); given(uuidFileService.updateFile(mockUuidFile, toBeUpdateMockMultipartFile, FilePath.EVENT)).willReturn(updatedUuidFile); @@ -295,8 +289,7 @@ private void givenWhenPreviousEventExist() { private MultipartFile createMockMultipartFile(final String name, final String content) { return new MockMultipartFile( - name, name + ".png", "png", content.getBytes() - ); + name, name + ".png", "png", content.getBytes()); } } @@ -321,8 +314,7 @@ void setUp() { "uuid", "fileKey", "fileUrl", previousMockMultipartFile.getName(), previousMockMultipartFile.getContentType(), - FilePath.CALENDAR - ); + FilePath.CALENDAR); mockEvent = Event.of(eventUpdateRequestDto.getUrl(), mockUuidFile, false); } @@ -371,8 +363,7 @@ private void givenWhenPreviousEventExist() { private MultipartFile createMockMultipartFile(final String name, final String content) { return new MockMultipartFile( - name, name + ".png", "png", content.getBytes() - ); + name, name + ".png", "png", content.getBytes()); } } } diff --git a/app-main/src/test/java/net/causw/app/main/service/excel/ExcelAbstractServiceTest.java b/app-main/src/test/java/net/causw/app/main/service/excel/ExcelAbstractServiceTest.java index 6581ce221..380674b55 100644 --- a/app-main/src/test/java/net/causw/app/main/service/excel/ExcelAbstractServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/excel/ExcelAbstractServiceTest.java @@ -1,7 +1,8 @@ package net.causw.app.main.service.excel; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.Mockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.Mockito.mock; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -89,8 +90,7 @@ void testGenerateExcelWithEmptyHeaderListFailure(ExcelAbstractService service sheetDataMap.put(sheetName, dataList); // when & then - assertThatThrownBy(() -> - service.generateExcel(response, fileName, headerStringList, sheetDataMap)) + assertThatThrownBy(() -> service.generateExcel(response, fileName, headerStringList, sheetDataMap)) .as("헤더가 비어 있으면 예외가 발생해야 합니다.") .isInstanceOf(InternalServerException.class); } @@ -106,8 +106,7 @@ void testGenerateExcelWithNullHeaderListFailure(ExcelAbstractService service, sheetDataMap.put(sheetName, dataList); // when & then - assertThatThrownBy(() -> - service.generateExcel(response, fileName, headerStringList, sheetDataMap)) + assertThatThrownBy(() -> service.generateExcel(response, fileName, headerStringList, sheetDataMap)) .as("헤더가 null이면 예외가 발생해야 합니다.") .isInstanceOf(InternalServerException.class); } @@ -159,8 +158,7 @@ private void verifySheet(Sheet sheet, int expectedRowNum) { sheet.iterator().forEachRemaining( row -> assertThat(row) .as("모든 행은 null이 아니어야 합니다.") - .isNotNull() - ); + .isNotNull()); } private void verifyHeaderRow(Row row, int expectedColNum) { @@ -180,8 +178,7 @@ private void verifyHeaderRow(Row row, int expectedColNum) { assertThat(cell.getStringCellValue()) .as("실제 엑셀의 헤더와 headerStringList의 내용이 일치해야 합니다.") .isNotNull().isEqualTo(headerStringList.get(cell.getColumnIndex())); - } - ); + }); } private void verifyDataRow(Row row) { @@ -195,7 +192,6 @@ private void verifyDataRow(Row row) { assertThat(cell.getCellType()) .as("모든 셀은 STRING 타입이어야 합니다.") .isNotNull().isEqualTo(CellType.STRING); - } - ); + }); } } diff --git a/app-main/src/test/java/net/causw/app/main/service/notification/BoardNotificationServiceTest.java b/app-main/src/test/java/net/causw/app/main/service/notification/BoardNotificationServiceTest.java index 429125256..5af466066 100644 --- a/app-main/src/test/java/net/causw/app/main/service/notification/BoardNotificationServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/notification/BoardNotificationServiceTest.java @@ -1,13 +1,13 @@ package net.causw.app.main.service.notification; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.doAnswer; import static org.mockito.BDDMockito.doThrow; +import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.mock; import static org.mockito.BDDMockito.never; import static org.mockito.BDDMockito.verify; -import static org.mockito.BDDMockito.*; import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.eq; @@ -24,18 +24,18 @@ import org.mockito.junit.jupiter.MockitoExtension; import net.causw.app.main.domain.community.board.entity.Board; +import net.causw.app.main.domain.community.post.entity.Post; import net.causw.app.main.domain.notification.notification.entity.Notification; import net.causw.app.main.domain.notification.notification.entity.NotificationLog; import net.causw.app.main.domain.notification.notification.entity.UserBoardSubscribe; -import net.causw.app.main.domain.community.post.entity.Post; -import net.causw.app.main.domain.notification.notification.service.BoardNotificationService; -import net.causw.app.main.domain.notification.notification.service.FirebasePushNotificationService; -import net.causw.app.main.domain.user.account.entity.user.User; -import net.causw.app.main.shared.infra.firebase.FcmUtils; import net.causw.app.main.domain.notification.notification.repository.NotificationLogRepository; import net.causw.app.main.domain.notification.notification.repository.NotificationRepository; import net.causw.app.main.domain.notification.notification.repository.UserBoardSubscribeRepository; +import net.causw.app.main.domain.notification.notification.service.BoardNotificationService; +import net.causw.app.main.domain.notification.notification.service.FirebasePushNotificationService; +import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.relation.service.UserBlockEntityService; +import net.causw.app.main.shared.infra.firebase.FcmUtils; import net.causw.app.main.util.ObjectFixtures; import com.google.firebase.messaging.FirebaseMessagingException; diff --git a/app-main/src/test/java/net/causw/app/main/service/notification/CeremonyNotificationServiceTest.java b/app-main/src/test/java/net/causw/app/main/service/notification/CeremonyNotificationServiceTest.java index ba426a769..8a1be6b8e 100644 --- a/app-main/src/test/java/net/causw/app/main/service/notification/CeremonyNotificationServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/notification/CeremonyNotificationServiceTest.java @@ -1,8 +1,15 @@ package net.causw.app.main.service.notification; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.BDDMockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.doAnswer; +import static org.mockito.BDDMockito.doThrow; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.mock; +import static org.mockito.BDDMockito.never; +import static org.mockito.BDDMockito.verify; import java.time.LocalDate; import java.util.HashSet; @@ -18,22 +25,22 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import net.causw.app.main.api.dto.user.UserCreateRequestDto; import net.causw.app.main.domain.community.ceremony.entity.Ceremony; +import net.causw.app.main.domain.community.ceremony.enums.CeremonyCategory; +import net.causw.app.main.domain.community.ceremony.repository.CeremonyRepository; import net.causw.app.main.domain.notification.notification.entity.CeremonyNotificationSetting; import net.causw.app.main.domain.notification.notification.entity.Notification; import net.causw.app.main.domain.notification.notification.entity.NotificationLog; +import net.causw.app.main.domain.notification.notification.repository.CeremonyNotificationSettingRepository; +import net.causw.app.main.domain.notification.notification.repository.NotificationLogRepository; +import net.causw.app.main.domain.notification.notification.repository.NotificationRepository; import net.causw.app.main.domain.notification.notification.service.CeremonyNotificationService; import net.causw.app.main.domain.notification.notification.service.FirebasePushNotificationService; import net.causw.app.main.domain.user.account.entity.user.User; -import net.causw.app.main.domain.community.ceremony.enums.CeremonyCategory; import net.causw.app.main.domain.user.account.enums.user.Department; -import net.causw.app.main.api.dto.user.UserCreateRequestDto; -import net.causw.app.main.shared.infra.firebase.FcmUtils; -import net.causw.app.main.domain.community.ceremony.repository.CeremonyRepository; -import net.causw.app.main.domain.notification.notification.repository.CeremonyNotificationSettingRepository; -import net.causw.app.main.domain.notification.notification.repository.NotificationLogRepository; -import net.causw.app.main.domain.notification.notification.repository.NotificationRepository; import net.causw.app.main.domain.user.relation.service.UserBlockEntityService; +import net.causw.app.main.shared.infra.firebase.FcmUtils; import com.google.firebase.messaging.FirebaseMessagingException; diff --git a/app-main/src/test/java/net/causw/app/main/service/notification/CommentNotificationServiceTest.java b/app-main/src/test/java/net/causw/app/main/service/notification/CommentNotificationServiceTest.java index 80a9b7c2e..e1ce6fb2c 100644 --- a/app-main/src/test/java/net/causw/app/main/service/notification/CommentNotificationServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/notification/CommentNotificationServiceTest.java @@ -1,8 +1,16 @@ package net.causw.app.main.service.notification; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.BDDMockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.doAnswer; +import static org.mockito.BDDMockito.doThrow; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.lenient; +import static org.mockito.BDDMockito.mock; +import static org.mockito.BDDMockito.never; +import static org.mockito.BDDMockito.verify; import java.util.HashSet; import java.util.List; @@ -19,18 +27,18 @@ import net.causw.app.main.domain.community.board.entity.Board; import net.causw.app.main.domain.community.comment.entity.ChildComment; import net.causw.app.main.domain.community.comment.entity.Comment; +import net.causw.app.main.domain.community.post.entity.Post; import net.causw.app.main.domain.notification.notification.entity.Notification; import net.causw.app.main.domain.notification.notification.entity.NotificationLog; import net.causw.app.main.domain.notification.notification.entity.UserCommentSubscribe; -import net.causw.app.main.domain.community.post.entity.Post; -import net.causw.app.main.domain.notification.notification.service.CommentNotificationService; -import net.causw.app.main.domain.notification.notification.service.FirebasePushNotificationService; -import net.causw.app.main.domain.user.account.entity.user.User; -import net.causw.app.main.shared.infra.firebase.FcmUtils; import net.causw.app.main.domain.notification.notification.repository.NotificationLogRepository; import net.causw.app.main.domain.notification.notification.repository.NotificationRepository; import net.causw.app.main.domain.notification.notification.repository.UserCommentSubscribeRepository; +import net.causw.app.main.domain.notification.notification.service.CommentNotificationService; +import net.causw.app.main.domain.notification.notification.service.FirebasePushNotificationService; +import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.relation.service.UserBlockEntityService; +import net.causw.app.main.shared.infra.firebase.FcmUtils; import net.causw.app.main.util.ObjectFixtures; import com.google.firebase.messaging.FirebaseMessagingException; diff --git a/app-main/src/test/java/net/causw/app/main/service/notification/NotificationLogServiceTest.java b/app-main/src/test/java/net/causw/app/main/service/notification/NotificationLogServiceTest.java index 75f14f115..6b18e926b 100644 --- a/app-main/src/test/java/net/causw/app/main/service/notification/NotificationLogServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/notification/NotificationLogServiceTest.java @@ -1,8 +1,10 @@ package net.causw.app.main.service.notification; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.BDDMockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.lenient; +import static org.mockito.BDDMockito.verify; import java.lang.reflect.Field; import java.util.Arrays; @@ -21,13 +23,13 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import net.causw.app.main.api.dto.notification.NotificationResponseDto; import net.causw.app.main.domain.notification.notification.entity.Notification; import net.causw.app.main.domain.notification.notification.entity.NotificationLog; -import net.causw.app.main.domain.notification.notification.service.NotificationLogService; -import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.notification.notification.enums.NoticeType; -import net.causw.app.main.api.dto.notification.NotificationResponseDto; import net.causw.app.main.domain.notification.notification.repository.NotificationLogRepository; +import net.causw.app.main.domain.notification.notification.service.NotificationLogService; +import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.shared.pageable.PageableFactory; import net.causw.app.main.util.ObjectFixtures; import net.causw.global.constant.MessageUtil; @@ -197,8 +199,8 @@ void readNotificationNotFound() { given(notificationLogRepository.findByIdAndUser("non-existent-id", mockUser)) .willReturn(java.util.Optional.empty()); - org.assertj.core.api.Assertions.assertThatThrownBy(() -> - notificationLogService.readNotification(mockUser, "non-existent-id")) + org.assertj.core.api.Assertions + .assertThatThrownBy(() -> notificationLogService.readNotification(mockUser, "non-existent-id")) .isInstanceOf(BadRequestException.class) .hasMessageContaining(MessageUtil.NOTIFICATION_LOG_NOT_FOUND); diff --git a/app-main/src/test/java/net/causw/app/main/service/notification/PostNotificationServiceTest.java b/app-main/src/test/java/net/causw/app/main/service/notification/PostNotificationServiceTest.java index c516467fa..5166d779d 100644 --- a/app-main/src/test/java/net/causw/app/main/service/notification/PostNotificationServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/notification/PostNotificationServiceTest.java @@ -1,8 +1,16 @@ package net.causw.app.main.service.notification; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.BDDMockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.doAnswer; +import static org.mockito.BDDMockito.doThrow; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.lenient; +import static org.mockito.BDDMockito.mock; +import static org.mockito.BDDMockito.never; +import static org.mockito.BDDMockito.verify; import java.util.HashSet; import java.util.List; @@ -18,18 +26,18 @@ import net.causw.app.main.domain.community.board.entity.Board; import net.causw.app.main.domain.community.comment.entity.Comment; +import net.causw.app.main.domain.community.post.entity.Post; import net.causw.app.main.domain.notification.notification.entity.Notification; import net.causw.app.main.domain.notification.notification.entity.NotificationLog; import net.causw.app.main.domain.notification.notification.entity.UserPostSubscribe; -import net.causw.app.main.domain.community.post.entity.Post; -import net.causw.app.main.domain.notification.notification.service.FirebasePushNotificationService; -import net.causw.app.main.domain.notification.notification.service.PostNotificationService; -import net.causw.app.main.domain.user.account.entity.user.User; -import net.causw.app.main.shared.infra.firebase.FcmUtils; import net.causw.app.main.domain.notification.notification.repository.NotificationLogRepository; import net.causw.app.main.domain.notification.notification.repository.NotificationRepository; import net.causw.app.main.domain.notification.notification.repository.UserPostSubscribeRepository; +import net.causw.app.main.domain.notification.notification.service.FirebasePushNotificationService; +import net.causw.app.main.domain.notification.notification.service.PostNotificationService; +import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.relation.service.UserBlockEntityService; +import net.causw.app.main.shared.infra.firebase.FcmUtils; import net.causw.app.main.util.ObjectFixtures; import com.google.firebase.messaging.FirebaseMessagingException; diff --git a/app-main/src/test/java/net/causw/app/main/service/post/PostServiceTest.java b/app-main/src/test/java/net/causw/app/main/service/post/PostServiceTest.java index a4b24cb7e..352932d0e 100644 --- a/app-main/src/test/java/net/causw/app/main/service/post/PostServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/post/PostServiceTest.java @@ -1,9 +1,16 @@ package net.causw.app.main.service.post; -import static org.assertj.core.api.Assertions.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.BDDMockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.mock; +import static org.mockito.BDDMockito.times; +import static org.mockito.BDDMockito.verify; +import static org.mockito.BDDMockito.when; import java.util.Collections; import java.util.List; @@ -27,26 +34,26 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; -import net.causw.app.main.domain.community.board.entity.Board; -import net.causw.app.main.domain.community.reaction.entity.LikePost; -import net.causw.app.main.domain.community.post.entity.Post; -import net.causw.app.main.domain.community.post.service.PostEntityService; -import net.causw.app.main.domain.community.post.service.PostService; -import net.causw.app.main.domain.user.account.entity.user.User; -import net.causw.app.main.domain.user.account.enums.user.Role; -import net.causw.app.main.domain.user.account.enums.user.UserState; import net.causw.app.main.api.dto.post.BoardPostsResponseDto; import net.causw.app.main.api.dto.post.PostsResponseDto; +import net.causw.app.main.domain.community.board.entity.Board; import net.causw.app.main.domain.community.board.repository.BoardRepository; import net.causw.app.main.domain.community.board.repository.FavoriteBoardRepository; -import net.causw.app.main.domain.notification.notification.repository.UserBoardSubscribeRepository; -import net.causw.app.main.domain.community.reaction.repository.FavoritePostRepository; -import net.causw.app.main.domain.community.reaction.repository.LikePostRepository; +import net.causw.app.main.domain.community.post.entity.Post; import net.causw.app.main.domain.community.post.repository.PostRepository; import net.causw.app.main.domain.community.post.repository.query.PostQueryRepository; import net.causw.app.main.domain.community.post.repository.query.PostQueryResult; -import net.causw.app.main.shared.pageable.PageableFactory; +import net.causw.app.main.domain.community.post.service.PostEntityService; +import net.causw.app.main.domain.community.post.service.PostService; +import net.causw.app.main.domain.community.reaction.entity.LikePost; +import net.causw.app.main.domain.community.reaction.repository.FavoritePostRepository; +import net.causw.app.main.domain.community.reaction.repository.LikePostRepository; +import net.causw.app.main.domain.notification.notification.repository.UserBoardSubscribeRepository; +import net.causw.app.main.domain.user.account.entity.user.User; +import net.causw.app.main.domain.user.account.enums.user.Role; +import net.causw.app.main.domain.user.account.enums.user.UserState; import net.causw.app.main.domain.user.relation.service.UserBlockEntityService; +import net.causw.app.main.shared.pageable.PageableFactory; import net.causw.app.main.util.ObjectFixtures; import net.causw.global.constant.MessageUtil; import net.causw.global.constant.StaticValue; @@ -299,16 +306,14 @@ private static Stream provideUnauthorizedUserCases() { Arguments.of(Role.NONE, UserState.ACTIVE), Arguments.of(Role.COMMON, UserState.INACTIVE), Arguments.of(Role.COMMON, UserState.DROP), - Arguments.of(Role.COMMON, UserState.DELETED) - ); + Arguments.of(Role.COMMON, UserState.DELETED)); } private static Stream provideSearchByKeywordSuccessCases() { return Stream.of( Arguments.of("제목에 키워드 포함", null), Arguments.of(null, "내용에 키워드 포함"), - Arguments.of("제목에 키워드 포함", "내용에 키워드 포함") - ); + Arguments.of("제목에 키워드 포함", "내용에 키워드 포함")); } @DisplayName("인증되지 않은 사용자는 게시글 조회 불가") @@ -332,8 +337,7 @@ void testfindAllPostByDeletedBoard() { board.setIsDeleted(true); //when & then - assertThatThrownBy(() -> - postService.findAllPost(user, boardId, keyword, pageNum)) + assertThatThrownBy(() -> postService.findAllPost(user, boardId, keyword, pageNum)) .isInstanceOf(BadRequestException.class) .extracting("errorCode") .isEqualTo(ErrorCode.TARGET_DELETED); @@ -393,8 +397,7 @@ void testfindAllPostNoResult() { given(pageableFactory.create(anyInt(), anyInt())).willReturn(pageable); given(postQueryRepository.findPostsByBoardWithFilters( - eq(boardId), eq(false), eq(Set.of()), eq(keyword), eq(pageable) - )).willReturn(emptyPage); + eq(boardId), eq(false), eq(Set.of()), eq(keyword), eq(pageable))).willReturn(emptyPage); // when BoardPostsResponseDto result = postService.findAllPost(user, boardId, keyword, pageNum); @@ -463,8 +466,7 @@ void testfindAllPostByAdmin() { private void verifyPost( Page searchedPagedPost, - boolean isDeleted, String title, String content - ) { + boolean isDeleted, String title, String content) { assertThat(searchedPagedPost).isNotNull(); assertThat(searchedPagedPost.getTotalElements()).isEqualTo(1); assertThat(searchedPagedPost.getTotalPages()).isEqualTo(1); @@ -476,8 +478,7 @@ private void verifyPost( () -> assertThat(postResponseDto.getIsDeleted()).isEqualTo(isDeleted), () -> assertThat(postResponseDto.getTitle()).isEqualTo(title), () -> assertThat(postResponseDto.getContent()).isEqualTo(content), - () -> assertThat(postResponseDto.getWriterNickname()).isEqualTo(user.getNickname()) - ); + () -> assertThat(postResponseDto.getWriterNickname()).isEqualTo(user.getNickname())); }); } } diff --git a/app-main/src/test/java/net/causw/app/main/service/report/ReportServiceTest.java b/app-main/src/test/java/net/causw/app/main/service/report/ReportServiceTest.java index 3ffc587b3..8c57c0b38 100644 --- a/app-main/src/test/java/net/causw/app/main/service/report/ReportServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/report/ReportServiceTest.java @@ -1,7 +1,9 @@ package net.causw.app.main.service.report; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.BDDMockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.verify; import java.util.Optional; @@ -19,15 +21,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.test.util.ReflectionTestUtils; -import net.causw.app.main.domain.community.comment.entity.ChildComment; -import net.causw.app.main.domain.community.comment.entity.Comment; -import net.causw.app.main.domain.community.post.entity.Post; -import net.causw.app.main.domain.community.report.entity.Report; -import net.causw.app.main.domain.community.report.service.ReportService; -import net.causw.app.main.domain.user.account.entity.user.User; -import net.causw.app.main.domain.community.report.enums.ReportReason; -import net.causw.app.main.domain.community.report.enums.ReportType; -import net.causw.app.main.domain.user.account.enums.user.UserState; import net.causw.app.main.api.dto.report.ReportCreateRequestDto; import net.causw.app.main.api.dto.report.ReportCreateResponseDto; import net.causw.app.main.api.dto.report.ReportedCommentNativeProjection; @@ -36,10 +29,19 @@ import net.causw.app.main.api.dto.report.ReportedPostResponseDto; import net.causw.app.main.api.dto.report.ReportedUserResponseDto; import net.causw.app.main.api.dto.util.dtoMapper.ReportDtoMapper; +import net.causw.app.main.domain.community.comment.entity.ChildComment; +import net.causw.app.main.domain.community.comment.entity.Comment; import net.causw.app.main.domain.community.comment.repository.ChildCommentRepository; import net.causw.app.main.domain.community.comment.repository.CommentRepository; +import net.causw.app.main.domain.community.post.entity.Post; import net.causw.app.main.domain.community.post.repository.PostRepository; +import net.causw.app.main.domain.community.report.entity.Report; +import net.causw.app.main.domain.community.report.enums.ReportReason; +import net.causw.app.main.domain.community.report.enums.ReportType; import net.causw.app.main.domain.community.report.repository.ReportRepository; +import net.causw.app.main.domain.community.report.service.ReportService; +import net.causw.app.main.domain.user.account.entity.user.User; +import net.causw.app.main.domain.user.account.enums.user.UserState; import net.causw.app.main.domain.user.account.repository.user.UserRepository; import net.causw.app.main.shared.pageable.PageableFactory; import net.causw.app.main.util.ObjectFixtures; diff --git a/app-main/src/test/java/net/causw/app/main/service/user/UserRoleServiceTest.java b/app-main/src/test/java/net/causw/app/main/service/user/UserRoleServiceTest.java index a635fd5ea..9cb81d1e8 100644 --- a/app-main/src/test/java/net/causw/app/main/service/user/UserRoleServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/user/UserRoleServiceTest.java @@ -1,11 +1,27 @@ package net.causw.app.main.service.user; import static java.util.Map.entry; -import static net.causw.app.main.domain.user.account.enums.user.Role.*; -import static net.causw.app.main.domain.user.account.policy.RolePolicy.*; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; +import static net.causw.app.main.domain.user.account.enums.user.Role.ADMIN; +import static net.causw.app.main.domain.user.account.enums.user.Role.COMMON; +import static net.causw.app.main.domain.user.account.enums.user.Role.COUNCIL; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_1; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_2; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_3; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_4; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_ALUMNI; +import static net.causw.app.main.domain.user.account.enums.user.Role.LEADER_CIRCLE; +import static net.causw.app.main.domain.user.account.enums.user.Role.NONE; +import static net.causw.app.main.domain.user.account.enums.user.Role.PRESIDENT; +import static net.causw.app.main.domain.user.account.enums.user.Role.PROFESSOR; +import static net.causw.app.main.domain.user.account.enums.user.Role.VICE_PRESIDENT; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.canAssign; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.getRolePriority; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.getRoleUnique; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.getRolesAssignableFor; +import static net.causw.app.main.domain.user.account.policy.RolePolicy.isPrivilegeInverted; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.Collection; @@ -32,14 +48,14 @@ import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; +import net.causw.app.main.api.dto.user.UserResponseDto; +import net.causw.app.main.api.dto.user.UserUpdateRoleRequestDto; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.domain.user.account.enums.user.UserState; import net.causw.app.main.domain.user.account.policy.RolePolicy; -import net.causw.app.main.domain.user.account.service.UserRoleService; -import net.causw.app.main.api.dto.user.UserResponseDto; -import net.causw.app.main.api.dto.user.UserUpdateRoleRequestDto; import net.causw.app.main.domain.user.account.repository.user.UserRepository; +import net.causw.app.main.domain.user.account.service.UserRoleService; import net.causw.app.main.util.ObjectFixtures; @ExtendWith(MockitoExtension.class) @@ -65,8 +81,7 @@ public class UserRoleServiceTest { entry(NONE, false), entry(LEADER_CIRCLE, false), - entry(PROFESSOR, false) - ); + entry(PROFESSOR, false)); private static final Map MOCK_ROLE_PRIORITY = Map.ofEntries( entry(ADMIN, 0), @@ -82,15 +97,13 @@ public class UserRoleServiceTest { entry(NONE, 100), entry(LEADER_CIRCLE, 5), - entry(PROFESSOR, 6) - ); + entry(PROFESSOR, 6)); private static final Map> MOCK_ROLES_ASSIGNABLE_FOR = Map.of( // 부학생회장과 학생회 권한이 같이 삭제되므로 대상이 일반, 학생회장, 부학생회장 권한까지 설정 가능함. PRESIDENT, Set.of(VICE_PRESIDENT, COUNCIL, COMMON), // 일반 권한의 경우 모두 권한에 설정 가능함. - COMMON, EnumSet.allOf(Role.class) - ); + COMMON, EnumSet.allOf(Role.class)); @Nested class UpdateRoleTest { @@ -270,19 +283,14 @@ class GrantRoleTest { private static final Map> MOCK_GRANTABLE_ROLES = Map.of( ADMIN, Set.of( Role.PRESIDENT, - Role.LEADER_1 - ), + Role.LEADER_1), Role.PRESIDENT, Set.of( - Role.VICE_PRESIDENT - ) - ); + Role.VICE_PRESIDENT)); private static final Map> MOCK_PROXY_DELEGATABLE_ROLES = Map.of( ADMIN, Set.of( - Role.COUNCIL - ) - ); + Role.COUNCIL)); @BeforeEach void setUp() { @@ -417,8 +425,8 @@ private void mockDefaultRolePolicy(MockedStatic rolePolicyMockedStat rolePolicyMockedStatic.when(() -> getRoleUnique(assignedRole)) .thenReturn(MOCK_ROLE_UNIQUE.get(assignedRole)); - Stream.concat(assignerRoles.stream(), assigneeRoles.stream()).forEach(role -> - rolePolicyMockedStatic.when(() -> getRolePriority(role)) + Stream.concat(assignerRoles.stream(), assigneeRoles.stream()) + .forEach(role -> rolePolicyMockedStatic.when(() -> getRolePriority(role)) .thenReturn(MOCK_ROLE_PRIORITY.get(role))); rolePolicyMockedStatic.when(() -> canAssign(any(), any())) diff --git a/app-main/src/test/java/net/causw/app/main/service/user/UserServiceTest.java b/app-main/src/test/java/net/causw/app/main/service/user/UserServiceTest.java index df3f2ad2a..f881ac009 100644 --- a/app-main/src/test/java/net/causw/app/main/service/user/UserServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/user/UserServiceTest.java @@ -1,9 +1,20 @@ package net.causw.app.main.service.user; -import static org.assertj.core.api.Assertions.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.BDDMockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.lenient; +import static org.mockito.BDDMockito.mock; +import static org.mockito.BDDMockito.never; +import static org.mockito.BDDMockito.times; +import static org.mockito.BDDMockito.verify; +import static org.mockito.BDDMockito.when; import java.util.HashSet; import java.util.LinkedHashMap; @@ -26,13 +37,6 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.test.util.ReflectionTestUtils; -import net.causw.app.main.domain.community.reaction.entity.LikePost; -import net.causw.app.main.domain.community.post.entity.Post; -import net.causw.app.main.domain.user.account.entity.user.User; -import net.causw.app.main.domain.user.account.entity.user.UserAdmission; -import net.causw.app.main.domain.user.account.enums.user.Role; -import net.causw.app.main.domain.user.account.enums.user.UserState; -import net.causw.app.main.domain.user.account.service.UserService; import net.causw.app.main.api.dto.post.PostsResponseDto; import net.causw.app.main.api.dto.user.UserCreateRequestDto; import net.causw.app.main.api.dto.user.UserPostsResponseDto; @@ -40,17 +44,24 @@ import net.causw.app.main.api.dto.user.UserSignInResponseDto; import net.causw.app.main.api.dto.util.dtoMapper.PostDtoMapper; import net.causw.app.main.api.dto.util.dtoMapper.UserDtoMapper; -import net.causw.app.main.shared.infra.redis.RedisUtils; import net.causw.app.main.core.security.JwtTokenProvider; +import net.causw.app.main.domain.community.post.entity.Post; +import net.causw.app.main.domain.community.post.repository.PostRepository; +import net.causw.app.main.domain.community.post.service.PostService; +import net.causw.app.main.domain.community.reaction.entity.LikePost; import net.causw.app.main.domain.community.reaction.repository.FavoritePostRepository; import net.causw.app.main.domain.community.reaction.repository.LikePostRepository; -import net.causw.app.main.domain.community.post.repository.PostRepository; +import net.causw.app.main.domain.integration.export.service.UserExcelService; +import net.causw.app.main.domain.user.account.entity.user.User; +import net.causw.app.main.domain.user.account.entity.user.UserAdmission; +import net.causw.app.main.domain.user.account.enums.user.Role; +import net.causw.app.main.domain.user.account.enums.user.UserState; import net.causw.app.main.domain.user.account.repository.user.UserAdmissionRepository; import net.causw.app.main.domain.user.account.repository.user.UserRepository; -import net.causw.app.main.domain.integration.export.service.UserExcelService; -import net.causw.app.main.shared.pageable.PageableFactory; -import net.causw.app.main.domain.community.post.service.PostService; +import net.causw.app.main.domain.user.account.service.UserService; import net.causw.app.main.domain.user.relation.service.UserBlockEntityService; +import net.causw.app.main.shared.infra.redis.RedisUtils; +import net.causw.app.main.shared.pageable.PageableFactory; import net.causw.app.main.util.ObjectFixtures; import net.causw.global.constant.StaticValue; import net.causw.global.exception.BadRequestException; @@ -151,8 +162,8 @@ void testExportActiveUserListToExcelSuccess() { } private LinkedHashMap> captureGeneratedExcelData() { - ArgumentCaptor>> captor = - ArgumentCaptor.forClass(LinkedHashMap.class); + ArgumentCaptor>> captor = ArgumentCaptor + .forClass(LinkedHashMap.class); verify(userExcelService, times(1)) .generateExcel(eq(response), anyString(), anyList(), captor.capture()); @@ -161,8 +172,7 @@ private LinkedHashMap> captureGeneratedExcelData() private void verifyUserResponseDto( List exportedUserList, - UserState userState - ) { + UserState userState) { for (UserResponseDto userResponseDto : exportedUserList) { assertThat(userResponseDto).isNotNull(); assertThat(userResponseDto.getState()) @@ -223,8 +233,7 @@ void findLikePosts_ShouldSuccess() { anyLong(), any(), anyBoolean(), - anyBoolean() - )).willReturn(mockPostDto); + anyBoolean())).willReturn(mockPostDto); given(userDtoMapper.toUserPostsResponseDto(eq(user), any())) .willReturn(expectedResponseDto); @@ -398,8 +407,7 @@ void recoverUser_InactiveUser_Success() { given(jwtTokenProvider.createAccessToken( eq("test-user-id"), eq(Set.of(Role.COMMON)), - eq(UserState.ACTIVE) - )).willReturn("access-token"); + eq(UserState.ACTIVE))).willReturn("access-token"); // when UserSignInResponseDto result = userService.recoverUser("test@cau.ac.kr"); diff --git a/app-main/src/test/java/net/causw/app/main/service/userCouncilFee/UserCouncilFeeServiceTest.java b/app-main/src/test/java/net/causw/app/main/service/userCouncilFee/UserCouncilFeeServiceTest.java index ce1d14f10..21dbe0e1c 100644 --- a/app-main/src/test/java/net/causw/app/main/service/userCouncilFee/UserCouncilFeeServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/userCouncilFee/UserCouncilFeeServiceTest.java @@ -1,8 +1,12 @@ package net.causw.app.main.service.userCouncilFee; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.BDDMockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.times; +import static org.mockito.BDDMockito.verify; import java.util.LinkedHashMap; import java.util.List; @@ -17,13 +21,13 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import net.causw.app.main.api.dto.userCouncilFee.UserCouncilFeeResponseDto; import net.causw.app.main.domain.campus.semester.entity.Semester; +import net.causw.app.main.domain.campus.semester.service.SemesterService; import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFee; -import net.causw.app.main.domain.finance.usercouncilfee.service.UserCouncilFeeService; -import net.causw.app.main.api.dto.userCouncilFee.UserCouncilFeeResponseDto; import net.causw.app.main.domain.finance.usercouncilfee.repository.UserCouncilFeeRepository; +import net.causw.app.main.domain.finance.usercouncilfee.service.UserCouncilFeeService; import net.causw.app.main.domain.integration.export.service.CouncilFeeExcelService; -import net.causw.app.main.domain.campus.semester.service.SemesterService; import net.causw.app.main.util.ObjectFixtures; import jakarta.servlet.http.HttpServletResponse; @@ -68,10 +72,8 @@ void testExportJoinedUserCouncilFeeToExcelTest() { userCouncilFeeService.exportUserCouncilFeeToExcel(response); //then - LinkedHashMap> exportedUserCouncilFeeDataMap - = captureGeneratedExcelData(); - List exportedUserCouncilFeeList - = exportedUserCouncilFeeDataMap.get(sheetName); + LinkedHashMap> exportedUserCouncilFeeDataMap = captureGeneratedExcelData(); + List exportedUserCouncilFeeList = exportedUserCouncilFeeDataMap.get(sheetName); verifyUserCouncilFeeResponseDto( exportedUserCouncilFeeList, userCouncilFee.getUser().getStudentId()); @@ -88,18 +90,16 @@ void testExportNotJoinedUserCouncilFeeToExcelTest() { userCouncilFeeService.exportUserCouncilFeeToExcel(response); //then - LinkedHashMap> exportedUserCouncilFeeDataMap - = captureGeneratedExcelData(); - List exportedUserCouncilFeeList - = exportedUserCouncilFeeDataMap.get(sheetName); + LinkedHashMap> exportedUserCouncilFeeDataMap = captureGeneratedExcelData(); + List exportedUserCouncilFeeList = exportedUserCouncilFeeDataMap.get(sheetName); verifyUserCouncilFeeResponseDto( exportedUserCouncilFeeList, userCouncilFee.getCouncilFeeFakeUser().getStudentId()); } private LinkedHashMap> captureGeneratedExcelData() { - ArgumentCaptor>> captor = - ArgumentCaptor.forClass(LinkedHashMap.class); + ArgumentCaptor>> captor = ArgumentCaptor + .forClass(LinkedHashMap.class); verify(councilFeeExcelService, times(1)) .generateExcel(eq(response), anyString(), anyList(), captor.capture()); @@ -108,8 +108,7 @@ private LinkedHashMap> captureGeneratedE private void verifyUserCouncilFeeResponseDto( List exportedUserCouncilFeeList, - String studentId - ) { + String studentId) { for (UserCouncilFeeResponseDto actual : exportedUserCouncilFeeList) { assertThat(actual).isNotNull(); assertThat(actual.getStudentId()) diff --git a/app-main/src/test/java/net/causw/app/main/service/userInfo/UserInfoServiceTest.java b/app-main/src/test/java/net/causw/app/main/service/userInfo/UserInfoServiceTest.java index 06ca4d20f..50809e244 100644 --- a/app-main/src/test/java/net/causw/app/main/service/userInfo/UserInfoServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/userInfo/UserInfoServiceTest.java @@ -1,8 +1,13 @@ package net.causw.app.main.service.userInfo; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.BDDMockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.mock; +import static org.mockito.BDDMockito.never; +import static org.mockito.BDDMockito.times; +import static org.mockito.BDDMockito.verify; import java.util.List; import java.util.Optional; @@ -20,12 +25,12 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import net.causw.app.main.api.dto.userInfo.UserInfoSearchConditionDto; import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.domain.user.account.entity.userInfo.UserInfo; -import net.causw.app.main.domain.user.account.service.UserInfoService; -import net.causw.app.main.api.dto.userInfo.UserInfoSearchConditionDto; -import net.causw.app.main.domain.user.account.repository.userInfo.UserInfoRepository; import net.causw.app.main.domain.user.account.repository.userInfo.UserInfoQueryRepository; +import net.causw.app.main.domain.user.account.repository.userInfo.UserInfoRepository; +import net.causw.app.main.domain.user.account.service.UserInfoService; import net.causw.global.exception.ErrorCode; import net.causw.global.exception.NotFoundException; @@ -98,8 +103,7 @@ void searchUserInfo_Success() { // given Pageable pageable = PageRequest.of(0, 10); UserInfoSearchConditionDto condition = new UserInfoSearchConditionDto( - "keyword", 2000, 2020, null - ); + "keyword", 2000, 2020, null); UserInfo testUserInfo = mock(UserInfo.class); Page expectedPage = new PageImpl<>(List.of(testUserInfo), pageable, 1); diff --git a/app-main/src/test/java/net/causw/app/main/service/vote/VoteServiceTest.java b/app-main/src/test/java/net/causw/app/main/service/vote/VoteServiceTest.java index fa745ae3c..a0afafb5c 100644 --- a/app-main/src/test/java/net/causw/app/main/service/vote/VoteServiceTest.java +++ b/app-main/src/test/java/net/causw/app/main/service/vote/VoteServiceTest.java @@ -1,8 +1,16 @@ package net.causw.app.main.service.vote; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.BDDMockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.BDDMockito.doAnswer; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.mock; +import static org.mockito.BDDMockito.never; +import static org.mockito.BDDMockito.spy; +import static org.mockito.BDDMockito.times; +import static org.mockito.BDDMockito.verify; import java.time.LocalDateTime; import java.util.List; @@ -19,21 +27,21 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.test.util.ReflectionTestUtils; -import net.causw.app.main.domain.community.board.entity.Board; -import net.causw.app.main.domain.community.post.entity.Post; -import net.causw.app.main.domain.community.vote.service.VoteService; -import net.causw.app.main.domain.user.account.entity.user.User; -import net.causw.app.main.domain.community.vote.entity.Vote; -import net.causw.app.main.domain.community.vote.entity.VoteOption; -import net.causw.app.main.domain.community.vote.entity.VoteRecord; import net.causw.app.main.api.dto.vote.CastVoteRequestDto; import net.causw.app.main.api.dto.vote.CreateVoteRequestDto; import net.causw.app.main.api.dto.vote.VoteOptionResponseDto; import net.causw.app.main.api.dto.vote.VoteResponseDto; +import net.causw.app.main.domain.community.board.entity.Board; +import net.causw.app.main.domain.community.post.entity.Post; import net.causw.app.main.domain.community.post.repository.PostRepository; +import net.causw.app.main.domain.community.vote.entity.Vote; +import net.causw.app.main.domain.community.vote.entity.VoteOption; +import net.causw.app.main.domain.community.vote.entity.VoteRecord; import net.causw.app.main.domain.community.vote.repository.VoteOptionRepository; import net.causw.app.main.domain.community.vote.repository.VoteRecordRepository; import net.causw.app.main.domain.community.vote.repository.VoteRepository; +import net.causw.app.main.domain.community.vote.service.VoteService; +import net.causw.app.main.domain.user.account.entity.user.User; import net.causw.app.main.util.ObjectFixtures; import net.causw.global.exception.BadRequestException; import net.causw.global.exception.ErrorCode; @@ -203,7 +211,7 @@ public void castVote_FailWhenVoteOptionNotExist() { // when & then assertThatThrownBy(() -> voteService.castVote(castVoteRequestDto, writerUser)).isInstanceOf( - BadRequestException.class).hasMessageContaining("존재하지 않는 투표 옵션입니다.") + BadRequestException.class).hasMessageContaining("존재하지 않는 투표 옵션입니다.") .extracting("errorCode") .isEqualTo(ErrorCode.ROW_DOES_NOT_EXIST); @@ -220,7 +228,7 @@ public void castVote_FailWhenSelectMultipleVoteOptionsNotAllowed() { // when & then assertThatThrownBy(() -> voteService.castVote(castVoteRequestDto, writerUser)).isInstanceOf( - BadRequestException.class).hasMessageContaining("이 투표는 여러 항목을 선택할 수 없습니다.") + BadRequestException.class).hasMessageContaining("이 투표는 여러 항목을 선택할 수 없습니다.") .extracting("errorCode") .isEqualTo(ErrorCode.INVALID_PARAMETER); @@ -238,7 +246,7 @@ public void castVote_FailWhenVoteRecordAlreadyExist() { // when & then assertThatThrownBy(() -> voteService.castVote(castVoteRequestDto, writerUser)).isInstanceOf( - BadRequestException.class).hasMessageContaining("해당 투표에 이미 참여한 이력이 있습니다.") + BadRequestException.class).hasMessageContaining("해당 투표에 이미 참여한 이력이 있습니다.") .extracting("errorCode") .isEqualTo(ErrorCode.INVALID_PARAMETER); diff --git a/app-main/src/test/java/net/causw/app/main/util/DummyController.java b/app-main/src/test/java/net/causw/app/main/util/DummyController.java index a559c914a..0480e44fe 100644 --- a/app-main/src/test/java/net/causw/app/main/util/DummyController.java +++ b/app-main/src/test/java/net/causw/app/main/util/DummyController.java @@ -1,6 +1,13 @@ package net.causw.app.main.util; -import static org.springframework.web.bind.annotation.RequestMethod.*; +import static org.springframework.web.bind.annotation.RequestMethod.DELETE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.HEAD; +import static org.springframework.web.bind.annotation.RequestMethod.OPTIONS; +import static org.springframework.web.bind.annotation.RequestMethod.PATCH; +import static org.springframework.web.bind.annotation.RequestMethod.POST; +import static org.springframework.web.bind.annotation.RequestMethod.PUT; +import static org.springframework.web.bind.annotation.RequestMethod.TRACE; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/app-main/src/test/java/net/causw/app/main/util/ObjectFixtures.java b/app-main/src/test/java/net/causw/app/main/util/ObjectFixtures.java index 0b6f9007b..0d7fad988 100644 --- a/app-main/src/test/java/net/causw/app/main/util/ObjectFixtures.java +++ b/app-main/src/test/java/net/causw/app/main/util/ObjectFixtures.java @@ -5,24 +5,24 @@ import org.springframework.test.util.ReflectionTestUtils; +import net.causw.app.main.api.dto.user.UserCreateRequestDto; +import net.causw.app.main.domain.campus.semester.entity.Semester; +import net.causw.app.main.domain.campus.semester.enums.SemesterType; import net.causw.app.main.domain.community.board.entity.Board; import net.causw.app.main.domain.community.comment.entity.ChildComment; import net.causw.app.main.domain.community.comment.entity.Comment; import net.causw.app.main.domain.community.post.entity.Post; -import net.causw.app.main.domain.campus.semester.entity.Semester; -import net.causw.app.main.domain.user.account.entity.user.User; -import net.causw.app.main.domain.user.account.entity.user.UserAdmission; -import net.causw.app.main.domain.finance.usercouncilfee.entity.CouncilFeeFakeUser; -import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFee; import net.causw.app.main.domain.community.vote.entity.Vote; import net.causw.app.main.domain.community.vote.entity.VoteOption; -import net.causw.app.main.domain.campus.semester.enums.SemesterType; +import net.causw.app.main.domain.finance.usercouncilfee.entity.CouncilFeeFakeUser; +import net.causw.app.main.domain.finance.usercouncilfee.entity.UserCouncilFee; +import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; +import net.causw.app.main.domain.user.account.entity.user.User; +import net.causw.app.main.domain.user.account.entity.user.UserAdmission; import net.causw.app.main.domain.user.account.enums.user.Department; import net.causw.app.main.domain.user.account.enums.user.GraduationType; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.domain.user.account.enums.user.UserState; -import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; -import net.causw.app.main.api.dto.user.UserCreateRequestDto; import net.causw.global.constant.StaticValue; public class ObjectFixtures { @@ -60,8 +60,7 @@ public static UserCreateRequestDto getUserCreateRequestDto() { "nickName", "major", Department.SCHOOL_OF_SW, - "010-2000-2000" - ); + "010-2000-2000"); } public static CouncilFeeFakeUser getCouncilFeeFakeUser() { @@ -74,8 +73,7 @@ public static CouncilFeeFakeUser getCouncilFeeFakeUser() { AcademicStatus.UNDETERMINED, 4, 2004, - GraduationType.FEBRUARY - ); + GraduationType.FEBRUARY); } public static UserCouncilFee getUserCouncilFee(boolean isJoinedService) { @@ -87,8 +85,7 @@ public static UserCouncilFee getUserCouncilFee(boolean isJoinedService) { 1, 8, false, - 0 - ); + 0); } else { return UserCouncilFee.of( false, @@ -97,8 +94,7 @@ public static UserCouncilFee getUserCouncilFee(boolean isJoinedService) { 1, 8, false, - 0 - ); + 0); } } @@ -106,16 +102,14 @@ public static UserAdmission getUserAdmission() { return UserAdmission.of( getUser(), List.of(), - "description" - ); + "description"); } public static Semester getSemester() { return Semester.of( 2000, SemesterType.FIRST, - getUser() - ); + getUser()); } public static Board getBoard() { @@ -124,8 +118,7 @@ public static Board getBoard() { "boardDescription", "category", true, - null - ); + null); } public static Board getNoticeBoard(boolean isAlumni) { @@ -136,8 +129,7 @@ public static Board getNoticeBoard(boolean isAlumni) { StaticValue.BOARD_NAME_APP_NOTICE, false, isAlumni, - null - ); + null); } public static Post getPost(User user, Board board) { @@ -149,8 +141,7 @@ public static Post getPost(User user, Board board) { false, board, null, - List.of() - ); + List.of()); } public static Comment getComment(User user, Post post) { @@ -169,8 +160,7 @@ public static ChildComment getChildComment(User user, Comment parentComment) { false, false, user, - parentComment - ); + parentComment); } public static List getVoteOptions() { @@ -183,7 +173,6 @@ public static Vote getVote(List voteOptions, Post post) { false, false, voteOptions, - post - ); + post); } } diff --git a/app-main/src/test/java/net/causw/app/main/util/WithMockCustomUser.java b/app-main/src/test/java/net/causw/app/main/util/WithMockCustomUser.java index a804c3ea1..0d9150589 100644 --- a/app-main/src/test/java/net/causw/app/main/util/WithMockCustomUser.java +++ b/app-main/src/test/java/net/causw/app/main/util/WithMockCustomUser.java @@ -8,15 +8,15 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.security.test.context.support.WithSecurityContext; +import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; import net.causw.app.main.domain.user.account.enums.user.Role; import net.causw.app.main.domain.user.account.enums.user.UserState; -import net.causw.app.main.domain.user.academic.enums.userAcademicRecord.AcademicStatus; @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @WithSecurityContext(factory = WithMockCustomUserSecurityContextFactory.class) @WithMockUser -public @interface WithMockCustomUser { +public @interface WithMockCustomUser{ Role[] roles() default Role.NONE; diff --git a/app-main/src/test/resources/logback-spring.xml b/app-main/src/test/resources/logback-spring.xml index aa9763263..6fee4ba26 100644 --- a/app-main/src/test/resources/logback-spring.xml +++ b/app-main/src/test/resources/logback-spring.xml @@ -1,47 +1,47 @@ - - - - %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n - - + + + + %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n + + - - - - true - - yyyy-MM-dd'T'HH:mm:ss.SSSZ - Asia/Seoul - true - true - true - true - true - - - + + + + true + + yyyy-MM-dd'T'HH:mm:ss.SSSZ + Asia/Seoul + true + true + true + true + true + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + +