Skip to content

Comments

[강지원] sprint 4#73

Open
jikang24 wants to merge 26 commits intocodeit-bootcamp-spring:강지원from
jikang24:강지원-sprint_misson_4

Hidden character warning

The head ref may contain hidden characters: "\uac15\uc9c0\uc6d0-sprint_misson_4"
Open

[강지원] sprint 4#73
jikang24 wants to merge 26 commits intocodeit-bootcamp-spring:강지원from
jikang24:강지원-sprint_misson_4

Conversation

@jikang24
Copy link
Collaborator

@jikang24 jikang24 commented Feb 13, 2026

요구사항

기본

컨트롤러 레이어 구현

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

  • 지금까지 구현한 서비스 로직을 활용해 웹 API를 구현하세요. 이때 @RequestMapping만 사용해 구현해보세요.

  • 웹 API의 예외를 전역으로 처리하세요.

웹 API 요구사항

사용자 관리

  • 사용자를 등록할 수 있다.
  • 사용자 정보를 수정할 수 있다.
  • [x]사용자를 삭제할 수 있다.
  • [x]모든 사용자를 조회할 수 있다.
  • [x]사용자의 온라인 상태를 업데이트할 수 있다.

권한 관리

  • 사용자는 로그인할 수 있다.

채널 관리

  • 공개 채널을 생성할 수 있다.
  • 비공개 채널을 생성할 수 있다.
  • 공개 채널의 정보를 수정할 수 있다.
  • 채널을 삭제할 수 있다.
  • [x]특정 사용자가 볼 수 있는 모든 채널 목록을 조회할 수 있다.

메시지 관리

  • 메시지를 보낼 수 있다.
  • 메시지를 수정할 수 있다.
  • 메시지를 삭제할 수 있다.
  • 특정 채널의 메시지 목록을 조회할 수 있다.

메시지 수신 정보 관리

  • 특정 채널의 메시지 수신 정보를 생성할 수 있다.
  • 특정 채널의 메시지 수신 정보를 수정할 수 있다.
  • 특정 사용자의 메시지 수신 정보를 조회할 수 있다.

바이너리 파일 다운로드

  • 바이너리 파일을 1개 또는 여러 개 조회할 수 있다.

API 테스트

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

심화

정적 리소스 서빙

  • 사용자 목록 조회, BinaryContent 파일 조회 API를 다음의 조건을 만족하도록 수정하세요.

[ ] 사용자 목록 조회
url: /api/user/findAll

요청
파라미터, 바디 없음

응답
ResponseEntity<List>

  • BinaryContent 파일 조회

url: /api/binaryContent/find
요청
파라미터: binaryContentId
바디 없음
응답: ResponseEntity

  • 다음의 파일을 활용하여 사용자 목록을 보여주는 화면을 서빙해보세요.

생성형 AI 활용

  • 생성형 AI (Claude, ChatGPT 등)를 활용해서 위 이미지와 비슷한 화면을 생성 후 서빙해보세요.

주요 변경사항

  • 제공받은 베이스코드를 기반으로 작성했습니다.
  • 각각의 Entity명시는 별도로 진행하지 않았으나, 추후의 미션부터 진행하도록 하겠습니다.
  • static폴더에 프로필 및 binaryContent 테스트용 이미지를 추가하였습니다.
  • 사용한 이미지의 지적재산권은 아래 사이트에 있습니다.
    https://blog.naver.com/minju1420
    @pocco_gk

스크린샷

채팅 화면

포스트맨

https://documenter.getpostman.com/view/52123577/2sBXcBnh7q

멘토에게

  • 미션3부터 있던 부분들은 대부분 베이스코드이기에 컨트롤러와 전역처리 기반으로 피드백 부탁드립니다.
  • 포스트맨의 첨부가 제대로 진행되었는지 의문이 듭니다. 확인 부탁드립니다.
  • 그동안 정성스러운 피드백 남겨주셔서 감사합니다. 덕분에 많이 배워갑니다.

@jikang24 jikang24 added the 매운맛🔥 뒤는 없습니다. 그냥 필터 없이 말해주세요. 책임은 제가 집니다. label Feb 13, 2026
@jikang24 jikang24 changed the title 강지원 sprint misson 4 [강지원] sprint 4 Feb 13, 2026

Choose a reason for hiding this comment

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

.gitignore에 이게 들어가야할까요?

@joonfluence
Copy link

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

Comment on lines +15 to +18
@ResponseBody
@RequestMapping("/api/auth")
@RequiredArgsConstructor
@Controller

Choose a reason for hiding this comment

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

v1 버저닝을 추가 해주는 것도 좋습니다 (계속 버전이 변화될 수 있기 때문에) 나중에 추가하긴 어렵거든요

Copy link

@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

Comment on lines +25 to +53
@RequestMapping(
path = "find",
method = {RequestMethod.GET}
)
public ResponseEntity<BinaryContent> find(
@RequestParam("binaryContentId") UUID binaryContentId
){
BinaryContent binaryContent
= binaryContentService.find(binaryContentId);
return ResponseEntity
.status(HttpStatus.OK)
.body(binaryContent);


}

@RequestMapping(
path = "findAll",
method = {RequestMethod.GET}
)
public ResponseEntity<List<BinaryContent>> findAllByIdIn(
@RequestParam("binaryContentIds") List<UUID> binaryContentIds
){
List<BinaryContent> binaryContents
= binaryContentService.findAllByIdIn(binaryContentIds);
return ResponseEntity
.status(HttpStatus.OK)
.body(binaryContents);
}

Choose a reason for hiding this comment

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

findById <-> findAllByIdIn

이렇게 분리해야 명확할 것 같네요

Comment on lines +31 to +60
@RequestMapping(
path = "createPublic",
consumes = {MediaType.MULTIPART_FORM_DATA_VALUE}
)
public ResponseEntity<Channel> publicChannelCreate(
@RequestPart("PublicChannelCreateRequest") PublicChannelCreateRequest request
){
PublicChannelCreateRequest publicChannelCreateRequest
= new PublicChannelCreateRequest(request.name(), request.description());
Channel publicChannel = channelService.create(publicChannelCreateRequest);
return ResponseEntity
.status(HttpStatus.CREATED)
.body(publicChannel);
}

@RequestMapping(
path = "createPrivate",
consumes = {MediaType.MULTIPART_FORM_DATA_VALUE}
)
public ResponseEntity<Channel> privateChannelCreate(
@RequestPart("PrivateChannelCreateRequest")
PrivateChannelCreateRequest request
){
PrivateChannelCreateRequest privateChannelCreateRequest
= new PrivateChannelCreateRequest(request.participantIds());
Channel privateChannel = channelService.create(privateChannelCreateRequest);
return ResponseEntity
.status(HttpStatus.CREATED)
.body(privateChannel);
}

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 +32 to +70
@RequestMapping(
path = "create",
consumes = {MediaType.MULTIPART_FORM_DATA_VALUE}
)
public ResponseEntity<Message> create(
@RequestPart("messageCreateRequest") MessageCreateRequest messageCreateRequest,
@RequestPart(value = "files", required = false) List<MultipartFile> files
){
List<BinaryContentCreateRequest> binaryAttachments = new ArrayList<>();

if (files != null) {
for (MultipartFile file : files) {
try {
binaryAttachments.add(
new BinaryContentCreateRequest(
file.getOriginalFilename(),
file.getContentType(),
file.getBytes()
)
);
} catch (IOException e) {
throw new RuntimeException(e);
}
System.out.println(file.getOriginalFilename());
System.out.println(file.getSize());
System.out.println(file.getContentType());

}
}

Message createdMessage =
messageService.create(messageCreateRequest, binaryAttachments);

return ResponseEntity
.status(HttpStatus.CREATED)
.body(createdMessage);


}

Choose a reason for hiding this comment

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

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

byte[] bytes = attachmentRequest.bytes();

BinaryContent binaryContent = new BinaryContent(fileName, (long) bytes.length, contentType, bytes);
BinaryContent createdBinaryContent = binaryContentRepository.save(binaryContent);

Choose a reason for hiding this comment

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

부수효과 없이 작성하기 위해 데이터 수정/생성 작업은 외부로 빼서 for-each 에서 최종적으로 수행하는 편이 좋습니다!

path = "findAll",
method = {RequestMethod.GET}
)
public ResponseEntity<List<BinaryContent>> findAllByIdIn(

Choose a reason for hiding this comment

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

지금 Entity 바로 반환하고 있는데 ResponseDto 만들어서 반환하는게 좋긴 해요. 그 이유에 대해선 한번 AI에 물어봐보세요!

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

Labels

매운맛🔥 뒤는 없습니다. 그냥 필터 없이 말해주세요. 책임은 제가 집니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants