diff --git a/src/main/kotlin/com/asap/asapbackend/domain/classroom/application/ClassroomService.kt b/src/main/kotlin/com/asap/asapbackend/domain/classroom/application/ClassroomService.kt index 5660858d..871b8fb4 100644 --- a/src/main/kotlin/com/asap/asapbackend/domain/classroom/application/ClassroomService.kt +++ b/src/main/kotlin/com/asap/asapbackend/domain/classroom/application/ClassroomService.kt @@ -45,7 +45,8 @@ class ClassroomService( child = student, description = it.description, type = it.todoType, - deadline = it.deadline + deadline = it.deadline, + isAssigned = true ) } }.toSet() diff --git a/src/main/kotlin/com/asap/asapbackend/domain/todo/application/TodoService.kt b/src/main/kotlin/com/asap/asapbackend/domain/todo/application/TodoService.kt index bac8328d..af901a8d 100644 --- a/src/main/kotlin/com/asap/asapbackend/domain/todo/application/TodoService.kt +++ b/src/main/kotlin/com/asap/asapbackend/domain/todo/application/TodoService.kt @@ -28,7 +28,8 @@ class TodoService( type = request.todoType, description = request.description, child = child, - deadline = request.deadline + deadline = request.deadline, + isAssigned = false ) todoAppender.appendTodo(todo) } diff --git a/src/main/kotlin/com/asap/asapbackend/domain/todo/application/dto/GetTodo.kt b/src/main/kotlin/com/asap/asapbackend/domain/todo/application/dto/GetTodo.kt index de3505c4..65d0b6cc 100644 --- a/src/main/kotlin/com/asap/asapbackend/domain/todo/application/dto/GetTodo.kt +++ b/src/main/kotlin/com/asap/asapbackend/domain/todo/application/dto/GetTodo.kt @@ -15,7 +15,8 @@ class GetTodo { val description: String, val todoType: TodoType, val deadline: LocalDate, - val status: Status + val status: Status, + val isAssigned:Boolean ) fun toTodoInfo(todos: List): List { @@ -25,7 +26,8 @@ class GetTodo { description = it.description, todoType = it.type, deadline = it.deadline, - status = it.status + status = it.status, + isAssigned = it.isAssigned ) } } diff --git a/src/main/kotlin/com/asap/asapbackend/domain/todo/domain/model/Todo.kt b/src/main/kotlin/com/asap/asapbackend/domain/todo/domain/model/Todo.kt index c2b8efcc..e8c233a4 100644 --- a/src/main/kotlin/com/asap/asapbackend/domain/todo/domain/model/Todo.kt +++ b/src/main/kotlin/com/asap/asapbackend/domain/todo/domain/model/Todo.kt @@ -13,7 +13,8 @@ class Todo ( type: TodoType, description: String, child: Child, - deadline: LocalDate + deadline: LocalDate, + isAssigned: Boolean ):BaseDateEntity(){ init { @@ -32,6 +33,8 @@ class Todo ( val deadline : LocalDate = deadline + val isAssigned : Boolean = isAssigned + @Enumerated(EnumType.STRING) @Column( nullable = false, diff --git a/src/main/kotlin/com/asap/asapbackend/domain/todo/domain/repository/TodoJdbcRepository.kt b/src/main/kotlin/com/asap/asapbackend/domain/todo/domain/repository/TodoJdbcRepository.kt index 421c667c..0e36b3a7 100644 --- a/src/main/kotlin/com/asap/asapbackend/domain/todo/domain/repository/TodoJdbcRepository.kt +++ b/src/main/kotlin/com/asap/asapbackend/domain/todo/domain/repository/TodoJdbcRepository.kt @@ -11,8 +11,8 @@ class TodoJdbcRepository( ) { fun insertBatch(todos: Set) { val sql = """ - insert into todo (created_at, updated_at, deadline, description, status, type, child_id) - values (now(), now(), ?, ?, ?, ?, ?) + insert into todo (created_at, updated_at, deadline, description, status, type, child_id,is_assigned) + values (now(), now(), ?, ?, ?, ?, ?,?) """.trimIndent() jdbcTemplate.batchUpdate(sql, todos, todos.size){ ps : PreparedStatement, todo: Todo -> ps.setObject(1, todo.deadline) @@ -20,6 +20,7 @@ class TodoJdbcRepository( ps.setObject(3, todo.status.name) ps.setObject(4, todo.type.name) ps.setLong(5, todo.child.id) + ps.setObject(6,todo.isAssigned) } } } \ No newline at end of file diff --git a/src/test/kotlin/com/asap/asapbackend/domain/todo/presentation/TodoControllerTest.kt b/src/test/kotlin/com/asap/asapbackend/domain/todo/presentation/TodoControllerTest.kt index 9f54b5f2..b47da0ae 100644 --- a/src/test/kotlin/com/asap/asapbackend/domain/todo/presentation/TodoControllerTest.kt +++ b/src/test/kotlin/com/asap/asapbackend/domain/todo/presentation/TodoControllerTest.kt @@ -70,8 +70,8 @@ class TodoControllerTest : AbstractRestDocsConfigurer() { val deadline = LocalDate.parse("2024-05-23") val getTodo: GetTodo.Response = generateFixture { it.setExp(GetTodo.Response::todoList, listOf( - GetTodo.TodoInfo(1,"체육복 챙기기",TodoType.SUPPLY,LocalDate.parse("2024-05-28"),Status.COMPLETE), - GetTodo.TodoInfo(2,"수학학원 숙제",TodoType.HOMEWORK,LocalDate.parse("2024-05-31"),Status.INCOMPLETE) + GetTodo.TodoInfo(1,"체육복 챙기기",TodoType.SUPPLY,LocalDate.parse("2024-05-28"),Status.COMPLETE, true), + GetTodo.TodoInfo(2,"수학학원 숙제",TodoType.HOMEWORK,LocalDate.parse("2024-05-31"),Status.INCOMPLETE,false) )) } @@ -98,7 +98,8 @@ class TodoControllerTest : AbstractRestDocsConfigurer() { fieldWithPath("todoList[].description").description("할 일"), fieldWithPath("todoList[].todoType").description("유형"), fieldWithPath("todoList[].deadline").description("마감일"), - fieldWithPath("todoList[].status").description("상태") + fieldWithPath("todoList[].status").description("상태"), + fieldWithPath("todoList[].isAssigned").description("할당 여부(선생님:true,학부모:false)") ) ) )