Skip to content

Commit

Permalink
hotfix: 내부에선 카멜 케이스 적용 & 외부에선 스네이크 케이스 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
ori0o0p committed Aug 19, 2024
1 parent 69cdf69 commit 8ea3ec1
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ public class StudentLoginService implements StudentLoginUseCase {

@Transactional
public TokenResponse studentLogin(LoginRequest request) {
return studentMongoRepository.existsByAccountId(request.account_id()) ?
return studentMongoRepository.existsByAccountId(request.accountId()) ?
loginExistingStudent(request) :
registerAndLoginNewStudent(request);
}

private TokenResponse loginExistingStudent(LoginRequest request) {
StudentEntity student = studentMongoRepository.findFirstByAccountId(request.account_id())
StudentEntity student = studentMongoRepository.findFirstByAccountId(request.accountId())
.orElseThrow(() -> StudentNotFoundException.EXCEPTION);

if (!passwordEncoder.matches(request.password(), student.getPassword())) {
Expand All @@ -52,7 +52,7 @@ private TokenResponse loginExistingStudent(LoginRequest request) {

private TokenResponse registerAndLoginNewStudent(LoginRequest request) {
XquareUserResponse xquareUserResponse = xquareClient.xquareUser(request);
if(!xquareUserResponse.getUser_role().equals("STU")) throw InvalidUserException.EXCEPTION;
if(!xquareUserResponse.getUserRole().equals("STU")) throw InvalidUserException.EXCEPTION;
StudentEntity newStudent = createAndSaveNewStudent(xquareUserResponse);

createDocumentComponent.create(newStudent);
Expand All @@ -66,7 +66,7 @@ private TokenResponse getTokenResponse(String id) {
private StudentEntity createAndSaveNewStudent(XquareUserResponse xquareUserResponse) {
return studentMongoRepository.save(
StudentEntity.builder()
.accountId(xquareUserResponse.getAccount_id())
.accountId(xquareUserResponse.getAccountId())
.password(xquareUserResponse.getPassword())
.name(xquareUserResponse.getName())
.classInfo(xquareUserResponse.toClassInfo())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public class TeacherLoginService implements TeacherLoginUseCase {
private final PasswordEncoder passwordEncoder;

public TokenResponse teacherLogin(LoginRequest request) {
return teacherMongoRepository.existsByAccountId(request.account_id())
return teacherMongoRepository.existsByAccountId(request.accountId())
? loginExistingTeacher(request)
: registerAndLoginNewTeacher(request);
}

private TokenResponse loginExistingTeacher(LoginRequest request) {
TeacherEntity teacher = teacherMongoRepository.findByAccountId(request.account_id())
TeacherEntity teacher = teacherMongoRepository.findByAccountId(request.accountId())
.orElseThrow(() -> TeacherNotFoundException.EXCEPTION);

if (!passwordEncoder.matches(request.password(), teacher.getPassword())) {
Expand All @@ -44,7 +44,7 @@ private TokenResponse loginExistingTeacher(LoginRequest request) {

private TokenResponse registerAndLoginNewTeacher(LoginRequest request) {
XquareUserResponse xquareUserResponse = xquareClient.xquareUser(request);
if(!xquareUserResponse.getUser_role().equals("SCH")) throw InvalidUserException.EXCEPTION;
if(!xquareUserResponse.getUserRole().equals("SCH")) throw InvalidUserException.EXCEPTION;
TeacherEntity newTeacher = createAndSaveNewTeacher(xquareUserResponse);

return jwtTokenProvider.receiveToken(newTeacher.getId(), UserRole.TEACHER);
Expand All @@ -53,7 +53,7 @@ private TokenResponse registerAndLoginNewTeacher(LoginRequest request) {
private TeacherEntity createAndSaveNewTeacher(XquareUserResponse xquareUserResponse) {
return teacherMongoRepository.save(
TeacherEntity.builder()
.accountId(xquareUserResponse.getAccount_id())
.accountId(xquareUserResponse.getAccountId())
.password(xquareUserResponse.getPassword())
.name(xquareUserResponse.getName())
.build());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.example.whopper.domain.auth.dto.request;

public record LoginRequest(
String account_id,
String accountId,
String password
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class AddFeedbackService implements AddFeedbackUseCase {

@Override
public void addFeedback(FeedbackRequest request) {
DocumentEntity document = documentRepository.findById(request.document_id())
DocumentEntity document = documentRepository.findById(request.documentId())
.orElseThrow(()-> DocumentNotFoundException.EXCEPTION);

if(document.getStatus() != DocumentStatus.SUBMITTED) throw DocumentIllegalStatusException.EXCEPTION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
public record FeedbackRequest(
String comment,
DocumentElementType type,
String document_id
String documentId
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public record LibraryResponse(
String id,
AccessRight access_right,
AccessRight accessRight,
Integer year,
Integer grade,
Integer generation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public Optional<MajorEntity> findByName(String name) {
return majorMongoRepository.findByName(name);
}

@Override
public Optional<MajorEntity> findById(String majorId) {
return majorMongoRepository.findById(majorId);
}

@Override
public List<MajorEntity> findAll() {
return majorMongoRepository.findAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public interface MajorRepository {
MajorEntity save(MajorEntity entity);
void saveAll(List<MajorEntity> entities);
Optional<MajorEntity> findByName(String name);
Optional<MajorEntity> findById(String majorId);
List<MajorEntity> findAll();
void delete(MajorEntity entity);
boolean existsByName(String name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ public class XquareUserResponse {

private UUID id;

private String account_id;
private String accountId;

private String password;

private String name;

private Integer grade;

private Integer class_num;
private Integer classNum;

private Integer num;

private String user_role;
private String userRole;

private String profileImgUrl;

private String clubName;

public ClassInfo toClassInfo() {
return ClassInfo.of(grade, class_num, num);
return ClassInfo.of(grade, classNum, num);
}
}
3 changes: 3 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ spring:
virtual:
enabled: true

jackson:
property-naming-strategy: SNAKE_CASE

jwt:
header: Authorization
prefix: Bearer
Expand Down

0 comments on commit 8ea3ec1

Please sign in to comment.