Skip to content

Comments

[이승민] Sprint4#117

Open
chosi123 wants to merge 80 commits intocodeit-bootcamp-spring:이승민from
chosi123:sprint4
Open

[이승민] Sprint4#117
chosi123 wants to merge 80 commits intocodeit-bootcamp-spring:이승민from
chosi123:sprint4

Conversation

@chosi123
Copy link
Collaborator

@chosi123 chosi123 commented Feb 9, 2026

요구사항

기본

  • DiscodeitApplication의 테스트 로직은 삭제하세요.

웹 API 구현

  • 사용자를 등록할 수 있다.
  • 사용자 정보를 수정할 수 있다.
  • 사용자를 삭제할 수 있다.
  • 모든 사용자를 조회할 수 있다.
  • 사용자의 온라인 상태를 업데이트할 수 있다.
  • 사용자는 로그인할 수 있다.
  • 공개 채널을 생성할 수 있다.
  • 비공개 채널을 생성할 수 있다.
  • 공개 채널의 정보를 수정할 수 있다.
  • 채널을 삭제할 수 있다.
  • 특정 사용자가 볼 수 있는 모든 채널 목록을 조회할 수 있다.
  • 메시지를 보낼 수 있다.
  • 메시지를 수정할 수 있다.
  • 메시지를 삭제할 수 있다.
  • 특정 채널의 메시지 목록을 조회할 수 있다.
  • 특정 채널의 메시지 수신 정보를 생성할 수 있다.
  • 특정 채널의 메시지 수신 정보를 수정할 수 있다.
  • 특정 사용자의 메시지 수신 정보를 조회할 수 있다.
  • 바이너리 파일을 1개 또는 여러 개 조회할 수 있다.

심화

  • 제공되는 파일을 이용해 유저 리스트 화면 서빙하기

API테스트

  • Postman을 활용해 컨트롤러를 테스트 하세요.

sprint 4.postman_collection.json

주요 변경사항

스크린샷

image

멘토에게

  • 셀프 코드 리뷰를 통해 질문 이어가겠습니다.

…adStatusRepository: 유저를 받아 특정 채널의 메시지 수신 정보 생성, 수정, 특정 유저의 메시지 수신 여부 조회 기능 구현
…adStatusRepository: 유저를 받아 특정 채널의 메시지 수신 정보 생성, 수정, 특정 유저의 메시지 수신 여부 조회 기능 구현
 UserService: userStatus탐색 과정에서의 버그 수정
userResponseDto: 요구조건에 맞추어 dto 내부로 전달되는 데이터 개수 증가
@joonfluence
Copy link
Collaborator

커밋 메세지에 대한 규칙을 컨벤션으로 적용해보시면 좋습니다
참고 https://www.conventionalcommits.org/ko/v1.0.0/

Comment on lines +1 to +7
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.yaml 파일로 바꿔보세요!

Comment on lines +23 to +29
//이미지 단순 조회(프로필, 메시지 내 파일 단일 모두 가능)
@RequestMapping(value = "/api/binaryContent/find", method = RequestMethod.GET)
public ResponseEntity<BinaryContent> getSimpleFiles(
@RequestParam UUID binaryContentId
){
return ResponseEntity.ok(binaryContentService.find(binaryContentId));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RESTFul API에서 GET이 이미 자원에 대한 조회의 의미를 내포하기 때문에 /find 굳이 추가할 필요 없습니다!

Comment on lines +21 to +33
@RequestMapping(value = "/public", method = RequestMethod.POST)
public ChannelResponseDto postPublicChannel(
@RequestBody PublicChannelCreateRequestDto requestDto
){
return channelService.createPublicChannel(requestDto);
}

@RequestMapping(value = "/private", method = RequestMethod.POST)
public ChannelResponseDto postPrivateChannel(
@RequestBody PrivateChannelCreateRequestDto requestDto
){
return channelService.createPrivateChannel(requestDto);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

과제에서 요구사항 대로 하신 것 같아 이해하지만, [POST] "/api/channels/public, private" private, public을 Body 값 안에 넣어서 처리하는 방식이 더 깔끔할 것 같긴 합니다. 정말 분리되어야 하면 모르겠지만 거의 구현 코드가 비슷할거거든요

Comment on lines +26 to +41
public MessageResponseDto postMessage(
@PathVariable UUID channelId,
@RequestPart("dto") MessageCreateRequestDto requestDto,
@RequestPart(value = "attachments", required = false) List<MultipartFile> attachments
)throws IOException {

if (attachments != null && !attachments.isEmpty()) {
for (MultipartFile file : attachments) {
if (file == null || file.isEmpty()) continue;

String fileName = file.getOriginalFilename();
Path savePath = Paths.get("./upload/" + fileName);
Files.createDirectories(savePath.getParent());
file.transferTo(savePath);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 로직들이 Controller에 있는게 맞을까요?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResponseDTO 별도로 선언해주신 것 좋네요 👍

Comment on lines +1 to +15
package com.sprint.mission.discodeit.mapper.channel;

import com.sprint.mission.discodeit.dto.channel.ChannelResponseDto;
import com.sprint.mission.discodeit.entity.Channel;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.time.Instant;

@Mapper(componentModel = "spring")
public interface ChannelResponseMapper {

@Mapping(source = "lastMessageTime", target = "lastMessageTime")
ChannelResponseDto toDto(Instant lastMessageTime, Channel channel);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MapStruct 사용 및 Mapper로 별도로 분리하신 것 좋네요 👍

Channel channel = channelRepository.findById(updateRequestDto.channelId())
.orElseThrow(() -> new NoSuchElementException("Channel with id " + updateRequestDto.channelId() + " not found"));

if(channel.getType()==PRIVATE) throw new AssertionError("Cannot update private channel");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChannelType.PRIVATE.equals(targetChannel.getType())

Copy link
Collaborator

@joonfluence joonfluence left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants