Skip to content

Commit

Permalink
Merge pull request #57 from PizzaPickle/feature/fixLoginResponse
Browse files Browse the repository at this point in the history
feat: 로그인 반환 dto 요소 추가
  • Loading branch information
colde99 authored Sep 10, 2024
2 parents 43fc9fb + 9879435 commit 71f61b0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.example.pickle_customer.auth.JwtService;
import com.example.pickle_customer.dto.CustomerJoinDto;
import com.example.pickle_customer.dto.CustomerLoginDto;
import com.example.pickle_customer.dto.LoginResponseDto;
import com.example.pickle_customer.entity.Customer;
import com.example.pickle_customer.repository.CustomerRepository;
import com.example.pickle_customer.service.AccountService;
Expand Down Expand Up @@ -83,8 +84,14 @@ public ResponseEntity<CommonResDto<?>> getToken(@RequestBody CustomerLoginDto au
String token = joinService.generateToken(customer.getCustomerId());

// 5. 성공적으로 토큰 생성 및 반환
LoginResponseDto result = LoginResponseDto.builder()
.token(token)
.name(customer.getName())
.userId(customer.getCustomerId())
.build();

return ResponseEntity.status(HttpStatus.CREATED)
.body(new CommonResDto<>(1, "고객 로그인 및 토큰 발급 완료", token));
.body(new CommonResDto<>(1, "고객 로그인 및 토큰 발급 완료", result));
} else {
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(new CommonResDto<>(-1, "고객 정보를 찾을 수 없습니다", "해당 사용자를 찾을 수 없습니다"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.pickle_customer.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class LoginResponseDto {
String token;
int userId;
String name;
}

0 comments on commit 71f61b0

Please sign in to comment.