diff --git a/src/main/java/team1/BE/seamless/DTO/TaskDTO.java b/src/main/java/team1/BE/seamless/DTO/TaskDTO.java index 679eb70c..a140ab4a 100644 --- a/src/main/java/team1/BE/seamless/DTO/TaskDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/TaskDTO.java @@ -11,6 +11,7 @@ import team1.BE.seamless.entity.MemberEntity; import team1.BE.seamless.entity.TaskEntity; import team1.BE.seamless.entity.enums.Priority; +import team1.BE.seamless.entity.enums.Status; import team1.BE.seamless.util.errorException.BaseHandler; import team1.BE.seamless.util.page.PageParam; @@ -31,7 +32,7 @@ public static class TaskCreate { private Long ownerId; @NotNull(message = "진행 상태(status)는 필수 입력 사항입니다.") - private Integer status; + private Status status; @NotNull(message = "중요도(priority)는 필수 입력 사항입니다.") private Priority priority; @@ -48,7 +49,7 @@ public static class TaskCreate { private LocalDateTime endDate; public TaskCreate(String name, String description, Long ownerId, LocalDateTime startDate, - LocalDateTime endDate, Priority priority, Integer status, Integer progress) { + LocalDateTime endDate, Priority priority, Status status, Integer progress) { if (endDate.isBefore(startDate)) { throw new BaseHandler(HttpStatus.BAD_REQUEST, "종료시간은 시작시간보다 이전일 수 없습니다."); } @@ -93,7 +94,7 @@ public Priority getPriority() { return priority; } - public Integer getStatus() { + public Status getStatus() { return status; } } @@ -110,7 +111,7 @@ public static class TaskUpdate { @Max(value = 100, message = "진행도(progress)는 최대 100이어야 합니다.") private Integer progress; - private Integer status; + private Status status; private Priority priority; @@ -120,7 +121,7 @@ public static class TaskUpdate { public TaskUpdate(String name, String description, Integer progress, Long ownerId, LocalDateTime startDate, - LocalDateTime endDate, Priority priority, Integer status) { + LocalDateTime endDate, Priority priority, Status status) { if (endDate.isBefore(startDate)) { throw new BaseHandler(HttpStatus.BAD_REQUEST, "종료시간은 시작시간보다 이전일 수 없습니다."); } @@ -158,7 +159,7 @@ public LocalDateTime getEndDate() { return endDate; } - public Integer getStatus() { + public Status getStatus() { return status; } @@ -185,11 +186,11 @@ public static class TaskDetail { private Priority priority; - private Integer status; + private Status status; public TaskDetail(Long id, String name, String description, Long ownerId, Integer progress, LocalDateTime startDate, LocalDateTime endDate, Priority priority, - Integer status) { + Status status) { this.id = id; this.name = name; this.description = description; @@ -246,7 +247,7 @@ public Priority getPriority() { return priority; } - public Integer getStatus() { + public Status getStatus() { return status; } } @@ -269,11 +270,11 @@ public static class TaskWithOwnerDetail { private Priority priority; - private Integer status; + private Status status; public TaskWithOwnerDetail(Long id, String name, String description, MemberEntity owner, Integer progress, - LocalDateTime startDate, LocalDateTime endDate, Priority priority, Integer status) { + LocalDateTime startDate, LocalDateTime endDate, Priority priority, Status status) { this.id = id; this.name = name; this.description = description; @@ -317,7 +318,7 @@ public Priority getPriority() { return priority; } - public Integer getStatus() { + public Status getStatus() { return status; } } diff --git a/src/main/java/team1/BE/seamless/entity/TaskEntity.java b/src/main/java/team1/BE/seamless/entity/TaskEntity.java index 73933311..f0843c17 100644 --- a/src/main/java/team1/BE/seamless/entity/TaskEntity.java +++ b/src/main/java/team1/BE/seamless/entity/TaskEntity.java @@ -12,15 +12,25 @@ import jakarta.persistence.ManyToOne; import java.time.LocalDateTime; import team1.BE.seamless.entity.enums.Priority; +import team1.BE.seamless.entity.enums.Status; @Entity(name = "taskss") public class TaskEntity { - public TaskEntity(String name, String description, Priority priority, ProjectEntity project, MemberEntity member, LocalDateTime startDate, LocalDateTime endDate, Integer progress, Integer status) { + public TaskEntity( + String name, + String description, + Priority priority, + ProjectEntity project, + MemberEntity member, + LocalDateTime startDate, + LocalDateTime endDate, + Integer progress, + Status status) { this.name = name; this.description = description; this.progress = progress; - this.status = status; + this.status = Status.PENDING; this.priority = priority; this.isDeleted = false; this.projectEntity = project; @@ -47,8 +57,9 @@ public TaskEntity() { @Column(name = "progress") private Integer progress = 0; + @Enumerated(EnumType.STRING) @Column(name = "status") - private Integer status = 0; + private Status status; @Enumerated(EnumType.STRING) @Column(name = "priority") @@ -87,7 +98,7 @@ public Integer getProgress() { return progress; } - public Integer getStatus() { + public Status getStatus() { return status; } @@ -143,7 +154,7 @@ public void setDeleted(Boolean deleted) { isDeleted = deleted; } - public void setStatus(Integer status) { + public void setStatus(Status status) { this.status = status; } diff --git a/src/main/java/team1/BE/seamless/entity/enums/Status.java b/src/main/java/team1/BE/seamless/entity/enums/Status.java new file mode 100644 index 00000000..a37d7111 --- /dev/null +++ b/src/main/java/team1/BE/seamless/entity/enums/Status.java @@ -0,0 +1,6 @@ +package team1.BE.seamless.entity.enums; + +public enum Status { + + PENDING, IN_PROGRESS, COMPLETED +} diff --git a/src/main/java/team1/BE/seamless/init/TaskCreator.java b/src/main/java/team1/BE/seamless/init/TaskCreator.java index 0814de84..36093786 100644 --- a/src/main/java/team1/BE/seamless/init/TaskCreator.java +++ b/src/main/java/team1/BE/seamless/init/TaskCreator.java @@ -5,6 +5,7 @@ import org.springframework.stereotype.Component; import team1.BE.seamless.DTO.TaskDTO.TaskCreate; import team1.BE.seamless.entity.enums.Priority; +import team1.BE.seamless.entity.enums.Status; import team1.BE.seamless.service.TaskService; @Component @@ -21,7 +22,7 @@ public void creator() { TaskCreate task1 = new TaskCreate("태스크1", "첫번째 태스크입니다.", 1L, LocalDateTime.of(2024, 10, 10, 0, 0), - LocalDateTime.of(2025, 9, 3, 0, 0), Priority.HIGH, 50, 1); + LocalDateTime.of(2025, 9, 3, 0, 0), Priority.HIGH, Status.IN_PROGRESS, 1); taskService.createTask(1L, task1); } diff --git a/src/main/java/team1/BE/seamless/repository/TaskRepository.java b/src/main/java/team1/BE/seamless/repository/TaskRepository.java index d25def8b..6946a3a6 100644 --- a/src/main/java/team1/BE/seamless/repository/TaskRepository.java +++ b/src/main/java/team1/BE/seamless/repository/TaskRepository.java @@ -23,6 +23,7 @@ public interface TaskRepository extends JpaRepository { Optional findByIdAndProjectEntityUserEntityEmail(Long id, String email); @Query(value = "SELECT * FROM taskss t WHERE t.project_id = :projectId " + + "AND (t.is_deleted = false) " + "AND (:status IS NULL OR t.status = :status) " + "AND (:priority IS NULL OR t.priority = :priority) " + "AND (:memberId IS NULL OR t.member_id = :memberId)", diff --git a/src/main/java/team1/BE/seamless/service/MemberService.java b/src/main/java/team1/BE/seamless/service/MemberService.java index 4d669bfa..e426ad29 100644 --- a/src/main/java/team1/BE/seamless/service/MemberService.java +++ b/src/main/java/team1/BE/seamless/service/MemberService.java @@ -1,12 +1,9 @@ package team1.BE.seamless.service; import jakarta.servlet.http.HttpServletRequest; -import jakarta.validation.Valid; -import java.util.List; +import java.time.LocalDateTime; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; -import org.springframework.data.domain.PageRequest; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -20,15 +17,12 @@ import team1.BE.seamless.mapper.MemberMapper; import team1.BE.seamless.repository.MemberRepository; import team1.BE.seamless.repository.ProjectRepository; -import team1.BE.seamless.util.Email.EmailSend; import team1.BE.seamless.util.MailSend; import team1.BE.seamless.util.Util; import team1.BE.seamless.util.auth.AesEncrypt; import team1.BE.seamless.util.auth.ParsingPram; import team1.BE.seamless.util.errorException.BaseHandler; -import java.time.LocalDateTime; - @Service public class MemberService { @@ -92,22 +86,7 @@ public Page getMemberList(Long projectId, throw new BaseHandler(HttpStatus.UNAUTHORIZED,"권한이 없습니다."); } - ProjectEntity project = projectRepository.findById(projectId) - .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "해당 프로젝트가 존재하지 않습니다.")); - - if (project.getEndDate().isBefore(LocalDateTime.now())) { - throw new BaseHandler(HttpStatus.BAD_REQUEST, "프로젝트는 종료되었습니다."); - } - -// return memberRepository.findAllByProjectEntityIdAndIsDeleteFalse(projectId, memberList.toPageable()) -// .map(memberMapper::toGetResponseDTO); - - int start = memberList.getPage() * memberList.getSize(); - int end = Math.min((start + memberList.getSize()), project.getMemberEntities().size()); - List memberEntities = project.getMemberEntities().subList(start, end); - - return new PageImpl<>(memberEntities,memberList.toPageable(), project.getMemberEntities().size()) - .map(memberMapper::toGetResponseDTO); + return memberRepository.findAllByProjectEntityIdAndIsDeleteFalse(projectId,memberList.toPageable()).map(memberMapper::toGetResponseDTO); } diff --git a/src/test/java/team1/BE/seamless/e2e/TaskServiceTest.java b/src/test/java/team1/BE/seamless/e2e/TaskServiceTest.java index 1204cd13..0f7ecc8f 100644 --- a/src/test/java/team1/BE/seamless/e2e/TaskServiceTest.java +++ b/src/test/java/team1/BE/seamless/e2e/TaskServiceTest.java @@ -22,6 +22,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; import team1.BE.seamless.DTO.TaskDTO.TaskCreate; import team1.BE.seamless.entity.enums.Priority; +import team1.BE.seamless.entity.enums.Status; import team1.BE.seamless.service.ProjectService; import team1.BE.seamless.service.TaskService; @@ -64,7 +65,10 @@ public void setUp() { @Test public void 태스크_시작_시간이_프로젝트_일정_범위보다_이를_경우_실패() { - TaskCreate body = new TaskCreate("태스크1", "첫번째 태스크입니다.", 1L, LocalDateTime.of(2001, 10, 10, 0, 0), LocalDateTime.of(2025, 5, 3, 1, 0, 0), Priority.HIGH, 50, 1); + TaskCreate body = new TaskCreate("태스크1", "첫번째 태스크입니다.", + 1L, LocalDateTime.of(2001, 10, 10, 0, 0), + LocalDateTime.of(2025, 5, 3, 1, 0, 0), + Priority.HIGH, Status.IN_PROGRESS, 1); HttpEntity requestEntity = new HttpEntity(body, headers); @@ -75,7 +79,10 @@ public void setUp() { @Test public void 태스크_마감_시간이_프로젝트_일정_범위보다_늦을_경우_실패() { - TaskCreate body = new TaskCreate("태스크1", "첫번째 태스크입니다.", 1L, LocalDateTime.of(2024, 12, 1, 0, 0), LocalDateTime.of(2100, 5, 3, 1, 0, 0), Priority.HIGH, 50, 1); + TaskCreate body = new TaskCreate("태스크1", "첫번째 태스크입니다.", + 1L, LocalDateTime.of(2024, 12, 1, 0, 0), + LocalDateTime.of(2100, 5, 3, 1, 0, 0), + Priority.HIGH, Status.IN_PROGRESS, 1); HttpEntity requestEntity = new HttpEntity(body, headers);