Skip to content

Commit

Permalink
Merge pull request EveryUniv#46 from EveryUniv/dev
Browse files Browse the repository at this point in the history
Release dev_deploy
  • Loading branch information
gutanbug authored Jan 4, 2024
2 parents fde4a79 + 83acf79 commit 9c4a26a
Show file tree
Hide file tree
Showing 51 changed files with 1,238 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,6 @@ public ResponsePage<SummarizedPetitionDto> list(@RequestParam(required = false)
return new ResponsePage<>(list);
}

/**
* 내가 쓴 글 조회
*/
@GetMapping("/my")
@UserAuth
public ResponsePage<SummarizedPetitionDto> listMyPosts(AppAuthentication auth,
@ParameterObject Pageable pageable,
@RequestParam(defaultValue = "50") int bodySize) {
Page<SummarizedPetitionDto> posts =
petitionService.listMyPosts(auth.getUserId(), pageable, bodySize);
return new ResponsePage<>(posts);
}

/**
* 내가 동의한 글 조회
*/
@GetMapping("/my/agreed")
@UserAuth
public ResponsePage<SummarizedPetitionDto> listMyAgreedPosts(AppAuthentication auth,
@ParameterObject Pageable pageable,
@RequestParam(defaultValue = "50") int bodySize) {
Page<SummarizedPetitionDto> posts =
petitionService.listMyAgreedPosts(auth.getUserId(), pageable, bodySize);
return new ResponsePage<>(posts);
}

/**
* 게시글 등록
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
import com.dku.council.domain.review.repository.ReviewRepository;
import com.dku.council.domain.user.model.entity.User;
import com.dku.council.domain.user.repository.UserRepository;
import com.dku.council.domain.with_dankook.exception.InvalidStatusException;
import com.dku.council.domain.with_dankook.exception.WithDankookUserNotFoundException;
import com.dku.council.domain.with_dankook.model.entity.WithDankook;
import com.dku.council.domain.with_dankook.model.entity.WithDankookUser;
import com.dku.council.domain.with_dankook.repository.WithDankookRepository;
import com.dku.council.domain.with_dankook.repository.with_dankook.WithDankookRepository;
import com.dku.council.domain.with_dankook.repository.WithDankookUserRepository;
import com.dku.council.domain.with_dankook.service.WithDankookService;
import com.dku.council.domain.with_dankook.service.WithDankookUserService;
Expand Down Expand Up @@ -56,7 +55,7 @@ public class ReviewService {
@Transactional
public void create(Long writerUserId, RequestCreateReviewDto dto) {
// 리뷰 작성자가 본인에 대해서 리뷰를 작성하려고 한다면
if (writerUserId == dto.getTargetUserId()) {
if (writerUserId.equals(dto.getTargetUserId())) {
throw new InvalidCreateReviewToMyselfException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public LectureTemplateDto(ObjectMapper mapper, LectureTemplate template) {
this.grade = template.getGrade();
} else {
this.major = null;
this.grade = null;
this.grade = 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.dku.council.domain.user.controller;

import com.dku.council.domain.post.model.dto.list.SummarizedGenericPostDto;
import com.dku.council.domain.post.model.dto.list.SummarizedPetitionDto;
import com.dku.council.domain.post.model.dto.response.ResponsePage;
import com.dku.council.domain.post.service.post.PetitionService;
import com.dku.council.domain.user.model.dto.request.*;
import com.dku.council.domain.user.model.dto.response.*;
import com.dku.council.domain.user.service.*;
Expand Down Expand Up @@ -29,6 +31,7 @@ public class UserController {
private final UserFindService userFindService;
private final SignupService signupService;
private final MyPostService myPostService;
private final PetitionService petitionService;
private final UserWithdrawService userWithdrawService;

/**
Expand Down Expand Up @@ -206,6 +209,32 @@ public ResponsePage<SummarizedGenericPostDto> listMyCommentedPosts(AppAuthentica
return new ResponsePage<>(commentedPosts);
}

/**
* 내가 쓴 청원 글 조회
*/
@GetMapping("/petition")
@UserAuth
public ResponsePage<SummarizedPetitionDto> listMyPosts(AppAuthentication auth,
@ParameterObject Pageable pageable,
@RequestParam(defaultValue = "50") int bodySize) {
Page<SummarizedPetitionDto> posts =
petitionService.listMyPosts(auth.getUserId(), pageable, bodySize);
return new ResponsePage<>(posts);
}

/**
* 내가 동의한 청원 글 조회
*/
@GetMapping("/petition/agreed")
@UserAuth
public ResponsePage<SummarizedPetitionDto> listMyAgreedPosts(AppAuthentication auth,
@ParameterObject Pageable pageable,
@RequestParam(defaultValue = "50") int bodySize) {
Page<SummarizedPetitionDto> posts =
petitionService.listMyAgreedPosts(auth.getUserId(), pageable, bodySize);
return new ResponsePage<>(posts);
}

/**
* 내가 좋아요 한 글들 모두 조회하기
*/
Expand Down
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());
}
}
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);
}
}
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");
}
}
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");
}
}
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");
}
}
Loading

0 comments on commit 9c4a26a

Please sign in to comment.