Skip to content

Commit

Permalink
Merge pull request #355 from Hous-Release/fix/#354
Browse files Browse the repository at this point in the history
  • Loading branch information
orijoon98 authored Sep 10, 2023
2 parents 6602de4 + cb44202 commit 5bd6684
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,7 @@ public ResponseEntity<SuccessResponse<String>> deleteRule(@ApiIgnore @UserId Lon
)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "성공입니다."),
@ApiResponse(
code = 400,
message = "1. 규칙 리스트를 입력해주세요. (rules)\n"
+ "2. 규칙 리스트는 빈 배열을 보낼 수 없습니다. (rules)",
response = ErrorResponse.class),
@ApiResponse(code = 400, message = "규칙 리스트를 입력해주세요. (rules)", response = ErrorResponse.class),
@ApiResponse(code = 401, message = "토큰이 만료되었습니다. 다시 로그인 해주세요.", response = ErrorResponse.class),
@ApiResponse(code = 403, message = "대표 rule 은 3개를 초과할 수 없습니다.", response = ErrorResponse.class),
@ApiResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class HomeInfoResponse {
public boolean isPersonalityTest() {
return isPersonalityTest;
}

@ToString
@Getter
@NoArgsConstructor(access = AccessLevel.PRIVATE)
Expand All @@ -62,6 +62,9 @@ public static HomeInfoResponse of(Onboarding me, Room room, LocalDate today, Lis
int doneOurTodosCnt = (int)ourTodos.stream()
.filter(ourTodo -> ourTodo.getStatus() == OurTodoStatus.FULL_CHECK)
.count();
List<Rule> representRules = rules.stream()
.filter(Rule::isRepresent)
.collect(Collectors.toList());
return HomeInfoResponse.builder()
.userNickname(me.getNickname())
.roomName(room.getName())
Expand All @@ -73,11 +76,16 @@ public static HomeInfoResponse of(Onboarding me, Room room, LocalDate today, Lis
.limit(3)
.map(TodoDetailInfo::getTodoName)
.collect(Collectors.toList()))
.ourRules(rules.stream()
.sorted(Comparator.comparing(Rule::getIdx))
.limit(3)
.map(Rule::getName)
.collect(Collectors.toList()))
.ourRules(representRules.isEmpty() ?
rules.stream()
.sorted(Comparator.comparing(Rule::getCreatedAt))
.limit(3)
.map(Rule::getName)
.collect(Collectors.toList()) :
representRules.stream()
.limit(3)
.map(Rule::getName)
.collect(Collectors.toList()))
.isPersonalityTest(!me.getPersonality().getColor().equals(PersonalityColor.GRAY))
.homies(participants.stream()
.map(onboarding -> HomieInfo.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import java.util.List;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import hous.common.constant.Constraint;
import io.swagger.annotations.ApiModelProperty;
import lombok.AccessLevel;
import lombok.Getter;
Expand All @@ -17,6 +15,5 @@ public class UpdateRuleRepresentRequestDto {

@ApiModelProperty(value = "설정한 대표 규칙 id 리스트", example = "[1, 2, 3]")
@NotNull(message = "{rule.list.notNull}")
@Size(min = Constraint.RULE_LIST_MIN, message = "{rule.list.min}")
private List<Long> rules;
}

0 comments on commit 5bd6684

Please sign in to comment.