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.1 #217

Merged
merged 16 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
f0f6575
feat: ν…ŒμŠ€νŠΈ ν™˜κ²½ docker-compose둜 pull λ°›κΈ° 전에 이미지 및 μ»¨ν…Œμ΄λ„ˆ μ‚­μ œ μΆ”κ°€
sanbonai06 Sep 9, 2022
34c026b
fix: κ°€μ‘± λ‚˜κ°€κΈ° ν•˜λ©΄ 레벨 0이 μ•„λ‹ˆλΌ 레벨1 #211
sanbonai06 Sep 9, 2022
7f5b04a
add: revoke κΆŒν•œ μˆ˜μ • #212
ozzing Sep 9, 2022
6fca5ef
refactor: κ°€μ‘± ν™œλ™ μ•Œλ¦Ό serviceOptIn으둜 λ³€κ²½ #212
ozzing Sep 9, 2022
b53914b
feat: μ•Œλ¦Ό λ™μ˜ μ—¬λΆ€ get API #212
ozzing Sep 9, 2022
2f8bf5a
feat: μ•Œλ¦Ό λ™μ˜ μ—¬λΆ€ get ν…ŒμŠ€νŠΈ μ½”λ“œ #212
ozzing Sep 9, 2022
95517dc
Merge pull request #213 from bankidz/feature/optIn
ozzing Sep 9, 2022
8966440
chore: uri μŠ€λ„€μ΄ν¬ μΌ€μ΄μŠ€μ—μ„œ ꢌμž₯사항인 ν•˜μ΄ν”ˆμœΌλ‘œ μˆ˜μ • #211
sanbonai06 Sep 9, 2022
49fab88
chore: nullable μž¬μ„€μ • 및 default 지정 #214
ozzing Sep 9, 2022
615b3e4
feat: notification에 μ—°κ²° url 컬럼 μΆ”κ°€ #211
sanbonai06 Sep 9, 2022
0825deb
fix: 돈길 μƒνƒœλ³€κ²½ μ•Œλ¦Ό λŒ€μƒ μœ μ € μˆ˜μ • #211
sanbonai06 Sep 9, 2022
ac9ffb0
refactor: μ—λŸ¬ μ½”λ“œ λ³€κ²½ 및 uri 뢄리 #214
ozzing Sep 9, 2022
c5c90b2
refactor: apple access token ν…ŒμŠ€νŠΈ μ½”λ“œ #214
ozzing Sep 9, 2022
d1fcda1
Merge pull request #215 from bankidz/feature/notificationLink
sanbonai06 Sep 9, 2022
aebebe0
add: μ—°λ™ν•΄μ œ 성곡 μ—¬λΆ€ query param μΆ”κ°€ #214
ozzing Sep 9, 2022
a83140f
Merge pull request #216 from bankidz/fix/user
ozzing Sep 9, 2022
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
6 changes: 4 additions & 2 deletions .github/workflows/dev-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
echo "$FIREBASEKEY" > ./src/main/resources/bankidz-firebase.json
env:
FIREBASEKEY: ${{ secrets.FIREBASE_KEY }}

- name: Make apple-auth-key.p8
run: |
touch ./src/main/resources/apple-auth-key.p8
Expand Down Expand Up @@ -121,7 +121,9 @@ jobs:
key: ${{ secrets.KEY_DEV }}
script: |
sh ~/srv/ubuntu/config/scripts/deploy.sh
sudo docker image prune -a
sudo docker stop $(sudo docker ps -a -q)
sudo docker rm $(sudo docker ps -a -q)
sudo docker rmi $(sudo docker images -q)
sudo docker-compose -f ~/srv/ubuntu/docker-compose.yml pull
sudo docker-compose -f ~/srv/ubuntu/docker-compose.yml up --build -d

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ protected void configure(HttpSecurity http) throws Exception {
.antMatchers(SwaggerPatterns).permitAll()
.antMatchers("/kakao/login").permitAll()
.antMatchers("/apple/login").permitAll()
.antMatchers("/apple/revoke").permitAll()
.antMatchers("/user/refresh").permitAll()
.anyRequest().authenticated()
.and()
Expand Down
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 @@ -74,6 +74,7 @@ public enum ErrorCode implements EnumMapperType {
APPLE_KEY_UNAVAILABLE("E400-80002"),
APPLE_TOKEN_EXPIRED("E400-80003"),
APPLE_NONCE_INCORRECT("E400-80004"),
APPLE_ACCESS_TOKEN_ERROR("E400-80005"),

// S3
PRESIGNEDURI_ERROR("E400-60001"),
Expand Down
21 changes: 13 additions & 8 deletions src/main/java/com/ceos/bankids/controller/AppleController.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void postAppleLogin(
AppleSubjectDTO appleSubjectDTO = appleService.verifyIdentityToken(appleRequest,
appleKeyListDTO);

AppleTokenDTO appleTokenDTO = appleService.getAppleAccessToken(appleRequest);
AppleTokenDTO appleTokenDTO = appleService.getAppleAccessToken(appleRequest, "login");

LoginDTO loginDTO = userService.loginWithAppleAuthenticationCode(
appleSubjectDTO.getAuthenticationCode(), appleRequest);
Expand All @@ -63,17 +63,22 @@ public void deleteAppleLogin(
throws IOException {

log.info("api = μ• ν”Œ μ—°λ™ν•΄μ œ");
AppleRequest appleRequest = appleService.getAppleRequest(formData);

AppleKeyListDTO appleKeyListDTO = appleService.getAppleIdentityToken();
try {
AppleRequest appleRequest = appleService.getAppleRequest(formData);

AppleSubjectDTO appleSubjectDTO = appleService.verifyIdentityToken(appleRequest,
appleKeyListDTO);
AppleKeyListDTO appleKeyListDTO = appleService.getAppleIdentityToken();

AppleSubjectDTO appleSubjectDTO = appleService.verifyIdentityToken(appleRequest,
appleKeyListDTO);

AppleTokenDTO appleTokenDTO = appleService.getAppleAccessToken(appleRequest);
AppleTokenDTO appleTokenDTO = appleService.getAppleAccessToken(appleRequest, "revoke");

Object appleResponse = appleService.revokeAppleAccount(appleTokenDTO);
Object appleResponse = appleService.revokeAppleAccount(appleTokenDTO);
} catch (Exception e) {
response.sendRedirect("https://bankidz.com/manage/withdraw/callback?isError=true");
}

response.sendRedirect("https://bankidz.com/manage/withdraw/callback");
response.sendRedirect("https://bankidz.com/manage/withdraw/callback?isError=false");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public CommonResponse<AchievedChallengeListDTO> getAchievedListChallenge(
}

@ApiOperation(value = "μ™„μ£Όν•œ λˆκΈΈμ— 이자 μ§€κΈ‰ν•˜κΈ°")
@PatchMapping(value = "/interest_payment/{challengeId}", produces = "application/json; charset=utf-8")
@PatchMapping(value = "/interest-payment/{challengeId}", produces = "application/json; charset=utf-8")
public CommonResponse<AchievedChallengeDTO> patchInterestPayment(
@AuthenticationPrincipal User authUser,
@PathVariable Long challengeId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class NotificationController {
private final NotificationRepository notificationRepository;

@ApiOperation(value = "λͺ¨λ“  μœ μ €μ—κ²Œ μ•Œλ¦Ό")
@PostMapping(value = "/all_user", produces = "application/json; charset=utf-8")
@PostMapping(produces = "application/json; charset=utf-8")
public CommonResponse<String> allSendNotification(
@RequestBody AllSendNotificationDTO allSendNotificationRequest,
@AuthenticationPrincipal User authUser) {
Expand All @@ -65,10 +65,11 @@ public CommonResponse<String> allSendNotification(
.forEach(user -> {
if (user.getNoticeOptIn()) {
expoNotificationService.sendMessage(user, title, message,
allSendNotificationRequest.getNewMap(), notificationCategory);
allSendNotificationRequest.getNewMap(), notificationCategory, "/");
} else {
Notification notification = Notification.builder().user(user).title(title)
.message(message).notificationCategory(notificationCategory).build();
.message(message).notificationCategory(notificationCategory).linkUrl("/")
.build();
notificationRepository.save(notification);
}
});
Expand Down Expand Up @@ -126,10 +127,10 @@ public void notification(Challenge challenge, User authUser) {
newMap.put("userId", authUser.getId());
NotificationCategory notificationCategory = NotificationCategory.CHALLENGE;
Boolean checkServiceOptIn = checkServiceOptIn(authUser, title, notificationBody,
notificationCategory);
notificationCategory, "/");
if (checkServiceOptIn) {
expoNotificationService.sendMessage(authUser, title, notificationBody, newMap,
notificationCategory);
notificationCategory, "/");
}
log.info("μœ μ € {}의 돈길 {}의 {} μƒνƒœλ³€κ²½ μ•Œλ¦Ό", authUser.getId(), challenge.getId(),
challenge.getChallengeStatus());
Expand All @@ -145,10 +146,10 @@ public void userLevelUpMinusOne(User authUser) {
newMap.put("userId", authUser.getId());
NotificationCategory notificationCategory = NotificationCategory.LEVEL;
Boolean checkServiceOptIn = checkServiceOptIn(authUser, title, notificationBody,
notificationCategory);
notificationCategory, "/mypage");
if (checkServiceOptIn) {
expoNotificationService.sendMessage(authUser, title, notificationBody, newMap,
notificationCategory);
notificationCategory, "/mypage");
}
log.info("μœ μ € id = {}의 λ ˆλ²¨μ—… 직전 μ•Œλ¦Ό", authUser.getId());
}
Expand All @@ -164,10 +165,10 @@ public void userLevelUpHalf(User authUser) {
newMap.put("userId", authUser.getId());
NotificationCategory notificationCategory = NotificationCategory.LEVEL;
Boolean checkServiceOptIn = checkServiceOptIn(authUser, title, notificationBody,
notificationCategory);
notificationCategory, "/mypage");
if (checkServiceOptIn) {
expoNotificationService.sendMessage(authUser, title, notificationBody, newMap,
notificationCategory);
notificationCategory, "/mypage");
}
log.info("μœ μ € id = {}의 λ ˆλ²¨μ—… 절반 달성 μ•Œλ¦Ό", authUser.getId());
}
Expand All @@ -184,10 +185,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) {
expoNotificationService.sendMessage(contractUser, title, notificationBody, newMap,
notificationCategory);
notificationCategory, "");
}
log.info("λΆ€λͺ¨ μœ μ € id = {}μ—κ²Œ μœ μ € id = {} 돈길 id = {} 의 돈길 μ œμ•ˆ", contractUser.getId(),
challengeUser.getUser().getId(), challengeUser.getChallenge().getId());
Expand All @@ -205,10 +206,10 @@ public void runProgressNotification(User contractUser, ChallengeUser challengeUs
newMap.put("challenge", challengeUser.getChallenge().getId());
NotificationCategory notificationCategory = NotificationCategory.CHALLENGE;
Boolean checkServiceOptIn = checkServiceOptIn(contractUser, title, notificationBody,
notificationCategory);
notificationCategory, "/");
if (checkServiceOptIn) {
expoNotificationService.sendMessage(contractUser, title, notificationBody, newMap,
notificationCategory);
notificationCategory, "/");
}
log.info("λΆ€λͺ¨ μœ μ € id = {}μ—κ²Œ μœ μ € id = {}의 돈길 id = {} 돈길 κ±·κΈ° μ•Œλ¦Ό 전솑", contractUser.getId(),
challengeUser.getUser().getId(), challengeUser.getChallenge().getId());
Expand All @@ -227,10 +228,10 @@ public void achieveChallengeNotification(User contractUser, ChallengeUser challe
newMap.put("challenge", challengeUser.getChallenge().getId());
NotificationCategory notificationCategory = NotificationCategory.CHALLENGE;
Boolean checkServiceOptIn = checkServiceOptIn(contractUser, title, notificationBody,
notificationCategory);
notificationCategory, "/");
if (checkServiceOptIn) {
expoNotificationService.sendMessage(contractUser, title, notificationBody, newMap,
notificationCategory);
notificationCategory, "/");
}
log.info("λΆ€λͺ¨ μœ μ € id = {}μ—κ²Œ μœ μ € id = {}의 돈길 id = {} 돈길 μ™„μ£Ό μ•Œλ¦Ό 전솑", contractUser.getId(),
challengeUser.getUser().getId(), challengeUser.getChallenge().getId());
Expand All @@ -247,10 +248,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) {
expoNotificationService.sendMessage(contractUser, title, notificationBody, newMap,
notificationCategory);
notificationCategory, "");
}
log.info("λΆ€λͺ¨ μœ μ € id = {}μ—κ²Œ μœ μ € id = {}의 λ ˆλ²¨μ—… μ•Œλ¦Ό 전솑", contractUser.getId(), user.getId());
}
Expand All @@ -266,10 +267,10 @@ public void challengeFailedNotification(User contractUser, ChallengeUser challen
newMap.put("challenge", challengeUser.getChallenge().getId());
NotificationCategory notificationCategory = NotificationCategory.CHALLENGE;
Boolean checkServiceOptIn = checkServiceOptIn(contractUser, title, notificationBody,
notificationCategory);
notificationCategory, "/");
if (checkServiceOptIn) {
expoNotificationService.sendMessage(contractUser, title, notificationBody, newMap,
notificationCategory);
notificationCategory, "/");
}
log.info("λΆ€λͺ¨ μœ μ € id = {}μ—κ²Œ μœ μ € id = {}의 돈길 id = {} 돈길 μ‹€νŒ¨ μ•Œλ¦Ό 전솑", contractUser.getId(),
challengeUser.getChallenge().getId(), challengeUser.getChallenge().getId());
Expand All @@ -286,21 +287,21 @@ public void newFamilyUserNotification(User newFamilyUser, List<FamilyUser> famil
familyUserList.forEach(familyUser -> {
User user = familyUser.getUser();
Boolean checkServiceOptIn = checkServiceOptIn(user, title, notificationBody,
notificationCategory);
notificationCategory, "");
if (checkServiceOptIn) {
expoNotificationService.sendMessage(user, title, notificationBody, newMap,
notificationCategory);
notificationCategory, "");
}
log.info("κΈ°μ‘΄ κ°€μ‘± ꡬ성원 id = {}μ—κ²Œ μœ μ € id = {}의 κ°€μ‘± μ°Έμ—¬ μ•Œλ¦Ό 전솑", familyUser.getUser().getId(),
newFamilyUser.getId());
});
}

private Boolean checkServiceOptIn(User user, String title, String body,
NotificationCategory notificationCategory) {
NotificationCategory notificationCategory, String linkUrl) {
if (!user.getServiceOptIn()) {
Notification notification = Notification.builder().user(user).title(title).message(body)
.notificationCategory(notificationCategory)
.notificationCategory(notificationCategory).linkUrl(linkUrl)
.build();
notificationRepository.save(notification);
return false;
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/com/ceos/bankids/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,24 @@ public CommonResponse<OptInDTO> patchNoticeOptIn(@AuthenticationPrincipal User a
}

@ApiOperation(value = "κ°€μ‘± ν™œλ™ μ•Œλ¦Ό λ™μ˜")
@PatchMapping(value = "/action", produces = "application/json; charset=utf-8")
@PatchMapping(value = "/service", produces = "application/json; charset=utf-8")
@ResponseBody
public CommonResponse<OptInDTO> patchActionOptIn(@AuthenticationPrincipal User authUser) {
public CommonResponse<OptInDTO> patchServiceOptIn(@AuthenticationPrincipal User authUser) {

log.info("api = κ°€μ‘± ν™œλ™ μ•Œλ¦Ό λ™μ˜, user = {}", authUser.getUsername());
OptInDTO optInDTO = userService.updateServiceOptIn(authUser);

return CommonResponse.onSuccess(optInDTO);
}

@ApiOperation(value = "μœ μ € μ•Œλ¦Ό λ™μ˜ 쑰회")
@GetMapping(value = "/opt-in", produces = "application/json; charset=utf-8")
@ResponseBody
public CommonResponse<OptInDTO> getOptIn(@AuthenticationPrincipal User authUser) {

log.info("api = μœ μ € μ•Œλ¦Ό λ™μ˜ 쑰회, user = {}", authUser.getUsername());
OptInDTO optInDTO = userService.getOptIn(authUser);

return CommonResponse.onSuccess(optInDTO);
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/ceos/bankids/domain/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public class Notification extends AbstractTimestamp {
@Enumerated(EnumType.STRING)
private NotificationCategory notificationCategory;

@Column(nullable = false)
private String linkUrl;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "userId", nullable = false)
private User user;
Expand All @@ -58,6 +61,7 @@ public Notification(
String message,
Boolean isRead,
NotificationCategory notificationCategory,
String linkUrl,
User user
) {

Expand All @@ -66,6 +70,7 @@ public Notification(
this.message = message;
this.isRead = isRead;
this.notificationCategory = notificationCategory;
this.linkUrl = linkUrl;
this.user = user;
}
}
12 changes: 6 additions & 6 deletions src/main/java/com/ceos/bankids/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public class User extends AbstractTimestamp implements UserDetails {
@Column(nullable = false, length = 10)
private String username;

@Column(nullable = true)
@Column()
private Boolean isFemale;

@Column(nullable = true, length = 8)
@Column(length = 8)
private String birthday;

@Column(nullable = true, length = 12, unique = true)
@Column(length = 12, unique = true)
private String phone;

@Column(name = "authentication_code", nullable = false, unique = true)
Expand All @@ -55,7 +55,7 @@ public class User extends AbstractTimestamp implements UserDetails {
@Column(nullable = false, length = 10)
private String provider;

@Column(nullable = true)
@Column()
private Boolean isKid;

@Column(columnDefinition = "TEXT")
Expand All @@ -64,11 +64,11 @@ public class User extends AbstractTimestamp implements UserDetails {
@Column(columnDefinition = "TEXT")
private String expoToken;

@Column(nullable = false)
@Column()
@ColumnDefault("false")
private Boolean noticeOptIn;

@Column(nullable = false)
@Column()
@ColumnDefault("false")
private Boolean serviceOptIn;

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/ceos/bankids/dto/NotificationDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public class NotificationDTO {
@ApiModelProperty(example = "CHALLENGE")
private NotificationCategory notificationCategory;

@ApiModelProperty(example = "/")
private String linkUrl;

@ApiModelProperty(example = "2022/07/05 05:05:05")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd hh:mm:ss", timezone = "Asia/Seoul")
private Timestamp createdAt;
Expand All @@ -41,6 +44,7 @@ public NotificationDTO(Notification notification) {
this.message = notification.getMessage();
this.isRead = notification.getIsRead();
this.notificationCategory = notification.getNotificationCategory();
this.linkUrl = notification.getLinkUrl();
this.createdAt = notification.getCreatedAt();
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/ceos/bankids/service/AppleService.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public interface AppleService {
public AppleSubjectDTO verifyIdentityToken(AppleRequest appleRequest,
AppleKeyListDTO appleKeyListDTO);

public AppleTokenDTO getAppleAccessToken(AppleRequest appleRequest);
public AppleTokenDTO getAppleAccessToken(AppleRequest appleRequest, String option);

public Object revokeAppleAccount(AppleTokenDTO appleTokenDTO);

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/ceos/bankids/service/AppleServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ public AppleSubjectDTO verifyIdentityToken(AppleRequest appleRequest,
}

@Override
public AppleTokenDTO getAppleAccessToken(AppleRequest appleRequest) {
public AppleTokenDTO getAppleAccessToken(AppleRequest appleRequest, String option) {
APPLE_SECRET = makeClientSecret();

String getTokenURL =
"https://appleid.apple.com/auth/token?client_id=" + APPLE_CLIENT_ID + "&client_secret="
+ APPLE_SECRET + "&grant_type=authorization_code&code=" + appleRequest.getCode()
+ "&redirect_uri=" + APPLE_URI;
+ "&redirect_uri=" + APPLE_URI + option;

WebClient.ResponseSpec responseSpec = webClient.post().uri(getTokenURL).retrieve();

Expand All @@ -155,7 +155,7 @@ public AppleTokenDTO getAppleAccessToken(AppleRequest appleRequest) {
return appleTokenDTO;
} catch (Exception e) {
e.printStackTrace();
throw new BadRequestException(ErrorCode.APPLE_BAD_REQUEST.getErrorCode());
throw new BadRequestException(ErrorCode.APPLE_ACCESS_TOKEN_ERROR.getErrorCode());
}
}

Expand Down
Loading