-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/BSVR-118
- Loading branch information
Showing
55 changed files
with
1,093 additions
and
228 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
application/src/main/java/org/depromeet/spot/application/block/BlockReadController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.depromeet.spot.application.block; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Positive; | ||
|
||
import org.depromeet.spot.application.block.dto.response.BlockCodeInfoResponse; | ||
import org.depromeet.spot.usecase.port.in.block.BlockReadUsecase; | ||
import org.depromeet.spot.usecase.port.in.block.BlockReadUsecase.BlockCodeInfo; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@Tag(name = "블록") | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1") | ||
public class BlockReadController { | ||
|
||
private final BlockReadUsecase blockReadUsecase; | ||
|
||
@ResponseStatus(HttpStatus.OK) | ||
@GetMapping("/stadiums/{stadiumId}/sections/{sectionId}/blocks") | ||
@Operation(summary = "특정 야구 경기장 특정 구역 내의 블록 리스트를 조회한다.") | ||
public List<BlockCodeInfoResponse> findCodeInfosByStadium( | ||
@PathVariable("stadiumId") | ||
@NotNull | ||
@Positive | ||
@Parameter(name = "stadiumId", description = "야구 경기장 PK", required = true) | ||
final Long stadiumId, | ||
@PathVariable("sectionId") | ||
@NotNull | ||
@Positive | ||
@Parameter(name = "sectionId", description = "구역 PK", required = true) | ||
final Long sectionId) { | ||
List<BlockCodeInfo> infos = blockReadUsecase.findCodeInfosByStadium(stadiumId, sectionId); | ||
return infos.stream().map(BlockCodeInfoResponse::from).toList(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...rc/main/java/org/depromeet/spot/application/block/dto/response/BlockCodeInfoResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.depromeet.spot.application.block.dto.response; | ||
|
||
import org.depromeet.spot.usecase.port.in.block.BlockReadUsecase.BlockCodeInfo; | ||
|
||
public record BlockCodeInfoResponse(Long id, String code) { | ||
|
||
public static BlockCodeInfoResponse from(BlockCodeInfo blockCodeInfo) { | ||
return new BlockCodeInfoResponse(blockCodeInfo.getId(), blockCodeInfo.getCode()); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
application/src/main/java/org/depromeet/spot/application/common/dto/RgbCodeRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.depromeet.spot.application.common.dto; | ||
|
||
import org.depromeet.spot.domain.common.RgbCode; | ||
|
||
public record RgbCodeRequest(Integer red, Integer green, Integer blue) { | ||
public RgbCode toDomain() { | ||
return RgbCode.builder().red(red).green(green).blue(blue).build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...ation/src/main/java/org/depromeet/spot/application/team/CreateBaseballTeamController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.depromeet.spot.application.team; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.NotEmpty; | ||
|
||
import org.depromeet.spot.application.team.dto.request.CreateBaseballTeamReq; | ||
import org.depromeet.spot.domain.team.BaseballTeam; | ||
import org.depromeet.spot.usecase.port.in.team.CreateBaseballTeamUsecase; | ||
import org.springframework.http.HttpStatus; | ||
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.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@Tag(name = "야구 팀") | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1") | ||
public class CreateBaseballTeamController { | ||
|
||
private final CreateBaseballTeamUsecase createBaseballTeamUsecase; | ||
|
||
@PostMapping("/baseball-teams") | ||
@ResponseStatus(HttpStatus.CREATED) | ||
@Operation(summary = "신규 야구 팀(구단) 정보를 생성한다.") | ||
public void create(@RequestBody @Valid @NotEmpty List<CreateBaseballTeamReq> requests) { | ||
List<BaseballTeam> teams = requests.stream().map(CreateBaseballTeamReq::toDomain).toList(); | ||
createBaseballTeamUsecase.saveAll(teams); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...ication/src/main/java/org/depromeet/spot/application/team/ReadBaseballTeamController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.depromeet.spot.application.team; | ||
|
||
import java.util.List; | ||
|
||
import org.depromeet.spot.application.team.dto.response.BaseballTeamLogoRes; | ||
import org.depromeet.spot.domain.team.BaseballTeam; | ||
import org.depromeet.spot.usecase.port.in.team.ReadBaseballTeamUsecase; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@Tag(name = "야구 팀") | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1") | ||
public class ReadBaseballTeamController { | ||
|
||
private final ReadBaseballTeamUsecase readBaseballTeamUsecase; | ||
|
||
@GetMapping("/baseball-teams") | ||
@ResponseStatus(HttpStatus.OK) | ||
@Operation(summary = "SPOT에서 관리하는 모든 야구 팀 정보를 조회한다.") | ||
public List<BaseballTeamLogoRes> findAll() { | ||
List<BaseballTeam> infos = readBaseballTeamUsecase.findAll(); | ||
return infos.stream().map(BaseballTeamLogoRes::from).toList(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
.../src/main/java/org/depromeet/spot/application/team/dto/request/CreateBaseballTeamReq.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.depromeet.spot.application.team.dto.request; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
|
||
import org.depromeet.spot.application.common.dto.RgbCodeRequest; | ||
import org.depromeet.spot.domain.team.BaseballTeam; | ||
import org.hibernate.validator.constraints.Length; | ||
|
||
public record CreateBaseballTeamReq( | ||
@NotBlank(message = "구단명을 입력해주세요.") | ||
@Length(max = 20, message = "구단명은 최대 20글자 까지만 입력할 수 있습니다.") | ||
String name, | ||
@NotBlank(message = "구단 별칭을 입력해주세요.") | ||
@Length(max = 10, message = "구단 별칭은 최대 10글자 까지만 입력할 수 있습니다.") | ||
String alias, | ||
@NotBlank(message = "구단 로고를 입력해주세요.") String logo, | ||
RgbCodeRequest rgbCode) { | ||
|
||
public BaseballTeam toDomain() { | ||
return BaseballTeam.builder() | ||
.name(name) | ||
.alias(alias) | ||
.logo(logo) | ||
.labelRgbCode(rgbCode.toDomain()) | ||
.build(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...n/src/main/java/org/depromeet/spot/application/team/dto/response/BaseballTeamLogoRes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.depromeet.spot.application.team.dto.response; | ||
|
||
import org.depromeet.spot.domain.team.BaseballTeam; | ||
|
||
public record BaseballTeamLogoRes(Long id, String name, String logo) { | ||
|
||
public static BaseballTeamLogoRes from(BaseballTeam team) { | ||
return new BaseballTeamLogoRes(team.getId(), team.getName(), team.getLogo()); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
common/src/main/java/org/depromeet/spot/common/exception/section/SectionErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.depromeet.spot.common.exception.section; | ||
|
||
import org.depromeet.spot.common.exception.ErrorCode; | ||
import org.springframework.http.HttpStatus; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum SectionErrorCode implements ErrorCode { | ||
SECTION_NOT_FOUND(HttpStatus.NOT_FOUND, "SE001", "요청 구역이 존재하지 않습니다."), | ||
SECTION_NOT_BELONG_TO_STADIUM(HttpStatus.BAD_REQUEST, "SE002", "요청 경기장의 구역이 아닙니다."), | ||
; | ||
|
||
private final HttpStatus status; | ||
private final String code; | ||
private String message; | ||
|
||
SectionErrorCode(HttpStatus status, String code, String message) { | ||
this.status = status; | ||
this.code = code; | ||
this.message = message; | ||
} | ||
|
||
public SectionErrorCode appended(Object o) { | ||
message = message + " {" + o.toString() + "}"; | ||
return this; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
common/src/main/java/org/depromeet/spot/common/exception/section/SectionException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.depromeet.spot.common.exception.section; | ||
|
||
import org.depromeet.spot.common.exception.BusinessException; | ||
|
||
public abstract class SectionException extends BusinessException { | ||
|
||
protected SectionException(SectionErrorCode errorCode) { | ||
super(errorCode); | ||
} | ||
|
||
public static class SectionNotFoundException extends SectionException { | ||
public SectionNotFoundException() { | ||
super(SectionErrorCode.SECTION_NOT_FOUND); | ||
} | ||
} | ||
|
||
public static class SectionNotBelongStadiumException extends SectionException { | ||
public SectionNotBelongStadiumException() { | ||
super(SectionErrorCode.SECTION_NOT_BELONG_TO_STADIUM); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
common/src/main/java/org/depromeet/spot/common/exception/team/TeamErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.depromeet.spot.common.exception.team; | ||
|
||
import org.depromeet.spot.common.exception.ErrorCode; | ||
import org.springframework.http.HttpStatus; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum TeamErrorCode implements ErrorCode { | ||
BASEBALL_TEAM_NOT_FOUND(HttpStatus.NOT_FOUND, "T001", "요청 구단이 존재하지 않습니다."), | ||
INVALID_TEAM_NAME_NOT_FOUND(HttpStatus.BAD_REQUEST, "T002", "구단명이 잘못되었습니다."), | ||
INVALID_TEAM_ALIAS_NOT_FOUND(HttpStatus.BAD_REQUEST, "T003", "구단 별칭이 잘못되었습니다."), | ||
DUPLICATE_TEAM_NAME(HttpStatus.CONFLICT, "T004", "이미 등록된 구단입니다."), | ||
EMPTY_TEAM_LOGO(HttpStatus.BAD_REQUEST, "T005", "구단 로고를 등록해주세요."), | ||
; | ||
|
||
private final HttpStatus status; | ||
private final String code; | ||
private String message; | ||
|
||
TeamErrorCode(HttpStatus status, String code, String message) { | ||
this.status = status; | ||
this.code = code; | ||
this.message = message; | ||
} | ||
|
||
public TeamErrorCode appended(Object o) { | ||
message = message + " {" + o.toString() + "}"; | ||
return this; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
common/src/main/java/org/depromeet/spot/common/exception/team/TeamException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.depromeet.spot.common.exception.team; | ||
|
||
import org.depromeet.spot.common.exception.BusinessException; | ||
|
||
public abstract class TeamException extends BusinessException { | ||
|
||
protected TeamException(TeamErrorCode errorCode) { | ||
super(errorCode); | ||
} | ||
|
||
public static class BaseballTeamNotFoundException extends TeamException { | ||
public BaseballTeamNotFoundException() { | ||
super(TeamErrorCode.BASEBALL_TEAM_NOT_FOUND); | ||
} | ||
} | ||
|
||
public static class InvalidBaseballTeamNameException extends TeamException { | ||
public InvalidBaseballTeamNameException() { | ||
super(TeamErrorCode.INVALID_TEAM_NAME_NOT_FOUND); | ||
} | ||
} | ||
|
||
public static class InvalidBaseballAliasNameException extends TeamException { | ||
public InvalidBaseballAliasNameException() { | ||
super(TeamErrorCode.INVALID_TEAM_ALIAS_NOT_FOUND); | ||
} | ||
} | ||
|
||
public static class DuplicateTeamNameException extends TeamException { | ||
public DuplicateTeamNameException() { | ||
super(TeamErrorCode.DUPLICATE_TEAM_NAME); | ||
} | ||
} | ||
|
||
public static class EmptyTeamLogoException extends TeamException { | ||
public EmptyTeamLogoException() { | ||
super(TeamErrorCode.EMPTY_TEAM_LOGO); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.