Skip to content

Commit

Permalink
Feat: 최근 접속 일시 업데이트 API 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
suminnnnn committed Oct 10, 2024
1 parent 69e7740 commit 8e5ded3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/main/java/cmc/blink/domain/user/business/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,9 @@ public void deleteExpiredAccounts() {
userCommandAdapter.delete(user);
}
}

@Transactional
public void updateLastLoginTime(User user) {
userCommandAdapter.updateLastLoginTime(user);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public User updateDeleteRequestDate(User user) {
return userRepository.save(user);
}

public void updateLastLoginTime(User user) {
user.updateLoginTime();

userRepository.save(user);
}

public void delete(User user) {
userRepository.delete(user);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

@Tag(name="유저", description = "마이페이지 관련 API 입니다.")
@RestController
Expand Down Expand Up @@ -56,5 +53,14 @@ public ApiResponseDto<?> cancelAccountDeletion(@AuthUser User user) {
return ApiResponseDto.of("계정 삭제 신청 취소가 완료되었습니다.", null);
}

@PatchMapping("/last-access")
@Operation(summary = "최근 접속 일시 업데이트 API", description = "사용자가 앱에 마지막으로 접속한 일시를 업데이트하는 API입니다.")
@ApiResponses({
@ApiResponse(description = "<<OK>> 접속 일시 업데이트 완료.", content = @Content(schema = @Schema(implementation = ApiResponseDto.class)))})
public ApiResponseDto<?> updateLastLoginTime(@AuthUser User user) {
userService.updateLastLoginTime(user);

return ApiResponseDto.of("최근 접속 일시 업데이트가 완료되었습니다.", null);
}

}
6 changes: 2 additions & 4 deletions src/main/java/cmc/blink/global/security/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ public AuthResponse.LoginResponseDto googleLogin(AuthRequest.GoogleLoginRequestD

if(optionalUser.isEmpty()){
user = UserMapper.toUser(userInfo, "google");
user.updateLoginTime();
userCommandAdapter.save(user);
userCommandAdapter.updateLastLoginTime(user);

linkService.saveDefaultLink(user, language);
}else{
Expand Down Expand Up @@ -112,8 +111,7 @@ public AuthResponse.LoginResponseDto appleLogin(AuthRequest.AppleLoginRequestDto

if(optionalUser.isEmpty()){
user = UserMapper.toUser(requestDto, "apple");
user.updateLoginTime();
userCommandAdapter.save(user);
userCommandAdapter.updateLastLoginTime(user);

linkService.saveDefaultLink(user, language);
}else{
Expand Down

0 comments on commit 8e5ded3

Please sign in to comment.