Skip to content

Commit

Permalink
Merge pull request #20 from potenday-project/feat/#19
Browse files Browse the repository at this point in the history
fix(TODO): update type of status enum -> boolean #19
  • Loading branch information
cyzlcyzl authored Dec 15, 2023
2 parents 62a7b54 + 39d1d30 commit 8ec0daa
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 26 deletions.
6 changes: 3 additions & 3 deletions src/main/java/mvc/promiseme/project/entity/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ public class Project {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long projectId;

@Column(nullable = false, length = 50)
@Column(length = 50)
private String name;

@Column(nullable = false)
@Enumerated(EnumType.STRING)
private Progress isProgress;

@Column(nullable = false, length = 50)
@Column(length = 50)
private String category;

@Column(nullable = false, length = 100)
@Column(length = 100)
private String topic;

private LocalDate start;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public interface ProjectRepository extends JpaRepository<Project,Long> {

@Query("SELECT CAST((SELECT COUNT(t1) FROM Todo t1 WHERE t1.project.id = :projectId AND t1.isCompleted = 'COMPLETE') / COUNT(t2) * 100 AS INTEGER) " +
@Query("SELECT CAST((SELECT COUNT(t1) FROM Todo t1 WHERE t1.project.id = :projectId AND t1.isCompleted = true) / COUNT(t2) * 100 AS INTEGER) " +
"FROM Todo t2 WHERE t2.project.id = :projectId")
int getProgress(@Param("projectId") Long projecrtId);
@Query("SELECT datediff(p.deadline, now()) From Project p where p.projectId = :projectId")
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/mvc/promiseme/todo/dto/TodoResponseDTO.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package mvc.promiseme.todo.dto;

import lombok.*;
import mvc.promiseme.todo.entity.ToDoStatus;
import mvc.promiseme.todo.entity.Todo;

import java.util.List;
Expand All @@ -16,7 +15,7 @@ public class TodoResponseDTO {

private Long todoId;
private String content;
private ToDoStatus isCompleted;
private boolean isCompleted;

public List<TodoResponseDTO> convertToDtoList(List<Todo> todoList) {
return todoList.stream()
Expand All @@ -28,7 +27,7 @@ private TodoResponseDTO convertToDto(Todo todo) {
return TodoResponseDTO.builder()
.todoId(todo.getToDoId())
.content(todo.getContent())
.isCompleted(todo.getIsCompleted())
.isCompleted(todo.isCompleted())
.build();
}
}
13 changes: 0 additions & 13 deletions src/main/java/mvc/promiseme/todo/entity/ToDoStatus.java

This file was deleted.

3 changes: 1 addition & 2 deletions src/main/java/mvc/promiseme/todo/entity/Todo.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ public class Todo {
private String content;

@Column(nullable = false)
@Enumerated(EnumType.STRING)
@Builder.Default
private ToDoStatus isCompleted = ToDoStatus.INCOMPLETE;
private boolean isCompleted = false;

private LocalDate todoDate;
private LocalDate createdAt;
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/mvc/promiseme/todo/service/TodoServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import mvc.promiseme.project.repository.ProjectRepository;
import mvc.promiseme.todo.dto.TodoRequestDTO;
import mvc.promiseme.todo.dto.TodoResponseDTO;
import mvc.promiseme.todo.entity.ToDoStatus;
import mvc.promiseme.todo.entity.Todo;
import mvc.promiseme.todo.repository.TodoRepository;
import mvc.promiseme.users.entity.Users;
Expand Down Expand Up @@ -54,9 +53,8 @@ public String check(Long todoId){
}

private Todo updateStatus(Todo todo){
ToDoStatus status = todo.getIsCompleted();
if(status.equals(ToDoStatus.COMPLETE)) todo.setIsCompleted(ToDoStatus.INCOMPLETE);
else if (status.equals(ToDoStatus.INCOMPLETE)) todo.setIsCompleted(ToDoStatus.COMPLETE);
if(todo.isCompleted() == true) todo.setCompleted(false);
else if (todo.isCompleted() == false) todo.setCompleted(true);
return todo;
}

Expand Down

0 comments on commit 8ec0daa

Please sign in to comment.