Skip to content

Commit

Permalink
Merge pull request #504 from Walkhub/503-pr-error
Browse files Browse the repository at this point in the history
🔀 :: (#503) 날라간 pr 복구, zonedDateTime 에러
  • Loading branch information
glay415 authored Mar 2, 2022
2 parents be55a42 + 8a7e363 commit 5bb8c5f
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.walkhub.walkhub.domain.calorielevel.domain.repository;

import com.walkhub.walkhub.domain.calorielevel.domain.CalorieLevel;
import java.util.Optional;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface CalorieLevelRepository extends CrudRepository<CalorieLevel, Long> {
List<CalorieLevel> findAllBy();

Optional<CalorieLevel> findByLevel(Integer level);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.walkhub.walkhub.domain.challenge.domain.type.GoalScope;
import com.walkhub.walkhub.domain.exercise.domain.type.GoalType;
import com.walkhub.walkhub.global.enums.Authority;
import com.walkhub.walkhub.global.enums.UserScope;
import lombok.Builder;
import lombok.Getter;
Expand Down Expand Up @@ -34,5 +35,9 @@ public static class Writer{
private final Long userId;
private final String name;
private final String profileImageUrl;
private final Authority authority;
private final String schoolName;
private final Integer grade;
private final Integer classNum;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.walkhub.walkhub.domain.challenge.facade.ChallengeFacade;
import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeDetailsResponse;
import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeDetailsResponse.Writer;
import com.walkhub.walkhub.domain.school.domain.School;
import com.walkhub.walkhub.domain.user.domain.Section;
import com.walkhub.walkhub.domain.user.domain.User;
import com.walkhub.walkhub.domain.user.facade.UserFacade;
import com.walkhub.walkhub.global.enums.UserScope;
Expand All @@ -30,6 +32,9 @@ public QueryChallengeDetailsResponse execute(Long challengeId) {
throw InvalidRoleException.EXCEPTION;
}

School writerSchool = writer.hasSchool() ? writer.getSchool() : School.builder().build();
Section wrtierSection = writer.hasSection() ? writer.getSection() : Section.builder().build();

Boolean isMine = challenge.getChallengeStatuses()
.stream()
.anyMatch(challengeStatus -> challengeStatus.getUser().equals(user));
Expand All @@ -53,6 +58,10 @@ public QueryChallengeDetailsResponse execute(Long challengeId) {
.userId(writer.getId())
.name(writer.getName())
.profileImageUrl(writer.getProfileImageUrl())
.authority(writer.getAuthority())
.schoolName(writerSchool.getName())
.classNum(wrtierSection.getClassNum())
.grade(wrtierSection.getGrade())
.build())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.walkhub.walkhub.domain.exercise.presentation.dto.request;

import com.walkhub.walkhub.domain.exercise.domain.type.GoalType;
import javax.validation.constraints.NotNull;
import lombok.Getter;
import lombok.NoArgsConstructor;

Expand All @@ -10,6 +11,7 @@ public class CreateExerciseRequest {

private Integer goal;

@NotNull(message = "goal_type은 null, 공백을 허용x")
private GoalType goalType;

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class QueryExerciseDetailsResponse {
@Getter
@Builder
public static class ExerciseResponse {
private final Integer order;
private final Integer sequence;
private final BigDecimal latitude;
private final BigDecimal longitude;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public QueryExerciseDetailsResponse execute(Long exerciseId) {
List<ExerciseResponse> locations = locationRepository.findAllByExercise(exercise)
.stream()
.map(location -> ExerciseResponse.builder()
.order(location.getSequence())
.sequence(location.getSequence())
.latitude(location.getLatitude())
.longitude(location.getLongitude())
.build())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.walkhub.walkhub.domain.rank.domain;

import java.time.LocalDate;
import lombok.*;

import java.io.Serializable;
import java.time.ZonedDateTime;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand All @@ -12,7 +12,7 @@
public class SchoolRankId implements Serializable {
private Long schoolId;

private ZonedDateTime createdAt;
private LocalDate createdAt;

private String dateType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public UserListResponse userSearch(@PathVariable("school-id") Long schoolId,
}

@GetMapping("/schools")
public SchoolRankResponse querySchoolRank(@RequestParam SchoolDateType dateType) {
public SchoolRankResponse querySchoolRank(@RequestParam("schoolDateType") SchoolDateType dateType) {
return querySchoolRankService.execute(dateType);
}

Expand Down
10 changes: 8 additions & 2 deletions src/main/java/com/walkhub/walkhub/domain/user/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public class User extends BaseTimeEntity {
private HealthInfo healthInfo;

@NotNull
@ColumnDefault("X")
@Enumerated(EnumType.STRING)
@Setter
private Sex sex;
Expand Down Expand Up @@ -119,7 +120,7 @@ public class User extends BaseTimeEntity {
@Builder
public User(String accountId, String password, String phoneNumber, String name,
Authority authority, Section section, School school, boolean isMeasuring,
Integer weight, BigDecimal height, Sex sex, Badge badge) {
Integer weight, BigDecimal height, Sex sex, Badge badge, CalorieLevel calorieLevel) {
this.accountId = accountId;
this.password = password;
this.phoneNumber = phoneNumber;
Expand All @@ -130,8 +131,9 @@ public User(String accountId, String password, String phoneNumber, String name,
this.isMeasuring = isMeasuring;
this.healthInfo = new HealthInfo(weight, height);
this.dailyWalkCountGoal = 10000;
this.sex = sex;
if(sex != null) this.sex = sex;
this.badge = badge;
this.maxLevel = calorieLevel;
}

public void setDeviceToken(String deviceToken) {
Expand Down Expand Up @@ -182,6 +184,10 @@ public boolean hasSection() {
return this.section != null;
}

public boolean hasSchool() {
return this.school != null;
}

public void setMaxLevel(CalorieLevel calorieLevel) {
this.maxLevel = calorieLevel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.walkhub.walkhub.domain.badge.domain.Badge;
import com.walkhub.walkhub.domain.calorielevel.domain.CalorieLevel;
import com.walkhub.walkhub.domain.user.domain.Section;
import com.walkhub.walkhub.domain.user.domain.User;
import com.walkhub.walkhub.domain.user.facade.UserFacade;
import com.walkhub.walkhub.domain.user.presentation.dto.response.QueryUserProfileResponse;
Expand All @@ -21,14 +22,15 @@ public QueryUserProfileResponse execute(Long userId) {
User user = userFacade.getUserById(userId);
Badge titleBadge = user.getBadge();
CalorieLevel level = user.getMaxLevel();
Section section = user.hasSection() ? user.getSection() : Section.builder().build();

return QueryUserProfileResponse.builder()
.userId(user.getId())
.name(user.getName())
.profileImageUrl(user.getProfileImageUrl())
.schoolName(user.getSchool().getName())
.grade(user.getSection().getGrade())
.classNum(user.getSection().getClassNum())
.classNum(section.getClassNum())
.grade(section.getGrade())
.titleBadge(TitleBadge.builder()
.id(titleBadge.getId())
.name(titleBadge.getName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import com.walkhub.walkhub.domain.auth.presentation.dto.response.UserTokenResponse;
import com.walkhub.walkhub.domain.badge.domain.Badge;
import com.walkhub.walkhub.domain.badge.domain.repository.BadgeRepository;
import com.walkhub.walkhub.domain.calorielevel.domain.CalorieLevel;
import com.walkhub.walkhub.domain.calorielevel.domain.repository.CalorieLevelRepository;
import com.walkhub.walkhub.domain.calorielevel.exception.CalorieLevelNotFoundException;
import com.walkhub.walkhub.domain.school.domain.School;
import com.walkhub.walkhub.domain.school.domain.repository.SchoolRepository;
import com.walkhub.walkhub.domain.user.domain.User;
Expand Down Expand Up @@ -38,6 +41,7 @@ public class UserSignUpService {
private final JwtTokenProvider jwtTokenProvider;
private final JwtProperties jwtProperties;
private final BadgeRepository badgeRepository;
private final CalorieLevelRepository calorieLevelRepository;

@Transactional
public UserTokenResponse execute(UserSignUpRequest request) {
Expand All @@ -55,6 +59,9 @@ public UserTokenResponse execute(UserSignUpRequest request) {
School school = schoolRepository.findById(request.getSchoolId())
.orElseThrow(() -> SchoolNotFoundException.EXCEPTION);

CalorieLevel calorieLevel = calorieLevelRepository.findByLevel(1)
.orElseThrow(() -> CalorieLevelNotFoundException.EXCEPTION);

User user = User.builder()
.accountId(request.getAccountId())
.password(passwordEncoder.encode(request.getPassword()))
Expand All @@ -67,6 +74,7 @@ public UserTokenResponse execute(UserSignUpRequest request) {
.sex(request.getSex())
.isMeasuring(false)
.badge(defaultTitleBadge)
.calorieLevel(calorieLevel)
.build();
userRepository.save(user);

Expand Down

0 comments on commit 5bb8c5f

Please sign in to comment.