Skip to content

Commit

Permalink
refactor : 스페이스 생성 api response dto 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
seongjunnoh committed Jul 31, 2024
1 parent 658e4dd commit ded8b2b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 24 deletions.
11 changes: 4 additions & 7 deletions src/main/java/space/space_spring/controller/SpaceController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@
import space.space_spring.argument_resolver.jwtLogin.JwtLoginAuth;
import space.space_spring.dto.space.GetUserInfoBySpaceResponse;
import space.space_spring.dto.space.PostSpaceCreateRequest;
import space.space_spring.dto.space.PostSpaceCreateResponse;

import space.space_spring.entity.UserSpace;
import space.space_spring.exception.MultipartFileException;
import space.space_spring.exception.SpaceException;
import space.space_spring.response.BaseResponse;
import space.space_spring.service.S3Uploader;
import space.space_spring.service.SpaceService;
import space.space_spring.util.userSpace.UserSpaceUtils;

import java.io.IOException;
import java.util.Optional;

import static space.space_spring.response.status.BaseExceptionResponseStatus.INVALID_SPACE_CREATE;
import static space.space_spring.response.status.BaseExceptionResponseStatus.IS_NOT_IMAGE_FILE;
Expand All @@ -33,12 +29,11 @@
public class SpaceController {

private final SpaceService spaceService;
private final UserSpaceUtils userSpaceUtils;
private final S3Uploader s3Uploader;
private final String spaceImgDirName = "spaceImg";

@PostMapping("")
public BaseResponse<PostSpaceCreateResponse> createSpace(@JwtLoginAuth Long userId, @Validated @ModelAttribute PostSpaceCreateRequest postSpaceCreateRequest, BindingResult bindingResult) throws IOException {
public BaseResponse<String> createSpace(@JwtLoginAuth Long userId, @Validated @ModelAttribute PostSpaceCreateRequest postSpaceCreateRequest, BindingResult bindingResult) throws IOException {
if (bindingResult.hasErrors()) {
throw new SpaceException(INVALID_SPACE_CREATE, getErrorMessage(bindingResult));
}
Expand All @@ -47,7 +42,9 @@ public BaseResponse<PostSpaceCreateResponse> createSpace(@JwtLoginAuth Long user
String spaceImgUrl = processSpaceImage(postSpaceCreateRequest.getSpaceProfileImg());

// TODO 2. s3에 저장하고 받은 이미지 url 정보와 spaceName 정보로 space create 작업 수행
return new BaseResponse<>(spaceService.createSpace(userId, postSpaceCreateRequest.getSpaceName(), spaceImgUrl));
spaceService.createSpace(userId, postSpaceCreateRequest.getSpaceName(), spaceImgUrl);

return new BaseResponse<>("스페이스 생성 성공");
}

private String processSpaceImage(MultipartFile spaceProfileImg) throws IOException {
Expand Down

This file was deleted.

7 changes: 2 additions & 5 deletions src/main/java/space/space_spring/service/SpaceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@
import space.space_spring.dao.UserDao;
import space.space_spring.dao.UserSpaceDao;
import space.space_spring.dto.space.GetUserInfoBySpaceResponse;
import space.space_spring.dto.space.PostSpaceCreateResponse;
import space.space_spring.entity.Space;
import space.space_spring.entity.User;
import space.space_spring.dto.space.PostSpaceCreateRequest;
import space.space_spring.entity.UserSpace;
import space.space_spring.util.space.SpaceUtils;

import java.util.List;

@Service
@RequiredArgsConstructor
Expand All @@ -26,7 +23,7 @@ public class SpaceService {
private final SpaceUtils spaceUtils;

@Transactional
public PostSpaceCreateResponse createSpace(Long userId, String spaceName, String spaceImgUrl) {
public Long createSpace(Long userId, String spaceName, String spaceImgUrl) {

// TODO 1. 스페이스 생성 정보 db insert
Space saveSpace = spaceDao.saveSpace(spaceName, spaceImgUrl);
Expand All @@ -35,7 +32,7 @@ public PostSpaceCreateResponse createSpace(Long userId, String spaceName, String
User manager = userDao.findUserByUserId(userId);
UserSpace userSpace = userSpaceDao.createUserSpace(manager, saveSpace);

return new PostSpaceCreateResponse(saveSpace.getSpaceId(), spaceImgUrl);
return saveSpace.getSpaceId();
}

@Transactional
Expand Down

0 comments on commit ded8b2b

Please sign in to comment.