Skip to content

Commit

Permalink
refactor : UserSpace 엔티티 생성 로직 수정(권한 선택할 수 있도록 설정)
Browse files Browse the repository at this point in the history
  • Loading branch information
seongjunnoh committed Aug 12, 2024
1 parent 745c6ef commit bde6df4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/main/java/space/space_spring/dao/UserSpaceDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import space.space_spring.entity.Space;
import space.space_spring.entity.User;
import space.space_spring.entity.UserSpace;
import space.space_spring.entity.enumStatus.UserSpaceAuth;

import java.util.*;

Expand All @@ -21,9 +22,9 @@ public class UserSpaceDao {
@PersistenceContext
private EntityManager em;

public UserSpace createUserSpace(User manager, Space saveSpace) {
public UserSpace createUserSpace(User manager, Space saveSpace, UserSpaceAuth userSpaceAuth) {
UserSpace userSpace = new UserSpace();
userSpace.createUserSpace(manager, saveSpace, MANAGER);
userSpace.createUserSpace(manager, saveSpace, userSpaceAuth);

em.persist(userSpace);
return userSpace;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/space/space_spring/service/SpaceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import space.space_spring.entity.Space;
import space.space_spring.entity.User;
import space.space_spring.entity.UserSpace;
import space.space_spring.entity.enumStatus.UserSpaceAuth;
import space.space_spring.exception.UserSpaceException;
import space.space_spring.util.space.SpaceUtils;
import space.space_spring.util.user.UserUtils;
Expand Down Expand Up @@ -44,7 +45,7 @@ public Long createSpace(Long userId, String spaceName, String spaceImgUrl) {

// TODO 2. 유저_스페이스 매핑 정보 db insert
User manager = userDao.findUserByUserId(userId);
UserSpace userSpace = userSpaceDao.createUserSpace(manager, saveSpace);
UserSpace userSpace = userSpaceDao.createUserSpace(manager, saveSpace, UserSpaceAuth.MANAGER);

return saveSpace.getSpaceId();
}
Expand Down Expand Up @@ -147,7 +148,7 @@ public void createUserSpace(Long userId, Long spaceId, PostSpaceJoinDto postSpac
Space spaceBySpaceId = spaceUtils.findSpaceBySpaceId(spaceId);

// TODO 3. 유저_스페이스 매핑 정보 db insert
UserSpace userSpace = userSpaceDao.createUserSpace(userByUserId, spaceBySpaceId);
UserSpace userSpace = userSpaceDao.createUserSpace(userByUserId, spaceBySpaceId, UserSpaceAuth.NORMAL);

userSpace.changeUserProfileImg(postSpaceJoinDto.getUserProfileImg());
userSpace.changeUserName(postSpaceJoinDto.getUserName());
Expand Down

0 comments on commit bde6df4

Please sign in to comment.