Skip to content

Commit

Permalink
Merge pull request #274 from bankidz/dev
Browse files Browse the repository at this point in the history
[v1.1.5] 출시 후 이슈 대응 버전 배포
  • Loading branch information
sanbonai06 authored Nov 19, 2022
2 parents b29767f + e961c06 commit 3ba68dc
Show file tree
Hide file tree
Showing 18 changed files with 111 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/ceos/bankids/constant/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public enum ErrorCode implements EnumMapperType {
USER_ALREADY_HAS_TYPE("E400-20002"),
INVALID_BIRTHDAY("E400-20003"),
USER_TYPE_NOT_CHOSEN("E400-20004"),
USER_ALREADY_LOGINED("E400-20005"),

// Family
FAMILY_NOT_EXISTS("E403-30001"),
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/ceos/bankids/controller/ChallengeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ public CommonResponse<List<ChallengeDTO>> getListChallenge(
return CommonResponse.onSuccess(challengeDTOList);
}

@ApiOperation(value = "돈길 상세 가져오기")
@GetMapping(value = "/{challengeId}", produces = "application/json; charset=utf-8")
public CommonResponse<ChallengeDTO> getChallengeDetail(@AuthenticationPrincipal User authUser,
@PathVariable Long challengeId) {

log.info("api = 돈길 상세 가져오기, user = {}, challenge = {}", authUser.getUsername(),
challengeId);

return CommonResponse.onSuccess(challengeMapper.readChallengeDetail(authUser, challengeId));
}

@ApiOperation(value = "자녀의 돈길 리스트 가져오기")
@GetMapping(value = "/kid/{kidId}", produces = "application/json; charset=utf-8")
public CommonResponse<KidChallengeListDTO> getListKidChallenge(
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ceos/bankids/dto/ChallengeDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class ChallengeDTO {
private Long weeks;

@ApiModelProperty(example = "2022/07/05 05:05:05")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd kk:mm:ss", timezone = "Asia/Seoul")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd HH:mm:ss", timezone = "Asia/Seoul")
private Timestamp createdAt;

@ApiModelProperty(example = "true")
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ceos/bankids/dto/NoticeDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class NoticeDTO {
private String body;

@ApiModelProperty(example = "2022/07/05 05:05:05")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd kk:mm:ss", timezone = "Asia/Seoul")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd HH:mm:ss", timezone = "Asia/Seoul")
private Timestamp createdAt;

public NoticeDTO(Notice notice) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ceos/bankids/dto/NoticeListDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class NoticeListDTO {
private String title;

@ApiModelProperty(example = "2022/07/05 05:05:05")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd kk:mm:ss", timezone = "Asia/Seoul")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd HH:mm:ss", timezone = "Asia/Seoul")
private Timestamp createdAt;

public NoticeListDTO(Notice notice) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ceos/bankids/dto/NotificationDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class NotificationDTO {
private String linkUrl;

@ApiModelProperty(example = "2022/07/05 05:05:05")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd kk:mm:ss", timezone = "Asia/Seoul")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd HH:mm:ss", timezone = "Asia/Seoul")
private Timestamp createdAt;

public NotificationDTO(Notification notification) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ceos/bankids/dto/OptInDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class OptInDTO {
@ApiModelProperty(example = "true")
private Boolean serviceOptIn;
@ApiModelProperty(example = "2022/07/05 05:05:05")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd kk:mm:ss", timezone = "Asia/Seoul")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd HH:mm:ss", timezone = "Asia/Seoul")
private Timestamp updatedAt;

public OptInDTO(User user) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ceos/bankids/dto/ProgressDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ProgressDTO {
private ChallengeStatus challengeStatus;

@ApiModelProperty(example = "2022/05/05 06:33:13")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd kk:mm:ss", timezone = "Asia/Seoul")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd HH:mm:ss", timezone = "Asia/Seoul")
private Timestamp approvedAt;


Expand Down
17 changes: 16 additions & 1 deletion src/main/java/com/ceos/bankids/mapper/ChallengeMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,14 @@ public ChallengeDTO deleteChallengeMapper(User authUser, Long challengeId) {
}
if (deleteChallenge.getChallengeStatus() == ChallengeStatus.WALKING) {
kidService.checkKidDeleteChallenge(authUser, deleteChallenge);
return challengeService.deleteWalkingChallenge(
ChallengeDTO challengeDTO = challengeService.deleteWalkingChallenge(
authUser,
challengeUser);
kidService.updateKidDecreaseTotalChallenge(authUser);
parentService.parentAcceptedChallengeDecrease(deleteChallenge.getContractUser());
notificationService.deleteChallengeNotification(authUser,
deleteChallenge.getContractUser(), deleteChallenge);
return challengeDTO;
} else if (deleteChallenge.getChallengeStatus() == ChallengeStatus.FAILED) {
return challengeService.deleteWalkingChallenge(
authUser,
Expand Down Expand Up @@ -156,6 +161,16 @@ public List<ChallengeDTO> readChallengeListMapper(User authUser, String status)
return challengeDTOList;
}

// 돈길 상세 가져오기 API Mapper
@Transactional
public ChallengeDTO readChallengeDetail(User authUser, Long challengeId) {
ChallengeUser challengeUser = challengeUserService.readChallengeUser(challengeId);
if (authUser.getId() != challengeUser.getUser().getId()) {
throw new ForbiddenException(ErrorCode.NOT_MATCH_CHALLENGE_USER.getErrorCode());
}
return challengeService.readChallengeDetail(challengeId);
}

// 자녀의 돈길 리스트 가져오기 API Mapper
@Transactional
public KidChallengeListDTO readKidChallengeListMapper(User authUser, Long kidId,
Expand Down
25 changes: 15 additions & 10 deletions src/main/java/com/ceos/bankids/mapper/UserMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public class UserMapper {

@Transactional
public UserDTO updateUserType(User user, UserTypeRequest userTypeRequest) {
// 이미 로그인한 유저인지 검사
if (user.getExpoToken() != null && user.getExpoToken().contains("ExponentPushToken")) {
throw new BadRequestException(ErrorCode.USER_ALREADY_LOGINED.getErrorCode());
}

// 유저 타입이 이미 선택되었는지 검사
if (user.getIsFemale() != null) {
throw new BadRequestException(ErrorCode.USER_ALREADY_HAS_TYPE.getErrorCode());
Expand Down Expand Up @@ -106,11 +111,11 @@ public LoginDTO updateUserToken(User user) {
LoginDTO loginDTO;
if (updatedUser.getIsKid() == null || updatedUser.getIsKid() == false) {
loginDTO = new LoginDTO(updatedUser.getIsKid(), newAccessToken,
updatedUser.getProvider());
updatedUser.getProvider());
} else {
loginDTO = new LoginDTO(updatedUser.getIsKid(), newAccessToken,
updatedUser.getKid().getLevel(),
updatedUser.getProvider());
updatedUser.getKid().getLevel(),
updatedUser.getProvider());
}
return loginDTO;
}
Expand Down Expand Up @@ -144,20 +149,20 @@ public void deleteFamilyUserIfExists(User user) {
if (familyUser.isPresent()) {
Family family = familyUser.get().getFamily();
List<FamilyUser> familyUserList = familyUserService.getFamilyUserListExclude(family,
user);
user);

if (user.getIsKid()) {
List<Challenge> challengeList = challengeUserService.readAllChallengeUserListToChallengeList(
user);
user);
challengeUserService.deleteAllChallengeUserOfUser(user);
ChallengeCompleteDeleteByKidMapperDTO challengeCompleteDeleteByKidMapperDTO = challengeService.challengeCompleteDeleteByKid(
challengeList);
challengeList);
kidService.updateInitKid(user);
parentService.updateParentForDeleteFamilyUserByKid(familyUserList,
challengeCompleteDeleteByKidMapperDTO);
challengeCompleteDeleteByKidMapperDTO);
} else {
List<ChallengeUser> challengeUserList = challengeUserService.getChallengeUserListByContractUser(
user);
user);
kidService.updateKidForDeleteFamilyUserByParent(challengeUserList);
parentService.updateInitParent(user);
challengeService.challengeCompleteDeleteByParent(challengeUserList);
Expand All @@ -175,12 +180,12 @@ public UserDTO deleteUserAccount(User user, WithdrawalRequest withdrawalRequest)
if (user.getIsKid()) {
KidBackupDTO kidBackupDTO = kidBackupService.backupKidUser(user);
slackService.sendWithdrawalMessage("KidBackup ", kidBackupDTO.getId(),
withdrawalRequest.getMessage());
withdrawalRequest.getMessage());
kidService.deleteKid(user);
} else {
ParentBackupDTO parentBackupDTO = parentBackupService.backupParentUser(user);
slackService.sendWithdrawalMessage("ParentBackup ", parentBackupDTO.getId(),
withdrawalRequest.getMessage());
withdrawalRequest.getMessage());
parentService.deleteParent(user);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public AppleSubjectDTO verifyIdentityToken(AppleRequest appleRequest,
appleHeaderDTO.getAlg())
.orElseThrow(
() -> new BadRequestException(ErrorCode.APPLE_KEY_UNAVAILABLE.getErrorCode()));

byte[] nBytes = Base64.getUrlDecoder().decode(appleKeyDTO.getN());
byte[] eBytes = Base64.getUrlDecoder().decode(appleKeyDTO.getE());

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/ceos/bankids/service/ChallengeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ public ChallengeCompleteDeleteByKidMapperDTO challengeCompleteDeleteByKid(
List<Challenge> challengeList);

public List<ChallengeDTO> readChallengeHistory(String status);

public ChallengeDTO readChallengeDetail(Long challengeId);
}
10 changes: 10 additions & 0 deletions src/main/java/com/ceos/bankids/service/ChallengeServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ public ChallengeListMapperDTO readPendingChallenge(Challenge challenge) {
return new ChallengeListMapperDTO(challenge, null, false);
}

@Transactional
@Override
public ChallengeDTO readChallengeDetail(Long challengeId) {
Challenge challenge = challengeRepository.findById(challengeId).orElseThrow(
() -> new BadRequestException(ErrorCode.NOT_EXIST_CHALLENGE.getErrorCode()));
return new ChallengeDTO(challenge, challenge.getProgressList().stream()
.map(progress -> new ProgressDTO(progress, challenge)).collect(
Collectors.toList()), challenge.getComment());
}

// 돈길 수락 / 거절 API
@Transactional
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ public void createPendingChallengeNotification(User contractUser, ChallengeUser
newMap.put("challenge", challengeUser.getChallenge().getId());
NotificationCategory notificationCategory = NotificationCategory.CHALLENGE;
Boolean checkServiceOptIn = checkServiceOptIn(contractUser, title, notificationBody,
notificationCategory, "");
notificationCategory, "/");
if (checkServiceOptIn) {
this.sendMessage(contractUser, title, notificationBody, newMap,
notificationCategory, "");
notificationCategory, "/");
}
log.info("부모 유저 id = {}에게 유저 id = {} 돈길 id = {} 의 돈길 제안", contractUser.getId(),
challengeUser.getUser().getId(), challengeUser.getChallenge().getId());
Expand Down Expand Up @@ -288,10 +288,10 @@ public void kidLevelUpNotification(User contractUser, User user, Long level, Lon
newMap.put("user", user.getId());
NotificationCategory notificationCategory = NotificationCategory.LEVEL;
Boolean checkServiceOptIn = checkServiceOptIn(contractUser, title, notificationBody,
notificationCategory, "");
notificationCategory, "/");
if (checkServiceOptIn) {
this.sendMessage(contractUser, title, notificationBody, newMap,
notificationCategory, "");
notificationCategory, "/");
}
log.info("부모 유저 id = {}에게 유저 id = {}의 레벨업 알림 전송", contractUser.getId(), user.getId());
}
Expand Down Expand Up @@ -380,6 +380,26 @@ public void runProgressNotification(User user, User contractUser, Challenge chal
user.getId(), challenge.getId());
}

@Async
@ApiOperation(value = "자녀가 돈길을 포기했을 때 부모 알림")
public void deleteChallengeNotification(User user, User contractUser, Challenge challenge) {

String title = "🚨자녀가 돈길을 포기했어요";
String notificationBody = "포기한 돈길은 무엇인지 확인해볼까요?\uD83D\uDE1F\n포기한 돈길들은 마이페이지 - 돈길 기록에서 확인가능해요";
HashMap<String, Object> newMap = new HashMap<>();
newMap.put("user", user.getId());
newMap.put("challenge", challenge.getId());
NotificationCategory notificationCategory = NotificationCategory.CHALLENGE;
Boolean checkServiceOptIn = checkServiceOptIn(contractUser, title, notificationBody,
notificationCategory, "/");
if (checkServiceOptIn) {
this.sendMessage(contractUser, title, notificationBody, newMap, notificationCategory,
"/");
}
log.info("부모 유저 id = {}에게 유저 id = {}의 돈길 id = {} 돈길 포기 알림 전송", contractUser.getId(),
user.getId(), challenge.getId());
}

@Async
public void newFamilyUserNotification(User newFamilyUser, List<FamilyUser> familyUserList) {

Expand All @@ -391,10 +411,10 @@ public void newFamilyUserNotification(User newFamilyUser, List<FamilyUser> famil
familyUserList.forEach(familyUser -> {
User user = familyUser.getUser();
Boolean checkServiceOptIn = checkServiceOptIn(user, title, notificationBody,
notificationCategory, "");
notificationCategory, "/newFamily");
if (checkServiceOptIn) {
this.sendMessage(user, title, notificationBody, newMap,
notificationCategory, "");
notificationCategory, "/mypage/new");
}
log.info("기존 가족 구성원 id = {}에게 유저 id = {}의 가족 참여 알림 전송", familyUser.getUser().getId(),
newFamilyUser.getId());
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/ceos/bankids/service/KidService.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ public interface KidService {
public void updateInitKid(User user);

public void updateKidByPatchProgress(User user, Challenge challenge);

public void updateKidDecreaseTotalChallenge(User user);
}
9 changes: 9 additions & 0 deletions src/main/java/com/ceos/bankids/service/KidServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ public void updateKidTotalChallenge(User user) {
kidRepository.save(kid);
}

@Transactional
@Override
public void updateKidDecreaseTotalChallenge(User user) {
Kid kid = user.getKid();
Long totalChallenge = kid.getTotalChallenge();
kid.setTotalChallenge(totalChallenge - 1L);
kidRepository.save(kid);
}

@Transactional
@Override
public void updateInitKid(User user) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/ceos/bankids/service/ParentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public interface ParentService {

public void updateParentAcceptedChallenge(User contractUser);

public void parentAcceptedChallengeDecrease(User contractUser);

public void updateParentForDeleteFamilyUserByKid(List<FamilyUser> familyUserList,
ChallengeCompleteDeleteByKidMapperDTO challengeCompleteDeleteByKidMapperDTO);

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/ceos/bankids/service/ParentServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ public void updateParentAcceptedChallenge(User contractUser) {
parentRepository.save(parent);
}

@Transactional
@Override
public void parentAcceptedChallengeDecrease(User contractUser) {

Parent parent = contractUser.getParent();
Long acceptedRequest = parent.getAcceptedRequest();
parent.setAcceptedRequest(acceptedRequest - 1L);
parentRepository.save(parent);
}

@Transactional
@Override
public void updateParentForDeleteFamilyUserByKid(List<FamilyUser> familyUserList,
Expand Down

0 comments on commit 3ba68dc

Please sign in to comment.