-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
323 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
user-service/src/main/java/com/waither/userservice/dto/converter/AccountConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
package com.waither.userservice.dto.converter; | ||
|
||
import com.waither.userservice.dto.request.AccountReqDto; | ||
import com.waither.userservice.entity.Setting; | ||
import com.waither.userservice.entity.User; | ||
import com.waither.userservice.entity.type.UserStatus; | ||
|
||
public class AccountConverter { | ||
|
||
public static User toCreateUser(AccountReqDto.RegisterRequestDto requestDto, String encodedPw) { | ||
public static User toUser(AccountReqDto.RegisterRequestDto requestDto, String encodedPw) { | ||
return User.builder() | ||
.email(requestDto.email()) | ||
.password(encodedPw) | ||
.nickname("추워하는 곰탱이") | ||
.status(UserStatus.ACTIVE) | ||
.role("ROLE_USER") | ||
.custom(true) | ||
.setting(Setting.builder().build()) | ||
.build(); | ||
} | ||
|
||
|
||
} |
76 changes: 76 additions & 0 deletions
76
user-service/src/main/java/com/waither/userservice/dto/converter/SettingConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.waither.userservice.dto.converter; | ||
|
||
import com.waither.userservice.dto.response.SettingResDto; | ||
import com.waither.userservice.entity.Setting; | ||
import com.waither.userservice.entity.User; | ||
|
||
import java.time.DayOfWeek; | ||
import java.util.AbstractMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
public class SettingConverter { | ||
|
||
public static SettingResDto.CustomDto toCustomDto(User user) { | ||
return new SettingResDto.CustomDto(user.isCustom()); | ||
} | ||
|
||
public static SettingResDto.RegionNameDto toRegionNameDto(Setting setting) { | ||
return new SettingResDto.RegionNameDto(setting.getRegion().getRegionName()); | ||
} | ||
|
||
public static SettingResDto.NotificationDto toNotificationDto(Setting setting) { | ||
List<String> days = Stream.of( | ||
new AbstractMap.SimpleEntry<>(DayOfWeek.SUNDAY, setting.isSun()), | ||
new AbstractMap.SimpleEntry<>(DayOfWeek.MONDAY, setting.isMon()), | ||
new AbstractMap.SimpleEntry<>(DayOfWeek.TUESDAY, setting.isTue()), | ||
new AbstractMap.SimpleEntry<>(DayOfWeek.WEDNESDAY, setting.isWed()), | ||
new AbstractMap.SimpleEntry<>(DayOfWeek.THURSDAY, setting.isThu()), | ||
new AbstractMap.SimpleEntry<>(DayOfWeek.FRIDAY, setting.isFri()), | ||
new AbstractMap.SimpleEntry<>(DayOfWeek.SATURDAY, setting.isSat()) | ||
) | ||
.filter(Map.Entry::getValue) | ||
.map(entry -> entry.getKey().toString()) | ||
.collect(Collectors.toList()); | ||
|
||
return new SettingResDto.NotificationDto( | ||
setting.isOutAlert(), | ||
days, | ||
setting.getOutTime(), | ||
setting.isClimateAlert(), | ||
setting.isUserAlert(), | ||
setting.isSnowAlert() | ||
); | ||
} | ||
|
||
public static SettingResDto.WindDto toWindDto(Setting setting) { | ||
return new SettingResDto.WindDto( | ||
setting.isWindAlert(), | ||
setting.getWindDegree() | ||
); | ||
} | ||
|
||
public static SettingResDto.DisplayDto toDisplayDto(Setting setting) { | ||
return new SettingResDto.DisplayDto( | ||
setting.isPrecipitation(), | ||
setting.isWind(), | ||
setting.isDust() | ||
); | ||
} | ||
|
||
public static SettingResDto.WeightDto toWeightDto(Setting setting) { | ||
return new SettingResDto.WeightDto( | ||
setting.getWeight() | ||
); | ||
} | ||
|
||
public static SettingResDto.UserInfoDto toUserInfoDto(User user) { | ||
return new SettingResDto.UserInfoDto( | ||
user.getEmail(), | ||
user.getNickname() | ||
); | ||
} | ||
|
||
} |
2 changes: 2 additions & 0 deletions
2
user-service/src/main/java/com/waither/userservice/dto/request/AccountReqDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
user-service/src/main/java/com/waither/userservice/dto/response/SettingResDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,45 @@ | ||
package com.waither.userservice.dto.response; | ||
|
||
import java.time.LocalTime; | ||
import java.util.List; | ||
|
||
public class SettingResDto { | ||
|
||
public record CustomDto( | ||
boolean custom | ||
) { } | ||
|
||
public record RegionNameDto( | ||
String regionName | ||
) { } | ||
|
||
public record NotificationDto( | ||
boolean outAlert, | ||
List<String> days, | ||
LocalTime outTime, | ||
boolean climateAlert, | ||
boolean userAlert, | ||
boolean snowAlert | ||
) { } | ||
|
||
public record WindDto( | ||
boolean windAlert, | ||
Integer windDegree | ||
) { } | ||
|
||
public record DisplayDto( | ||
boolean rainfallDisplay, | ||
boolean windDisplay, | ||
boolean dustDisplay | ||
) { } | ||
|
||
public record WeightDto( | ||
Double weight | ||
) { } | ||
|
||
public record UserInfoDto( | ||
String email, | ||
String nickname | ||
) { } | ||
|
||
} |
Oops, something went wrong.