Skip to content

Commit

Permalink
feat: login 시 device token update
Browse files Browse the repository at this point in the history
  • Loading branch information
dgjinsu committed Jan 3, 2024
1 parent e92a26d commit bd66579
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/main/java/jikgong/domain/common/Address.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package jikgong.domain.common;

import jakarta.persistence.Embeddable;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

@Embeddable
@AllArgsConstructor
@NoArgsConstructor
public class Address {
private String address; // 주소
private Float latitude; // 위도
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ public class LoginRequest {
private String phone;
@Schema(description = "인증 코드 6자리", example = "123456")
private String authCode;
@Schema(description = "device token")
private String deviceToken;
}
4 changes: 4 additions & 0 deletions src/main/java/jikgong/domain/member/entity/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ public Member(String phone, String authCode, String account, String bank, String
public void setCertification(Certification certification) {
this.certification = certification;
}

public void updateDeviceToken(String deviceToken) {
this.deviceToken = deviceToken;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package jikgong.domain.member.service;

import jikgong.domain.common.Address;
import jikgong.domain.location.entity.Location;
import jikgong.domain.location.repository.LocationRepository;
import jikgong.domain.member.dtos.join.*;
Expand Down Expand Up @@ -58,9 +59,7 @@ public Long joinWorkerMember(JoinWorkerRequest request) {
.build();

Location location = Location.builder()
.address(request.getAddress())
.latitude(request.getLatitude())
.longitude(request.getLongitude())
.address(new Address(request.getAddress(), request.getLatitude(), request.getLongitude()))
.isMain(true)
.member(member)
.build();
Expand Down Expand Up @@ -139,6 +138,7 @@ public VerificationAccountResponse verificationAccount(VerificationAccountReques
}

public LoginResponse login(LoginRequest request) {
// todo: 기업, 노동자 로그인 분리
// id 체크
Member member = memberRepository.findByPhone(request.getPhone())
.orElseThrow(() -> new CustomException(ErrorCode.MEMBER_NOT_FOUND));
Expand All @@ -152,6 +152,9 @@ public LoginResponse login(LoginRequest request) {
String accessToken = jwtTokenProvider.createAccessToken(member.getPhone());
String refreshToken = jwtTokenProvider.createRefreshToken(member.getPhone());

// device token update
member.updateDeviceToken(request.getDeviceToken());

return new LoginResponse(accessToken, refreshToken, member.getRole());
}

Expand Down

0 comments on commit bd66579

Please sign in to comment.