Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] #115 - individaul user #117

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ public class WbUserDTO {
private String addrProvince;
private int jobPoint;
private YN jobInterest;
private Date createdAt;
private Date updatedAt;
private YN dataSharingConsent;
// private Date createdAt;
// private Date updatedAt;
private YN isDeleted;
private List<String> workHistoryJobs;
private List<String> interestJobs;
Expand Down
41 changes: 21 additions & 20 deletions src/main/java/com/wooribound/domain/wbuser/WbUser.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
package com.wooribound.domain.wbuser;

import com.wooribound.domain.employment.Employment;
import com.wooribound.domain.interestjob.InterestJob;
import com.wooribound.domain.knowhow.Knowhow;
import com.wooribound.domain.knowhowreported.KnowhowReported;
import com.wooribound.domain.notification.Notification;
import com.wooribound.domain.resume.Resume;
import com.wooribound.domain.userapply.UserApply;
import com.wooribound.domain.workhistory.WorkHistory;
import com.wooribound.global.constant.Gender;
import com.wooribound.global.constant.YN;
import com.wooribound.domain.employment.Employment;
import com.wooribound.domain.notification.Notification;
import com.wooribound.domain.userapply.UserApply;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import jakarta.persistence.*;
import lombok.*;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@NoArgsConstructor(access = AccessLevel.PUBLIC)
@Getter
Expand Down Expand Up @@ -78,10 +67,10 @@ public class WbUser {
private YN jobInterest = YN.N;

@Column(name = "created_at", nullable = false) // NOT NULL μ œμ•½ 쑰건
private Date createdAt;
private LocalDateTime createdAt;

@Column(name = "updated_at")
private Date updatedAt;
private LocalDateTime updatedAt;

@Enumerated(value = EnumType.STRING)
@Column(name = "is_deleted", nullable = false, columnDefinition = "CHAR(1) DEFAULT 'N'", length = 10) // NOT NULL μ œμ•½ 쑰건
Expand Down Expand Up @@ -118,4 +107,16 @@ public class WbUser {

@OneToMany(mappedBy = "wbUser", fetch = FetchType.LAZY)
private List<KnowhowReported> knowhowReportedList;

@PrePersist
public void prePersist() {
createdAt = LocalDateTime.now();
updatedAt = LocalDateTime.now();
}

// @PreUpdateλŠ” μ—”ν‹°ν‹°κ°€ μ—…λ°μ΄νŠΈλ  λ•Œ ν˜ΈμΆœλ©λ‹ˆλ‹€.
@PreUpdate
public void preUpdate() {
updatedAt = LocalDateTime.now();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ public WbUserDTO getUserInfo(String userId) {
.addrCity(user.getAddrCity())
.addrProvince(user.getAddrProvince())
.jobPoint(user.getJobPoint())
.dataSharingConsent(user.getDataSharingConsent())
.jobInterest(user.getJobInterest())
.createdAt(user.getCreatedAt())
.updatedAt(user.getUpdatedAt())
.isDeleted(user.getIsDeleted())
.workHistoryJobs(workHistoryNames)
.interestJobs(interestJobNames)
Expand Down Expand Up @@ -91,8 +90,6 @@ public WbUserUpdateDTO updateUserInfo(WbUserUpdateDTO wbUserUpdateDTO) {
.addrProvince(wbUser.getAddrProvince())
.jobPoint(wbUser.getJobPoint())
.jobInterest(wbUser.getJobInterest())
.createdAt(wbUser.getCreatedAt())
.updatedAt(wbUser.getUpdatedAt())
.isDeleted(wbUser.getIsDeleted())
.workHistoryJobs(wbUser.getWorkHistories().stream()
.map(workHistory -> workHistory.getJob().getJobName()) // WorkHistory -> Job -> JobName
Expand Down Expand Up @@ -237,7 +234,6 @@ public String craeteWbUser(WbUserJoinDTO wbUserJoinDTO) {
user.setJobInterest(wbUserJoinDTO.getJobInterest());
user.setAddrCity(wbUserJoinDTO.getAddrCity());
user.setAddrProvince(wbUserJoinDTO.getAddrProvince());
user.setUpdatedAt(new Date());
user.setDataSharingConsent(wbUserJoinDTO.getDataSharingConsent());
user.setInterestChk(wbUserJoinDTO.getInterestChk());
wbUserRepository.save(user);
Expand Down Expand Up @@ -266,8 +262,6 @@ public WbUserDTO getOneUserInfo(String userId) {
.addrProvince(user.getAddrProvince())
.jobPoint(user.getJobPoint())
.jobInterest(user.getJobInterest())
.createdAt(user.getCreatedAt())
.updatedAt(user.getUpdatedAt())
.isDeleted(user.getIsDeleted())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ public OAuth2User loadUser(OAuth2UserRequest request) throws OAuth2Authenticatio
newWbUser.setPhone(phone);
newWbUser.setBirth(birth);

// createdAt ν•„λ“œμ— ν˜„μž¬ λ‚ μ§œ μ„€μ •
newWbUser.setCreatedAt(new Date());
System.out.println("μƒˆ μœ μ € μ €μž₯");
wbUserRepository.save(newWbUser); // νšŒμ› 정보 μ €μž₯ (μ‚¬μ‹€μƒμ˜ 졜초 νšŒμ›κ°€μž…)

Expand Down
Loading