Skip to content

Commit

Permalink
Merge pull request #95 from depromeet/develop
Browse files Browse the repository at this point in the history
deploy-22.06.26.1
  • Loading branch information
daseulll authored Jun 26, 2022
2 parents ef074b3 + 6b262ed commit 6a4f236
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 57 deletions.
12 changes: 4 additions & 8 deletions src/main/java/com/depromeet/fairer/api/MemberController.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,18 @@ public class MemberController {

@Tag(name = "members")
@GetMapping("/me")
@ApiOperation(value = "내 정보 조회")
public ResponseEntity<MemberResponseDto> getMe(@ApiIgnore @RequestMemberId Long memberId) {
return ResponseEntity.ok(MemberResponseDto.from(memberService.find(memberId)));
}

@Tag(name = "members")
@PutMapping("/me")
public ResponseEntity<MemberResponseDto> updateMe(@Valid MemberUpdateRequestDto request, @ApiIgnore @RequestMemberId Long memberId) {
return ResponseEntity.ok(MemberResponseDto.from(memberService.updateMember(memberId, request.getMemberName(), request.getProfilePath(), request.getStatusMessage())));
}

/***
* 기본적으로 제공해주는 프로필 이미지는 profileImageDefaultPath 하위에 보관
* 추후에 유저가 업로드 하는 프로필 이미지는 각 유저 폴더에 보관
*/
@Tag(name = "members")
@GetMapping("/profile-image")
@ApiOperation(value = "기본 프로필 이미지 리스트 조회")
public ResponseEntity<MemberProfileImageResponseDto> getDefaultProfileImageList() {
return ResponseEntity.ok(
MemberProfileImageResponseDto.builder()
Expand All @@ -61,9 +57,9 @@ public ResponseEntity<MemberProfileImageResponseDto> getDefaultProfileImageList(
@ApiOperation(value = "멤버 업데이트", notes = "멤버 정보 업데이트<br/><br/>" +
"멤버 이름<br/>프로필 url")
@PatchMapping(value = "")
public ResponseEntity<CommonApiResult> updateTeam(@ApiIgnore @RequestMemberId Long memberId, @RequestBody com.depromeet.fairer.dto.member.MemberUpdateRequestDto requestDto) {
public ResponseEntity<CommonApiResult> updateTeam(@ApiIgnore @RequestMemberId Long memberId, @RequestBody MemberUpdateRequestDto requestDto) {
// TODO 이름, url 정규식 검증
memberService.updateMember(memberId, requestDto.getMemberName(), requestDto.getProfileUrl());
memberService.updateMember(memberId, requestDto.getMemberName(), requestDto.getProfilePath(), requestDto.getStatusMessage());
return ResponseEntity.ok(CommonApiResult.createOk("멤버 정보가 업데이트 되었습니다."));
}
}
5 changes: 3 additions & 2 deletions src/main/java/com/depromeet/fairer/domain/member/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ public boolean hasTeam() {
return this.team != null;
}

public void update(String memberName, String profileUrl) {
public void update(String memberName, String profilePath, String statusMessage) {
this.memberName = memberName;
this.profilePath = profileUrl;
this.profilePath = profilePath;
this.statusMessage = statusMessage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@
@Getter
@AllArgsConstructor
public enum ProfileImage {
PROFILE_1("%2Fblue3.png?alt=media&token=3b0ffa34-cf13-4eb2-9e19-ba91d8952c9a"),
PROFILE_2("%2Fblue4.png?alt=media&token=d31d6d31-a04e-4c4c-b2f6-8670ca122375"),
PROFILE_3("%2Forange1.png?alt=media&token=055a8cc0-9f37-4282-9acd-d237563410ae"),
PROFILE_4("%2Forange2.png?alt=media&token=f5c42e87-708e-4e97-a86f-9688d09a4d89"),
PROFILE_5("%2Fpink1.png?alt=media&token=8cde7d10-718e-4027-9f6f-02582d907bd5"),
PROFILE_6("%2Fpink3.png?alt=media&token=984009db-d0a9-4ae8-a89d-cd194b5f0af2"),
PROFILE_7("%2Fgreen1.png?alt=media&token=8d8711ff-1bfd-42ef-bd0d-64d91dab536c"),
PROFILE_8("%2Fgreen3.png?alt=media&token=9a326f5b-aaea-491b-aa9a-63b68a19562b"),
PROFILE_9("%2Fpurple1.png?alt=media&token=f6c2c333-1847-45a7-bd71-5149d41b02a8"),
PROFILE_10("%2Fpurple3.png?alt=media&token=e7b8a734-75a9-44aa-8c85-a505aee71d00"),
PROFILE_11("%2Fpurple2.png?alt=media&token=108ec0bc-5d7d-4c44-9f12-6e3b8f6b52a0"),
PROFILE_12("%2Fyellow1.png?alt=media&token=a4c653b8-0962-4e17-b91b-de3e75af38ba"),
PROFILE_13("%2Fyellow2.png?alt=media&token=ae0666de-7cf1-41dd-88cc-94c654ff4d44"),
PROFILE_14("%2Flight_blue1.png?alt=media&token=3b358768-8144-4adb-95fa-822e29ec07c1"),
PROFILE_15("%2Flight_blue2.png?alt=media&token=f52561f6-818e-4730-b72c-8530c48ccd0f"),
PROFILE_16("%2Findigo3.png?alt=media&token=933a7607-833f-4f4e-b5b9-e0fba1374d30");
PROFILE_1("%2Fblue3-3x.png?alt=media&token=13eaabdf-1729-46b4-bd23-85c5f8908fdb"),
PROFILE_2("%2Fblue4-3x.png?alt=media&token=fa208353-fcb9-4996-b596-57e3d07a463d"),
PROFILE_3("%2Forange1-3x.png?alt=media&token=6a875a5f-3af0-41a7-872c-5c725ef1eb18"),
PROFILE_4("%2Forange2-3x.png?alt=media&token=bc4f0cc7-76d3-4aa2-95b3-aee112fecb28"),
PROFILE_5("%2Fpink1-3x.png?alt=media&token=2317c3c0-fdb9-4236-88ed-5991c4b47f17"),
PROFILE_6("%2Fpink3-3x.png?alt=media&token=bb23c78c-51ec-4fe4-95ad-7a93c7c59f84"),
PROFILE_7("%2Fgreen1-3x.png?alt=media&token=9a27b20c-602c-4750-a100-659cd08409af"),
PROFILE_8("%2Fgreen3-3x.png?alt=media&token=a17b07bb-816b-414c-836f-7d53a41d230b"),
PROFILE_9("%2Fpurple1-3x.png?alt=media&token=828f20f0-6451-40d9-a38f-83e5981ad029"),
PROFILE_10("%2Fpurple3-3x.png?alt=media&token=b8793e5c-9ebf-474e-805f-e0279e82bfa2"),
PROFILE_11("%2Fpurple2-3x.png?alt=media&token=1f38ac6e-6c49-49c6-be11-be161f2b3079"),
PROFILE_12("%2Fyellow1-3x.png?alt=media&token=adbdd7a8-8c57-406f-9433-b120b5626644"),
PROFILE_13("%2Fyellow2-3x.png?alt=media&token=ccf1bbcf-615f-4950-824a-c51b15ac719a"),
PROFILE_14("%2Flight-blue1-3x.png?alt=media&token=4df1d835-a7e2-4d04-9a66-3c47237f38ce"),
PROFILE_15("%2Flight-blue2-3x.png?alt=media&token=5d249bd7-648c-4dba-8d6b-a9b34befd821"),
PROFILE_16("%2Findigo3-3x.png?alt=media&token=7c0a18bb-d746-4d62-9fa1-87c3876d9eac");

final String bigImageName;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;

@Data
@Builder
@ApiModel(value="멤버 정보 업데이트 요청 객체", description = "멤버 정보 업데이트 요청 객체")
@AllArgsConstructor @NoArgsConstructor
public class MemberUpdateRequestDto {
@NotBlank
@ApiModelProperty(value = "프로필 이미지 경로")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.depromeet.fairer.global.exception.handler;

import com.depromeet.fairer.global.exception.BadRequestException;
import com.depromeet.fairer.global.exception.CannotJoinTeamException;
import com.depromeet.fairer.global.exception.PermissionDeniedException;
import com.depromeet.fairer.global.exception.*;
import com.depromeet.fairer.global.exception.dto.ErrorResponseDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
Expand Down Expand Up @@ -92,6 +90,12 @@ protected ResponseEntity<ErrorResponseDto> handlePermissionDeniedException(
return exceptionResponseEntity(e.getMessage(), HttpStatus.FORBIDDEN, request.getRequestURI());
}

@ExceptionHandler(NoSuchMemberException.class)
protected ResponseEntity<ErrorResponseDto> handleNoSuchMemberException(NoSuchMemberException e, HttpServletRequest request) {
log.error("NoSuchMemberException", e);
return exceptionResponseEntity(e.getMessage(), HttpStatus.NOT_FOUND, request.getRequestURI());
}

/**
* 어떤 객체를 생성하지 못할 경우 발생
*/
Expand All @@ -101,6 +105,20 @@ protected ResponseEntity<ErrorResponseDto> handleCannotJoinTeamException(CannotJ
return exceptionResponseEntity(e.getMessage(), HttpStatus.NOT_ACCEPTABLE, request.getRequestURI());
}

@ExceptionHandler(FeignClientException.class)
protected ResponseEntity<ErrorResponseDto> handleFeignClientException(FeignClientException e, HttpServletRequest request) {
log.error("FeignClientException", e);
return exceptionResponseEntity(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR, request.getRequestURI());
}

@ExceptionHandler(MemberTokenNotFoundException.class)
protected ResponseEntity<ErrorResponseDto> handleMemberTokenNotFoundException(MemberTokenNotFoundException e, HttpServletRequest request) {
log.error("MemberTokenNotFoundException", e);
return exceptionResponseEntity(e.getMessage(), HttpStatus.NOT_FOUND, request.getRequestURI());
}



/**
* exception 발생사 ResponseEntity 로 변환 후 반환
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,8 @@ public List<Member> getMemberListByHouseWorkId(Long houseWorkId) {
return memberRepository.getMemberDtoListByHouseWorkId(houseWorkId);
}

public void updateMember(Long memberId, String memberName, String profileUrl) {
final Member reqMember = find(memberId);
reqMember.update(memberName, profileUrl);
}

public Member updateMember(Long memberId, String memberName, String profilePath, String statusMessage) {
Member member = this.find(memberId);
member.setMemberName(memberName);
member.setProfilePath(profilePath);
member.setStatusMessage(statusMessage);
member.update(memberName, profilePath, statusMessage);
return memberRepository.save(member);
}}
17 changes: 17 additions & 0 deletions src/main/java/com/depromeet/fairer/service/team/TeamService.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.depromeet.fairer.service.team;


import com.depromeet.fairer.domain.assignment.Assignment;
import com.depromeet.fairer.domain.member.Member;
import com.depromeet.fairer.domain.team.Team;
import com.depromeet.fairer.global.exception.BadRequestException;
import com.depromeet.fairer.global.exception.CannotJoinTeamException;
import com.depromeet.fairer.global.exception.MemberTokenNotFoundException;
import com.depromeet.fairer.repository.assignment.AssignmentRepository;
import com.depromeet.fairer.repository.housework.HouseWorkRepository;
import com.depromeet.fairer.repository.member.MemberRepository;
import com.depromeet.fairer.repository.team.TeamRepository;
import com.depromeet.fairer.service.member.MemberService;
Expand All @@ -17,6 +20,7 @@

import javax.transaction.Transactional;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

Expand All @@ -29,6 +33,8 @@ public class TeamService {
private final MemberService memberService;
private final TeamRepository teamRepository;
private final MemberRepository memberRepository;
private final AssignmentRepository assignmentRepository;
private final HouseWorkRepository houseWorkRepository;

public Team createTeam(Long memberId, String teamName) {
final Member reqMember = memberService.findWithTeam(memberId);
Expand Down Expand Up @@ -112,6 +118,17 @@ public void leaveTeam(Long memberId) {
if (!member.hasTeam()) {
throw new BadRequestException("소속된 팀이 없습니다.");
}

List<Assignment> assignmentList = assignmentRepository.findAllByMember(member);
assignmentRepository.deleteAll(assignmentList);

for(Assignment assignment : assignmentList) {
int count = assignmentRepository.findAllByHouseWorkAndMemberNotIn(assignment.getHouseWork(), List.of(member)).size();
if(count == 0) {
houseWorkRepository.delete(assignment.getHouseWork());
}
}

Team team = member.getTeam();
team.getMembers().remove(member);
member.setTeam(null);
Expand Down

0 comments on commit 6a4f236

Please sign in to comment.