Skip to content

Commit

Permalink
โ™ป๏ธ Refactor: googleJavaFormat().aosp() ์ ์šฉ
Browse files Browse the repository at this point in the history
  • Loading branch information
swa07016 committed Dec 27, 2023
1 parent 8bbd6fc commit fe8987d
Show file tree
Hide file tree
Showing 106 changed files with 2,904 additions and 2,856 deletions.
11 changes: 7 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.1.2'
id 'io.spring.dependency-management' version '1.1.2'
id 'com.diffplug.spotless' version '6.23.3'
id 'com.diffplug.spotless' version '6.23.3' // Spotless ํ”Œ๋Ÿฌ๊ทธ์ธ
}

group = 'briefing.info'
Expand Down Expand Up @@ -88,7 +88,12 @@ jar {
spotless {
java {
// Google Java ํฌ๋งท ์ ์šฉ
googleJavaFormat()
/*
googleJavaFormat() : ํƒญ์€ 2๊ฐœ์˜ ๊ณต๋ฐฑ
googleJavaFormat().aosp() : ํƒญ์€ 4๊ฐœ์˜ ๊ณต๋ฐฑ
[์ฐธ๊ณ ] https://github.com/google/google-java-format/issues/525
*/
googleJavaFormat().aosp()
// ์•„๋ž˜ ์ˆœ์„œ๋กœ import๋ฌธ ์ •๋ ฌ
importOrder('java', 'javax', 'jakarta', 'org', 'com')
// ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” import ์ œ๊ฑฐ
Expand All @@ -97,7 +102,5 @@ spotless {
trimTrailingWhitespace()
// ํŒŒ์ผ ๋์— ์ƒˆ๋กœ์šด ๋ผ์ธ ์ถ”๊ฐ€
endWithNewline()
// ๊ณต๋ฐฑ 4๊ฐœ๋กœ ๋“ค์—ฌ์“ฐ๊ธฐ
indentWithTabs(4)
}
}
6 changes: 3 additions & 3 deletions src/main/java/briefing/BriefingApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@ImportAutoConfiguration({FeignAutoConfiguration.class})
public class BriefingApplication {

public static void main(final String[] args) {
SpringApplication.run(BriefingApplication.class, args);
}
public static void main(final String[] args) {
SpringApplication.run(BriefingApplication.class, args);
}
}
22 changes: 11 additions & 11 deletions src/main/java/briefing/GlobalControllerAdvice.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
// @RestControllerAdvice
public class GlobalControllerAdvice {

@ExceptionHandler(BaseException.class)
public ResponseEntity<ExceptionResponse> handleException(final BaseException e) {
final BaseExceptionType type = e.exceptionType();
log.warn("[WARN] MESSAGE: {}", type.message());
return new ResponseEntity<>(ExceptionResponse.from(e), e.exceptionType().status());
}
@ExceptionHandler(BaseException.class)
public ResponseEntity<ExceptionResponse> handleException(final BaseException e) {
final BaseExceptionType type = e.exceptionType();
log.warn("[WARN] MESSAGE: {}", type.message());
return new ResponseEntity<>(ExceptionResponse.from(e), e.exceptionType().status());
}

private record ExceptionResponse(String message) {
private record ExceptionResponse(String message) {

private static ExceptionResponse from(final BaseException e) {
return new ExceptionResponse(e.exceptionType().message());
}
}
private static ExceptionResponse from(final BaseException e) {
return new ExceptionResponse(e.exceptionType().message());
}
}
}
8 changes: 4 additions & 4 deletions src/main/java/briefing/base/BaseDateTimeEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
@Getter
public abstract class BaseDateTimeEntity {

@Column(updatable = false)
@CreatedDate
private LocalDateTime createdAt;
@Column(updatable = false)
@CreatedDate
private LocalDateTime createdAt;

@LastModifiedDate private LocalDateTime updatedAt;
@LastModifiedDate private LocalDateTime updatedAt;
}
8 changes: 4 additions & 4 deletions src/main/java/briefing/base/BaseException.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

public abstract class BaseException extends RuntimeException {

protected BaseException(final String message) {
super(message);
}
protected BaseException(final String message) {
super(message);
}

public abstract BaseExceptionType exceptionType();
public abstract BaseExceptionType exceptionType();
}
4 changes: 2 additions & 2 deletions src/main/java/briefing/base/BaseExceptionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public interface BaseExceptionType {

HttpStatus status();
HttpStatus status();

String message();
String message();
}
175 changes: 88 additions & 87 deletions src/main/java/briefing/briefing/api/BriefingApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,91 +30,92 @@
@RequiredArgsConstructor
public class BriefingApi {

private final BriefingQueryService briefingQueryService;
private final BriefingCommandService briefingCommandService;
private final ScrapQueryService scrapQueryService;

@GetMapping("/v2/briefings")
@Operation(summary = "03-01Briefing \uD83D\uDCF0 ๋ธŒ๋ฆฌํ•‘ ๋ชฉ๋ก ์กฐํšŒ V2", description = "")
public CommonResponse<BriefingResponseDTO.BriefingPreviewListDTOV2> findBriefingsV2(
@ParameterObject @ModelAttribute BriefingRequestParam.BriefingPreviewListParam params) {
List<Briefing> briefingList = briefingQueryService.findBriefings(params, APIVersion.V2);
return CommonResponse.onSuccess(
BriefingConverter.toBriefingPreviewListDTOV2(params.getDate(), briefingList));
}

@GetMapping("/briefings")
@Parameter(name = "timeOfDay", hidden = true)
@Operation(summary = "03-01Briefing \uD83D\uDCF0 ๋ธŒ๋ฆฌํ•‘ ๋ชฉ๋ก ์กฐํšŒ V1", description = "")
public CommonResponse<BriefingResponseDTO.BriefingPreviewListDTO> findBriefings(
@ParameterObject @ModelAttribute BriefingRequestParam.BriefingPreviewListParam params) {

List<Briefing> briefingList = briefingQueryService.findBriefings(params, APIVersion.V1);
return CommonResponse.onSuccess(
BriefingConverter.toBriefingPreviewListDTO(params.getDate(), briefingList));
}

@Deprecated
@Operation(
summary = "ํ‚ค์›Œ๋“œ ์ „๋‹ฌ V2 ์ž„์‹œ API",
description = "ํ‚ค์›Œ๋“œ ์ „๋‹ฌ V2 ์ž„์‹œ API ์ž…๋‹ˆ๋‹ค. ์‘๋‹ต์€ ๋ฌด์กฐ๊ฑด ๋™์ผํ•ฉ๋‹ˆ๋‹ค. type๋งŒ ์ฃผ์‹ ๊ฑธ ๋‹ด์•„์„œ ๋“œ๋ฆฝ๋‹ˆ๋‹ค.")
@ApiResponse(responseCode = "1000", description = "OK, ์„ฑ๊ณต")
@GetMapping("/briefings/temp")
public CommonResponse<BriefingResponseDTO.BriefingV2PreviewListDTO> findBriefingsV2Temp(
@RequestParam("type") final BriefingType type, @RequestParam("date") final LocalDate date) {
List<Long> idList = Arrays.asList(346L, 347L, 348L, 349L, 350L);
return CommonResponse.onSuccess(
BriefingConverter.toBriefingPreviewV2TempListDTO(date, idList, type));
}

@GetMapping("/v2/briefings/{id}")
@Operation(summary = "03-02Briefing \uD83D\uDCF0 ๋ธŒ๋ฆฌํ•‘ ๋‹จ๊ฑด ์กฐํšŒ V2", description = "")
@Parameter(name = "member", hidden = true)
public CommonResponse<BriefingResponseDTO.BriefingDetailDTOV2> findBriefingV2(
@PathVariable final Long id, @AuthMember Member member) {

Boolean isScrap =
Optional.ofNullable(member)
.map(m -> scrapQueryService.existsByMemberIdAndBriefingId(m.getId(), id))
.orElseGet(() -> Boolean.FALSE);

Boolean isBriefingOpen = false;
Boolean isWarning = false;

return CommonResponse.onSuccess(
BriefingConverter.toBriefingDetailDTOV2(
briefingQueryService.findBriefing(id, APIVersion.V2),
isScrap,
isBriefingOpen,
isWarning));
}

@GetMapping("/briefings/{id}")
@Parameter(name = "member", hidden = true)
@Operation(summary = "03-02Briefing \uD83D\uDCF0 ๋ธŒ๋ฆฌํ•‘ ๋‹จ๊ฑด ์กฐํšŒ V1", description = "")
public CommonResponse<BriefingResponseDTO.BriefingDetailDTO> findBriefing(
@PathVariable final Long id, @AuthMember Member member) {

Boolean isScrap =
Optional.ofNullable(member)
.map(m -> scrapQueryService.existsByMemberIdAndBriefingId(m.getId(), id))
.orElseGet(() -> Boolean.FALSE);

Boolean isBriefingOpen = false;
Boolean isWarning = false;

return CommonResponse.onSuccess(
BriefingConverter.toBriefingDetailDTO(
briefingQueryService.findBriefing(id, APIVersion.V1),
isScrap,
isBriefingOpen,
isWarning));
}

@PostMapping("/briefings")
@ResponseStatus(HttpStatus.CREATED)
@Operation(summary = "03-03Briefing \uD83D\uDCF0 ๋ธŒ๋ฆฌํ•‘ ๋“ฑ๋ก", description = "")
public void createBriefing(@RequestBody final BriefingRequestDTO.BriefingCreate request) {
briefingCommandService.createBriefing(request);
}
private final BriefingQueryService briefingQueryService;
private final BriefingCommandService briefingCommandService;
private final ScrapQueryService scrapQueryService;

@GetMapping("/v2/briefings")
@Operation(summary = "03-01Briefing \uD83D\uDCF0 ๋ธŒ๋ฆฌํ•‘ ๋ชฉ๋ก ์กฐํšŒ V2", description = "")
public CommonResponse<BriefingResponseDTO.BriefingPreviewListDTOV2> findBriefingsV2(
@ParameterObject @ModelAttribute BriefingRequestParam.BriefingPreviewListParam params) {
List<Briefing> briefingList = briefingQueryService.findBriefings(params, APIVersion.V2);
return CommonResponse.onSuccess(
BriefingConverter.toBriefingPreviewListDTOV2(params.getDate(), briefingList));
}

@GetMapping("/briefings")
@Parameter(name = "timeOfDay", hidden = true)
@Operation(summary = "03-01Briefing \uD83D\uDCF0 ๋ธŒ๋ฆฌํ•‘ ๋ชฉ๋ก ์กฐํšŒ V1", description = "")
public CommonResponse<BriefingResponseDTO.BriefingPreviewListDTO> findBriefings(
@ParameterObject @ModelAttribute BriefingRequestParam.BriefingPreviewListParam params) {

List<Briefing> briefingList = briefingQueryService.findBriefings(params, APIVersion.V1);
return CommonResponse.onSuccess(
BriefingConverter.toBriefingPreviewListDTO(params.getDate(), briefingList));
}

@Deprecated
@Operation(
summary = "ํ‚ค์›Œ๋“œ ์ „๋‹ฌ V2 ์ž„์‹œ API",
description = "ํ‚ค์›Œ๋“œ ์ „๋‹ฌ V2 ์ž„์‹œ API ์ž…๋‹ˆ๋‹ค. ์‘๋‹ต์€ ๋ฌด์กฐ๊ฑด ๋™์ผํ•ฉ๋‹ˆ๋‹ค. type๋งŒ ์ฃผ์‹ ๊ฑธ ๋‹ด์•„์„œ ๋“œ๋ฆฝ๋‹ˆ๋‹ค.")
@ApiResponse(responseCode = "1000", description = "OK, ์„ฑ๊ณต")
@GetMapping("/briefings/temp")
public CommonResponse<BriefingResponseDTO.BriefingV2PreviewListDTO> findBriefingsV2Temp(
@RequestParam("type") final BriefingType type,
@RequestParam("date") final LocalDate date) {
List<Long> idList = Arrays.asList(346L, 347L, 348L, 349L, 350L);
return CommonResponse.onSuccess(
BriefingConverter.toBriefingPreviewV2TempListDTO(date, idList, type));
}

@GetMapping("/v2/briefings/{id}")
@Operation(summary = "03-02Briefing \uD83D\uDCF0 ๋ธŒ๋ฆฌํ•‘ ๋‹จ๊ฑด ์กฐํšŒ V2", description = "")
@Parameter(name = "member", hidden = true)
public CommonResponse<BriefingResponseDTO.BriefingDetailDTOV2> findBriefingV2(
@PathVariable final Long id, @AuthMember Member member) {

Boolean isScrap =
Optional.ofNullable(member)
.map(m -> scrapQueryService.existsByMemberIdAndBriefingId(m.getId(), id))
.orElseGet(() -> Boolean.FALSE);

Boolean isBriefingOpen = false;
Boolean isWarning = false;

return CommonResponse.onSuccess(
BriefingConverter.toBriefingDetailDTOV2(
briefingQueryService.findBriefing(id, APIVersion.V2),
isScrap,
isBriefingOpen,
isWarning));
}

@GetMapping("/briefings/{id}")
@Parameter(name = "member", hidden = true)
@Operation(summary = "03-02Briefing \uD83D\uDCF0 ๋ธŒ๋ฆฌํ•‘ ๋‹จ๊ฑด ์กฐํšŒ V1", description = "")
public CommonResponse<BriefingResponseDTO.BriefingDetailDTO> findBriefing(
@PathVariable final Long id, @AuthMember Member member) {

Boolean isScrap =
Optional.ofNullable(member)
.map(m -> scrapQueryService.existsByMemberIdAndBriefingId(m.getId(), id))
.orElseGet(() -> Boolean.FALSE);

Boolean isBriefingOpen = false;
Boolean isWarning = false;

return CommonResponse.onSuccess(
BriefingConverter.toBriefingDetailDTO(
briefingQueryService.findBriefing(id, APIVersion.V1),
isScrap,
isBriefingOpen,
isWarning));
}

@PostMapping("/briefings")
@ResponseStatus(HttpStatus.CREATED)
@Operation(summary = "03-03Briefing \uD83D\uDCF0 ๋ธŒ๋ฆฌํ•‘ ๋“ฑ๋ก", description = "")
public void createBriefing(@RequestBody final BriefingRequestDTO.BriefingCreate request) {
briefingCommandService.createBriefing(request);
}
}
Loading

0 comments on commit fe8987d

Please sign in to comment.