forked from EveryUniv/next-student-council-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request EveryUniv#45 from gutanbug/dev_deploy
fix: 구해줘! 룸메 서비스 로직 추가 및 내가 쓴 / 동의한 청원 게시글 조회 경로 변경
- Loading branch information
Showing
51 changed files
with
1,238 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
src/main/java/com/dku/council/domain/with_dankook/controller/EatingAloneController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package com.dku.council.domain.with_dankook.controller; | ||
|
||
import com.dku.council.domain.post.model.dto.response.ResponsePage; | ||
import com.dku.council.domain.with_dankook.model.dto.list.SummarizedEatingAloneDto; | ||
import com.dku.council.domain.with_dankook.model.dto.request.RequestCreateEatingAloneDto; | ||
import com.dku.council.domain.with_dankook.model.dto.response.ResponseSingleEatingAloneDto; | ||
import com.dku.council.domain.with_dankook.service.EatingAloneService; | ||
import com.dku.council.global.auth.jwt.AppAuthentication; | ||
import com.dku.council.global.auth.role.UserAuth; | ||
import com.dku.council.global.model.dto.ResponseIdDto; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springdoc.api.annotations.ParameterObject; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import javax.validation.Valid; | ||
|
||
@RestController | ||
@Tag(name = "단혼밥", description = "단혼밥 게시판") | ||
@RequestMapping("with-dankook/eating-alone") | ||
@RequiredArgsConstructor | ||
public class EatingAloneController { | ||
|
||
private final EatingAloneService eatingAloneService; | ||
|
||
/** | ||
* 단혼밥 게시글 목록 조회 | ||
* | ||
* @param bodySize 게시글 본문 길이. (글자 단위) 지정하지 않으면 50 글자. | ||
* @param pageable 페이징 size, sort, page | ||
* @return 페이징된 EatingAlone 게시판 목록 | ||
*/ | ||
@GetMapping | ||
public ResponsePage<SummarizedEatingAloneDto> list(@RequestParam(defaultValue = "50") int bodySize, | ||
@ParameterObject Pageable pageable) { | ||
Page<SummarizedEatingAloneDto> list = eatingAloneService.list(pageable, bodySize); | ||
return new ResponsePage<>(list); | ||
} | ||
|
||
/** | ||
* 내가 쓴 단혼밥 게시글 목록 조회 | ||
* | ||
* @param pageable 페이징 size, sort, page | ||
* @return 페이징된 내가 쓴 EatingAlone 게시판 목록 | ||
*/ | ||
@GetMapping("/my") | ||
@UserAuth | ||
public ResponsePage<SummarizedEatingAloneDto> listMyPosts(AppAuthentication auth, | ||
@ParameterObject Pageable pageable) { | ||
Page<SummarizedEatingAloneDto> list = eatingAloneService.listMyPosts(auth.getUserId(), pageable); | ||
return new ResponsePage<>(list); | ||
} | ||
|
||
/** | ||
* 단혼밥 게시글 상세 조회 | ||
* | ||
* @param id 게시글 id | ||
*/ | ||
@GetMapping("/{id}") | ||
@UserAuth | ||
public ResponseSingleEatingAloneDto findOne(AppAuthentication auth, | ||
@PathVariable Long id) { | ||
return eatingAloneService.findOne(id, auth.getUserId(), auth.getUserRole()); | ||
} | ||
|
||
/** | ||
* 단혼밥 게시글 생성 | ||
*/ | ||
@PostMapping | ||
@UserAuth | ||
public ResponseIdDto create(AppAuthentication auth, | ||
@Valid @RequestBody RequestCreateEatingAloneDto dto) { | ||
Long id = eatingAloneService.create(auth.getUserId(), dto); | ||
return new ResponseIdDto(id); | ||
} | ||
|
||
/** | ||
* 단혼밥 게시글 참여 | ||
* | ||
* @param id 게시글 id | ||
*/ | ||
@PostMapping("/{id}/enter") | ||
@UserAuth | ||
public void enter(AppAuthentication auth, | ||
@PathVariable @Valid Long id) { | ||
eatingAloneService.enter(id, auth.getUserId(), auth.getUserRole()); | ||
} | ||
|
||
/** | ||
* 단혼밥 게시글 삭제 | ||
* | ||
* @param id 게시글 id | ||
*/ | ||
@DeleteMapping("/{id}") | ||
@UserAuth | ||
public void delete(AppAuthentication auth, | ||
@PathVariable @Valid Long id) { | ||
eatingAloneService.delete(id, auth.getUserId(), auth.getUserRole().isAdmin()); | ||
} | ||
} |
139 changes: 139 additions & 0 deletions
139
src/main/java/com/dku/council/domain/with_dankook/controller/RoommateController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package com.dku.council.domain.with_dankook.controller; | ||
|
||
import com.dku.council.domain.post.model.dto.response.ResponsePage; | ||
import com.dku.council.domain.with_dankook.model.dto.list.SummarizedRoommateDto; | ||
import com.dku.council.domain.with_dankook.model.dto.request.RequestCreateRoommateDto; | ||
import com.dku.council.domain.with_dankook.model.dto.request.RequestCreateSurveyDto; | ||
import com.dku.council.domain.with_dankook.model.dto.response.ResponseSingleRoommateDto; | ||
import com.dku.council.domain.with_dankook.service.RoommateService; | ||
import com.dku.council.domain.with_dankook.service.SurveyService; | ||
import com.dku.council.global.auth.jwt.AppAuthentication; | ||
import com.dku.council.global.auth.role.UserAuth; | ||
import com.dku.council.global.model.dto.ResponseBooleanDto; | ||
import com.dku.council.global.model.dto.ResponseIdDto; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springdoc.api.annotations.ParameterObject; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import javax.validation.Valid; | ||
|
||
@RestController | ||
@Tag(name = "구해줘! 룸메", description = "구해줘! 룸메 관련 API") | ||
@RequiredArgsConstructor | ||
@RequestMapping("with-dankook/roommate") | ||
public class RoommateController { | ||
|
||
private final RoommateService roommateService; | ||
private final SurveyService surveyService; | ||
|
||
/** | ||
* 구해줘! 룸메 설문조사 작성 | ||
* <p>SleepTime: AVG_TEN, AVG_ELEVEN, AVG_TWELVE, AVG_ONE, AVG_TWO, AVG_TWO_AFTER, ETC</p> | ||
* <p>CleanUpCount : ONCE_UNDER_WEEK, TWICE_WEEK, TWICE_OVER_WEEK, ONCE_MONTH</p> | ||
* <p>noiseHabit이 true 일 때는, noiseHabitDetail을 필수로 작성해야 한다.</p> | ||
* | ||
* @param dto 룸메 설문조사 dto | ||
* @return 설문조사 id | ||
*/ | ||
@PostMapping("/create/survey") | ||
@UserAuth | ||
public ResponseIdDto createSurvey(AppAuthentication auth, | ||
@RequestBody @Valid RequestCreateSurveyDto dto) { | ||
Long result = surveyService.createSurvey(auth.getUserId(), dto); | ||
return new ResponseIdDto(result); | ||
} | ||
|
||
/** | ||
* 구해줘! 룸메 게시글 작성 | ||
* <p>ResidenceDuration : SEMESTER , HALF_YEAR, YEAR</p> | ||
*/ | ||
@PostMapping | ||
@UserAuth | ||
public ResponseIdDto create(AppAuthentication auth, | ||
@RequestBody @Valid RequestCreateRoommateDto dto) { | ||
Long result = roommateService.create(auth.getUserId(), dto); | ||
return new ResponseIdDto(result); | ||
} | ||
|
||
/** | ||
* 구해줘! 룸메 게시글 목록 조회 | ||
* | ||
* @param bodySize 게시글 본문 길이. (글자 단위) 지정하지 않으면 50 글자. | ||
* @param pageable 페이징 size, sort, page | ||
* @return 페이징된 게시판 목록 | ||
*/ | ||
@GetMapping | ||
@UserAuth | ||
public ResponsePage<SummarizedRoommateDto> list(AppAuthentication auth, | ||
@RequestParam(defaultValue = "50") int bodySize, | ||
@ParameterObject Pageable pageable) { | ||
Page<SummarizedRoommateDto> list = roommateService.list(auth.getUserId(), pageable, bodySize); | ||
return new ResponsePage<>(list); | ||
} | ||
|
||
/** | ||
* 구해줘! 룸메 게시글 상세 조회 | ||
* | ||
* @param id 게시글 id | ||
*/ | ||
@GetMapping("/{id}") | ||
@UserAuth | ||
public ResponseSingleRoommateDto findOne(AppAuthentication auth, | ||
@PathVariable Long id) { | ||
return roommateService.findOne(id, auth.getUserId(), auth.getUserRole()); | ||
} | ||
|
||
/** | ||
* 구해줘! 룸메 게시글 신청 | ||
* <p>게시글에 신청할 경우 바로 신청되는 것이 아닌 대기중으로 설정됩니다.</p> | ||
* | ||
* @param id 게시글 id | ||
*/ | ||
@PostMapping("/apply/{id}") | ||
@UserAuth | ||
public void apply(AppAuthentication auth, | ||
@Valid @PathVariable Long id) { | ||
roommateService.apply(auth.getUserId(), id, auth.getUserRole()); | ||
} | ||
|
||
/** | ||
* 구해줘! 룸메 게시글 승인 | ||
* <p>게시글 작성자가 신청자 id로 승인합니다.</p> | ||
* | ||
* @param id 게시글 id | ||
* @param targetUserId 승인할 사용자 id | ||
*/ | ||
@PatchMapping("/approve/{id}") | ||
@UserAuth | ||
public void approve(AppAuthentication auth, | ||
@Valid @PathVariable Long id, | ||
Long targetUserId) { | ||
roommateService.approve(auth.getUserId(), id, targetUserId); | ||
} | ||
|
||
/** | ||
* 구해줘! 룸메 게시글 삭제 | ||
* | ||
* @param roommateId 게시글 id | ||
*/ | ||
@DeleteMapping | ||
@UserAuth | ||
public void delete(AppAuthentication auth, | ||
@Valid @RequestParam Long roommateId) { | ||
roommateService.delete(auth.getUserId(), auth.isAdmin(), roommateId); | ||
} | ||
|
||
/** | ||
* 구해줘! 룸메 설문조사 작성 여부 확인 | ||
* <p>설문조사를 하지 않았을 때는 설문조사를 먼저 받아야하며, 설문조사가 꼭 있어야만 다른 기능 사용이 가능하다.</p> | ||
*/ | ||
@GetMapping("/survey") | ||
@UserAuth | ||
public ResponseBooleanDto isSurveyExist(AppAuthentication auth) { | ||
boolean result = surveyService.checkSurvey(auth.getUserId()); | ||
return new ResponseBooleanDto(result); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/dku/council/domain/with_dankook/exception/AlreadySurveyException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.dku.council.domain.with_dankook.exception; | ||
|
||
import com.dku.council.global.error.exception.LocalizedMessageException; | ||
import org.springframework.http.HttpStatus; | ||
|
||
public class AlreadySurveyException extends LocalizedMessageException { | ||
|
||
public AlreadySurveyException() { | ||
super(HttpStatus.BAD_REQUEST, "already.survey"); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...n/java/com/dku/council/domain/with_dankook/exception/AlreadyWrittenRoommateException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.dku.council.domain.with_dankook.exception; | ||
|
||
import com.dku.council.global.error.exception.LocalizedMessageException; | ||
import org.springframework.http.HttpStatus; | ||
|
||
public class AlreadyWrittenRoommateException extends LocalizedMessageException { | ||
|
||
public AlreadyWrittenRoommateException() { | ||
super(HttpStatus.BAD_REQUEST, "already.written.roommate"); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/dku/council/domain/with_dankook/exception/InvalidMBTIException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.dku.council.domain.with_dankook.exception; | ||
|
||
import com.dku.council.global.error.exception.LocalizedMessageException; | ||
import org.springframework.http.HttpStatus; | ||
|
||
public class InvalidMBTIException extends LocalizedMessageException { | ||
|
||
public InvalidMBTIException() { | ||
super(HttpStatus.BAD_REQUEST, "invalid.mbti"); | ||
} | ||
} |
Oops, something went wrong.