From ba8331b72e04f09f1ecc661e94643b0827aaac6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9E=AC=ED=98=81?= Date: Mon, 18 Nov 2024 22:42:13 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20Team=20=EB=8F=84=EB=A9=94=EC=9D=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=B0=8F=20=EC=9D=BC=EA=B8=89=20=EC=BB=AC?= =?UTF-8?q?=EB=A0=89=EC=85=98=ED=99=94=20(#18)=20(#19)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 결제 기능 요구사항 반영 * feat: Team 도메인 수정 및 일급 컬렉션화 (#3) --- .../domain/team/application/TeamService.java | 13 ++++++++ .../jangburich/domain/team/domain/Team.java | 16 ++++++++++ .../domain/team/domain/TeamLeader.java | 23 ++++++++++++++ .../domain/team/domain/TeamType.java | 22 ++++++++++++++ .../team/dto/request/RegisterTeamRequest.java | 4 +++ .../team/presentation/TeamController.java | 30 +++++++++++++++++++ 6 files changed, 108 insertions(+) create mode 100644 src/main/java/com/jangburich/domain/team/application/TeamService.java create mode 100644 src/main/java/com/jangburich/domain/team/domain/TeamLeader.java create mode 100644 src/main/java/com/jangburich/domain/team/domain/TeamType.java create mode 100644 src/main/java/com/jangburich/domain/team/dto/request/RegisterTeamRequest.java create mode 100644 src/main/java/com/jangburich/domain/team/presentation/TeamController.java diff --git a/src/main/java/com/jangburich/domain/team/application/TeamService.java b/src/main/java/com/jangburich/domain/team/application/TeamService.java new file mode 100644 index 0000000..af234d1 --- /dev/null +++ b/src/main/java/com/jangburich/domain/team/application/TeamService.java @@ -0,0 +1,13 @@ +package com.jangburich.domain.team.application; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional(readOnly = true) +@RequiredArgsConstructor +public class TeamService { + + +} diff --git a/src/main/java/com/jangburich/domain/team/domain/Team.java b/src/main/java/com/jangburich/domain/team/domain/Team.java index 3634cb6..621a694 100644 --- a/src/main/java/com/jangburich/domain/team/domain/Team.java +++ b/src/main/java/com/jangburich/domain/team/domain/Team.java @@ -1,5 +1,8 @@ package com.jangburich.domain.team.domain; +import jakarta.persistence.Embedded; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; import java.util.HashSet; import java.util.Set; @@ -29,12 +32,25 @@ public class Team extends BaseEntity { @Column(name = "name") private String name; + @Column(name = "description") + private String description; + + @Column(name = "secret_code") + private String secretCode; + + @Embedded + private TeamLeader teamLeader; + @Column(name = "point") private Integer point; @Column(name = "member_limit") private Integer memberLimit; + @Enumerated(EnumType.STRING) + @Column(name = "team_type") + private TeamType teamType; + @ManyToMany(mappedBy = "teams") private Set users = new HashSet<>(); diff --git a/src/main/java/com/jangburich/domain/team/domain/TeamLeader.java b/src/main/java/com/jangburich/domain/team/domain/TeamLeader.java new file mode 100644 index 0000000..1bdba9c --- /dev/null +++ b/src/main/java/com/jangburich/domain/team/domain/TeamLeader.java @@ -0,0 +1,23 @@ +package com.jangburich.domain.team.domain; + +import jakarta.persistence.Embeddable; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.RequiredArgsConstructor; + +@Embeddable +@Getter +@NoArgsConstructor +public class TeamLeader { + private Long user_id; + private String accountNumber; + + public TeamLeader(Long user_id, String accountNumber) { + this.user_id = user_id; + this.accountNumber = accountNumber; + } + + public boolean isSameLeader(Long userId) { + return this.user_id.equals(userId); + } +} diff --git a/src/main/java/com/jangburich/domain/team/domain/TeamType.java b/src/main/java/com/jangburich/domain/team/domain/TeamType.java new file mode 100644 index 0000000..552f16d --- /dev/null +++ b/src/main/java/com/jangburich/domain/team/domain/TeamType.java @@ -0,0 +1,22 @@ +package com.jangburich.domain.team.domain; + +public enum TeamType { + INDIVIDUAL("개인"), + GATHERING("모임"), + FAMILY("가족"), + COMPANY("회사"), + CLUB("동아리"), + ALUMNI("동호회"), + STUDENT_ASSOCIATION("학생회"), + OTHER("기타"); + + private final String description; + + TeamType(String description) { + this.description = description; + } + + public String getDescription() { + return description; + } +} diff --git a/src/main/java/com/jangburich/domain/team/dto/request/RegisterTeamRequest.java b/src/main/java/com/jangburich/domain/team/dto/request/RegisterTeamRequest.java new file mode 100644 index 0000000..993d7c4 --- /dev/null +++ b/src/main/java/com/jangburich/domain/team/dto/request/RegisterTeamRequest.java @@ -0,0 +1,4 @@ +package com.jangburich.domain.team.dto.request; + +public record RegisterTeamRequest() { +} diff --git a/src/main/java/com/jangburich/domain/team/presentation/TeamController.java b/src/main/java/com/jangburich/domain/team/presentation/TeamController.java new file mode 100644 index 0000000..5a51616 --- /dev/null +++ b/src/main/java/com/jangburich/domain/team/presentation/TeamController.java @@ -0,0 +1,30 @@ +package com.jangburich.domain.team.presentation; + +import com.jangburich.domain.team.application.TeamService; +import com.jangburich.domain.team.dto.request.RegisterTeamRequest; +import com.jangburich.global.payload.Message; +import com.jangburich.global.payload.ResponseCustom; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.security.core.Authentication; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "Team", description = "Team API") +@RestController +@RequiredArgsConstructor +@RequestMapping("/teams") +public class TeamController { + + private final TeamService teamService; + + @PostMapping + public ResponseCustom registerTeam( + Authentication authentication, + @RequestBody RegisterTeamRequest registerTeamRequest + ) { + return ResponseCustom.OK(); + } +}