Skip to content

Commit

Permalink
Merge pull request #33 from HongDam-org/meeting
Browse files Browse the repository at this point in the history
[ADD] Group Controller + Service + Repository + Entity 설계 완료
  • Loading branch information
jinjoo-lab authored Oct 9, 2023
2 parents 257aaa3 + 1dcbaec commit c1ba424
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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<GroupMember> groupMembers = new ArrayList<>();
}
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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<GroupMember, UUID> {}
Original file line number Diff line number Diff line change
@@ -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<Group, UUID> {}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -26,6 +30,9 @@ public class Member {

@Embedded private OAuth2Info oAuth2Info;

@OneToMany(mappedBy = "member")
private List<GroupMember> groupMembers = new ArrayList<>();

public Member(String nickname, String profileImage) {
this.nickname = nickname;
this.profileImage = profileImage;
Expand Down

0 comments on commit c1ba424

Please sign in to comment.