Skip to content
Merged

fix #113

Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions src/main/java/com/example/prdoit/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,15 @@ public ResponseEntity<Object> getNotificationList(@PathVariable String userId) {
}
}

@GetMapping("/Information/{userId}")
public ResponseEntity<Object> getInformation(@PathVariable String userId) {
log.info("[getInformation] 회원 정보 조회 시작 - User ID: {}", userId);

try {
return ResponseEntity.ok(userService.getInformation(userId));
} catch (CustomException e) {
log.error("[getInformation] 회원 정보 조회 실패 - 이유: {}", e.getMessage());
return ResponseEntity.badRequest().body(e.getMessage());
}
}
}
16 changes: 16 additions & 0 deletions src/main/java/com/example/prdoit/dto/user/InformationDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.prdoit.dto.user;

import lombok.*;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class InformationDto {

private String id;
private String name;
private String email;
private String nickname;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.prdoit.service.user;

import com.example.prdoit.dto.user.InformationDto;
import com.example.prdoit.dto.user.UserDto;

public interface UserService {
Expand All @@ -22,4 +23,5 @@ public interface UserService {

void checkPassword(String userId, String password);

InformationDto getInformation(String userId);
}
15 changes: 15 additions & 0 deletions src/main/java/com/example/prdoit/service/user/UserServiceImpl.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.prdoit.service.user;

import com.example.prdoit.dto.user.InformationDto;
import com.example.prdoit.dto.user.UserDto;
import com.example.prdoit.exception.CustomException;
import com.example.prdoit.model.IdTable;
Expand Down Expand Up @@ -167,4 +168,18 @@ public void checkPassword(String userId, String password){
throw new CustomException(e.getMessage());
}
}

@Override
public InformationDto getInformation(String userId) {
log.info("[getInformation] 정보 조회 로직 시작");

IdTable idTable = idTableRepository.findById(userId).orElseThrow(() -> new CustomException("해당 아이디로 가입된 정보가 없습니다."));

return InformationDto.builder()
.id(idTable.getId())
.email(idTable.getEmail())
.name(idTable.getName())
.nickname(idTable.getNickname())
.build();
}
}