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] #34 - 기업 관련 기능 수정 #126

Merged
merged 7 commits into from
Nov 22, 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 @@ -13,6 +13,7 @@
public class EnterpriseInfoReqDTO {

private String entId;
private String entName;
private String ceoName;
private String entField;
private EntSize entSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ private EnterpriseDTO ConvertToOriginDTO(EnterpiseJoinDTO enterpiseJoinDTO){
.revenue(enterpiseJoinDTO.getRevenue())
.entAddr1(enterpiseJoinDTO.getEntAddr1())
.entAddr2(enterpiseJoinDTO.getEntAddr2())
.createdAt(new Date())
.build();
}

Expand Down
31 changes: 20 additions & 11 deletions src/main/java/com/wooribound/domain/enterprise/Enterprise.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
import com.wooribound.global.constant.EntSize;
import com.wooribound.domain.employment.Employment;
import com.wooribound.global.constant.YNP;
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.Table;
import jakarta.persistence.*;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import lombok.*;

Expand Down Expand Up @@ -58,13 +54,13 @@ public class Enterprise {
private String entAddr2;

@Column(name = "created_at", nullable = false)
private Date createdAt;
private LocalDateTime createdAt;

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

@Column(name = "delete_requested_at")
private Date deleteRequestedAt;
private LocalDateTime deleteRequestedAt;

@Enumerated(EnumType.STRING)
@Column(name = "is_deleted", nullable = false, columnDefinition = "CHAR(1) DEFAULT 'N'") // database default 설정 (jpql 사용에 대비)
Expand All @@ -75,5 +71,18 @@ public class Enterprise {

@OneToMany(mappedBy = "enterprise", fetch = FetchType.LAZY)
private List<JobPosting> jobPostings;

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

// @PreUpdate는 엔티티가 업데이트될 때 호출됩니다.
@PreUpdate
public void preUpdate() {
updatedAt = LocalDateTime.now();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Optional;

@Slf4j
Expand All @@ -37,7 +36,6 @@ public void create(EnterpriseDTO enterpriseDTO) {
.regNum(enterpriseDTO.getRegNum())
.entField(enterpriseDTO.getEntField())
.ceoName(enterpriseDTO.getCeoName())
.createdAt(enterpriseDTO.getCreatedAt())
.isDeleted(YNP.N)
.build();
enterpriseRepository.save(ent);
Expand Down Expand Up @@ -72,12 +70,15 @@ public EnterpriseInfoDTO getEnterpriseInfo(String entId) {
// 2. 기업회원 정보 수정
@Override
public String updateEnterpriseInfo(EnterpriseInfoReqDTO enterpriseInfoReqDTO) {

// logger.info("기업회원 정보 수정 START, entId: {}", enterpriseInfoReqDTO.getEntName());
String entId = enterpriseInfoReqDTO.getEntId();

Enterprise enterprise = enterpriseRepository.findById(entId)
.orElseThrow(() -> new RuntimeException("해당 기업 회원이 존재하지 않습니다. ID: " + entId));

if (enterpriseInfoReqDTO.getEntName() != null) {
enterprise.setEntName(enterpriseInfoReqDTO.getEntName());
}
if (enterpriseInfoReqDTO.getEntField() != null) {
enterprise.setEntField(enterpriseInfoReqDTO.getEntField());
}
Expand All @@ -94,10 +95,10 @@ public String updateEnterpriseInfo(EnterpriseInfoReqDTO enterpriseInfoReqDTO) {
enterprise.setEntAddr2(enterpriseInfoReqDTO.getEntAddr2());
}

enterprise.setUpdatedAt(new Date());
enterpriseRepository.save(enterprise);

return entId + " 기업회원 정보 수정 완료 : " +
"EntName : " + enterprise.getEntName() + ", " +
"EntField : " + enterprise.getEntField() + ", " +
"EntSize : " + enterprise.getEntSize() + ", " +
"CeoName : " + enterprise.getCeoName() + ", " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.wooribound.global.constant.EntSize;
import jakarta.validation.constraints.NotEmpty;
import java.util.Date;

import jakarta.validation.constraints.Pattern;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -17,6 +19,10 @@ public class EnterpriseDTO {
private String entId;

@NotEmpty(message = "regNum 필드는 필수입니다.")
@Pattern(
regexp = "^[0-9]{3}-[0-9]{2}-[0-9]{5}$",
message = "사업자번호는 ***-**-***** 형식이어야 합니다."
)
private String regNum;

@NotEmpty(message = "entPwd 필드는 필수입니다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -70,7 +69,6 @@ public List<AdminPendingEnterpriseDTO> getPendingRegist(String entName) {
.entId(enterprise.getEntId())
.entName(enterprise.getEntName())
.entField(enterprise.getEntField())
.createdAt(enterprise.getCreatedAt())
.build())
.collect(Collectors.toList());
}
Expand All @@ -83,7 +81,6 @@ public List<AdminPendingEnterpriseDTO> getPendingDeletion(String entName) {
.entId(enterprise.getEntId())
.entName(enterprise.getEntName())
.entField(enterprise.getEntField())
.deleteRequestedAt(enterprise.getDeleteRequestedAt())
.build())
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ List<JobPostingProjection> findJobPostingsNew(@Param("exJobs") List<String> exJo
"jp.job.jobName AS jobName, jp.enterprise.entAddr1 AS entAddr1, jp.enterprise.entAddr2 AS entAddr2, " +
"(SELECT COUNT(ua) FROM UserApply ua WHERE ua.jobPosting = jp) AS applicantCount, " +
"CASE " +
"WHEN jp.startDate > CURRENT_DATE THEN 'PENDING' " +
"WHEN jp.startDate <= CURRENT_DATE AND jp.endDate >= CURRENT_DATE THEN 'ACTIVE' " +
"WHEN jp.endDate < CURRENT_DATE THEN 'CLOSED' " +
"WHEN FUNCTION('DATE', jp.startDate) <= CURRENT_DATE AND FUNCTION('DATE', jp.endDate) >= CURRENT_DATE THEN 'ACTIVE' " +
"WHEN FUNCTION('DATE', jp.startDate) > CURRENT_DATE THEN 'PENDING' " +
"WHEN FUNCTION('DATE', jp.endDate) < CURRENT_DATE THEN 'CLOSED' " +
"END AS postState " +
"FROM JobPosting jp " +
"WHERE jp.enterprise.entId = :entId")
List<JobPostingDetailProjection> getMyJobPostings(@Param("entId") String entId);


@Modifying
@Query("UPDATE JobPosting jp SET jp.isDeleted = 'Y' WHERE jp.postId = :postId")
int updateIsDeletedByPostId(@Param("postId") Long postId);
Expand Down
Loading