diff --git a/backend/src/main/java/com/twtw/backend/config/security/SecurityConfig.java b/backend/src/main/java/com/twtw/backend/config/security/SecurityConfig.java index 9c8fef60..85d439d8 100644 --- a/backend/src/main/java/com/twtw/backend/config/security/SecurityConfig.java +++ b/backend/src/main/java/com/twtw/backend/config/security/SecurityConfig.java @@ -36,7 +36,8 @@ public SecurityFilterChain configure(HttpSecurity http) throws Exception { "/swagger-ui.html", "auth/refresh", "auth/save", - "auth/login") + "auth/login", + "member/duplicate/**") .permitAll()) .authorizeHttpRequests( x -> x.requestMatchers("/test/**").permitAll().anyRequest().authenticated()) diff --git a/backend/src/main/java/com/twtw/backend/domain/group/controller/GroupController.java b/backend/src/main/java/com/twtw/backend/domain/group/controller/GroupController.java new file mode 100644 index 00000000..4a529814 --- /dev/null +++ b/backend/src/main/java/com/twtw/backend/domain/group/controller/GroupController.java @@ -0,0 +1,16 @@ +package com.twtw.backend.domain.group.controller; + +import com.twtw.backend.domain.group.service.GroupService; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/group") +public class GroupController { + private final GroupService groupService; + + public GroupController(GroupService groupService) { + this.groupService = groupService; + } +} diff --git a/backend/src/main/java/com/twtw/backend/domain/group/entity/Group.java b/backend/src/main/java/com/twtw/backend/domain/group/entity/Group.java new file mode 100644 index 00000000..b7c80de0 --- /dev/null +++ b/backend/src/main/java/com/twtw/backend/domain/group/entity/Group.java @@ -0,0 +1,27 @@ +package com.twtw.backend.domain.group.entity; + +import jakarta.persistence.*; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Group { + @Id + @GeneratedValue(generator = "uuid2") + @Column(name = "id", columnDefinition = "BINARY(16)") + private UUID id; + + private String name; + private String groupImage; + + @OneToMany(mappedBy = "group") + private List groupMembers = new ArrayList<>(); +} diff --git a/backend/src/main/java/com/twtw/backend/domain/group/entity/GroupMember.java b/backend/src/main/java/com/twtw/backend/domain/group/entity/GroupMember.java new file mode 100644 index 00000000..c635dea5 --- /dev/null +++ b/backend/src/main/java/com/twtw/backend/domain/group/entity/GroupMember.java @@ -0,0 +1,29 @@ +package com.twtw.backend.domain.group.entity; + +import com.twtw.backend.domain.member.entity.Member; + +import jakarta.persistence.*; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.UUID; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class GroupMember { + @Id + @GeneratedValue(generator = "uuid2") + @Column(name = "id", columnDefinition = "BINARY(16)") + private UUID id; + + @ManyToOne + @JoinColumn(name = "group_id") + private Group group; + + @ManyToOne + @JoinColumn(name = "member_id") + private Member member; +} diff --git a/backend/src/main/java/com/twtw/backend/domain/group/repository/GroupMemberRepository.java b/backend/src/main/java/com/twtw/backend/domain/group/repository/GroupMemberRepository.java new file mode 100644 index 00000000..5b242778 --- /dev/null +++ b/backend/src/main/java/com/twtw/backend/domain/group/repository/GroupMemberRepository.java @@ -0,0 +1,9 @@ +package com.twtw.backend.domain.group.repository; + +import com.twtw.backend.domain.group.entity.GroupMember; + +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.UUID; + +public interface GroupMemberRepository extends JpaRepository {} diff --git a/backend/src/main/java/com/twtw/backend/domain/group/repository/GroupRepository.java b/backend/src/main/java/com/twtw/backend/domain/group/repository/GroupRepository.java new file mode 100644 index 00000000..7860acab --- /dev/null +++ b/backend/src/main/java/com/twtw/backend/domain/group/repository/GroupRepository.java @@ -0,0 +1,9 @@ +package com.twtw.backend.domain.group.repository; + +import com.twtw.backend.domain.group.entity.Group; + +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.UUID; + +public interface GroupRepository extends JpaRepository {} diff --git a/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java b/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java new file mode 100644 index 00000000..147e2f2a --- /dev/null +++ b/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java @@ -0,0 +1,14 @@ +package com.twtw.backend.domain.group.service; + +import com.twtw.backend.domain.group.repository.GroupRepository; + +import org.springframework.stereotype.Service; + +@Service +public class GroupService { + private final GroupRepository groupRepository; + + public GroupService(GroupRepository groupRepository) { + this.groupRepository = groupRepository; + } +} diff --git a/backend/src/main/java/com/twtw/backend/domain/member/entity/Member.java b/backend/src/main/java/com/twtw/backend/domain/member/entity/Member.java index 8aa6041f..4654903d 100644 --- a/backend/src/main/java/com/twtw/backend/domain/member/entity/Member.java +++ b/backend/src/main/java/com/twtw/backend/domain/member/entity/Member.java @@ -1,11 +1,15 @@ package com.twtw.backend.domain.member.entity; +import com.twtw.backend.domain.group.entity.GroupMember; + import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; @Entity @@ -26,6 +30,9 @@ public class Member { @Embedded private OAuth2Info oAuth2Info; + @OneToMany(mappedBy = "member") + private List groupMembers = new ArrayList<>(); + public Member(String nickname, String profileImage) { this.nickname = nickname; this.profileImage = profileImage;