Skip to content

Commit

Permalink
๐Ÿ”€ :: (#574) isStudent ์ถ”๊ฐ€ (#575)
Browse files Browse the repository at this point in the history
* โ™ป๏ธ :: isStudent ์ถ”๊ฐ€

* โ™ป๏ธ :: isStudent์— ๋”ฐ๋ผ ์ด๋ฆ„, ์ „ํ™”๋ฒˆํ˜ธ ์ €์žฅ ์ฝ”๋“œ ๋ฆฌํŒฉํ† ๋ง

* โ™ป๏ธ :: message ๋‚ด์šฉ ์ˆ˜์ •
  • Loading branch information
jyk1029 authored Aug 10, 2023
1 parent 66f017e commit 9b78140
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public class ChangeInformationRequest {

@NotNull(message = "birthday๋Š” Null์„ ํ—ˆ์šฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.") private LocalDate birthday;

@Length(max = 5, message = "TOO LONG NAME") private String name;

@NotEmpty(message = "telephone_number์€ Null ๋˜๋Š” ๊ณต๋ฐฑ์„ ํ—ˆ์šฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.")
@Length(max = 11) @Pattern(regexp = TEL_REGEXP, message = "INVALID TEL")
private String telephoneNumber;

@Length(max = 5, message = "TOO LONG NAME") private String parentName;

@NotEmpty(message = "parent_tel์€ Null ๋˜๋Š” ๊ณต๋ฐฑ์„ ํ—ˆ์šฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.")
Expand All @@ -32,7 +38,7 @@ public class ChangeInformationRequest {
@NotEmpty(message = "address๋Š” Null ๋˜๋Š” ๊ณต๋ฐฑ์„ ํ—ˆ์šฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.")
@Length(max = 300, message = "TOO LONG ADDRESS") private String address;

@NotEmpty(message = "detailAddress๋Š” Null ๋˜๋Š” ๊ณต๋ฐฑ์„ ํ—ˆ์šฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.")
@NotEmpty(message = "detail_address๋Š” Null ๋˜๋Š” ๊ณต๋ฐฑ์„ ํ—ˆ์šฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.")
@Length(max = 100, message = "TOO LONG DETAIL_ADDRESS") private String detailAddress;

@Length(min = 5, max = 5, message = "INVALID POST_CODE") private String postCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
public class QueryUserInfoResponse {
private final String name;
private final String telephoneNumber;
private final Boolean isStudent;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public void execute(ChangeInformationRequest request) {
if (distance.getFeatures().isEmpty()) throw RequestFailToTmapServerException.EXCEPTION;

entryInfo.updateEntryInformation(UpdateUserInformationDto.builder()
.name(request.getName())
.telephoneNumber(request.getTelephoneNumber())
.sex(EnumUtil.getEnum(Sex.class, request.getSex()))
.birthday(request.getBirthday())
.parentName(request.getParentName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public class QueryUserInfoService {
@Transactional(readOnly = true)
public QueryUserInfoResponse execute() {
User user = userFacade.getCurrentUser();
return new QueryUserInfoResponse(user.getName(), user.getTelephoneNumber());
return new QueryUserInfoResponse(user.getName(), user.getTelephoneNumber(), user.getIsStudent());
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
package kr.hs.entrydsm.rollsroyce.domain.entryinfo.domain;

import lombok.*;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import org.hibernate.annotations.DynamicInsert;

import java.time.LocalDate;

import javax.persistence.*;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;

import kr.hs.entrydsm.rollsroyce.domain.application.domain.Application;
import kr.hs.entrydsm.rollsroyce.domain.application.domain.Graduation;
Expand All @@ -30,6 +41,12 @@ public class EntryInfo {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long receiptCode;

@Column(columnDefinition = "char(5)")
private String name;

@Column(columnDefinition = "char(11)")
private String telephoneNumber;

@Enumerated(EnumType.STRING)
@Column(columnDefinition = "char(7)")
private ApplicationType applicationType;
Expand Down Expand Up @@ -91,6 +108,16 @@ public EntryInfo(User user) {
this.user = user;
}

public void updateUserNameAndTel(String name, String telephoneNumber) {
this.name = name;
this.telephoneNumber = telephoneNumber;
}

public void updateParentNameAndTel(String parentName, String parentTel) {
this.parentName = parentTel;
this.parentTel = parentTel;
}

public void updateUserApplication(ChangeTypeRequest request) {
this.educationalStatus = EnumUtil.getEnum(EducationalStatus.class, request.getEducationalStatus());
this.applicationType = EnumUtil.getEnum(ApplicationType.class, request.getApplicationType());
Expand All @@ -100,6 +127,8 @@ public void updateUserApplication(ChangeTypeRequest request) {
}

public void updateEntryInformation(UpdateUserInformationDto information) {
this.name = information.getName();
this.telephoneNumber = information.getTelephoneNumber();
this.sex = information.getSex();
this.birthday = information.getBirthday();
this.parentName = information.getParentName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public void execute() {
EntryInfo entryInfo =
entryInfoRepository.save(EntryInfo.builder().user(user).build());

if (user.getIsStudent()) {
entryInfo.updateUserNameAndTel(user.getName(), user.getTelephoneNumber());
} else {
entryInfo.updateParentNameAndTel(user.getName(), user.getTelephoneNumber());
}

statusRepository.save(Status.builder()
.entryInfo(entryInfo)
.isPrintsArrived(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ public class User extends BaseTimeEntity {
@Column(columnDefinition = "char(5)", nullable = false)
private String name;

@Column(columnDefinition = "bit(1) default 1", nullable = false)
private Boolean isStudent;

@OneToOne(fetch = FetchType.LAZY, mappedBy = "user", cascade = CascadeType.ALL)
private EntryInfo entryInfo;

@Builder
public User(String telephoneNumber, String password, String name, EntryInfo entryInfo) {
public User(String telephoneNumber, String password, String name, Boolean isStudent, EntryInfo entryInfo) {
this.telephoneNumber = telephoneNumber;
this.password = password;
this.name = name;
this.isStudent = isStudent;
this.entryInfo = entryInfo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

@Getter
Expand All @@ -20,4 +21,6 @@ public class SignupRequest {
"(?=.*[a-z])(?=.*[0-9])(?=.*[!#$%&'()*+,./:;<=>?@๏ผผ^_`{|}~])[a-zA-Z0-9!#$%&'()*+,./:;<=>?@๏ผผ^_`{|}~]{8,32}$",
message = "password๋Š” ์†Œ๋ฌธ์ž, ์ˆซ์ž, ํŠน์ˆ˜๋ฌธ์ž๊ฐ€ ํฌํ•จ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.")
private String password;

@NotNull private Boolean isStudent;
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public TokenResponse execute(SignupRequest request) {
.name(passInfo.getName())
.telephoneNumber(telephoneNumber)
.password(password)
.isStudent(request.getIsStudent())
.build());

return tokenProvider.generateToken(user.getTelephoneNumber(), Role.USER.toString());
Expand Down

0 comments on commit 9b78140

Please sign in to comment.