Skip to content

Commit

Permalink
[DDING-000] 컴파일 오류 수정 (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
5uhwann authored Oct 10, 2024
1 parent 10af9cd commit e47fc8f
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ddingdong.ddingdongBE.common.exception.ErrorResponse;
import ddingdong.ddingdongBE.domain.scorehistory.controller.dto.request.CreateScoreHistoryRequest;
import ddingdong.ddingdongBE.domain.scorehistory.controller.dto.response.ScoreHistoryListResponse;
import ddingdong.ddingdongBE.domain.scorehistory.controller.dto.response.AdminScoreHistoryListResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
Expand Down Expand Up @@ -62,7 +62,7 @@ public interface AdminScoreHistoryApi {
@ApiResponse(responseCode = "200",
description = "점수 변동 내역 목록 조회 성공",
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(implementation = ScoreHistoryListResponse.class))),
schema = @Schema(implementation = AdminScoreHistoryListResponse.class))),
@ApiResponse(responseCode = "400",
description = "잘못된 요청",
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
Expand All @@ -72,7 +72,7 @@ public interface AdminScoreHistoryApi {
value = """
{
"status": 400,
"message": "존재하지 않는 동아리입니다.",
"message": "존재하지 않는 동아리입니다.",
"timestamp": "2024-08-22T00:08:46.990585"
}
"""
Expand All @@ -83,6 +83,6 @@ public interface AdminScoreHistoryApi {
@GetMapping
@ResponseStatus(HttpStatus.OK)
@SecurityRequirement(name = "AccessToken")
ScoreHistoryListResponse findClubScoreHistories(@PathVariable Long clubId);
AdminScoreHistoryListResponse findClubScoreHistories(@PathVariable Long clubId);

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package ddingdong.ddingdongBE.domain.scorehistory.api;

import ddingdong.ddingdongBE.auth.PrincipalDetails;
import ddingdong.ddingdongBE.domain.scorehistory.controller.dto.response.ScoreHistoryListResponse;
import ddingdong.ddingdongBE.common.exception.ErrorResponse;
import ddingdong.ddingdongBE.domain.scorehistory.controller.dto.response.ClubScoreHistoryListResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -16,9 +23,31 @@
public interface ClubScoreHistoryApi {

@Operation(summary = "동아리 내 점수 내역 목록 조회 API")
@ApiResponses(value = {
@ApiResponse(responseCode = "200",
description = "점수 변동 내역 목록 조회 성공",
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(implementation = ClubScoreHistoryListResponse.class))),
@ApiResponse(responseCode = "400",
description = "잘못된 요청",
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(implementation = ErrorResponse.class),
examples = {
@ExampleObject(name = "존재하지 않는 동아리",
value = """
{
"status": 400,
"message": "존재하지 않는 동아리입니다.",
"timestamp": "2024-08-22T00:08:46.990585"
}
"""
)
})
)
})
@GetMapping
@ResponseStatus(HttpStatus.OK)
@SecurityRequirement(name = "AccessToken")
ScoreHistoryListResponse findMyScoreHistories(@AuthenticationPrincipal PrincipalDetails principalDetails);
ClubScoreHistoryListResponse findMyScoreHistories(@AuthenticationPrincipal PrincipalDetails principalDetails);

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import ddingdong.ddingdongBE.domain.scorehistory.api.AdminScoreHistoryApi;
import ddingdong.ddingdongBE.domain.scorehistory.controller.dto.request.CreateScoreHistoryRequest;
import ddingdong.ddingdongBE.domain.scorehistory.controller.dto.response.ScoreHistoryListResponse;
import ddingdong.ddingdongBE.domain.scorehistory.controller.dto.response.ScoreHistoryListResponse.ScoreHistoryResponse;
import ddingdong.ddingdongBE.domain.scorehistory.controller.dto.response.AdminScoreHistoryListResponse;
import ddingdong.ddingdongBE.domain.scorehistory.service.FacadeAdminScoreHistoryService;
import ddingdong.ddingdongBE.domain.scorehistory.service.dto.query.AdminClubScoreHistoryListQuery;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

Expand All @@ -20,8 +18,8 @@ public void createScoreHistory(Long clubId, CreateScoreHistoryRequest createScor
facadeAdminScoreHistoryService.create(createScoreHistoryRequest.toCommand(clubId));
}

public ScoreHistoryListResponse findClubScoreHistories(Long clubId) {
public AdminScoreHistoryListResponse findClubScoreHistories(Long clubId) {
AdminClubScoreHistoryListQuery query = facadeAdminScoreHistoryService.findAllByClubId(clubId);
return ScoreHistoryListResponse.of(query);
return AdminScoreHistoryListResponse.from(query);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import ddingdong.ddingdongBE.auth.PrincipalDetails;
import ddingdong.ddingdongBE.domain.scorehistory.api.ClubScoreHistoryApi;
import ddingdong.ddingdongBE.domain.scorehistory.controller.dto.response.ScoreHistoryListResponse;
import ddingdong.ddingdongBE.domain.scorehistory.controller.dto.response.ScoreHistoryListResponse.ScoreHistoryResponse;
import ddingdong.ddingdongBE.domain.scorehistory.controller.dto.response.ClubScoreHistoryListResponse;
import ddingdong.ddingdongBE.domain.scorehistory.service.FacadeClubScoreHistoryService;
import ddingdong.ddingdongBE.domain.scorehistory.service.dto.query.ClubScoreHistoryListQuery;
import ddingdong.ddingdongBE.domain.user.entity.User;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

Expand All @@ -17,12 +15,9 @@ public class ClubScoreHistoryController implements ClubScoreHistoryApi {

private final FacadeClubScoreHistoryService facadeClubScoreHistoryService;

public ScoreHistoryListResponse findMyScoreHistories(PrincipalDetails principalDetails) {
public ClubScoreHistoryListResponse findMyScoreHistories(PrincipalDetails principalDetails) {
User user = principalDetails.getUser();
ClubScoreHistoryListQuery query = facadeClubScoreHistoryService.findMyScoreHistories(user.getId());
List<ScoreHistoryResponse> scoreHistoryResponses = query.scoreHistories().stream()
.map(ScoreHistoryResponse::from)
.toList();
return ScoreHistoryListResponse.of(query.club(), scoreHistoryResponses);
return ClubScoreHistoryListResponse.from(query);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ddingdong.ddingdongBE.domain.scorehistory.controller.dto.response;

import com.fasterxml.jackson.annotation.JsonFormat;
import ddingdong.ddingdongBE.domain.club.entity.Club;
import ddingdong.ddingdongBE.domain.scorehistory.entity.ScoreHistory;
import ddingdong.ddingdongBE.domain.scorehistory.service.dto.query.AdminClubScoreHistoryListQuery;
import io.swagger.v3.oas.annotations.media.ArraySchema;
Expand All @@ -12,27 +11,24 @@
import lombok.Builder;

@Schema(
name = "ScoreHistoryFilterByClubResponse",
name = "AdminScoreHistoryListResponse",
description = "어드민 - 동아리 점수 변동 내역 목록 응답"
)
@Builder
public record ScoreHistoryListResponse(
public record AdminScoreHistoryListResponse(

@Schema(description = "동아리 총 점수", example = "50")
BigDecimal totalScore,
@ArraySchema(schema = @Schema(description = "점수내역 목록", implementation = ScoreHistoryResponse.class))
List<ScoreHistoryResponse> scoreHistories
) {

public static ScoreHistoryListResponse of(AdminClubScoreHistoryListQuery query) {
return ScoreHistoryListResponse.builder()
.totalScore(query.club().getScore().getValue())
.scoreHistories(
query.scoreHistories().stream()
.map(ScoreHistoryResponse::from)
.toList()
)
.build();
public static AdminScoreHistoryListResponse from(AdminClubScoreHistoryListQuery query) {
return new AdminScoreHistoryListResponse(
query.club().getScore().getValue(),
query.scoreHistories().stream()
.map(ScoreHistoryResponse::from)
.toList()
);
}

@Schema(
Expand All @@ -54,13 +50,12 @@ public record ScoreHistoryResponse(
) {

public static ScoreHistoryResponse from(ScoreHistory scoreHistory) {
return ScoreHistoryResponse.builder()
.scoreCategory(scoreHistory.getScoreCategory().getCategory())
.reason(scoreHistory.getReason())
.amount(scoreHistory.getAmount())
.createdAt(scoreHistory.getCreatedAt())
.build();
return new ScoreHistoryResponse(
scoreHistory.getScoreCategory().getCategory(),
scoreHistory.getReason(),
scoreHistory.getAmount(),
scoreHistory.getCreatedAt()
);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package ddingdong.ddingdongBE.domain.scorehistory.controller.dto.response;

import com.fasterxml.jackson.annotation.JsonFormat;
import ddingdong.ddingdongBE.domain.scorehistory.entity.ScoreHistory;
import ddingdong.ddingdongBE.domain.scorehistory.service.dto.query.ClubScoreHistoryListQuery;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Schema;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@Schema(
name = "ClubScoreHistoryListResponse",
description = "동아리 - 동아리 점수 변동 내역 목록 응답"
)
public record ClubScoreHistoryListResponse(

@Schema(description = "동아리 총 점수", example = "50")
BigDecimal totalScore,
@ArraySchema(schema = @Schema(description = "점수내역 목록", implementation = ScoreHistoryResponse.class))
List<ScoreHistoryResponse> scoreHistories
) {

public static ClubScoreHistoryListResponse from(ClubScoreHistoryListQuery query) {
return new ClubScoreHistoryListResponse(
query.club().getScore().getValue(),
query.scoreHistories().stream()
.map(ScoreHistoryResponse::from)
.toList()
);
}

@Schema(
name = "ScoreHistoryResponse",
description = "점수 변동 내역 응답"
)
public record ScoreHistoryResponse(

@Schema(description = "점수 내역 카테고리", example = "활동보고서")
String scoreCategory,
@Schema(description = "점수 내역 이유", example = "활동보고서 작성")
String reason,
@Schema(description = "변동 점수", example = "10")
BigDecimal amount,
@Schema(description = "작성일", example = "2024-01-01")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
LocalDateTime createdAt
) {

public static ScoreHistoryResponse from(ScoreHistory scoreHistory) {
return new ScoreHistoryResponse(
scoreHistory.getScoreCategory().getCategory(),
scoreHistory.getReason(),
scoreHistory.getAmount(),
scoreHistory.getCreatedAt()
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@
import ddingdong.ddingdongBE.domain.club.entity.Club;
import ddingdong.ddingdongBE.domain.scorehistory.entity.ScoreHistory;
import java.util.List;
import lombok.Builder;

@Builder
public record AdminClubScoreHistoryListQuery(
Club club,
List<ScoreHistory> scoreHistories
) {

public static AdminClubScoreHistoryListQuery of(Club club, List<ScoreHistory> scoreHistories) {
return AdminClubScoreHistoryListQuery.builder()
.club(club)
.scoreHistories(scoreHistories)
.build();
return new AdminClubScoreHistoryListQuery(club, scoreHistories);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,13 @@
import ddingdong.ddingdongBE.domain.club.entity.Club;
import ddingdong.ddingdongBE.domain.scorehistory.entity.ScoreHistory;
import java.util.List;
import lombok.Builder;

@Builder
public record ClubScoreHistoryListQuery(
Club club,
List<ScoreHistory> scoreHistories
) {

public static ClubScoreHistoryListQuery of(
Club club,
List<ScoreHistory> scoreHistories) {
return ClubScoreHistoryListQuery.builder()
.club(club)
.scoreHistories(scoreHistories)
.build();
public static ClubScoreHistoryListQuery of(Club club, List<ScoreHistory> scoreHistories) {
return new ClubScoreHistoryListQuery(club, scoreHistories);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import ddingdong.ddingdongBE.domain.documents.service.FacadeAdminDocumentService;
import ddingdong.ddingdongBE.domain.documents.service.FacadeDocumentService;
import ddingdong.ddingdongBE.domain.fileinformation.service.FileInformationService;
import ddingdong.ddingdongBE.domain.scorehistory.controller.AdminScoreHistoryController;
import ddingdong.ddingdongBE.file.service.FileService;
import org.junit.jupiter.api.BeforeEach;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -25,7 +24,6 @@
@WebMvcTest(controllers = {
AdminDocumentController.class,
DocumentController.class,
AdminScoreHistoryController.class,
})
public abstract class WebApiUnitTestSupport {

Expand Down

0 comments on commit e47fc8f

Please sign in to comment.