wjrmffldrhrl / goldenblock

블록체인교육 프로젝트
1 stars 1 forks source link

Main code refactoring #38

Closed wjrmffldrhrl closed 4 years ago

wjrmffldrhrl commented 4 years ago

Refactoring

cb737df08adf44455db68fd7a12bd04638dd6102

  1. 주석과 내용 사이에는 공백 넣기

    //retrieve expiration date from jwt token
    
    // retrieve expiration date from jwt token
  2. 데이터를 수정(추가, 변경, 삭제)하는 요청은 POST만 허용

    //@RequestMapping(value = "/student", method = RequestMethod.GET)
    @PostMapping("/student")
    public void saveStudent(@RequestBody StudentDto studentDto) {
        studentService.saveStudent(studentDto); // db에 저장
    }
    
    //@GetMapping("/enterprise")
    @PostMapping("/enterprise")
    public void saveEnterprise(@RequestBody EnterpriseDto enterpriseDto) {
        enterpriseService.saveEnterprise(enterpriseDto); // db에 저장
    }
  3. 100자가 넘어가는 내용은 줄바꿈으로 가독성 개선

    public EnterpriseDetails(Enterprise enterprise) {
        //super(enterprise.getEmail(), enterprise.getPassword(), List.of(new SimpleGrantedAuthority("ENTERPRISE")));
        super(enterprise.getEmail(), enterprise.getPassword(), 
            List.of(new SimpleGrantedAuthority("ENTERPRISE")));
        this.enterprise = enterprise;
    }
  4. Service에서의 의존성 주입 @RequiredArgsConstructorprivate final 사용

    @Service
    // @AllArgsConstructor
    @RequiredArgsConstructor
    public class StudentService {
    // private StudentRepository studentRepository;
    private final StudentRepository studentRepository;
    private final PasswordEncoder passwordEncoder;
    
    @Transactional
    public Long saveStudent(StudentDto studentDto) {
        studentDto.setPassword(passwordEncoder.encode(studentDto.getPassword()));
        boolean isExist = studentRepository.existsByEmail(studentDto.getEmail());
        if (isExist) {
            throw new MemberController.AlreadyExistsException("change_email");
        }
        return studentRepository.save(studentDto.toEntity()).getId();
    }
    }
xmxmqq commented 4 years ago

3.) 100자가 넘어가는 건 어떻게 확인하나요?

wjrmffldrhrl commented 4 years ago

3.) 100자가 넘어가는 건 어떻게 확인하나요?

IDE에서 확인이 될 것 입니다.

wz0405 commented 4 years ago

goldenblock.iml 삭제한 이유가 따로 있을까요? 프로젝트 실행시 maven 빌드를 수동으로 해야하는 문제아닌 문제?가 생겼습니다. @wjrmffldrhrl

wjrmffldrhrl commented 4 years ago

goldenblock.iml 삭제한 이유가 따로 있을까요? 프로젝트 실행시 maven 빌드를 수동으로 해야하는 문제아닌 문제?가 생겼습니다. @wjrmffldrhrl

문제가 맞는 것 같습니다.

Intellij IDE에 한정된 파일이라고 생각되어 pull request에서만 제외 한 줄 알았는데 삭제가 되었네요

새로 생성한 뒤 .gitignore에 명시하여야 될 것 같습니다.

wz0405 commented 4 years ago

문제가 맞는 것 같습니다.

Intellij IDE에 한정된 파일이라고 생각되어 pull request에서만 제외 한 줄 알았는데 삭제가 되었네요

새로 생성한 뒤 .gitignore에 명시하여야 될 것 같습니다.

그럼 코드 완성 후 push 하겠습니다.