Skip to content

Commit

Permalink
[COZY-202] 방 생성시 피드 자동 생성, 멤버 상세정보 삭제 기능 (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpark0506 authored Aug 28, 2024
1 parent fdfe423 commit 55e901d
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ public class FeedController {
private final FeedCommandService feedCommandService;
private final FeedQueryService feedQueryService;

@Deprecated
@Operation(
summary = "[포비] 피드 정보 등록하기",
description = "사용자의 토큰을 넣어 사용하고, body로 룸 ID와 피드 상세정보를 넣어 사용합니다.\n\n"
description = "해당 API는 더 이상 사용하지 않습니다"
)
@SwaggerApiError({
ErrorStatus._ROOM_NOT_FOUND,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@ public static FeedResponseDTO toDto(Feed feed) {
.build();
}

public static Feed toEntity(Room room) {
return Feed.builder()
.room(room)
.name("")
.description("")
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down Expand Up @@ -104,9 +105,9 @@ public ResponseEntity<ApiResponse<MemberStatQueryResponseDTO>> getMemberStat(
@Operation(
summary = "[포비] 사용자 상세정보 조회",
description = "사용자 토큰을 넣고, memberId를 PathVariable로 사용합니다.\n\n"
+ "시간 관련 처리를 유의해주세요."
)
@SwaggerApiError({
ErrorStatus._MEMBER_NOT_FOUND,
ErrorStatus._MEMBERSTAT_NOT_EXISTS
})
@GetMapping("/{memberId}")
Expand Down Expand Up @@ -213,5 +214,24 @@ public ResponseEntity<ApiResponse<PageResponseDto<List<?>>>> getFilteredMemberLi
));
}

@Operation(
summary = "[포비] 사용자 상세정보 삭제(관리자용)",
description = "요청자의 토큰을 넣고, 삭제하고자 하는 사용자의 ID를 넣어 사용합니다.\n\n"
)
@DeleteMapping("/{memberId}")
@SwaggerApiError({
ErrorStatus._MEMBER_NOT_FOUND,
ErrorStatus._MEMBERSTAT_NOT_EXISTS
})
public ResponseEntity<ApiResponse<Boolean>> deleteMemberStat(
@PathVariable Long memberId
){
// TODO : 관리자 권한 분리시 일반 사용자가 삭제하는 것을 제한하기
memberStatCommandService.deleteMemberStat(memberId);
return ResponseEntity.ok(
ApiResponse.onSuccess(
true
));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,18 @@ public Long modifyMemberStat(
return updatedMemberStat.getId();

}

public void deleteMemberStat(Long memberId){

if(!memberStatRepository.existsById(memberId)){
throw new GeneralException(ErrorStatus._MEMBER_NOT_FOUND);
}

MemberStat memberStat = memberStatRepository.findByMemberId(memberId).orElseThrow(
() -> new GeneralException(ErrorStatus._MEMBERSTAT_NOT_EXISTS)
);

memberStatRepository.delete(memberStat);

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.cozymate.cozymate_server.domain.room.service;

import com.cozymate.cozymate_server.domain.feed.Feed;
import com.cozymate.cozymate_server.domain.feed.converter.FeedConverter;
import com.cozymate.cozymate_server.domain.feed.repository.FeedRepository;
import com.cozymate.cozymate_server.domain.friend.FriendRepository;
import com.cozymate.cozymate_server.domain.friend.enums.FriendStatus;
Expand Down Expand Up @@ -74,6 +75,9 @@ public RoomCreateResponse createRoom(RoomCreateRequest request, Member member) {
Mate mate = MateConverter.toEntity(room, creator, true);
mateRepository.save(mate);

Feed feed = FeedConverter.toEntity(room);
feedRepository.save(feed);

return roomQueryService.getRoomById(room.getId(), member.getId());
}

Expand Down

0 comments on commit 55e901d

Please sign in to comment.