diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..2b63946
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/kotlin/data/dataSource/fakeCourseData.json b/src/main/kotlin/data/dataSource/fakeCourseData.json
deleted file mode 100644
index 8e6e364..0000000
--- a/src/main/kotlin/data/dataSource/fakeCourseData.json
+++ /dev/null
@@ -1,37 +0,0 @@
-{
- "コース": [
- {
- "ID": "C001",
- "名前": "コンピュータサイエンス入門",
- "講師": "山田太郎",
- "曜日": "月曜日",
- "時限": "1",
- "学期": "前期",
- "説明": "このコースは、コンピュータサイエンスの基本概念を紹介します。プログラミング言語の基本から始め、アルゴリズム、データ構造、ソフトウェア開発の基礎を網羅します。",
- "学年": "1年",
- "専攻": "コンピュータサイエンス"
- },
- {
- "ID": "C002",
- "名前": "データベース設計",
- "講師": "田中花子",
- "曜日": "水曜日",
- "時限": "3",
- "学期": "後期",
- "説明": "このコースでは、データベース設計の基本を学びます。正規化、データモデリング、SQLクエリの実行などが含まれます。",
- "学年": "3年",
- "専攻": "情報システム"
- },
- {
- "ID": "C003",
- "名前": "ソフトウェアエンジニアリング",
- "講師": "鈴木次郎",
- "曜日": "金曜日",
- "時限": "5",
- "学期": "前期",
- "説明": "このコースでは、ソフトウェアエンジニアリングの原則と実践をカバーします。ソフトウェア設計、テスト、プロジェクト管理などを理解します。",
- "学年": "2年",
- "専攻": "ソフトウェアエンジニアリング"
- }
- ]
-}
\ No newline at end of file
diff --git a/src/main/kotlin/data/dataSource/fakeStudentsData.json b/src/main/kotlin/data/dataSource/fakeStudentsData.json
deleted file mode 100644
index e69de29..0000000
diff --git a/src/main/kotlin/data/repository/CourseMembersRepository.kt b/src/main/kotlin/data/repository/CourseMembersRepository.kt
index 545985c..406a94b 100644
--- a/src/main/kotlin/data/repository/CourseMembersRepository.kt
+++ b/src/main/kotlin/data/repository/CourseMembersRepository.kt
@@ -3,6 +3,13 @@ package data.repository
import domain.entity.CourseId
import domain.entity.Student
+class CourseMembersRepositoryImpl():CourseMembersRepository{
+ override fun save(courseId: CourseId, courseMemberList: List) {
+
+
+ }
+}
+
interface CourseMembersRepository {
fun save(courseId: CourseId, courseMemberList:List)
}
\ No newline at end of file
diff --git a/src/main/kotlin/data/repository/CourseTakingApplicationsRepository.kt b/src/main/kotlin/data/repository/CourseTakingApplicationsRepository.kt
index f1dfc15..7f66eb0 100644
--- a/src/main/kotlin/data/repository/CourseTakingApplicationsRepository.kt
+++ b/src/main/kotlin/data/repository/CourseTakingApplicationsRepository.kt
@@ -10,4 +10,27 @@ interface CourseTakingApplicationsRepository {
suspend fun save(courseTakingApplication: CourseTakingApplication)
suspend fun delete(courseTakingApplication: CourseTakingApplication)
+}
+
+class CourseTakingApplicationsRepositoryImpl(): CourseTakingApplicationsRepository {
+ override suspend fun findByStudentId(studentId: StudentId): List {
+ TODO("Not yet implemented")
+ }
+
+ override suspend fun findByCourseId(courseId: CourseId): List {
+ TODO("Not yet implemented")
+ }
+
+ override suspend fun findByCourseTakingApplicationId(courseTakingApplicationId: CourseTakingApplicationId): CourseTakingApplication {
+ TODO("Not yet implemented")
+ }
+
+ override suspend fun save(courseTakingApplication: CourseTakingApplication) {
+ TODO("Not yet implemented")
+ }
+
+ override suspend fun delete(courseTakingApplication: CourseTakingApplication) {
+ TODO("Not yet implemented")
+ }
+
}
\ No newline at end of file
diff --git a/src/main/kotlin/data/repository/CoursesRepository.kt b/src/main/kotlin/data/repository/CoursesRepository.kt
index 65b6939..45708f5 100644
--- a/src/main/kotlin/data/repository/CoursesRepository.kt
+++ b/src/main/kotlin/data/repository/CoursesRepository.kt
@@ -8,4 +8,18 @@ interface CoursesRepository {
suspend fun findAll() : List
suspend fun findById(courseId: CourseId) : Course
suspend fun findByFaculty(faculty: Faculty) : List
-}
\ No newline at end of file
+}
+
+ class CoursesRepositoryImpl():CoursesRepository {
+ override suspend fun findAll(): List {
+ TODO("Not yet implemented")
+ }
+
+ override suspend fun findById(courseId: CourseId): Course {
+ TODO("Not yet implemented")
+ }
+
+ override suspend fun findByFaculty(faculty: Faculty): List {
+ TODO("Not yet implemented")
+ }
+ }
\ No newline at end of file
diff --git a/src/main/kotlin/data/repository/StudentsRepository.kt b/src/main/kotlin/data/repository/StudentsRepository.kt
index 1264633..8ba4ee7 100644
--- a/src/main/kotlin/data/repository/StudentsRepository.kt
+++ b/src/main/kotlin/data/repository/StudentsRepository.kt
@@ -6,4 +6,15 @@ import domain.entity.StudentId
interface StudentsRepository {
suspend fun findAll(): List
suspend fun findById(studentId: StudentId): Student
+}
+
+class StudentsRepositoryImpl:StudentsRepository {
+ override suspend fun findAll(): List {
+ TODO("Not yet implemented")
+ }
+
+ override suspend fun findById(studentId: StudentId): Student {
+ TODO("Not yet implemented")
+ }
+
}
\ No newline at end of file
diff --git a/src/main/kotlin/domain/Hub.kt b/src/main/kotlin/domain/Hub.kt
deleted file mode 100644
index 436834d..0000000
--- a/src/main/kotlin/domain/Hub.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package domain
-
-interface IHub {
-
-}
-
-class Hub: IHub {
-
-}
\ No newline at end of file
diff --git a/src/main/kotlin/domain/entity/CourseTakingApplication.kt b/src/main/kotlin/domain/entity/CourseTakingApplication.kt
index 7bab51b..2e715bf 100644
--- a/src/main/kotlin/domain/entity/CourseTakingApplication.kt
+++ b/src/main/kotlin/domain/entity/CourseTakingApplication.kt
@@ -45,5 +45,5 @@ class CourseTakingApplication(
}
enum class State {
- CREATED, UNCONFIRMED, CONFIRMED, INVALIDATED
+ UNCONFIRMED, CONFIRMED, INVALIDATED
}
\ No newline at end of file
diff --git a/src/main/kotlin/domain/service/CourseManagementService.kt b/src/main/kotlin/domain/service/CourseRegistrationService.kt
similarity index 98%
rename from src/main/kotlin/domain/service/CourseManagementService.kt
rename to src/main/kotlin/domain/service/CourseRegistrationService.kt
index 36b2256..a10834b 100644
--- a/src/main/kotlin/domain/service/CourseManagementService.kt
+++ b/src/main/kotlin/domain/service/CourseRegistrationService.kt
@@ -3,9 +3,6 @@ package domain.service
import domain.entity.*
interface CourseRegistrationService {
-
-
suspend fun drawingAndRegisterMembers(courseId: CourseId)
-
suspend fun registerMembers(courseId: CourseId)
}
diff --git a/src/main/kotlin/domain/service/CourseTakingApplicationService.kt b/src/main/kotlin/domain/service/CourseTakingApplicationService.kt
index ed04ed1..eb31705 100644
--- a/src/main/kotlin/domain/service/CourseTakingApplicationService.kt
+++ b/src/main/kotlin/domain/service/CourseTakingApplicationService.kt
@@ -5,6 +5,5 @@ import domain.entity.*
interface CourseTakingApplicationService {
suspend fun applyCourseTaking(courseTakingApplicationId: CourseTakingApplicationId, studentId:StudentId, courseId: CourseId)
suspend fun cancelCourseTaking(courseTakingApplicationId: CourseTakingApplicationId)
- suspend fun applyCourseTakingBasedOnFirstserved(courseTakingApplicationId: CourseTakingApplicationId, studentId:StudentId, courseId: CourseId)
suspend fun getCourseTakingApplications(studentId: StudentId): List
}
\ No newline at end of file
diff --git a/src/main/kotlin/domain/service/FirstServedManagementService.kt b/src/main/kotlin/domain/service/FirstServedManagementService.kt
index 4e40b7a..ebb8ab0 100644
--- a/src/main/kotlin/domain/service/FirstServedManagementService.kt
+++ b/src/main/kotlin/domain/service/FirstServedManagementService.kt
@@ -4,7 +4,5 @@ import domain.entity.Course
import domain.entity.CourseId
interface FirstServedManagementService {
- suspend fun checkCanTake(courseId: CourseId):Boolean
-
suspend fun getCoursesCanTake(): List
}
\ No newline at end of file
diff --git a/src/main/kotlin/domain/service/impl/CourseTakingApplicationServiceImpl.kt b/src/main/kotlin/domain/service/impl/CourseTakingApplicationServiceImpl.kt
index be79008..2232d5a 100644
--- a/src/main/kotlin/domain/service/impl/CourseTakingApplicationServiceImpl.kt
+++ b/src/main/kotlin/domain/service/impl/CourseTakingApplicationServiceImpl.kt
@@ -11,7 +11,6 @@ import domain.service.FirstServedManagementService
* */
class CourseTakingApplicationServiceImpl(
val repository: CourseTakingApplicationsRepository,
- val firstServedManagementService: FirstServedManagementService
) : CourseTakingApplicationService {
override suspend fun applyCourseTaking(
@@ -31,15 +30,6 @@ class CourseTakingApplicationServiceImpl(
repository.delete(canceledCourseTakingApplication)
}
- override suspend fun applyCourseTakingBasedOnFirstserved(
- courseTakingApplicationId: CourseTakingApplicationId,
- studentId: StudentId,
- courseId: CourseId
- ) {
- if (firstServedManagementService.checkCanTake(courseId))
- applyCourseTaking(courseTakingApplicationId, studentId, courseId)
- }
-
override suspend fun getCourseTakingApplications(studentId: StudentId): List {
return repository.findByStudentId(studentId)
}
diff --git a/src/main/kotlin/domain/service/impl/FirstServedManagementServiceImpl.kt b/src/main/kotlin/domain/service/impl/FirstServedManagementServiceImpl.kt
index 3a273e4..6c8e42d 100644
--- a/src/main/kotlin/domain/service/impl/FirstServedManagementServiceImpl.kt
+++ b/src/main/kotlin/domain/service/impl/FirstServedManagementServiceImpl.kt
@@ -10,10 +10,6 @@ class FirstServedManagementServiceImpl(
val repository: CourseTakingApplicationsRepository,
val coursesRepository: CoursesRepository
) : FirstServedManagementService {
- override suspend fun checkCanTake(courseId: CourseId): Boolean {
- return repository.findByCourseId(courseId).size < coursesRepository.findById(courseId).getMax()
- }
-
override suspend fun getCoursesCanTake(): List {
return coursesRepository.findAll()
.filter { course ->
diff --git a/src/main/kotlin/webServer/Main.kt b/src/main/kotlin/webServer/Main.kt
index ebb90ca..4341850 100644
--- a/src/main/kotlin/webServer/Main.kt
+++ b/src/main/kotlin/webServer/Main.kt
@@ -1,11 +1,30 @@
package webServer
-fun main(args: Array) {
-
- /* CourseTakingAndRegistration(
+import data.repository.*
+import domain.service.impl.CourseRegistrationServiceImpl
+import domain.service.impl.CourseTakingApplicationServiceImpl
+import domain.service.impl.FirstServedManagementServiceImpl
+import org.http4k.server.Jetty
+import org.http4k.server.asServer
- ).asServer(Jetty(8080)).start()*/
+fun main(args: Array) {
+ CourseTakingAndRegistration(
+ CourseTakingApplicationServiceImpl(
+ CourseTakingApplicationsRepositoryImpl(),
+ ),
+ FirstServedManagementServiceImpl(
+ CourseTakingApplicationsRepositoryImpl(),
+ CoursesRepositoryImpl(),
+ ),
+ CourseRegistrationServiceImpl(
+ CourseTakingApplicationsRepositoryImpl(),
+ CourseMembersRepositoryImpl(),
+ CoursesRepositoryImpl(),
+ StudentsRepositoryImpl(),
+ ),
+ CoursesRepositoryImpl(),
+ ).asServer(Jetty(8080)).start()
println("Server started at http://localhost:8080")
diff --git a/src/main/kotlin/webServer/Routes.kt b/src/main/kotlin/webServer/Routes.kt
index 0b0d62b..13e2264 100644
--- a/src/main/kotlin/webServer/Routes.kt
+++ b/src/main/kotlin/webServer/Routes.kt
@@ -4,6 +4,7 @@ import data.repository.CoursesRepository
import domain.entity.*
import domain.service.CourseRegistrationService
import domain.service.CourseTakingApplicationService
+import domain.service.impl.FirstServedManagementServiceImpl
import kotlinx.coroutines.*
import org.http4k.core.*
import org.http4k.routing.bind
@@ -19,19 +20,22 @@ import org.http4k.core.Status.Companion.OK
* */
class CourseTakingAndRegistration(
private val courseTakingApplicationService: CourseTakingApplicationService,
+ private val firstServedManagementServiceImpl: FirstServedManagementServiceImpl,
private val courseRegistrationService: CourseRegistrationService,
private val coursesRepository: CoursesRepository
) : HttpHandler {
override fun invoke(request: Request): Response = httpHandler(request)
val httpHandler = routes(
- /*QUERY*/
- "/course" bind Method.GET to ::getCourses,
+ /*申請履歴*/
"/application/{studentId}" bind Method.GET to ::getApplications,
- /*courseTaking*/
+ "/course" bind Method.GET to ::getCourses,
+ /*先着申請可能な科目*/
+ "/course" bind Method.GET to ::getCoursesCanTake,
+ /*申請*/
"/application/createApplication" bind Method.POST to ::applyCourseTaking,
"/application/cancelApplication" bind Method.DELETE to ::cancelCourseTaking,
- /*courseRegistration*/
+ /*抽選・登録*/
"/course/{courseId}/drawAndRegisterMembers" bind Method.POST to ::drawAndRegisterCourseMembers,
"/course/{courseId}/registerMembers" bind Method.POST to ::registerCourseMembers,
)
@@ -52,6 +56,21 @@ class CourseTakingAndRegistration(
}
}
+ private fun getCoursesCanTake(request: Request): Response {
+ val result = CoroutineScope(Dispatchers.IO).async {
+ runCatching {
+ firstServedManagementServiceImpl.getCoursesCanTake()
+ }
+ }
+
+ /*responseを返す*/
+ return if (result.getCompleted().isSuccess) {
+ Response(OK)
+ } else {
+ Response(Status.BAD_REQUEST)
+ }
+ }
+
/*
* {studentId}
* */
@@ -74,7 +93,7 @@ class CourseTakingAndRegistration(
}
/*
- * {studentId, courseId, applicationFormat}
+ * {studentId, courseId}
* */
private fun applyCourseTaking(request: Request): Response {
val result = CoroutineScope(Dispatchers.IO).async {
@@ -82,24 +101,13 @@ class CourseTakingAndRegistration(
/*requestからuser, applicationを取得*/
val studentId: StudentId = StudentId(request.path("studentId") ?: "")
val courseId: CourseId = CourseId(request.path("courseId") ?: "")
- val applicationFormat: String = request.path("applicationFormat") ?: ""
/*申請*/
- val courseTakingApplicationId = CourseTakingApplicationId(UUID.randomUUID().toString())
- when (applicationFormat) {
- /*事前申請*/
- "advanced" -> courseTakingApplicationService.applyCourseTaking(
- courseTakingApplicationId,
- studentId,
- courseId
- )
- /*先着申請*/
- "first-served" -> courseTakingApplicationService.applyCourseTakingBasedOnFirstserved(
- courseTakingApplicationId,
- studentId,
- courseId
- )
- }
+ courseTakingApplicationService.applyCourseTaking(
+ CourseTakingApplicationId(UUID.randomUUID().toString()),
+ studentId,
+ courseId
+ )
}
}
@@ -112,13 +120,12 @@ class CourseTakingAndRegistration(
}
/*
- * {studentId, courseTakingApplicationId}
+ * {courseTakingApplicationId}
* */
private fun cancelCourseTaking(request: Request): Response {
val result = CoroutineScope(Dispatchers.IO).async {
runCatching {
- /*requestからuser, applicationを取得*/
- val studentId: StudentId = StudentId(request.path("studentId") ?: "")
+ /*requestからapplicationIdを取得*/
val courseTakingApplicationId: CourseTakingApplicationId =
CourseTakingApplicationId(request.path("courseTakingApplicationId") ?: "")