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

v0.7.0 버전 배포 #205

Merged
merged 5 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -70,8 +70,8 @@ protected CorsConfigurationSource corsConfigurationSource() {
private CorsConfiguration getDefaultCorsConfiguration() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(
Arrays.asList("http://localhost:3000", "https://bankids.click", "https://bankidz.com",
"https://api.bankidz.com", "https://appleid.apple.com"));
Arrays.asList("http://localhost:3000", "https://bankidz.com",
"https://appleid.apple.com"));
configuration.setAllowedHeaders(Arrays.asList("*"));
configuration.setAllowedMethods(Arrays.asList("*"));
configuration.setAllowCredentials(true);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/ceos/bankids/dto/ChallengeDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public class ChallengeDTO {
@ApiModelProperty(example = "30")
private Long interestRate;

@ApiModelProperty(example = "3000")
private Long interestPrice;

@ApiModelProperty(example = "150000")
private Long totalPrice;

Expand Down Expand Up @@ -71,6 +74,7 @@ public ChallengeDTO(Challenge challenge, List<ProgressDTO> progressDTOList, Comm
this.itemName = challenge.getTargetItem().getName();
this.challengeCategory = challenge.getChallengeCategory().getCategory();
this.interestRate = challenge.getInterestRate();
this.interestPrice = challenge.getInterestPrice();
this.totalPrice = challenge.getTotalPrice();
this.weekPrice = challenge.getWeekPrice();
this.successWeeks = challenge.getSuccessWeeks();
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/ceos/bankids/service/ChallengeServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,19 @@ public KidAchievedChallengeListDTO readKidAchievedChallenge(User user, Long kidI

AchievedChallengeListDTO achievedChallengeListDTO = readAchievedChallenge(kidUser,
interestPayment);
List<AchievedChallengeDTO> challengeDTOList = achievedChallengeListDTO.getChallengeDTOList();
List<AchievedChallengeDTO> contractUserChallengeDTOList = challengeDTOList.stream().filter(
achievedChallengeDTO -> achievedChallengeDTO.getChallenge().getIsMom()
== user.getIsFemale()).collect(
Collectors.toList());
achievedChallengeListDTO.setChallengeDTOList(contractUserChallengeDTOList);
Long[] totalInterestPrice = {0L};
contractUserChallengeDTOList.forEach(challenge -> {
totalInterestPrice[0] +=
(challenge.getChallenge().getInterestPrice() / challenge.getChallenge().getWeeks())
* challenge.getChallenge().getSuccessWeeks();
});
achievedChallengeListDTO.setTotalInterestPrice(totalInterestPrice[0]);

return new KidAchievedChallengeListDTO(kidId, achievedChallengeListDTO);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public String encodeJwtToken(TokenDTO tokenDTO) {
.setIssuer("bankids")
.setIssuedAt(now)
.setSubject(tokenDTO.getId().toString())
// .setExpiration(new Date(now.getTime() + Duration.ofMinutes(2880).toMillis()))
.setExpiration(new Date(now.getTime() + Duration.ofMinutes(40320).toMillis()))
.setExpiration(new Date(now.getTime() + Duration.ofDays(180).toMillis()))
.claim("id", tokenDTO.getId())
.claim("roles", "USER")
.signWith(SignatureAlgorithm.HS256,
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/com/ceos/bankids/service/UserServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.ceos.bankids.repository.KidRepository;
import com.ceos.bankids.repository.ParentRepository;
import com.ceos.bankids.repository.UserRepository;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Optional;
import javax.servlet.http.Cookie;
Expand Down Expand Up @@ -99,9 +101,16 @@ public UserDTO updateUserType(User user, UserTypeRequest userTypeRequest) {
Calendar cal = Calendar.getInstance();
Integer currYear = cal.get(Calendar.YEAR);
Integer birthYear = Integer.parseInt(userTypeRequest.getBirthday()) / 10000;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
dateFormat.setLenient(false);
try {
dateFormat.parse(userTypeRequest.getBirthday());
} catch (ParseException e) {
throw new BadRequestException(ErrorCode.INVALID_BIRTHDAY.getErrorCode());
}
if (user.getIsFemale() != null) {
throw new BadRequestException(ErrorCode.USER_ALREADY_HAS_TYPE.getErrorCode());
} else if (birthYear > currYear || birthYear <= currYear - 100) {
} else if (birthYear >= currYear || birthYear <= currYear - 100) {
throw new BadRequestException(ErrorCode.INVALID_BIRTHDAY.getErrorCode());
} else {
user.setBirthday(userTypeRequest.getBirthday());
Expand Down