Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Team 도메인 수정 및 일급 컬렉션화 #3

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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 {


}
16 changes: 16 additions & 0 deletions src/main/java/com/jangburich/domain/team/domain/Team.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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<User> users = new HashSet<>();

Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/jangburich/domain/team/domain/TeamLeader.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
22 changes: 22 additions & 0 deletions src/main/java/com/jangburich/domain/team/domain/TeamType.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.jangburich.domain.team.dto.request;

public record RegisterTeamRequest() {
}
Original file line number Diff line number Diff line change
@@ -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<Message> registerTeam(
Authentication authentication,
@RequestBody RegisterTeamRequest registerTeamRequest
) {
return ResponseCustom.OK();
}
}