Skip to content

Commit

Permalink
[FEAT] add team leader position in updateTeam API request
Browse files Browse the repository at this point in the history
  • Loading branch information
nogamsung committed Feb 13, 2024
1 parent 934c12c commit e89d80e
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ public class TeamController {
@ApiOperation(value = "팀 생성",
notes = "<응답 코드>\n" +
"- 201 = TEAM_CREATED\n" +
"- 400 = DESIGNER_MAX_CNT_FIELD_REQUIRED || BACKEND_MAX_CNT_FIELD_REQUIRED || " +
"FRONTEND_MAX_CNT_FIELD_REQUIRED || MANAGER_MAX_CNT_FIELD_REQUIRED || " +
"PROJECT_NAME_LENGTH_INVALID || PROJECT_DESCRIPTION_LENGTH_INVALID || " +
"- 400 = PROJECT_NAME_LENGTH_INVALID || PROJECT_DESCRIPTION_LENGTH_INVALID || " +
"EXPECTATION_LENGTH_INVALID || OPEN_CHAT_URL_LENGTH_INVALID || OPEN_CHAT_URL_FORMAT_INVALID || " +
"DESIGNER_MAX_CNT_POSITIVE_OR_ZERO_ONLY || BACKEND_MAX_CNT_POSITIVE_OR_ZERO_ONLY || " +
"FRONTEND_MAX_CNT_POSITIVE_OR_ZERO_ONLY || MANAGER_MAX_CNT_POSITIVE_OR_ZERO_ONLY\n" +
"LEADER_POSITION_FIELD_REQUIRED || LEADER_POSITION_TYPE_INVALID || " +
"DESIGNER_MAX_CNT_FIELD_REQUIRED || DESIGNER_MAX_CNT_POSITIVE_OR_ZERO_ONLY || " +
"BACKEND_MAX_CNT_FIELD_REQUIRED || BACKEND_MAX_CNT_POSITIVE_OR_ZERO_ONLY || " +
"FRONTEND_MAX_CNT_FIELD_REQUIRED || FRONTEND_MAX_CNT_POSITIVE_OR_ZERO_ONLY || " +
"MANAGER_MAX_CNT_FIELD_REQUIRED || MANAGER_MAX_CNT_POSITIVE_OR_ZERO_ONLY\n" +
"- 401 = TOKEN_UNAUTHENTICATED\n" +
"- 403 = TOKEN_UNAUTHORIZED\n" +
"- 404 = USER_NOT_FOUND\n" +
Expand Down Expand Up @@ -91,17 +92,18 @@ public ResponseEntity<DefaultSingleResponse<Object>> createTeam(
@ApiOperation(value = "팀 수정",
notes = "<응답 코드>\n" +
"- 200 = TEAM_UPDATED\n" +
"- 400 = DESIGNER_MAX_CNT_FIELD_REQUIRED || BACKEND_MAX_CNT_FIELD_REQUIRED || " +
"FRONTEND_MAX_CNT_FIELD_REQUIRED || MANAGER_MAX_CNT_FIELD_REQUIRED || " +
"PROJECT_NAME_LENGTH_INVALID || PROJECT_DESCRIPTION_LENGTH_INVALID || " +
"- 400 = PROJECT_NAME_LENGTH_INVALID || PROJECT_DESCRIPTION_LENGTH_INVALID || " +
"EXPECTATION_LENGTH_INVALID || OPEN_CHAT_URL_LENGTH_INVALID || OPEN_CHAT_URL_FORMAT_INVALID || " +
"DESIGNER_MAX_CNT_POSITIVE_OR_ZERO_ONLY || BACKEND_MAX_CNT_POSITIVE_OR_ZERO_ONLY || " +
"FRONTEND_MAX_CNT_POSITIVE_OR_ZERO_ONLY || MANAGER_MAX_CNT_POSITIVE_OR_ZERO_ONLY\n" +
"LEADER_POSITION_FIELD_REQUIRED || LEADER_POSITION_TYPE_INVALID || " +
"DESIGNER_MAX_CNT_FIELD_REQUIRED || DESIGNER_MAX_CNT_POSITIVE_OR_ZERO_ONLY || " +
"BACKEND_MAX_CNT_FIELD_REQUIRED || BACKEND_MAX_CNT_POSITIVE_OR_ZERO_ONLY || " +
"FRONTEND_MAX_CNT_FIELD_REQUIRED || FRONTEND_MAX_CNT_POSITIVE_OR_ZERO_ONLY || " +
"MANAGER_MAX_CNT_FIELD_REQUIRED || MANAGER_MAX_CNT_POSITIVE_OR_ZERO_ONLY\n" +
"- 401 = TOKEN_UNAUTHENTICATED\n" +
"- 403 = TOKEN_UNAUTHORIZED || REQUEST_FORBIDDEN\n" +
"- 404 = USER_NOT_FOUND || CURRENT_TEAM_NOT_FOUND\n" +
"- 409 = DESIGNER_CNT_UPDATE_UNAVAILABLE || BACKEND_CNT_UPDATE_UNAVAILABLE || " +
"FRONTEND_CNT_UPDATE_UNAVAILABLE || MANAGER_CNT_UPDATE_AVAILABLE\n" +
"FRONTEND_CNT_UPDATE_UNAVAILABLE || MANAGER_CNT_UPDATE_AVAILABLE || TEAM_POSITION_UNAVAILABLE\n" +
"- 500 = SERVER_ERROR\n" +
"- 503 = ONGOING_INSPECTION")
@ApiResponses(value = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.PositiveOrZero;
import javax.validation.constraints.Size;
import javax.validation.constraints.*;

@Getter
@Setter
Expand Down Expand Up @@ -39,6 +36,7 @@ public class TeamCreateRequest {

@ApiModelProperty(position = 5, required = true, value = "팀장 포지션", example = "MANAGER",
allowableValues = "DESIGNER, BACKEND, FRONTEND, MANAGER")
@NotBlank(message = "팀장 포지션은 필수 입력입니다.")
@Pattern(regexp = "^(DESIGNER|BACKEND|FRONTEND|MANAGER)",
message = "팀장 포지션은 'DESIGNER', 'BACKEND', 'FRONTEND', 또는 'MANAGER' 중 하나여야 됩니다.")
private String leaderPosition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.PositiveOrZero;
import javax.validation.constraints.Size;
import javax.validation.constraints.*;

@Getter
@Setter
Expand All @@ -33,22 +30,29 @@ public class TeamUpdateRequest {
@Pattern(regexp = "^https\\:\\/\\/open\\.kakao\\.com\\/.+$", message = "오픈 채팅 URL은 카카오 오픈 채팅 형식만 가능합니다.")
private String openChatUrl;

@ApiModelProperty(position = 5, required = true, value = "디자이너 최대 수")
@ApiModelProperty(position = 5, required = true, value = "팀장 포지션", example = "MANAGER",
allowableValues = "DESIGNER, BACKEND, FRONTEND, MANAGER")
@NotBlank(message = "팀장 포지션은 필수 입력입니다.")
@Pattern(regexp = "^(DESIGNER|BACKEND|FRONTEND|MANAGER)",
message = "팀장 포지션은 'DESIGNER', 'BACKEND', 'FRONTEND', 또는 'MANAGER' 중 하나여야 됩니다.")
private String leaderPosition;

@ApiModelProperty(position = 6, required = true, value = "디자이너 최대 수")
@NotNull(message = "디자이너 최대 수는 필수 입력입니다.")
@PositiveOrZero(message = "디자이너 최대 수는 0 또는 양수만 가능합니다.")
private Byte designerMaxCnt;

@ApiModelProperty(position = 6, required = true, value = "백엔드 최대 수")
@ApiModelProperty(position = 7, required = true, value = "백엔드 최대 수")
@NotNull(message = "백엔드 최대 수는 필수 입력입니다.")
@PositiveOrZero(message = "백엔드 최대 수는 0 또는 양수만 가능합니다.")
private Byte backendMaxCnt;

@ApiModelProperty(position = 7, required = true, value = "프런트 최대 수")
@ApiModelProperty(position = 8, required = true, value = "프런트 최대 수")
@NotNull(message = "프런트 최대 수는 필수 입력입니다.")
@PositiveOrZero(message = "프런트 최대 수는 0 또는 양수만 가능합니다.")
private Byte frontendMaxCnt;

@ApiModelProperty(position = 8, required = true, value = "매니저 최대 수")
@ApiModelProperty(position = 9, required = true, value = "매니저 최대 수")
@NotNull(message = "매니저 최대 수는 필수 입력입니다.")
@PositiveOrZero(message = "매니저 최대 수는 0 또는 양수만 가능합니다.")
private Byte managerMaxCnt;
Expand All @@ -58,6 +62,7 @@ private TeamUpdateRequest(String projectName,
String projectDescription,
String expectation,
String openChatUrl,
String leaderPosition,
byte designerMaxCnt,
byte backendMaxCnt,
byte frontendMaxCnt,
Expand All @@ -66,6 +71,7 @@ private TeamUpdateRequest(String projectName,
this.projectDescription = projectDescription;
this.expectation = expectation;
this.openChatUrl = openChatUrl;
this.leaderPosition = leaderPosition;
this.designerMaxCnt = designerMaxCnt;
this.backendMaxCnt = backendMaxCnt;
this.frontendMaxCnt = frontendMaxCnt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ public TeamCreateResponse createTeam(long userId, TeamCreateRequest request) {
public TeamUpdateResponse updateTeam(long userId, TeamUpdateRequest request) {
TeamMember teamMember = findCurrentTeamMemberFetchTeam(userId);
validateLeader(teamMember);
Team team = teamMember.getTeam();
teamMember.updatePosition(Position.valueOf(request.getLeaderPosition()));

Team team = teamMember.getTeam();
team.update(request.getProjectName(), request.getProjectDescription(), request.getExpectation(),
request.getDesignerMaxCnt(), request.getBackendMaxCnt(), request.getFrontendMaxCnt(),
request.getManagerMaxCnt());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import lombok.Getter;
import org.springframework.http.HttpStatus;

import javax.validation.constraints.NotBlank;

import static org.springframework.http.HttpStatus.*;

@Getter
Expand All @@ -24,6 +26,7 @@ public enum ErrorCode {
IS_EXPERIENCED_FIELD_REQUIRED(BAD_REQUEST, "경험 여부는 필수 입력입니다."),
STARTED_AT_FIELD_REQUIRED(BAD_REQUEST, "시작일은 필수 입력입니다."),
IS_CURRENT_FIELD_REQUIRED(BAD_REQUEST, "현재 여부는 필수 입력입니다."),
LEADER_POSITION_FIELD_REQUIRED(BAD_REQUEST, "팀장 포지션은 필수 입력입니다."),
DESIGNER_MAX_CNT_FIELD_REQUIRED(BAD_REQUEST, "디자이너 최대 수는 필수 입력입니다."),
BACKEND_MAX_CNT_FIELD_REQUIRED(BAD_REQUEST, "백엔드 최대 수는 필수 입력입니다."),
FRONTEND_MAX_CNT_FIELD_REQUIRED(BAD_REQUEST, "프런트 최대 수는 필수 입력입니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ private TeamMember(Position position, boolean isLeader, User user, Team team) {
user.updateIsSeekingTeam(false);
}

public void updatePosition(Position position) {
team.leave(this.position);

this.position = position;

team.join(position);
}

public void complete(String projectUrl, LocalDateTime completedAt) {
this.teamMemberStatus = TeamMemberStatus.COMPLETE;

Expand Down
Loading

0 comments on commit e89d80e

Please sign in to comment.