Skip to content

Commit

Permalink
[FEAT] V1에 대한 엔티티 재설계 (#31)
Browse files Browse the repository at this point in the history
* [MOVE] BaseEntity 위치를 global 패키지로 이동

* [RENAME] MeeteamInvite -> InvitedUser

* [RENAME] RecruitmentMember -> RecruitmentRole

* [DEL] 기획제거된 엔티티 제거

* [ADD] 학교, 학과 Entity 분리

* [MOVE] 스키마 별 패키지 구조변경

* [CHORE] User Entity 필드 수정
- 관심있는 역할 추가
- 기존 Enum Role -> Enum Authority로 변경

* [Rename] Spec -> Skill

* [CHORE] 패키지 구조 유지를 위한 dummy.txt 추가

* [DEL] dummy.txt 제거

* [ADD] global enum에 필수정보 추가

* [CHORE] 밋팀, 구인글 필수정보 필드 및 구인글 태그 도메인 추가

* [CHORE] 구인글 스키마 수정
- 명칭 RecruitmentPost로 변경
- 작성자 추가
  - 기존에는 created by 로 접근하려 했으나, 작성/수정 모두 작성자에게만 권한이 있기에 변경
- 신청자에 역할, 전할 말 추가
- 북마크 수 추가
- 분야 추가
- 구인 역할에 인원 수 추가
- 마감 여부 추가 (soft delete)

* [CHORE] 구인글 밋팀 추가
- 관계 스키마 제거 후, 1:N 매핑

* [FIX] ColumnDefault 정상 동작하도록 변경
- @DynamicInsert 추가
- 클래스 멤버 변수의 default value 제거

* [CHORE] 구인글 댓글 추가

* [RENAME] 패키지명 오타 수정

* [CHORE] 구인글 전할 말 제약 조건 추가

* [CHORE] 평가를 위한 점수 저장 위치 변경

* [CHORE] 제약조건 수정

* [CHORE] InvitedUser BaseTimeEntity로 변경

* [CHORE] 산출물 엔티티 추가

* [CHORE] 포트폴리오 스키마 추가

* [FIX] 학교 테이블 변경으로 인한 버그 수정

* [CHORE] 전화번호 길이제한 15로 변경
  • Loading branch information
Goder-0 authored Feb 20, 2024
1 parent abd632d commit 955beb8
Show file tree
Hide file tree
Showing 238 changed files with 836 additions and 416 deletions.
2 changes: 1 addition & 1 deletion src/main/java/synk/meeteam/domain/auth/api/AuthApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import synk.meeteam.domain.auth.dto.response.LogoutUserResponseDto;
import synk.meeteam.domain.auth.dto.response.ReissueUserResponseDto;
import synk.meeteam.domain.auth.dto.response.SignUpUserResponseDto;
import synk.meeteam.domain.user.entity.User;
import synk.meeteam.domain.user.user.entity.User;
import synk.meeteam.security.AuthUser;


Expand Down
24 changes: 11 additions & 13 deletions src/main/java/synk/meeteam/domain/auth/api/AuthController.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
import synk.meeteam.domain.auth.dto.response.SignUpUserResponseDto;
import synk.meeteam.domain.auth.service.AuthServiceProvider;
import synk.meeteam.domain.auth.service.vo.UserSignUpVO;
import synk.meeteam.domain.university.service.UniversityService;
import synk.meeteam.domain.user.entity.User;
import synk.meeteam.domain.user.entity.UserVO;
import synk.meeteam.domain.user.entity.enums.Role;
import synk.meeteam.domain.user.service.UserService;
import synk.meeteam.domain.common.university.service.UniversityService;
import synk.meeteam.domain.user.user.entity.User;
import synk.meeteam.domain.user.user.entity.UserVO;
import synk.meeteam.domain.user.user.entity.enums.Authority;
import synk.meeteam.domain.user.user.service.UserService;
import synk.meeteam.infra.mail.MailService;
import synk.meeteam.infra.oauth.service.vo.enums.AuthType;
import synk.meeteam.security.AuthUser;
Expand Down Expand Up @@ -60,9 +60,9 @@ public ResponseEntity<AuthUserResponseDto> login(
UserSignUpVO vo = authServiceProvider.getAuthService(requestDto.platformType())
.saveUserOrLogin(authorizationCode, requestDto);

if (vo.role() == Role.GUEST) {
if (vo.authority() == Authority.GUEST) {
return ResponseEntity.ok(AuthUserResponseDto
.of(vo.platformId(), vo.authType(), vo.name(), vo.role(), null, null));
.of(vo.platformId(), vo.authType(), vo.name(), vo.authority(), null, null));
}

AuthUserResponseDto responseDTO = jwtService.issueToken(vo);
Expand All @@ -74,11 +74,9 @@ public ResponseEntity<AuthUserResponseDto> login(
public ResponseEntity<SignUpUserResponseDto> createTempUserAndSendEmail(
@RequestBody @Valid SignUpUserRequestDto requestDto
) {
Long universityId = universityService.getUniversityId(requestDto.universityName(), requestDto.departmentName(),
requestDto.email());

authServiceProvider.getAuthService(requestDto.platformType()).updateUniversityInfo(requestDto, universityId);
mailService.sendMail(requestDto, requestDto.platformId());
String email = universityService.getEmail(requestDto.universityId(), requestDto.emailId());
authServiceProvider.getAuthService(requestDto.platformType()).updateUniversityInfo(requestDto, email);
mailService.sendMail(requestDto.platformId(), email);

return ResponseEntity.ok(SignUpUserResponseDto.of(requestDto.platformId()));
}
Expand All @@ -92,7 +90,7 @@ public ResponseEntity<AuthUserResponseDto> signUp(
User user = authServiceProvider.getAuthService(userVO.getPlatformType())
.createSocialUser(userVO, requestDto.nickName());

UserSignUpVO vo = UserSignUpVO.of(user, user.getPlatformType(), user.getRole(), AuthType.SIGN_UP);
UserSignUpVO vo = UserSignUpVO.of(user, user.getPlatformType(), user.getAuthority(), AuthType.SIGN_UP);
AuthUserResponseDto responseDTO = jwtService.issueToken(vo);

return ResponseEntity.status(HttpStatus.CREATED).body(responseDTO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import synk.meeteam.domain.user.entity.enums.PlatformType;
import synk.meeteam.domain.user.user.entity.enums.PlatformType;

@Schema(name = "AuthUserRequestDto", description = "소셜 로그인 요청 Dto")
public record AuthUserRequestDto(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import synk.meeteam.domain.user.entity.enums.PlatformType;
import synk.meeteam.domain.user.user.entity.enums.PlatformType;

@Schema(name = "SignUpUserRequestDto", description = "임시 회원 가입 및 이메일 인증 요청 Dto")
public record SignUpUserRequestDto(
Expand All @@ -14,17 +14,16 @@ public record SignUpUserRequestDto(
@Schema(description = "플랫폼 타입", example = "NAVER")
PlatformType platformType,
@NotNull
@Schema(description = "학사 이메일", example = "thdalsrb123@kw.ac.kr")
String email,
@Schema(description = "학사 이메일 계정", example = "thdalsrb123")
String emailId,
@NotNull
@Schema(description = "학교 이름", example = "광운대학교")
String universityName,
@Schema(description = "학교 id", example = "광운대학교")
Long universityId,
@NotNull
@Schema(description = "학과 이름", example = "소프트웨어학부")
String departmentName,
@Schema(description = "학과 id", example = "소프트웨어학부")
Long departmentId,
@NotNull
@Schema(description = "입학년도", example = "2018")
int admissionYear

) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import synk.meeteam.domain.user.entity.enums.Role;
import synk.meeteam.domain.user.user.entity.enums.Authority;
import synk.meeteam.infra.oauth.service.vo.enums.AuthType;

@Schema(name = "AuthUserResponseDto", description = "소셜 로그인 응답 Dto")
Expand All @@ -18,13 +18,13 @@ public record AuthUserResponseDto(
String userName,
@NotNull
@Schema(description = "역할, GUEST는 임시 유저", example = "USER")
Role role,
Authority authority,
@Schema(description = "액세스 토큰", example = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJBY2Nlc3NUb2tlbiIsInBsYXRmb3JtSWQiOiJEaTdsQ2hNR3hqWlZUYWk2ZDc2SG8xWUxEVV94TDh0bDFDZmRQTVY1U1FNIiwicGxhdGZvcm1UeXBlIjoiTkFWRVIiLCJpYXQiOjE3MDYyODA1MjMsImV4cCI6MTgxNDI4MDUyM30.doPtAdLQMZ8NeuhRAOg7GNMBBtFZzPOOZp60HskGtZ0")
String accessToken,
@Schema(description = "리프레시 토큰", example = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJSZWZyZXNoVG9rZW4iLCJpYXQiOjE3MDYyODA1MjMsImV4cCI6MTcwNjg4NTMyM30.yvftTGVld0ZMnv1a79wpuzuTo8EJ1zOHoSlT_jfH3cs")
String refreshToken) {
public static AuthUserResponseDto of(String platformId, AuthType authType, String userName, Role role,
public static AuthUserResponseDto of(String platformId, AuthType authType, String userName, Authority authority,
String accessToken, String refreshToken) {
return new AuthUserResponseDto(platformId, authType, userName, role, accessToken, refreshToken);
return new AuthUserResponseDto(platformId, authType, userName, authority, accessToken, refreshToken);
}
}
25 changes: 12 additions & 13 deletions src/main/java/synk/meeteam/domain/auth/service/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import synk.meeteam.domain.auth.dto.request.AuthUserRequestDto;
import synk.meeteam.domain.auth.dto.request.SignUpUserRequestDto;
import synk.meeteam.domain.auth.service.vo.UserSignUpVO;
import synk.meeteam.domain.university.entity.University;
import synk.meeteam.domain.university.repository.UniversityRepository;
import synk.meeteam.domain.user.entity.User;
import synk.meeteam.domain.user.entity.UserVO;
import synk.meeteam.domain.user.entity.enums.PlatformType;
import synk.meeteam.domain.user.entity.enums.Role;
import synk.meeteam.domain.user.repository.UserRepository;
import synk.meeteam.domain.common.university.entity.University;
import synk.meeteam.domain.common.university.repository.UniversityRepository;
import synk.meeteam.domain.user.user.entity.User;
import synk.meeteam.domain.user.user.entity.UserVO;
import synk.meeteam.domain.user.user.entity.enums.Authority;
import synk.meeteam.domain.user.user.entity.enums.PlatformType;
import synk.meeteam.domain.user.user.repository.UserRepository;
import synk.meeteam.infra.redis.repository.RedisUserRepository;

@Service
Expand Down Expand Up @@ -41,7 +41,7 @@ protected User saveTempUser(AuthUserRequestDto request, String email, String nam
.phoneNumber(phoneNumber)
.platformType(request.platformType())
.platformId(id)
.role(Role.GUEST)
.authority(Authority.GUEST)
.build();
}

Expand All @@ -56,13 +56,12 @@ private static UserVO createTempSocialUser(String email, String name, PlatformTy
.build();
}

public void updateUniversityInfo(SignUpUserRequestDto requestDTO, Long universityId) {

public void updateUniversityInfo(SignUpUserRequestDto requestDTO, String email) {
UserVO userVO = redisUserRepository.findByPlatformIdOrElseThrowException(requestDTO.platformId());

userVO.updateUniversityId(universityId);
userVO.updateEmail(requestDTO.email());
userVO.updateUniversityId(requestDTO.universityId());
userVO.updateAdmissionYear(requestDTO.admissionYear());
userVO.updateEmail(email);

redisUserRepository.save(userVO);
}
Expand All @@ -78,7 +77,7 @@ public User createSocialUser(UserVO userVO, String nickName) {
.phoneNumber(userVO.getPhoneNumber())
.admissionYear(userVO.getAdmissionYear())
.university(foundUniversity)
.role(Role.USER)
.authority(Authority.USER)
.platformType(userVO.getPlatformType())
.platformId(userVO.getPlatformId())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.concurrent.ConcurrentHashMap;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import synk.meeteam.domain.user.entity.enums.PlatformType;
import synk.meeteam.domain.user.user.entity.enums.PlatformType;
import synk.meeteam.infra.oauth.service.NaverAuthService;

@Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@


import lombok.Builder;
import synk.meeteam.domain.user.entity.User;
import synk.meeteam.domain.user.entity.enums.PlatformType;
import synk.meeteam.domain.user.entity.enums.Role;
import synk.meeteam.domain.user.user.entity.User;
import synk.meeteam.domain.user.user.entity.enums.Authority;
import synk.meeteam.domain.user.user.entity.enums.PlatformType;
import synk.meeteam.infra.oauth.service.vo.enums.AuthType;

@Builder
public record UserSignUpVO(Long userId, String email, String name, PlatformType platformType, Role role,
public record UserSignUpVO(Long userId, String email, String name, PlatformType platformType, Authority authority,
String platformId, String phoneNumber, AuthType authType) {
public static UserSignUpVO of(User user, PlatformType platformType, Role role, AuthType authType) {
public static UserSignUpVO of(User user, PlatformType platformType, Authority authority, AuthType authType) {
return UserSignUpVO.builder()
.email(user.getEmail())
.name(user.getName())
.platformType(platformType)
.platformId(user.getPlatformId())
.role(role)
.authority(authority)
.phoneNumber(user.getPhoneNumber())
.authType(authType)
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package synk.meeteam.domain.common.department.entity;

import static jakarta.persistence.FetchType.LAZY;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import synk.meeteam.domain.common.university.entity.University;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class Department {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "department_id")
private Long id;

@ManyToOne(fetch = LAZY, optional = false)
@JoinColumn(name = "university_id")
private University university;

@NotNull
@Column(length = 20)
private String name;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package synk.meeteam.domain.field.entity;
package synk.meeteam.domain.common.field.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/synk/meeteam/domain/common/output/entity/Output.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package synk.meeteam.domain.common.output.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.DynamicInsert;
import synk.meeteam.global.entity.BaseTimeEntity;

@Getter
@Setter
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@DynamicInsert
public class Output extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "output_id")
private Long id;

@NotNull
@ColumnDefault("0")
private Long totalSlideCnt;

@NotNull
@ColumnDefault("0")
private Long totalLinkCnt;

}
Original file line number Diff line number Diff line change
@@ -1,51 +1,42 @@
package synk.meeteam.domain.timetable_block.entity;
package synk.meeteam.domain.common.output_link.entity;

import static jakarta.persistence.FetchType.LAZY;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.DayOfWeek;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import synk.meeteam.domain.user.entity.User;
import synk.meeteam.domain.common.output.entity.Output;
import synk.meeteam.global.entity.BaseTimeEntity;

@Getter
@Setter
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class TimetableBlock {
public class OutputLink extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "timetable_block_id")
@Column(name = "output_link_id")
private Long id;

@ManyToOne(fetch = LAZY, optional = false)
@JoinColumn(name = "user_id")
private User user;
@JoinColumn(name = "output_id")
private Output output;

@NotNull
@Enumerated(EnumType.STRING)
@Column(length = 10)
private DayOfWeek dayOfWeek;
@NotBlank
@Column(length = 300)
@Size(max = 300)
private String url;

@NotNull
@Size(max = 5)
@Column(length = 5)
private String startTime;

@NotNull
@Size(max = 5)
@Column(length = 5)
private String endTime;
}
Loading

0 comments on commit 955beb8

Please sign in to comment.