Skip to content

Commit

Permalink
Merge pull request #6 from Kusitms-28th-Hackathon-D/feat/qogustj
Browse files Browse the repository at this point in the history
feat : 회원가입
  • Loading branch information
eckrin authored Oct 7, 2023
2 parents e905c8e + 91bb1b1 commit 55fb708
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class AuthController {
@PostMapping("/signUp")
@ResponseStatus(HttpStatus.OK)
public void signUp(@Valid @RequestBody SignUpRequestDto dto) {
authService.signUp(dto.getEmail(), dto.getPassword(), dto.getRole(), "IN_APP", null);
authService.signUp(dto);
}

@ApiOperation("로그인")
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/com/groupD/server/domain/Disability.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.groupD.server.domain;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Getter
public enum Disability {
PhysicalDisability("지체 장애"),
IntellectualDisability("시각 장애"),
HearingImpairment("청각 장애"),
SpeechDisorder("언어 장애"),
CognitiveImpairment("지적 정애"),
FacialDisability("안면 장애");
private final String displayName;


public String getDisplayName() {
return displayName;
}
}
23 changes: 23 additions & 0 deletions src/main/java/com/groupD/server/domain/PreferJob.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.groupD.server.domain;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Getter
public enum PreferJob {
ManagementandAdministration("경영 사무"),
SalesandMarketing("영업 판매"),
EducationandWelfare("교육 복지"),
HealthcareandMedical("보건 의료 "),
ArtsandSports("예술 스포츠 "),
InstallationandMaintenance("설치 정비"),
AgricultureForestryandFisheries("농림 어업" );

private final String displayName;


public String getDisplayName() {
return displayName;
}
}
21 changes: 21 additions & 0 deletions src/main/java/com/groupD/server/domain/dto/SignUpRequestDto.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.groupD.server.domain.dto;

import com.groupD.server.domain.Disability;
import com.groupD.server.domain.PreferJob;
import com.groupD.server.domain.Role;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
Expand All @@ -20,4 +24,21 @@ public class SignUpRequestDto {
private String password;
@NotNull
private Role role;
@NotBlank
private String phonenum;

@Enumerated(EnumType.STRING)
private Disability disability;

@Enumerated(EnumType.STRING)
private PreferJob jobPriority1;

@Enumerated(EnumType.STRING)
private PreferJob jobPriority2;

@Enumerated(EnumType.STRING)
private PreferJob jobPriority3;
@NotBlank
private String imageUrl;

}
21 changes: 20 additions & 1 deletion src/main/java/com/groupD/server/domain/entity/Member.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.groupD.server.domain.entity;

import com.groupD.server.domain.Disability;
import com.groupD.server.domain.PreferJob;
import com.groupD.server.domain.Role;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down Expand Up @@ -29,12 +31,29 @@ public class Member extends DateEntity {
@NotBlank
private String password;

@NotBlank
private String phonenum;

@Enumerated(EnumType.STRING)
private Disability disability;

@Enumerated(EnumType.STRING)
private PreferJob jobPriority1;

@Enumerated(EnumType.STRING)
private PreferJob jobPriority2;

@Enumerated(EnumType.STRING)
private PreferJob jobPriority3;

@NotBlank
private String imageUrl;
@Enumerated(EnumType.STRING)
private Role role;

private String refreshToken;
private String oauth;
private String image;


public void updateRefreshToken(String newRefreshToken) {
this.refreshToken = newRefreshToken;
Expand Down
24 changes: 16 additions & 8 deletions src/main/java/com/groupD/server/service/AuthService.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.groupD.server.service;

import com.groupD.server.domain.Disability;
import com.groupD.server.domain.PreferJob;
import com.groupD.server.domain.Role;
import com.groupD.server.domain.dto.SignInResponseDto;
import com.groupD.server.domain.dto.SignUpRequestDto;
import com.groupD.server.domain.entity.Member;
import com.groupD.server.exception.auth.EmailExistsException;
import com.groupD.server.exception.auth.InvalidEmailException;
Expand Down Expand Up @@ -29,17 +32,22 @@ public class AuthService {
private String KAKAO_SECRET_SERVER_PWD;

@Transactional
public void signUp(String email, String password, Role role, String oauth, String image) {
if(memberRepository.existsByEmail(email)) throw new EmailExistsException("이미 가입한 이메일입니다.");
public void signUp(SignUpRequestDto dto) {
if(memberRepository.existsByEmail(dto.getEmail())) throw new EmailExistsException("이미 가입한 이메일입니다.");
memberRepository.save(
Member.builder()
.id(null)
.email(email)
.password(passwordEncoder.encode(password))
.image(image)
.role(role)
.email(dto.getEmail())
.password(passwordEncoder.encode(dto.getPassword()))
.imageUrl(dto.getImageUrl())
.role(dto.getRole())
.disability(dto.getDisability())
.phonenum(dto.getPhonenum())
.jobPriority1(dto.getJobPriority1())
.jobPriority2(dto.getJobPriority2())
.jobPriority3(dto.getJobPriority3())
.refreshToken(null)
.oauth(oauth)
.oauth("IN_APP")
.build()
);
}
Expand All @@ -58,7 +66,7 @@ public SignInResponseDto signIn(String email, String password) {
TokenInfo refreshToken = tokenProvider.createRefreshToken(member.getEmail(), member.getRole());
member.updateRefreshToken(refreshToken.getToken());
return new SignInResponseDto(
member.getId(), member.getEmail(), member.getImage(), member.getRole(), accessToken.getToken(), refreshToken.getToken(), accessToken.getExpireTime(), refreshToken.getExpireTime()
member.getId(), member.getEmail(), member.getImageUrl(), member.getRole(), accessToken.getToken(), refreshToken.getToken(), accessToken.getExpireTime(), refreshToken.getExpireTime()
);
}
}

0 comments on commit 55fb708

Please sign in to comment.