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

Develop #94

Merged
merged 86 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
eba52f8
FLASH-270 feat: 해설 댓글 엔티티 생성
ChoiWonYu Oct 10, 2024
8c5bedf
FLASH-270 feat: 기본적인 생성과 해설 아이디로 댓글을 조회하는 시나리오 생성
ChoiWonYu Oct 10, 2024
46dfd2f
FLASH-270 feat: 해설 댓글의 리포지토리 객체 생성
ChoiWonYu Oct 10, 2024
8517ed6
FLASH-270 feat: 해설 댓글 생성 요청/응답 dto 틀 생성
ChoiWonYu Oct 10, 2024
93afd07
FLASH-270 feat: 해설 댓글 응답 dto 생성
ChoiWonYu Oct 10, 2024
b617dc0
FLASH-270 feat: 댓글을 단 사람에 대한 정보 값타입으로 변경
ChoiWonYu Oct 10, 2024
afad970
FLASH-270 feat: 해설 댓글 querydsl repository 추가
ChoiWonYu Oct 10, 2024
b121a01
FLASH-270 feat: 기본적인 조회, 수정, 삭제 로직 추가
ChoiWonYu Oct 10, 2024
bfd9396
FLASH-270 feat: 단건 조회, 수정, 삭제 기능 추가
ChoiWonYu Oct 10, 2024
8d6905c
FLASH-270 feat: id로 단건 조회시 찾지 못했을 때 예외 객체
ChoiWonYu Oct 10, 2024
91cfe6f
FLASH-270 feat: 본인의 댓글 이외 댓글에 대한 삭제 요청을 보냈을 때 예외처리
ChoiWonYu Oct 10, 2024
034d358
FLASH-270 feat: 댓글 작성자 디테일 분리 반영
ChoiWonYu Oct 10, 2024
6fa4e11
FLASH-270 feat: 댓글 작성자의 정보 수정, 삭제를 댓글에도 반영
ChoiWonYu Oct 10, 2024
3ec74d5
FLASH-270 feat: 댓글 수정 시나리오 분리
ChoiWonYu Oct 10, 2024
2fe256c
FLASH-270 feat: 해설의 댓글 CRUD에서 발생하는 예외 핸들러
ChoiWonYu Oct 10, 2024
156934a
FLASH-270 feat: 해설을 조회했을 때 응답 dto 값 추가
ChoiWonYu Oct 10, 2024
6bca747
FLASH-270 feat: 해설을 생성했을 때 응답 dto 값 추가
ChoiWonYu Oct 10, 2024
9657e51
feat: 체감 난이도 컬럼 추가 및 API 요청 추가
wonyangs Oct 10, 2024
19aff79
FLASH-270 refactor: 해설 업데이트 시 dto를 통해 수정사항을 받도록 수정
ChoiWonYu Oct 10, 2024
c28665b
FLASH-270 feat: 해설 댓글 Controller 구현
ChoiWonYu Oct 10, 2024
f3dc721
FLASH-270 feat: 해설 댓글 생성, 수정 시 dto 유효성 검사 추가
ChoiWonYu Oct 10, 2024
924d508
FLASH-270 feat: 댓글 수정 시에도 응답을 받도록 수정
ChoiWonYu Oct 10, 2024
135c6c4
FLASH-270 feat: api에 대한 swagger 추가
ChoiWonYu Oct 10, 2024
0a5c57a
FLASH-270 feat: 내 댓글인지 여부를 알려주는 필드 추가
ChoiWonYu Oct 10, 2024
79d9c34
feat: 체감 난이도 컬럼이 없을 때 예외처리 추가
wonyangs Oct 10, 2024
6d4cd43
refactor: 롬복 getter 적용
wonyangs Oct 10, 2024
daf25d3
feat: QueryProblem에 체감 난이도 컬럼 추가
wonyangs Oct 10, 2024
04a2a3d
feat: 체감 난이도 설정 이벤트 추가 및 발행 로직 구현
wonyangs Oct 10, 2024
ff30867
FLASH-270 feat: cascade solution 쪽에 설정
ChoiWonYu Oct 10, 2024
2bfe9a1
FLASH-270 feat: 순환 참조를 피하기 위해 comments의 toString 제외
ChoiWonYu Oct 10, 2024
4eb209c
FLASH-270 fix: 댓글 수정 응답 dto 올바르게 수정
ChoiWonYu Oct 10, 2024
31c4182
FLASH-270 feat: 댓글 여러 건 조회 시 solution 이용
ChoiWonYu Oct 10, 2024
6326817
feat: 체감 난이도 설정 시 queryproblem에 합계 반영
wonyangs Oct 11, 2024
8314888
FLASH-270 refactor: dto 변수명 통일
ChoiWonYu Oct 11, 2024
21d027c
FLASH-270 fix: swagger 응답 객체 수정
ChoiWonYu Oct 11, 2024
254c946
Merge pull request #82 from SWM-Flash/feature/FLASH-270-solution-repl…
ChoiWonYu Oct 11, 2024
0f25153
feat: 체감 난이도 수정 시 변경된 차이만큼 query problem에 반영하도록 수정
wonyangs Oct 11, 2024
5634e16
refactor: 해설 사용자 검증 로직 코드 리팩토링
wonyangs Oct 11, 2024
d05ae3c
refactor: 해설 수정 코드 리팩토링
wonyangs Oct 11, 2024
2071c85
feat: 존재하지 않는 체감 난이도가 요청되었을 때 예외처리 추가
wonyangs Oct 11, 2024
a50b045
feat: 해설 삭제 시 query problem에 체감 난이도도 제거되도록 구현
wonyangs Oct 11, 2024
96cb6f3
refactor: query problem의 체감 난이도 수정을 엔티티에서 하도록 수정
wonyangs Oct 11, 2024
953301c
refactor: Solution entity의 PerceivedDifficulty 타입을 Enum으로 수정
wonyangs Oct 11, 2024
43ca055
FLASH-293 feat: 쓰기 작업에 대한 Solution 응답 분리
ChoiWonYu Oct 11, 2024
6cd5255
feat: 해설 상세 조회 시 체감 난이도 반환 추가
wonyangs Oct 11, 2024
c7ab254
FLASH-293 feat: 쓰기 작업에 대한 dto 변경
ChoiWonYu Oct 11, 2024
a3d98c8
FLASH-293 feat: 읽기 작업에 대한 응답 dto 위치 변경
ChoiWonYu Oct 11, 2024
ce9d2a5
FLASH-293 feat: 읽기 작업에 대한 응답들 모두 댓글 수 추가
ChoiWonYu Oct 11, 2024
d787bc0
FLASH-293 feat: NPE 방지
ChoiWonYu Oct 11, 2024
d21db9d
FLASH-293 feat: 저장, 수정 후 SolutionWriteResponseDto를 반환하도록 수정
ChoiWonYu Oct 11, 2024
457bb95
FLASH-293 feat: solution 조회 응답 dto를 반환하도록 수정
ChoiWonYu Oct 11, 2024
8671939
refactor: problem 애그리거트에서 체감 난이도 더하기 메서드명 수정
wonyangs Oct 11, 2024
f7aeb1e
FLASH-293 feat: 본인의 해설인지 판단하는 작업을 DB에서 가져올 때부터 진행
ChoiWonYu Oct 11, 2024
4b2ab1f
FLASH-293 feat: solution 조회 dto에 comment 개수 추가
ChoiWonYu Oct 11, 2024
b5d605d
feat: 본문이 누락되었을 때 예외 핸들링 추가
wonyangs Oct 11, 2024
9517f39
feat: 어드민용 체감 난이도 가중치 수정 API 구현
wonyangs Oct 11, 2024
5f21ea1
docs: 체감 난이도 수정 API swagger 문서 추가
wonyangs Oct 11, 2024
aee78c4
Merge pull request #83 from SWM-Flash/feature/FLASH-293-solution-resp…
ChoiWonYu Oct 11, 2024
d061bf9
Merge branch 'integration' into feature/FLASH-269-perceived-difficult…
wonyangs Oct 11, 2024
52e7300
feat: 문제 상세, 리스트 조회 응답에 isHoney 필드 추가
wonyangs Oct 11, 2024
108553f
feat: 꿀 문제 필터링 추가
wonyangs Oct 11, 2024
4379eb5
Merge pull request #85 from SWM-Flash/integration
ChoiWonYu Oct 11, 2024
cf4e5f6
feat: 신고할 콘텐츠의 타입 enum
ChoiWonYu Oct 13, 2024
d5d4e59
feat: report 엔티티에 content type 추가
ChoiWonYu Oct 13, 2024
be05af0
feat: 신고 시나리오에 content type 추가
ChoiWonYu Oct 13, 2024
7c241f0
fix: detailSolution에 댓글 개수 누락 부분 수정
wonyangs Oct 15, 2024
f5cf934
refactor: getResponseWithStatus를 활용하여 메서드 수정
wonyangs Oct 15, 2024
001e038
refactor: 차이값 계산 로직을 객체 안에서 하도록 수정
wonyangs Oct 15, 2024
01edda5
Merge pull request #84 from SWM-Flash/feature/FLASH-269-perceived-dif…
wonyangs Oct 15, 2024
44a4428
FLASH-295 refactor: 해당 사용자가 작성자인지 판단하는 로직 레포지토리에서 제거
ChoiWonYu Oct 15, 2024
88b4b5e
FLASH-295 refactor: 기존 업로더인지 구분하는 필드 삭제
ChoiWonYu Oct 15, 2024
005e891
FLASH-295 feat: 업로더인지 판단하는 로직을 응용 계층으로 이동
ChoiWonYu Oct 15, 2024
a6b492f
Merge pull request #87 from SWM-Flash/integration
wonyangs Oct 15, 2024
f36c636
FLASH-295 Merge remote-tracking branch 'origin/integration' into hotf…
ChoiWonYu Oct 15, 2024
7c44e50
FLASH-295 chore: 필요없는 코드 삭제
ChoiWonYu Oct 15, 2024
be66345
Merge pull request #88 from SWM-Flash/hotfix/FLASH-295-is-my-solution
ChoiWonYu Oct 16, 2024
257a635
Merge pull request #86 from SWM-Flash/feature/FLASH-294-report-conten…
ChoiWonYu Oct 16, 2024
3495ccf
Merge pull request #89 from SWM-Flash/integration
ChoiWonYu Oct 16, 2024
c64fef9
feat: 앱 버전 조회 API 구현
wonyangs Oct 17, 2024
388fc1a
refactor: DB 조회 방법 개선
wonyangs Oct 17, 2024
fe46b85
Merge pull request #90 from SWM-Flash/feature/FLASH-296-version-info-api
wonyangs Oct 17, 2024
731fe58
Merge pull request #91 from SWM-Flash/integration
wonyangs Oct 17, 2024
5a82ec5
FLASH-307 feat: 해설 체감 난이도를 입력하지 않으면 보통으로 간주
ChoiWonYu Oct 19, 2024
2f544d6
FLASH-307 feat: 신고 컨텐츠 유형을 선택하지 않으면 해설 신고로 간주
ChoiWonYu Oct 19, 2024
ac54153
Merge pull request #92 from SWM-Flash/feature/FLASH-307-API-Compatibi…
ChoiWonYu Oct 19, 2024
9fa0e07
Merge pull request #93 from SWM-Flash/integration
ChoiWonYu Oct 19, 2024
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
Expand Up @@ -25,8 +25,9 @@ public MemberReportResponse reportMember(final Long reportedContentId,
UUID reporterId = AuthUtil.getId();
Member reporter = memberService.findById(reporterId);
MemberReport memberReport = MemberReport.reportContent(request.reason(), reporter,
reportedContentId);
reportRepository.save(memberReport);
return MemberReportResponse.toDto(reportedContentId, request.reason());
reportedContentId, request.contentType());
MemberReport savedReport = reportRepository.save(memberReport);
return MemberReportResponse.toDto(savedReport.getReportedContentId(),
savedReport.getContentType(), savedReport.getReason());
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package com.first.flash.account.member.application.dto;

import com.first.flash.account.member.domain.ContentType;
import com.first.flash.global.annotation.ValidEnum;
import jakarta.validation.constraints.NotEmpty;

public record MemberReportRequest(@NotEmpty(message = "신고 사유는 필수입니다.") String reason) {
public record MemberReportRequest(@NotEmpty(message = "신고 사유는 필수입니다.") String reason,
@ValidEnum(enumClass = ContentType.class) ContentType contentType) {

public MemberReportRequest(final String reason, final ContentType contentType) {
this.reason = reason;
this.contentType = contentType != null ? contentType : ContentType.SOLUTION;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.first.flash.account.member.application.dto;

public record MemberReportResponse(Long reportedContentId, String reason) {
import com.first.flash.account.member.domain.ContentType;

public static MemberReportResponse toDto(final Long reportedContentId, final String reason) {
return new MemberReportResponse(reportedContentId, reason);
public record MemberReportResponse(Long reportedContentId, String contentType, String reason) {

public static MemberReportResponse toDto(final Long reportedContentId,
final ContentType contentType, final String reason) {
return new MemberReportResponse(reportedContentId, contentType.name(), reason);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.first.flash.account.member.domain;

import lombok.ToString;

@ToString
public enum ContentType {
SOLUTION, COMMENT;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.first.flash.global.domain.BaseEntity;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
Expand All @@ -27,15 +29,19 @@ public class MemberReport extends BaseEntity {
@JoinColumn(name = "reporterId")
private Member reporter;
private Long reportedContentId;
@Enumerated(EnumType.STRING)
private ContentType contentType;

private MemberReport(final String reason, final Member reporter, final Long reportedContentId) {
private MemberReport(final String reason, final Member reporter, final Long reportedContentId,
final ContentType contentType) {
this.reason = reason;
this.reporter = reporter;
this.reportedContentId = reportedContentId;
this.contentType = contentType;
}

public static MemberReport reportContent(final String reason, final Member reporter,
final Long reportedContentId) {
return new MemberReport(reason, reporter, reportedContentId);
final Long reportedContentId, final ContentType contentType) {
return new MemberReport(reason, reporter, reportedContentId, contentType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.first.flash.climbing.sector.domain.SectorExpiredEvent;
import com.first.flash.climbing.sector.domain.SectorInfoUpdatedEvent;
import com.first.flash.climbing.sector.domain.SectorRemovalDateUpdatedEvent;
import com.first.flash.climbing.solution.domain.PerceivedDifficultySetEvent;
import com.first.flash.climbing.solution.domain.SolutionDeletedEvent;
import com.first.flash.climbing.solution.domain.SolutionSavedEvent;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -39,7 +40,7 @@ public void updateProblemSolutionInfo(final SolutionSavedEvent event) {
@EventListener
@Transactional
public void updateProblemDeletedSolutionInfo(final SolutionDeletedEvent event) {
problemsService.updateProblemDeletedSolutionInfo(event.getProblemId());
problemsService.updateProblemDeletedSolutionInfo(event.getProblemId(), event.getPerceivedDifficulty());
}

@EventListener
Expand All @@ -54,4 +55,10 @@ public void updateQueryProblemInfo(final SectorInfoUpdatedEvent event) {
public void confirmProblemId(final ProblemIdConfirmRequestedEvent event) {
problemReadService.findProblemById(event.getProblemId());
}

@EventListener
@Transactional
public void updatePerceivedDifficulty(final PerceivedDifficultySetEvent event) {
problemsService.addPerceivedDifficulty(event.getProblemId(), event.getPerceivedDifficulty());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ public class ProblemReadService {
private final ProblemRepository problemRepository;

public ProblemsResponseDto findAll(final Long gymId, final String cursor,
final String sortByRequest, final Integer size,
final List<String> difficulty, final List<String> sector, final Boolean hasSolution) {
final String sortByRequest, final Integer size, final List<String> difficulty,
final List<String> sector, final Boolean hasSolution, final Boolean isHoney) {
ProblemCursor prevProblemCursor = ProblemCursor.decode(cursor);
ProblemSortBy problemSortBy = ProblemSortBy.from(sortByRequest);

Events.raise(ClimbingGymIdConfirmRequestedEvent.of(gymId));

List<QueryProblem> queryProblems = queryProblemRepository.findAll(prevProblemCursor,
problemSortBy, size,
gymId, difficulty, sector, hasSolution);
gymId, difficulty, sector, hasSolution, isHoney);
String nextCursor = getNextCursor(problemSortBy, size, queryProblems);
return ProblemsResponseDto.of(queryProblems, nextCursor);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.first.flash.climbing.problem.application;

import com.first.flash.climbing.problem.application.dto.ProblemDetailResponseDto;
import com.first.flash.climbing.problem.domain.ProblemRepository;
import com.first.flash.climbing.problem.domain.QueryProblem;
import com.first.flash.climbing.problem.domain.QueryProblemRepository;
Expand Down Expand Up @@ -37,14 +38,28 @@ public void updateProblemSolutionInfo(final UUID problemId) {
}

@Transactional
public void updateProblemDeletedSolutionInfo(final UUID problemId) {
public void updateProblemDeletedSolutionInfo(final UUID problemId, final Integer perceivedDifficulty) {
QueryProblem queryProblem = problemReadService.findQueryProblemById(problemId);
queryProblem.decrementSolutionCount();
queryProblem.subtractPerceivedDifficulty(perceivedDifficulty);
}

@Transactional
public void updateQueryProblemInfo(final Long sectorId, final String sectorName,
final LocalDate settingDate) {
queryProblemRepository.updateQueryProblemInfo(sectorId, sectorName, settingDate);
}

@Transactional
public void addPerceivedDifficulty(final UUID problemId, final Integer perceivedDifficulty) {
QueryProblem queryProblem = problemReadService.findQueryProblemById(problemId);
queryProblem.addPerceivedDifficulty(perceivedDifficulty);
}

@Transactional
public ProblemDetailResponseDto setPerceivedDifficulty(final UUID problemId, final Integer perceivedDifficulty) {
QueryProblem queryProblem = problemReadService.findQueryProblemById(problemId);
queryProblem.setPerceivedDifficulty(perceivedDifficulty);
return ProblemDetailResponseDto.of(queryProblem);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
public record ProblemDetailResponseDto(UUID id, String sector, String difficulty,
LocalDate settingDate, LocalDate removalDate,
boolean isFakeRemovalDate, boolean hasSolution,
String imageUrl, String gymName, String imageSource) {
String imageUrl, String gymName, String imageSource, Boolean isHoney) {

public static ProblemDetailResponseDto of(final QueryProblem queryProblem) {
return new ProblemDetailResponseDto(queryProblem.getId(), queryProblem.getSectorName(),
queryProblem.getDifficultyName(), queryProblem.getSettingDate(),
queryProblem.getRemovalDate(), queryProblem.getIsFakeRemovalDate(),
queryProblem.getHasSolution(), queryProblem.getImageUrl(), queryProblem.getGymName(),
queryProblem.getImageSource());
queryProblem.getImageSource(), queryProblem.isHoney());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.first.flash.climbing.problem.application.dto;

import jakarta.validation.constraints.NotNull;

public record ProblemPerceivedDifficultyRequestDto(
@NotNull(message = "변경할 체감 난이도 수치는 필수입니다.") Integer perceivedDifficulty) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import java.util.UUID;

public record ProblemResponseDto(UUID id, String sector, String difficulty, LocalDate settingDate,
LocalDate removalDate, boolean hasSolution, String imageUrl) {
LocalDate removalDate, boolean hasSolution, String imageUrl, Boolean isHoney) {

public static ProblemResponseDto toDto(QueryProblem queryProblem) {
return new ProblemResponseDto(queryProblem.getId(), queryProblem.getSectorName(),
queryProblem.getDifficultyName(), queryProblem.getSettingDate(),
queryProblem.getRemovalDate(), queryProblem.getHasSolution(),
queryProblem.getImageUrl());
queryProblem.getImageUrl(), queryProblem.isHoney());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class ProblemsCreateService {
private static final Boolean DEFAULT_HAS_SOLUTION = false;
private static final Integer INITIAL_SOLUTION_COUNT = 0;
private static final Long INITIAL_RECOMMENDATION_VALUE = 0L;
private static final Integer INITIAL_PERCEIVED_DIFFICULTY_VALUE = 0;

private final UUIDGenerator uuidGenerator;

Expand All @@ -36,6 +37,7 @@ public QueryProblem createQueryProblem(final ClimbingGym climbingGym, final Sect
.views(problem.getViews())
.isExpired(problem.getIsExpired())
.hasSolution(DEFAULT_HAS_SOLUTION)
.perceivedDifficulty(INITIAL_PERCEIVED_DIFFICULTY_VALUE)
.recommendationValue(INITIAL_RECOMMENDATION_VALUE)
.solutionCount(INITIAL_SOLUTION_COUNT)
.isFakeRemovalDate(sector.getRemovalInfo().getIsFakeRemovalDate())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@Entity
Expand Down Expand Up @@ -42,6 +43,8 @@ public class QueryProblem {
private Integer views;
private Boolean isExpired;
private Integer solutionCount;
@Setter
private Integer perceivedDifficulty;
private Long recommendationValue;
private Boolean hasSolution;
private Boolean isFakeRemovalDate;
Expand Down Expand Up @@ -79,6 +82,18 @@ public void decrementSolutionCount() {
calculateRecommendationValue();
}

public void addPerceivedDifficulty(final Integer value) {
perceivedDifficulty += value;
}

public void subtractPerceivedDifficulty(final Integer value) {
perceivedDifficulty -= value;
}

public Boolean isHoney() {
return perceivedDifficulty < 0;
}

private void enableSolution() {
if (!hasSolution) {
hasSolution = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public interface QueryProblemRepository {

List<QueryProblem> findAll(final ProblemCursor preProblemCursor, final ProblemSortBy problemSortBy, final int size,
final Long gymId, final List<String> difficulty, final List<String> sector,
final Boolean hasSolution);
final Boolean hasSolution, final Boolean isHoney);

void updateRemovalDateBySectorId(final Long sectorId, final LocalDate removalDate);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public class QueryProblemQueryDslRepository {

public List<QueryProblem> findAll(final ProblemCursor prevProblemCursor, final ProblemSortBy problemSortBy, final int size,
final Long gymId, final List<String> difficulty, final List<String> sector,
final Boolean hasSolution) {
final Boolean hasSolution, final Boolean isHoney) {
return queryFactory
.selectFrom(queryProblem)
.where(notExpired(), cursorCondition(prevProblemCursor), inGym(gymId), inSectors(sector),
inDifficulties(difficulty), hasSolution(hasSolution))
inDifficulties(difficulty), hasSolution(hasSolution), isHoneyCondition(isHoney))
.orderBy(sortItem(problemSortBy), queryProblem.id.desc())
.limit(size)
.fetch();
Expand Down Expand Up @@ -63,6 +63,13 @@ private BooleanExpression inGym(final Long gymId) {
return queryProblem.gymId.eq(gymId);
}

private BooleanExpression isHoneyCondition(final Boolean isHoney) {
if (Boolean.TRUE.equals(isHoney)) {
return queryProblem.perceivedDifficulty.lt(0);
}
return null;
}

private BooleanExpression cursorCondition(final ProblemCursor prevProblemCursor) {
if (Objects.isNull(prevProblemCursor) || Objects.isNull(prevProblemCursor.cursorValue())) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public Optional<QueryProblem> findById(final UUID id) {
@Override
public List<QueryProblem> findAll(final ProblemCursor prevProblemCursor, final ProblemSortBy problemSortBy, final int size,
final Long gymId, final List<String> difficulty, final List<String> sector,
final Boolean hasSolution) {
final Boolean hasSolution, final Boolean isHoney) {
return queryProblemQueryDslRepository.findAll(prevProblemCursor, problemSortBy, size,
gymId, difficulty, sector, hasSolution);
gymId, difficulty, sector, hasSolution, isHoney);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.first.flash.climbing.problem.application.ProblemReadService;
import com.first.flash.climbing.problem.application.ProblemsSaveService;
import com.first.flash.climbing.problem.application.ProblemsService;
import com.first.flash.climbing.problem.application.dto.ProblemCreateResponseDto;
import com.first.flash.climbing.problem.application.dto.ProblemDetailResponseDto;
import com.first.flash.climbing.problem.application.dto.ProblemPerceivedDifficultyRequestDto;
import com.first.flash.climbing.problem.application.dto.ProblemsResponseDto;
import com.first.flash.climbing.problem.domain.dto.ProblemCreateRequestDto;
import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -20,6 +22,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -36,6 +39,7 @@ public class ProblemController {

private final ProblemsSaveService problemsSaveService;
private final ProblemReadService problemReadService;
private final ProblemsService problemsService;

@Operation(summary = "문제 생성", description = "특정 섹터에 문제 생성")
@ApiResponses(value = {
Expand Down Expand Up @@ -78,10 +82,11 @@ public ResponseEntity<ProblemsResponseDto> findAllProblems(
@RequestParam(defaultValue = DEFAULT_SIZE, required = false) final int size,
@RequestParam(required = false) final List<String> difficulty,
@RequestParam(required = false) final List<String> sector,
@RequestParam(name = "has-solution", required = false) final Boolean hasSolution) {
@RequestParam(name = "has-solution", required = false) final Boolean hasSolution,
@RequestParam(name = "is-honey", required = false) final Boolean isHoney) {
return ResponseEntity.ok(
problemReadService.findAll(gymId, cursor, sortBy, size, difficulty, sector,
hasSolution));
hasSolution, isHoney));
}

@Operation(summary = "문제 단건 조회", description = "특정 문제의 정보 조회")
Expand All @@ -98,4 +103,24 @@ public ResponseEntity<ProblemDetailResponseDto> findProblemById(
@PathVariable final UUID problemId) {
return ResponseEntity.ok(problemReadService.viewProblems(problemId));
}

@Operation(summary = "문제 체감 난이도 수정", description = "특정 문제의 체감 난이도 수정")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공적으로 문제 정보 수정함",
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ProblemDetailResponseDto.class))),
@ApiResponse(responseCode = "400", description = "유효하지 않은 요청 형식",
content = @Content(mediaType = "application/json", examples = {
@ExampleObject(name = "요청값 누락", value = "{\"perceivedDifficulty\": \"변경할 체감 난이도 수치는 필수입니다.\"}")
})),
@ApiResponse(responseCode = "404", description = "리소스를 찾을 수 없음",
content = @Content(mediaType = "application/json", examples = {
@ExampleObject(name = "문제 없음", value = "{\"error\": \"아이디가 0190c558-9063-7050-b4fc-eb421e3236b3인 문제를 찾을 수 없습니다.\"}")
}))
})
@PatchMapping("/admin/problems/{problemId}/perceivedDifficulty")
public ResponseEntity<ProblemDetailResponseDto> changePerceivedDifficulty(
@PathVariable final UUID problemId,
@Valid @RequestBody final ProblemPerceivedDifficultyRequestDto requestDto) {
return ResponseEntity.ok(problemsService.setPerceivedDifficulty(problemId, requestDto.perceivedDifficulty()));
}
}
Loading
Loading