diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/AddTimeRequest.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/AddTimeRequest.kt deleted file mode 100644 index fd852fd6..00000000 --- a/app/src/main/java/umc/com/mobile/project/data/model/plan/AddTimeRequest.kt +++ /dev/null @@ -1,18 +0,0 @@ -package umc.com.mobile.project.data.model.plan - -data class AddTimeRequest( -val semesterDto: SemesterDto, -val subjectDtoList: List, -) - -data class SemesterDto( - val grade: Long, - val semester: Long, -) - -data class SubjectDtoList( - val type: String, - val name: String, - val credit: String, -) - diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/BringlicenseResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/BringlicenseResponse.kt deleted file mode 100644 index d437092c..00000000 --- a/app/src/main/java/umc/com/mobile/project/data/model/plan/BringlicenseResponse.kt +++ /dev/null @@ -1,16 +0,0 @@ -package umc.com.mobile.project.data.model.plan - -import java.time.LocalDateTime - -data class BringlicenseResponse( - val isSuccess: Boolean, - val code: String, - val message: String, - val result: List, -) - -data class BringResult( - val certificateId: Long, - val createdAt: String, -) - diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/EditMemoRequest.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/EditMemoRequest.kt deleted file mode 100644 index 20fa4b33..00000000 --- a/app/src/main/java/umc/com/mobile/project/data/model/plan/EditMemoRequest.kt +++ /dev/null @@ -1,6 +0,0 @@ -package umc.com.mobile.project.data.model.plan - -data class EditMemoRequest( - val memo: String -) - diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/ListTimeResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/ListTimeResponse.kt deleted file mode 100644 index 0ebe8053..00000000 --- a/app/src/main/java/umc/com/mobile/project/data/model/plan/ListTimeResponse.kt +++ /dev/null @@ -1,17 +0,0 @@ -package umc.com.mobile.project.data.model.plan - - - -data class ListTimeResponse( - val isSuccess: Boolean, - val code: String, - val message: String, - val result: List, -) - -data class TimeResult( - val searchGrade: String, - val searchType: String, - val searchName: String, - val searchCredit: String, -) diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/PlanFreeRequest.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/PlanFreeRequest.kt deleted file mode 100644 index 953dfb79..00000000 --- a/app/src/main/java/umc/com/mobile/project/data/model/plan/PlanFreeRequest.kt +++ /dev/null @@ -1,6 +0,0 @@ -package umc.com.mobile.project.data.model.plan - -data class PlanFreeRequest( - val memo: String, -) - diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/PlanFreeResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/PlanFreeResponse.kt deleted file mode 100644 index ac41ce3c..00000000 --- a/app/src/main/java/umc/com/mobile/project/data/model/plan/PlanFreeResponse.kt +++ /dev/null @@ -1,13 +0,0 @@ -package umc.com.mobile.project.data.model.plan - -data class PlanFreeResponse( - val isSuccess: Boolean, - val code: String, - val message: String, - val result: FreeInfo, -) - -data class FreeInfo( - val memo: String, -) - diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/PlanTrackResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/PlanTrackResponse.kt deleted file mode 100644 index 1c956a16..00000000 --- a/app/src/main/java/umc/com/mobile/project/data/model/plan/PlanTrackResponse.kt +++ /dev/null @@ -1,14 +0,0 @@ -package umc.com.mobile.project.data.model.plan - -data class PlanTrackResponse( - val isSuccess: Boolean, - val code: String, - val message: String, - val result: List, -) - -data class TrackResult( - val trackCode: String, - val trackName: String, -) - diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/SemesterTimeResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/SemesterTimeResponse.kt deleted file mode 100644 index 7a9e4924..00000000 --- a/app/src/main/java/umc/com/mobile/project/data/model/plan/SemesterTimeResponse.kt +++ /dev/null @@ -1,17 +0,0 @@ -package umc.com.mobile.project.data.model.plan - -data class SemesterTimeResponse( - val isSuccess: Boolean, - val code: String, - val message: String, - val result: List, -) { - - -} - -data class semesterResult( - val hakkiNum: String, - val hakkiText: String, -) - diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/TimeInfoResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/TimeInfoResponse.kt deleted file mode 100644 index c0bbf970..00000000 --- a/app/src/main/java/umc/com/mobile/project/data/model/plan/TimeInfoResponse.kt +++ /dev/null @@ -1,7 +0,0 @@ -package umc.com.mobile.project.data.model.plan - -data class TimeInfoResponse( - val type: String, - val name: String, - val credit:String, -) diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/UPlicenseResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/UPlicenseResponse.kt deleted file mode 100644 index a62acc4b..00000000 --- a/app/src/main/java/umc/com/mobile/project/data/model/plan/UPlicenseResponse.kt +++ /dev/null @@ -1,14 +0,0 @@ -package umc.com.mobile.project.data.model.plan - -data class UPlicenseResponse( - val isSuccess: Boolean, - val code: String, - val message: String, - val result: List, -) - -data class Result( - val certificateId: Long, - val name: String, - val date: String, -) diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/UpTimeResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/UpTimeResponse.kt deleted file mode 100644 index 832cd3c3..00000000 --- a/app/src/main/java/umc/com/mobile/project/data/model/plan/UpTimeResponse.kt +++ /dev/null @@ -1,16 +0,0 @@ -package umc.com.mobile.project.data.model.plan - -data class UpTimeResponse( - val isSuccess: Boolean, - val code: String, - val message: String, - val result: List, -) - -data class upTimeResult( - val subjectId: Long, - val type: String, - val name: String, - val credit: Long, -) - diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/freememo/EditMemoRequest.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/freememo/EditMemoRequest.kt new file mode 100644 index 00000000..2592e6ae --- /dev/null +++ b/app/src/main/java/umc/com/mobile/project/data/model/plan/freememo/EditMemoRequest.kt @@ -0,0 +1,6 @@ +package umc.com.mobile.project.data.model.plan.freememo + +data class EditMemoRequest( + val memo: String +) + diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/freememo/PlanFreeRequest.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/freememo/PlanFreeRequest.kt new file mode 100644 index 00000000..33d2aded --- /dev/null +++ b/app/src/main/java/umc/com/mobile/project/data/model/plan/freememo/PlanFreeRequest.kt @@ -0,0 +1,6 @@ +package umc.com.mobile.project.data.model.plan.freememo + +data class PlanFreeRequest( + val memo: String, +) + diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/freememo/PlanFreeResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/freememo/PlanFreeResponse.kt new file mode 100644 index 00000000..4fe721a0 --- /dev/null +++ b/app/src/main/java/umc/com/mobile/project/data/model/plan/freememo/PlanFreeResponse.kt @@ -0,0 +1,13 @@ +package umc.com.mobile.project.data.model.plan.freememo + +data class PlanFreeResponse( + val isSuccess: Boolean, + val code: String, + val message: String, + val result: FreeInfo, +) + +data class FreeInfo( + val memo: String, +) + diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/license/BringlicenseResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/license/BringlicenseResponse.kt new file mode 100644 index 00000000..77dc90d8 --- /dev/null +++ b/app/src/main/java/umc/com/mobile/project/data/model/plan/license/BringlicenseResponse.kt @@ -0,0 +1,14 @@ +package umc.com.mobile.project.data.model.plan.license + +data class BringlicenseResponse( + val isSuccess: Boolean, + val code: String, + val message: String, + val result: List, +) + +data class BringResult( + val certificateId: Long, + val createdAt: String, +) + diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/CertificateLicenseRequest.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/license/CertificateLicenseRequest.kt similarity index 67% rename from app/src/main/java/umc/com/mobile/project/data/model/plan/CertificateLicenseRequest.kt rename to app/src/main/java/umc/com/mobile/project/data/model/plan/license/CertificateLicenseRequest.kt index 4a49f7ef..0a750f0d 100644 --- a/app/src/main/java/umc/com/mobile/project/data/model/plan/CertificateLicenseRequest.kt +++ b/app/src/main/java/umc/com/mobile/project/data/model/plan/license/CertificateLicenseRequest.kt @@ -1,4 +1,4 @@ -package umc.com.mobile.project.data.model.plan +package umc.com.mobile.project.data.model.plan.license data class CertificateLicenseRequest( val certificateId: Long, diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/CertificateResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/license/CertificateResponse.kt similarity index 81% rename from app/src/main/java/umc/com/mobile/project/data/model/plan/CertificateResponse.kt rename to app/src/main/java/umc/com/mobile/project/data/model/plan/license/CertificateResponse.kt index 3b8857e3..13916beb 100644 --- a/app/src/main/java/umc/com/mobile/project/data/model/plan/CertificateResponse.kt +++ b/app/src/main/java/umc/com/mobile/project/data/model/plan/license/CertificateResponse.kt @@ -1,4 +1,4 @@ -package umc.com.mobile.project.data.model.plan +package umc.com.mobile.project.data.model.plan.license data class CertificateResponse( val isSuccess: Boolean, diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/DeleteLicense.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/license/DeleteLicense.kt similarity index 81% rename from app/src/main/java/umc/com/mobile/project/data/model/plan/DeleteLicense.kt rename to app/src/main/java/umc/com/mobile/project/data/model/plan/license/DeleteLicense.kt index efd8410c..b4852f3a 100644 --- a/app/src/main/java/umc/com/mobile/project/data/model/plan/DeleteLicense.kt +++ b/app/src/main/java/umc/com/mobile/project/data/model/plan/license/DeleteLicense.kt @@ -1,4 +1,4 @@ -package umc.com.mobile.project.data.model +package umc.com.mobile.project.data.model.plan.license data class DeleteLicense( val isSuccess: Boolean, diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/SavelicenseRequest.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/license/SavelicenseRequest.kt similarity index 64% rename from app/src/main/java/umc/com/mobile/project/data/model/plan/SavelicenseRequest.kt rename to app/src/main/java/umc/com/mobile/project/data/model/plan/license/SavelicenseRequest.kt index 478df2ed..215caf52 100644 --- a/app/src/main/java/umc/com/mobile/project/data/model/plan/SavelicenseRequest.kt +++ b/app/src/main/java/umc/com/mobile/project/data/model/plan/license/SavelicenseRequest.kt @@ -1,6 +1,4 @@ -package umc.com.mobile.project.data.model.plan - -import java.time.LocalDate +package umc.com.mobile.project.data.model.plan.license data class SaveInfo( diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/license/UPlicenseResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/license/UPlicenseResponse.kt new file mode 100644 index 00000000..9bb5389b --- /dev/null +++ b/app/src/main/java/umc/com/mobile/project/data/model/plan/license/UPlicenseResponse.kt @@ -0,0 +1,14 @@ +package umc.com.mobile.project.data.model.plan.license + +data class UPlicenseResponse( + val isSuccess: Boolean, + val code: String, + val message: String, + val result: List, +) + +data class Result( + val certificateId: Long, + val name: String, + val date: String, +) diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/AddTimeResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/AddTimeResponse.kt similarity index 84% rename from app/src/main/java/umc/com/mobile/project/data/model/plan/AddTimeResponse.kt rename to app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/AddTimeResponse.kt index e210bcae..04d02d0d 100644 --- a/app/src/main/java/umc/com/mobile/project/data/model/plan/AddTimeResponse.kt +++ b/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/AddTimeResponse.kt @@ -1,4 +1,4 @@ -package umc.com.mobile.project.data.model.plan +package umc.com.mobile.project.data.model.plan.timetable data class AddTimeResponse( val isSuccess: Boolean, diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/DeleteTimeTableResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/DeleteTimeTableResponse.kt new file mode 100644 index 00000000..d2aa129c --- /dev/null +++ b/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/DeleteTimeTableResponse.kt @@ -0,0 +1,15 @@ +package umc.com.mobile.project.data.model.plan.timetable + +data class DeleteTimeTableResponse( + val isSuccess: Boolean, + val code: String, + val message: String, + val result: List +) + +data class DeleteResultDTO( + val subjectId: Int, + val type: String, + val name: String, + val credit: Int +) \ No newline at end of file diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/PutTimeTableResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/PutTimeTableResponse.kt new file mode 100644 index 00000000..abbc733f --- /dev/null +++ b/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/PutTimeTableResponse.kt @@ -0,0 +1,17 @@ +package umc.com.mobile.project.data.model.plan.timetable + +data class PutTimeTableResponse ( + val isSuccess: Boolean, + val code: String, + val message: String, + val result: DeleteResult +) + +data class DeleteResult( + val updateResponseDtos: List +) + +data class UpdateResponseDto( + val subjectId: Int, + val updatedAt: String +) \ No newline at end of file diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/SearchSemesterResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/SearchSemesterResponse.kt new file mode 100644 index 00000000..daa81dc0 --- /dev/null +++ b/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/SearchSemesterResponse.kt @@ -0,0 +1,14 @@ +package umc.com.mobile.project.data.model.plan.timetable + +data class SearchSemesterResponse( + val isSuccess: Boolean, + val code: String, + val message: String, + val result: List, +) + +data class semesterResult( + val hakkiNum: String, + val hakkiText: String, +) + diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/SearchSubjectResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/SearchSubjectResponse.kt new file mode 100644 index 00000000..4e72df56 --- /dev/null +++ b/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/SearchSubjectResponse.kt @@ -0,0 +1,15 @@ +package umc.com.mobile.project.data.model.plan.timetable + +data class SearchSubjectResponse( + val isSuccess: Boolean, + val code: String, + val message: String, + val result: List, +) + +data class TimeResult( + val searchGrade: String, + val searchType: String, + val searchName: String, + val searchCredit: String, +) diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/SearchTrackResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/SearchTrackResponse.kt new file mode 100644 index 00000000..bc5052f5 --- /dev/null +++ b/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/SearchTrackResponse.kt @@ -0,0 +1,14 @@ +package umc.com.mobile.project.data.model.plan.timetable + +data class PlanTrackResponse( + val isSuccess: Boolean, + val code: String, + val message: String, + val result: List, +) + +data class TrackResult( + val trackCode: String, + val trackName: String, +) + diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/TimeTableResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/TimeTableResponse.kt new file mode 100644 index 00000000..852ffdc5 --- /dev/null +++ b/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/TimeTableResponse.kt @@ -0,0 +1,16 @@ +package umc.com.mobile.project.data.model.plan.timetable + +data class TimeTableResponse( + val isSuccess: Boolean, + val code: String, + val message: String, + val result: List, +) + +data class UpTimeResult( + val subjectId: Int, + val type: String, + val name: String, + val credit: Int, +) + diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/request/AddTimeRequest.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/request/AddTimeRequest.kt new file mode 100644 index 00000000..b4bda535 --- /dev/null +++ b/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/request/AddTimeRequest.kt @@ -0,0 +1,18 @@ +package umc.com.mobile.project.data.model.plan.timetable.request + +data class AddTimeRequest( + val semesterDto: SemesterDto, + val subjectDtoList: List, +) + +data class SemesterDto( + val grade: Int, + val semester: Int, +) + +data class SubjectDtoList( + val type: String, + val name: String, + val credit: String, +) + diff --git a/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/request/PutTimeTableRequest.kt b/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/request/PutTimeTableRequest.kt new file mode 100644 index 00000000..19b58d9b --- /dev/null +++ b/app/src/main/java/umc/com/mobile/project/data/model/plan/timetable/request/PutTimeTableRequest.kt @@ -0,0 +1,19 @@ +package umc.com.mobile.project.data.model.plan.timetable.request + +data class PutTimeTableRequest( + val semesterDto: Semester, + val subjectDtoList: List +) + +data class Semester( + val grade: Int, + val semester: Int +) + +data class SubjectDTO( + val subjectId: Int, + val type: String, + val name: String, + val credit: Int +) + diff --git a/app/src/main/java/umc/com/mobile/project/data/network/api/PlanApi.kt b/app/src/main/java/umc/com/mobile/project/data/network/api/PlanApi.kt index ad4ac32d..e8ad5b7c 100644 --- a/app/src/main/java/umc/com/mobile/project/data/network/api/PlanApi.kt +++ b/app/src/main/java/umc/com/mobile/project/data/network/api/PlanApi.kt @@ -6,74 +6,92 @@ import retrofit2.http.Body import retrofit2.http.DELETE import retrofit2.http.PATCH import retrofit2.http.POST -import retrofit2.http.Path +import retrofit2.http.PUT import retrofit2.http.Query -import umc.com.mobile.project.data.model.DeleteLicense -import umc.com.mobile.project.data.model.plan.AddTimeRequest -import umc.com.mobile.project.data.model.plan.AddTimeResponse -import umc.com.mobile.project.data.model.plan.BringlicenseResponse -import umc.com.mobile.project.data.model.plan.CertificateLicenseRequest -import umc.com.mobile.project.data.model.plan.CertificateResponse -import umc.com.mobile.project.data.model.plan.ListTimeResponse -import umc.com.mobile.project.data.model.plan.PlanFreeRequest -import umc.com.mobile.project.data.model.plan.PlanFreeResponse -import umc.com.mobile.project.data.model.plan.PlanTrackResponse -import umc.com.mobile.project.data.model.plan.SaveInfo -import umc.com.mobile.project.data.model.plan.SemesterTimeResponse -import umc.com.mobile.project.data.model.plan.UPlicenseResponse -import umc.com.mobile.project.data.model.plan.EditMemoRequest -import umc.com.mobile.project.data.model.plan.UpTimeResponse +import umc.com.mobile.project.data.model.plan.license.DeleteLicense +import umc.com.mobile.project.data.model.plan.timetable.request.AddTimeRequest +import umc.com.mobile.project.data.model.plan.timetable.AddTimeResponse +import umc.com.mobile.project.data.model.plan.license.BringlicenseResponse +import umc.com.mobile.project.data.model.plan.license.CertificateLicenseRequest +import umc.com.mobile.project.data.model.plan.license.CertificateResponse +import umc.com.mobile.project.data.model.plan.timetable.DeleteTimeTableResponse +import umc.com.mobile.project.data.model.plan.freememo.PlanFreeRequest +import umc.com.mobile.project.data.model.plan.freememo.PlanFreeResponse +import umc.com.mobile.project.data.model.plan.timetable.PlanTrackResponse +import umc.com.mobile.project.data.model.plan.license.SaveInfo +import umc.com.mobile.project.data.model.plan.license.UPlicenseResponse +import umc.com.mobile.project.data.model.plan.freememo.EditMemoRequest +import umc.com.mobile.project.data.model.plan.timetable.request.PutTimeTableRequest +import umc.com.mobile.project.data.model.plan.timetable.PutTimeTableResponse +import umc.com.mobile.project.data.model.plan.timetable.SearchSemesterResponse +import umc.com.mobile.project.data.model.plan.timetable.SearchSubjectResponse +import umc.com.mobile.project.data.model.plan.timetable.TimeTableResponse interface PlanApi { - @GET("plans/certifications") - fun getUPlicense(): Call - - - @POST("plans/certifications") - fun saveLicense(@Body request: List): Call - - - - - @GET("/plans/timetable/searchSubject") - fun getListTime(@Query("hakki") hakki:String, @Query("track") track : String) : Call - - @GET("/plans/timetable/searchTrack") - fun getTrackInfo(@Query("hakki") hakki: String) : Call - - @GET("/plans/timetable/searchHakki") - fun getSemesterInfo():Call - - @POST("/plans/timetable") - fun addTime(@Body addTimeRequest: AddTimeRequest): Call - - @GET("/plans/memo") - fun getFreeInfo() : Call - - @POST("/plans/memo") - fun postFreeMemo(@Body request: PlanFreeRequest): Call - - @GET("/plans/timetable") - fun getUptime(@Query("grade") grade:Int, @Query("semester") semester : Int):Call - - @PATCH("/plans/memo") - fun editMemo(@Body editMemoRequest: EditMemoRequest) : Call - - @PATCH("/plans/certifications") - fun certificateLicense(@Body request: List) : Call - - @DELETE("/plans/certifications") - fun deleteLicense(@Query("certificateId") certificateId: Long): Call - - - - - - - - - - - + /** + * 시간표 + */ + @POST("/plans/timetable") + fun addTime(@Body addTimeRequest: AddTimeRequest): Call + + @GET("/plans/timetable") + fun getUptime( + @Query("grade") grade: Int, + @Query("semester") semester: Int + ): Call + + @PUT("/plans/timetable") + fun putTimeTable( + @Body request: PutTimeTableRequest + ): Call + + @DELETE("/plans/timetable") + fun deleteTimeTable( + @Query("grade") grade: Int, + @Query("semester") semester: Int, + @Query("subjectId") subjectId: Int + ): Call + + /** + * 시간표 검색 + */ + @GET("/plans/timetable/searchSubject") + fun getListTime( + @Query("hakki") hakki: String, + @Query("track") track: String + ): Call + + @GET("/plans/timetable/searchTrack") + fun getTrackInfo(@Query("hakki") hakki: String): Call + + @GET("/plans/timetable/searchHakki") + fun getSemesterInfo(): Call + + /** + * 자유 메모 + */ + @GET("/plans/memo") + fun getFreeInfo(): Call + + @POST("/plans/memo") + fun postFreeMemo(@Body request: PlanFreeRequest): Call + + @PATCH("/plans/memo") + fun editMemo(@Body editMemoRequest: EditMemoRequest): Call + + /** + * 자격증 + */ + @GET("plans/certifications") + fun getUPlicense(): Call + + @POST("plans/certifications") + fun saveLicense(@Body request: List): Call + + @PATCH("/plans/certifications") + fun certificateLicense(@Body request: List): Call + + @DELETE("/plans/certifications") + fun deleteLicense(@Query("certificateId") certificateId: Long): Call } \ No newline at end of file diff --git a/app/src/main/java/umc/com/mobile/project/ui/gradInfo/CompletionStateFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/gradInfo/CompletionStateFragment.kt index a7805d80..2816fe36 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/gradInfo/CompletionStateFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/gradInfo/CompletionStateFragment.kt @@ -27,24 +27,10 @@ class CompletionStateFragment : Fragment() { viewModel.completionInfo.observe(viewLifecycleOwner, Observer { it -> val completionDtoMap: List>>? = it?.result?.completionDtoMap val basicKeyList = listOf("필수교양(기초)", "필수(기초)교양", "필수교양") + /** * 필수 교양 (기초) */ -/* completionDtoMap?.firstOrNull { it.containsKey("필수교양(기초)") }?.get("필수교양(기초)")?.let { requiredBasicCourses1 -> - binding.tvBasic1.text = requiredBasicCourses1[0] - binding.tvBasic1Content.text = requiredBasicCourses1[1] - binding.tvBasic2.text = requiredBasicCourses1[2] - binding.tvBasic2Content.text = requiredBasicCourses1[3] - binding.tvBasic3.text = requiredBasicCourses1[4] - binding.tvBasic3Content.text = requiredBasicCourses1[5] - -// binding.tvBasic4.text = requiredBasicCourses1[6] -// binding.tvBasic4Content.text = requiredBasicCourses1[7] -// binding.tvBasic5.text = requiredBasicCourses1[8] -// binding.tvBasic5Content.text = requiredBasicCourses1[9] -// binding.tvBasic6.text = requiredBasicCourses1[10] -// binding.tvBasic6Content.text = requiredBasicCourses1[11] - }*/ val requiredBasicCourses = basicKeyList.mapNotNull { key -> completionDtoMap?.firstOrNull { it.containsKey(key) }?.get(key) } @@ -68,6 +54,7 @@ class CompletionStateFragment : Fragment() { /** * 필수 교양 (소양) - 나단 */ + /* completionDtoMap?.firstOrNull { it.containsKey("필수교양(소양)") }?.get("필수교양(소양)")?.let { requiredBasicCourses2 -> binding.tvSoyang1.text = requiredBasicCourses2[0] binding.tvSoyang1Content.text = requiredBasicCourses2[1] @@ -75,11 +62,11 @@ class CompletionStateFragment : Fragment() { binding.tvSoyang2Content.text = requiredBasicCourses2[3] binding.tvTotalScore.text = requiredBasicCourses2[5] } + */ /** * 필수 교양 (소양) - 준현 */ - /* completionDtoMap?.firstOrNull { it.containsKey("토대교양") }?.get("토대교양")?.let { requiredBasicCourses2 -> binding.tvSoyang1.text = requiredBasicCourses2[0] binding.tvSoyang1Content.text = requiredBasicCourses2[1] @@ -89,7 +76,6 @@ class CompletionStateFragment : Fragment() { completionDtoMap?.firstOrNull { it.containsKey("소 계") }?.get("소 계")?.let { binding.tvTotalScore.text = it[0] } - */ /** * 트랙 1, 트랙 2 diff --git a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanFreeFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/plan/PlanFreeFragment.kt index ae8e0a56..0cc7f367 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanFreeFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/plan/PlanFreeFragment.kt @@ -7,10 +7,9 @@ import android.view.ViewGroup import android.widget.Toast import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels -import androidx.fragment.app.viewModels -import umc.com.mobile.project.data.model.plan.PlanFreeRequest +import umc.com.mobile.project.data.model.plan.freememo.PlanFreeRequest import umc.com.mobile.project.databinding.FragmentPlanFreeBinding -import umc.com.mobile.project.ui.plan.PlanViewModel +import umc.com.mobile.project.ui.plan.viewmodel.PlanViewModel class PlanFreeFragment : Fragment() { private var _binding: FragmentPlanFreeBinding? = null diff --git a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanSemesterFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/plan/PlanSemesterFragment.kt index 8c754399..b8ec7328 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanSemesterFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/plan/PlanSemesterFragment.kt @@ -6,12 +6,13 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels -import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.LinearLayoutManager import umc.com.mobile.project.databinding.SemesterChooseBinding import umc.com.mobile.project.R +import umc.com.mobile.project.ui.plan.adapter.PlanSemesterAdapter +import umc.com.mobile.project.ui.plan.viewmodel.PlanViewModel class PlanSemesterFragment : Fragment() { diff --git a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanSettingFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/plan/PlanSettingFragment.kt index 931867d9..0484f6d4 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanSettingFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/plan/PlanSettingFragment.kt @@ -11,6 +11,8 @@ import androidx.viewpager2.widget.ViewPager2 import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayoutMediator import umc.com.mobile.project.databinding.PlanTimeTabMainBinding +import umc.com.mobile.project.ui.plan.adapter.PlanVPAdapter +import umc.com.mobile.project.ui.plan.viewmodel.PlanViewModel class PlanSettingFragment : Fragment() { private var _binding: PlanTimeTabMainBinding? = null diff --git a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanTimeAdapter.kt b/app/src/main/java/umc/com/mobile/project/ui/plan/PlanTimeAdapter.kt deleted file mode 100644 index f1e4c6a9..00000000 --- a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanTimeAdapter.kt +++ /dev/null @@ -1,48 +0,0 @@ -package umc.com.mobile.project.ui.plan - -import android.view.LayoutInflater -import android.view.ViewGroup -import androidx.recyclerview.widget.DiffUtil -import androidx.recyclerview.widget.ListAdapter -import androidx.recyclerview.widget.RecyclerView -import umc.com.mobile.project.data.model.plan.TimeInfoResponse -import umc.com.mobile.project.databinding.ItemPlanTimeBinding - -class PlanTimeAdapter(private var addnewtime: List = ArrayList()): ListAdapter(UpTimeResultDiffCallback()) { - - class ViewHolder(private val binding: ItemPlanTimeBinding) : RecyclerView.ViewHolder(binding.root) { - fun bind(item: TimeInfoResponse) { - binding.timeKindTitle.text = item.type - binding.timeClassTitle.text = item.name - // 학점을 문자열로 변환하여 표시 - binding.timeGradeTitle.text = item.credit.toString() - } - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - val binding = ItemPlanTimeBinding.inflate(LayoutInflater.from(parent.context), parent, false) - return ViewHolder(binding) - } - - override fun onBindViewHolder(holder: ViewHolder, position: Int) { - val item = getItem(position) - holder.bind(item) - } - - fun updateTimeList(addnewtime: ArrayList) { - submitList(addnewtime) - notifyDataSetChanged() - } - - class UpTimeResultDiffCallback : DiffUtil.ItemCallback() { - override fun areItemsTheSame(oldItem: TimeInfoResponse, newItem: TimeInfoResponse): Boolean { - // subjectId를 비교하여 동일한 아이템인지 판별 - return oldItem.name== newItem.name - } - - override fun areContentsTheSame(oldItem: TimeInfoResponse, newItem: TimeInfoResponse): Boolean { - // 내용이 동일한지 비교 - return oldItem == newItem - } - } -} diff --git a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanTimeFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/plan/PlanTimeFragment.kt index ac6c2a8c..78bf9223 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanTimeFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/plan/PlanTimeFragment.kt @@ -1,82 +1,87 @@ package umc.com.mobile.project.ui.plan import android.os.Bundle -import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels -import androidx.fragment.app.viewModels import androidx.recyclerview.widget.LinearLayoutManager import umc.com.mobile.project.R -import umc.com.mobile.project.data.model.plan.TimeInfoResponse +import umc.com.mobile.project.data.model.plan.timetable.TimeResult +import umc.com.mobile.project.data.model.plan.timetable.UpTimeResult import umc.com.mobile.project.databinding.PlanSubjectListBinding import umc.com.mobile.project.ui.common.NavigationUtil.navigate +import umc.com.mobile.project.ui.plan.adapter.PlanRecyclerAdapter +import umc.com.mobile.project.ui.plan.viewmodel.PlanViewModel class PlanTimeFragment : Fragment() { - private var _binding: PlanSubjectListBinding? = null - private val viewModel: PlanViewModel by activityViewModels() - private val binding get() = _binding!! - - override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? - ): View { - _binding = PlanSubjectListBinding.inflate(inflater, container, false) - return binding.root - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - setupRecyclerView() - observeViewModel() - setupNavigation() - } - - private fun setupRecyclerView() { - val adapter = PlanRecyclerAdapter(emptyList(), onAddButtonClicked = { timeResult -> - - if (timeResult != null) { - viewModel.setSelectedTimeResult(timeResult = TimeInfoResponse(timeResult.searchType,timeResult.searchName,timeResult.searchCredit)) - } - - - }) - - binding.recyclerView.apply { - this.adapter = adapter - layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) - } - } - - private fun observeViewModel() { - // 학기(hakki)와 트랙(trackId) 정보 변경 감지 - viewModel.hakki.observe(viewLifecycleOwner) { hakki -> - viewModel.track.value?.let { trackId -> - if (hakki.isNotEmpty() && trackId.isNotEmpty()) { - viewModel.getListTimeInfo(hakki, trackId) - } - } - } - - // listTimeInfo LiveData 관찰 - viewModel.listTimeInfo.observe(viewLifecycleOwner) { timeListResponse -> - (binding.recyclerView.adapter as PlanRecyclerAdapter).updateTimeList(timeListResponse?.result ?: emptyList()) - } - } - - private fun setupNavigation() { - - - binding.planSubjectListSemester.setOnClickListener { - navigate(R.id.action_planSettingFragment_to_planSemesterFragment) - } - } - - override fun onDestroyView() { - super.onDestroyView() - _binding = null - } + private var _binding: PlanSubjectListBinding? = null + private val viewModel: PlanViewModel by activityViewModels() + private val binding get() = _binding!! + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + _binding = PlanSubjectListBinding.inflate(inflater, container, false) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + setupRecyclerView() + observeViewModel() + setupNavigation() + } + + private fun setupRecyclerView() { + val adapter = PlanRecyclerAdapter(emptyList(), onAddButtonClicked = { timeResult -> + if (timeResult != null) { + viewModel.setSelectedTimeResult( + timeResult = TimeResult( + timeResult.searchGrade, + timeResult.searchType, + timeResult.searchName, + timeResult.searchCredit + ) + ) + } + }) + + binding.recyclerView.apply { + this.adapter = adapter + layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) + } + } + + private fun observeViewModel() { + // 학기(hakki)와 트랙(trackId) 정보 변경 감지 + viewModel.hakki.observe(viewLifecycleOwner) { hakki -> + viewModel.track.value?.let { trackId -> + if (hakki.isNotEmpty() && trackId.isNotEmpty()) { + viewModel.getListTimeInfo(hakki, trackId) + } + } + } + + // listTimeInfo LiveData 관찰 + viewModel.listTimeInfo.observe(viewLifecycleOwner) { timeListResponse -> + (binding.recyclerView.adapter as PlanRecyclerAdapter).updateTimeList( + timeListResponse?.result ?: emptyList() + ) + } + } + + private fun setupNavigation() { + binding.planSubjectListSemester.setOnClickListener { + navigate(R.id.action_planSettingFragment_to_planSemesterFragment) + } + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } } diff --git a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanTimetableFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/plan/PlanTimetableFragment.kt index 8be7cf34..ab804317 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanTimetableFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/plan/PlanTimetableFragment.kt @@ -10,10 +10,13 @@ import android.widget.ArrayAdapter import android.widget.Toast import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels +import androidx.lifecycle.Observer import androidx.recyclerview.widget.LinearLayoutManager import umc.com.mobile.project.R import umc.com.mobile.project.databinding.PlanTimeMainBinding import umc.com.mobile.project.ui.common.NavigationUtil.navigate +import umc.com.mobile.project.ui.plan.adapter.PlanTimeAdapter +import umc.com.mobile.project.ui.plan.viewmodel.PlanViewModel class PlanTimetableFragment : Fragment() { @@ -29,6 +32,7 @@ class PlanTimetableFragment : Fragment() { savedInstanceState: Bundle? ): View { _binding = PlanTimeMainBinding.inflate(inflater, container, false) + return binding.root } @@ -37,7 +41,6 @@ class PlanTimetableFragment : Fragment() { setupRecyclerView() observeSelectedTimeResults() - val spinner = binding.spinnerPlanTimeTrackSemester val adapter = ArrayAdapter.createFromResource( requireContext(), @@ -47,8 +50,6 @@ class PlanTimetableFragment : Fragment() { adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) spinner.adapter = adapter - // 선택한 항목 리스너 추가 (필요한 경우) - spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { override fun onItemSelected( parent: AdapterView<*>?, @@ -100,8 +101,6 @@ class PlanTimetableFragment : Fragment() { } } - - } override fun onNothingSelected(parent: AdapterView<*>?) { @@ -109,22 +108,17 @@ class PlanTimetableFragment : Fragment() { } } binding.timeStoreButton.setOnClickListener { - // grade와 semester가 선택되었는지 확인 val grade = viewModel.grade.value val semester = viewModel.semester.value if (grade == null || semester == null) { - // 학년 또는 학기가 선택되지 않았다면 토스트 메시지 표시 Toast.makeText(context, "학년과 학기를 선택해주세요.", Toast.LENGTH_SHORT).show() } else { - // 선택된 경우에만 서버로 데이터 전송 처리 viewModel.sendAddTimeRequest() viewModel.getTimeInfo(grade, semester) } } - - binding.titleMoveTimetable.setOnClickListener { navigate(R.id.action_planTimetableFragment_to_planSettingFragment) @@ -132,20 +126,14 @@ class PlanTimetableFragment : Fragment() { } - - - private fun observeSelectedTimeResults() { viewModel.selectedTimeResults.observe(viewLifecycleOwner) { selectedTimeResults -> (binding.recyclerView.adapter as PlanTimeAdapter).updateTimeList(selectedTimeResults) } } - // 추가하기 버튼으로 시간표에 과목 업데이트 private fun setupRecyclerView() { - // 초기 데이터 리스트를 비어 있는 리스트로 설정합니다. - // 데이터가 준비되면, 나중에 observeSelectedTimeResults 함수 내에서 submitList를 통해 업데이트합니다. - adapter = PlanTimeAdapter(emptyList()) + adapter = PlanTimeAdapter(viewModel) binding.recyclerView.layoutManager = LinearLayoutManager(context) binding.recyclerView.adapter = adapter } diff --git a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanTrackFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/plan/PlanTrackFragment.kt index d521e66d..a134152a 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanTrackFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/plan/PlanTrackFragment.kt @@ -5,15 +5,13 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels -import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.LinearLayoutManager import umc.com.mobile.project.R -import umc.com.mobile.project.data.model.plan.TrackResult +import umc.com.mobile.project.data.model.plan.timetable.TrackResult import umc.com.mobile.project.databinding.PlanTimeChooseTrackBinding -import umc.com.mobile.project.ui.plan.PlanSettingFragment -import umc.com.mobile.project.ui.plan.PlanTrackAdapter -import umc.com.mobile.project.ui.plan.PlanViewModel +import umc.com.mobile.project.ui.plan.adapter.PlanTrackAdapter +import umc.com.mobile.project.ui.plan.viewmodel.PlanViewModel class PlanTrackFragment : Fragment() { private var _binding: PlanTimeChooseTrackBinding? = null diff --git a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanViewModel.kt b/app/src/main/java/umc/com/mobile/project/ui/plan/PlanViewModel.kt deleted file mode 100644 index 599d9e6b..00000000 --- a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanViewModel.kt +++ /dev/null @@ -1,568 +0,0 @@ - package umc.com.mobile.project.ui.plan - - - import android.util.Log - import androidx.lifecycle.LiveData - import androidx.lifecycle.MutableLiveData - import androidx.lifecycle.ViewModel - import retrofit2.Call - import retrofit2.Callback - import retrofit2.Response - import umc.com.mobile.project.data.model.DeleteLicense - import umc.com.mobile.project.data.model.plan.AddTimeRequest - import umc.com.mobile.project.data.model.plan.AddTimeResponse - import umc.com.mobile.project.data.model.plan.BringlicenseResponse - import umc.com.mobile.project.data.model.plan.CertificateLicenseRequest - import umc.com.mobile.project.data.model.plan.CertificateResponse - import umc.com.mobile.project.data.model.plan.EditMemoRequest - import umc.com.mobile.project.data.model.plan.ListTimeResponse - import umc.com.mobile.project.data.model.plan.PlanFreeRequest - import umc.com.mobile.project.data.model.plan.PlanFreeResponse - import umc.com.mobile.project.data.model.plan.PlanTrackResponse - import umc.com.mobile.project.data.model.plan.SaveInfo - - import umc.com.mobile.project.data.model.plan.SavelicenseRequest - import umc.com.mobile.project.data.model.plan.SemesterDto - import umc.com.mobile.project.data.model.plan.SemesterTimeResponse - import umc.com.mobile.project.data.model.plan.SubjectDtoList - import umc.com.mobile.project.data.model.plan.TimeInfoResponse - - import umc.com.mobile.project.data.model.plan.UPlicenseResponse - import umc.com.mobile.project.data.model.plan.UpTimeResponse - import umc.com.mobile.project.data.network.ApiClient - import umc.com.mobile.project.data.network.api.PlanApi - - class PlanViewModel : ViewModel() { - - - //api - private val planApiService = ApiClient.createService() - - private val _upTimeResponse: MutableLiveData = MutableLiveData() - val upTimeResponse: LiveData - get() = upTimeResponse - - private val _grade: MutableLiveData = MutableLiveData() - val grade: LiveData - get() = _grade - - private val _semester: MutableLiveData = MutableLiveData() - val semester: LiveData - get() = _semester - fun setGradeAndSemester(grade: Int, semester: Int) { - _grade.value = grade - _semester.value = semester - } - - //viewmodel 에 데이터 저장, 시간표 조회, 과목 검색 - private val _selectedTimeResults = MutableLiveData>() - val selectedTimeResults: LiveData> = _selectedTimeResults - - fun setSelectedTimeResult(timeResult:TimeInfoResponse) { - val currentList = _selectedTimeResults.value ?: ArrayList() - currentList.add(timeResult) - _selectedTimeResults.value = currentList - Log.d("PlanTimetable", "setSelectedTimeResult: $timeResult") - } - - - - - private val _planFreeInfo: MutableLiveData = MutableLiveData() - val planFreeInfo: LiveData - get() = _planFreeInfo - - private val _postMemoResult = MutableLiveData() - val postMemoResult: LiveData - get() = _postMemoResult - - private val _hakki: MutableLiveData = MutableLiveData() - val hakki: LiveData - get() = _hakki - - private val _track: MutableLiveData = MutableLiveData() - val track: LiveData - get() = _track - - - private val _planSemesterInfo: MutableLiveData = MutableLiveData() - val planSemesterInfo: LiveData - get() = _planSemesterInfo - - private val _planTrackInfo: MutableLiveData = MutableLiveData() - val planTrackInfo: LiveData - get() = _planTrackInfo - - private val _timeTableInfo = MutableLiveData() - val timeTableInfo: LiveData = _timeTableInfo - - - private val _planTimeStatus: MutableLiveData = MutableLiveData() - val planTimeStatus: LiveData - get() = _planTimeStatus - - private val _bringLicenseInfo = MutableLiveData() - - - private val _listTimeInfo = MutableLiveData() - - val listTimeInfo: LiveData - get() = _listTimeInfo - - val bringLicenseInfo: LiveData - get() = _bringLicenseInfo - - - private val _licenseInfo: MutableLiveData = MutableLiveData() - val licenseInfo: LiveData - get() = _licenseInfo - - - private val _error: MutableLiveData = MutableLiveData() - val error: LiveData - get() = _error - - - private val _savelicenseInfo: MutableLiveData = MutableLiveData() - val savelicenseInfo: LiveData - get() = _savelicenseInfo - - private val _certificateResponse = MutableLiveData() - val certificateResponse: LiveData - get() = _certificateResponse - - - - - // 기존에 있던 text LiveData - private val _text = MutableLiveData().apply { - value = "This is Plan Fragment" - } - val text: LiveData = _text - - // 새로 추가된 isFilledAllOptions LiveData - private val _isFilledAllOptions = MutableLiveData().apply { - value = false // 초기값 설정 - } - val isFilledAllOptions: LiveData = _isFilledAllOptions - - // isFilledAllOptions의 값을 업데이트하는 메서드 - fun updateIsFilledAllOptions(isFilled: Boolean) { - _isFilledAllOptions.value = isFilled - } - fun resetSemesterSelection() { - // 학기 정보 관련 상태 초기화 - _planSemesterInfo.postValue(null) // 학기 정보 초기화 - _hakki.postValue("") // 학기 식별자 초기화 (또는 적절한 초기 값으로 설정) - } - - fun resetTrackSelection() { - // 선택된 트랙 정보 초기화 - _track.postValue("") // 트랙 식별자 초기화 (또는 적절한 초기 값으로 설정) - } - - fun setHakki(hakki: String) { - _hakki.value = hakki - Log.d("hakki value", "setHakki 호출됨: hakki=$hakki") - } - - - fun setHakkiAndTrack(hakki: String, trackId: String) { - Log.d("hakkitrackvalue", "setHakkiAndTrack 호출됨: hakki=$hakki, trackId=$trackId") - _hakki.value = hakki - _track.value = trackId - } - - private val _addTimeResponse = MutableLiveData() - val addTimeResponse: MutableLiveData = _addTimeResponse - - fun addTime(request: AddTimeRequest) { - planApiService.addTime(request).enqueue(object : Callback { - override fun onResponse(call: Call, response: Response) { - if (response.isSuccessful) { - // 서버로부터 응답을 성공적으로 받았을 때 LiveData 업데이트 - Log.d("TimeTableApi", "getListTimeInfo 성공: ${response.body()}") - Log.d("gradesemester", "Sending AddTimeRequest with grade: ${request.semesterDto.grade}, semester: ${request.semesterDto.semester}") - _addTimeResponse.postValue(response.body()) - } else { - // 에러 처리: 실패 응답 처리 - Log.e("TimeTableApi", "Error posting memo: ${response.errorBody()?.string()}") - _addTimeResponse.postValue(null) - } - } - - override fun onFailure(call: Call, t: Throwable) { - // 네트워크 에러 처리: LiveData 업데이트로 에러 상태 전달 가능 - _addTimeResponse.postValue(null) - } - }) - } - fun sendAddTimeRequest() { - val currentSelectedSubjects = _selectedTimeResults.value ?: return - - val grade = _grade.value - val semester = _semester.value - if (grade == null || semester == null) { - - return - } else { - // 로그 출력: grade와 semester 값 로깅 - Log.d("gradesemester1", "Sending AddTimeRequest with grade: $grade, semester: $semester") - } - - val semesterDto = SemesterDto(grade = grade.toLong(), semester = semester.toLong()) - - val request = AddTimeRequest( - semesterDto = semesterDto, - subjectDtoList = currentSelectedSubjects.map { SubjectDtoList(type = it.type, name = it.name, credit = it.credit) } - ) - - addTime(request) - } - - - - - - - fun postMemo(memoRequest: PlanFreeRequest) { - planApiService.postFreeMemo(memoRequest).enqueue(object : Callback { - override fun onResponse( - call: Call, - response: Response - ) { - if (response.isSuccessful) { - // API 호출 성공 시, 성공 LiveData 업데이트 - _postMemoResult.postValue(true) - } else { - // 실패 시, 실패 LiveData 업데이트 - Log.e("PlanViewModel", "Error posting memo: ${response.errorBody()?.string()}") - _postMemoResult.postValue(false) - } - } - - override fun onFailure(call: Call, t: Throwable) { - // 네트워크 오류 등으로 호출 실패 시, 실패 LiveData 업데이트 - _postMemoResult.postValue(false) - } - }) - } - - - fun getFreeInfo() { - planApiService.getFreeInfo().enqueue(object : Callback { - override fun onResponse( - call: Call, - response: Response - ) { - if (response.isSuccessful) { - if (response.body() != null) { - _planFreeInfo.postValue(response.body()) - Log.d("PlanFree", "${response.body()}") - } else { - _error.postValue("서버 응답이 올바르지 않습니다.") - } - } else { - _error.postValue("사용자 정보를 가져오지 못했습니다.") - try { - throw response.errorBody()?.string()?.let { - RuntimeException(it) - } ?: RuntimeException("Unknown error") - } catch (e: Exception) { - Log.e("PlanInfo", "PlanResponse API 오류: ${e.message}") - } - } - } - - override fun onFailure(call: Call, t: Throwable) { - _error.postValue("네트워크 오류: ${t.message}") - Log.d("gradInfo", "completion: ${t.message}") - } - }) - } - - - fun getListTimeInfo(hakki: String, track: String) { - Log.d("PlanViewModel", "getListTimeInfo 호출됨: hakki=$hakki, track=$track") - planApiService.getListTime(hakki, track).enqueue(object : Callback { - override fun onResponse(call: Call, response: Response) { - if (response.isSuccessful && response.body() != null) { - Log.d("PlanViewModel", "getListTimeInfo 성공: ${response.body()}") - _listTimeInfo.postValue(response.body()) - } else { - Log.e("PlanViewModel", "getListTimeInfo 실패: ${response.errorBody()?.string()}") - _error.postValue("리스트 정보를 가져오는데 실패했습니다.") - } - } - - override fun onFailure(call: Call, t: Throwable) { - Log.e("PlanViewModel", "getListTimeInfo 네트워크 오류: ${t.message}") - _error.postValue("네트워크 오류: ${t.message}") - } - }) - } - - - - fun getLicenseInfo() { - planApiService.getUPlicense().enqueue(object : Callback { - override fun onResponse( - call: Call, - response: Response - ) { - if (response.isSuccessful) { - if (response.body() != null) { - _licenseInfo.postValue(response.body()) - Log.d("Planlicense", "${response.body()}") - } else { - _error.postValue("서버 응답이 올바르지 않습니다.") - } - } else { - _error.postValue("사용자 정보를 가져오지 못했습니다.") - try { - throw response.errorBody()?.string()?.let { - RuntimeException(it) - } ?: RuntimeException("Unknown error") - } catch (e: Exception) { - Log.e("PlanInfo", "PlanResponse API 오류: ${e.message}") - } - } - } - - override fun onFailure(call: Call, t: Throwable) { - _error.postValue("네트워크 오류: ${t.message}") - Log.d("gradInfo", "completion: ${t.message}") - } - }) - } - - - - - fun saveLicense(request: List) { - - planApiService.saveLicense(request).enqueue(object : Callback { - override fun onResponse( - call: Call, response: Response - ) { - if (response.isSuccessful) { - _bringLicenseInfo.postValue(response.body()) - Log.d("PlanLicenseSave", "License saved successfully: ${response.body()}") - } else { - _error.postValue("자격증 정보 저장 실패: ${response.errorBody()?.string()}") - Log.e( - "PlanLicenseSave", - "Error saving license: ${response.errorBody()?.string()}" - ) - } - } - - override fun onFailure(call: Call, t: Throwable) { - _error.postValue("네트워크 오류: ${t.message}") - Log.e("PlanViewModel", "Network error: ${t.message}") - } - }) - } - - - fun getSemesterInfo() { - planApiService.getSemesterInfo().enqueue(object : Callback { - override fun onResponse( - call: Call, - response: Response - ) { - if (response.isSuccessful) { - if (response.body() != null) { - _planSemesterInfo.postValue(response.body()) - Log.d("PlanSemester", "${response.body()}") - } else { - _error.postValue("서버 응답이 올바르지 않습니다.") - } - } else { - _error.postValue("사용자 정보를 가져오지 못했습니다.") - try { - throw response.errorBody()?.string()?.let { - RuntimeException(it) - } ?: RuntimeException("Unknown error") - } catch (e: Exception) { - Log.e("PlanInfo", "PlanResponse API 오류: ${e.message}") - } - } - } - - override fun onFailure(call: Call, t: Throwable) { - _error.postValue("네트워크 오류: ${t.message}") - Log.d("gradInfo", "completion: ${t.message}") - } - }) - } - - - fun getTrackInfo(hakki: String) { - planApiService.getTrackInfo(hakki).enqueue(object : Callback { - override fun onResponse( - call: Call, - response: Response - ) { - if (response.isSuccessful) { - if (response.body() != null) { - _planTrackInfo.postValue(response.body()) - Log.d("PlanTrackInfo", "${response.body()}") - } else { - _error.postValue("서버 응답이 올바르지 않습니다.") - } - } else { - _error.postValue("사용자 정보를 가져오지 못했습니다.") - try { - throw response.errorBody()?.string()?.let { - RuntimeException(it) - } ?: RuntimeException("Unknown error") - } catch (e: Exception) { - Log.e("PlanInfo", "PlanResponse API 오류: ${e.message}") - } - } - } - - override fun onFailure(call: Call, t: Throwable) { - _error.postValue("네트워크 오류: ${t.message}") - Log.d("gradInfo", "completion: ${t.message}") - } - }) - } - - - fun editMemo(memo: String) { - val editMemoRequest = EditMemoRequest(memo = memo) - planApiService.editMemo(editMemoRequest).enqueue(object : Callback { - override fun onResponse( - call: Call, - response: Response - ) { - if (response.isSuccessful) { - Log.d("PlanMemoEdit", "Memo successfully edited: ${response.body()}") - // 필요한 경우, UI 업데이트를 위한 LiveData 업데이트 로직을 여기에 추가하세요. - } else { - Log.e("PlanMemoEdit", "Failed to edit memo: ${response.errorBody()?.string()}") - } - } - - override fun onFailure(call: Call, t: Throwable) { - Log.e("PlanMemoEdit", "Network error on edit memo: ${t.message}") - } - }) - } - - fun certificateLicense(request: List) { - planApiService.certificateLicense(request).enqueue(object : Callback { - override fun onResponse(call: Call, response: Response) { - if (response.isSuccessful) { - // 서버로부터 응답을 성공적으로 받았을 때 LiveData 업데이트 - _certificateResponse.postValue(response.body()) - Log.d("PlanViewModel", "Certificate License update success: ${response.body()}") - } else { - // 에러 처리: 실패 응답 처리 - _certificateResponse.postValue(null) - Log.e("PlanViewModel", "Failed to update certificate license: ${response.errorBody()?.string()}") - } - } - - override fun onFailure(call: Call, t: Throwable) { - // 네트워크 에러 처리: LiveData 업데이트로 에러 상태 전달 가능 - _certificateResponse.postValue(null) - Log.e("PlanViewModel", "Network error on certificate license update: ${t.message}") - } - }) - } - - - /** - * 시간표 조회하기 - */ - fun getTimeInfo(grade:Int, semester:Int) { - planApiService.getUptime(grade,semester).enqueue(object : Callback { - override fun onResponse( - call: Call, - response: Response - ) { - if (response.isSuccessful) { - if (response.body() != null) { - val timeList = response.body()!!.result - val itemList = ArrayList() - timeList.forEach { - itemList.add(TimeInfoResponse(it.type,it.name,it.credit.toString())) - } - _selectedTimeResults.value = itemList - - Log.d("PlanUpTime1", "TimeInfoResponse: $timeList") - Log.d("PlanUpTime", "${response.body()}") - } else { - Log.d("PlanUpTime", "${response.body()}") - _error.postValue("서버 응답이 올바르지 않습니다.") - } - } else { - _error.postValue("사용자 정보를 가져오지 못했습니다.") - try { - throw response.errorBody()?.string()?.let { - RuntimeException(it) - } ?: RuntimeException("Unknown error") - } catch (e: Exception) { - Log.e("PlanViewModel", "Failed to get time info: ${response.errorBody()?.string()}") - - } - } - } - - override fun onFailure(call: Call, t: Throwable) { - _error.postValue("네트워크 오류: ${t.message}") - Log.d("PlanUpTime12", "Network error: ${t.message}") - } - }) - } - - - fun deleteLicense(certificateId: Long) { - planApiService.deleteLicense(certificateId).enqueue(object : Callback { - override fun onResponse(call: Call, response: Response) { - if (response.isSuccessful) { - // 삭제 요청이 성공적으로 처리된 경우 - Log.d("DeleteLicense", "License deleted successfully") - // 여기에 필요한 처리를 추가하세요. - } else { - // 삭제 요청이 실패한 경우 - val errorMessage = response.errorBody()?.string() ?: "Unknown error" - Log.e("DeleteLicense", "Failed to delete license: $errorMessage") - // 여기에 필요한 처리를 추가하세요. - } - } - - override fun onFailure(call: Call, t: Throwable) { - // 네트워크 오류 등으로 요청이 실패한 경우 - Log.e("DeleteLicense", "Network error: ${t.message}") - // 여기에 필요한 처리를 추가하세요. - } - }) - } - - - - - - } - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanlicenseFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/plan/PlanlicenseFragment.kt index 94602daa..c1bb27f2 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanlicenseFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/plan/PlanlicenseFragment.kt @@ -1,7 +1,7 @@ package umc.com.mobile.project.ui.plan import android.content.res.ColorStateList -import umc.com.mobile.project.data.model.plan.SaveInfo +import umc.com.mobile.project.data.model.plan.license.SaveInfo import android.os.Bundle import android.text.Editable import android.text.TextWatcher @@ -11,10 +11,10 @@ import android.view.ViewGroup import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels -import androidx.fragment.app.viewModels import umc.com.mobile.project.R -import umc.com.mobile.project.data.model.plan.CertificateLicenseRequest +import umc.com.mobile.project.data.model.plan.license.CertificateLicenseRequest import umc.com.mobile.project.databinding.FragmentPlanlicenseBinding +import umc.com.mobile.project.ui.plan.viewmodel.PlanViewModel class PlanlicenseFragment : Fragment() { private var _binding: FragmentPlanlicenseBinding? = null diff --git a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanRVAdapter.kt b/app/src/main/java/umc/com/mobile/project/ui/plan/adapter/PlanRVAdapter.kt similarity index 96% rename from app/src/main/java/umc/com/mobile/project/ui/plan/PlanRVAdapter.kt rename to app/src/main/java/umc/com/mobile/project/ui/plan/adapter/PlanRVAdapter.kt index 4a058e66..6f72cef9 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanRVAdapter.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/plan/adapter/PlanRVAdapter.kt @@ -1,4 +1,4 @@ -package umc.com.mobile.project.ui.plan +package umc.com.mobile.project.ui.plan.adapter import android.text.Editable import android.view.LayoutInflater diff --git a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanRecyclerAdapter.kt b/app/src/main/java/umc/com/mobile/project/ui/plan/adapter/PlanRecyclerAdapter.kt similarity index 84% rename from app/src/main/java/umc/com/mobile/project/ui/plan/PlanRecyclerAdapter.kt rename to app/src/main/java/umc/com/mobile/project/ui/plan/adapter/PlanRecyclerAdapter.kt index 8c72eeb0..d96822c2 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanRecyclerAdapter.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/plan/adapter/PlanRecyclerAdapter.kt @@ -1,16 +1,14 @@ -package umc.com.mobile.project.ui.plan +package umc.com.mobile.project.ui.plan.adapter -import android.text.Editable import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView -import umc.com.mobile.project.data.model.plan.TimeInfoResponse -import umc.com.mobile.project.data.model.plan.TimeResult +import umc.com.mobile.project.data.model.plan.timetable.TimeResult import umc.com.mobile.project.databinding.ItemTimeSubjectBinding class PlanRecyclerAdapter( - private var timeList: List, - private val onAddButtonClicked: ((TimeResult?) -> Unit)? = null + private var timeList: List, + private val onAddButtonClicked: ((TimeResult?) -> Unit)? = null ) : RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NonSubjectViewHolder { diff --git a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanSemesterAdapter.kt b/app/src/main/java/umc/com/mobile/project/ui/plan/adapter/PlanSemesterAdapter.kt similarity index 82% rename from app/src/main/java/umc/com/mobile/project/ui/plan/PlanSemesterAdapter.kt rename to app/src/main/java/umc/com/mobile/project/ui/plan/adapter/PlanSemesterAdapter.kt index 4ea7acba..3203ce41 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanSemesterAdapter.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/plan/adapter/PlanSemesterAdapter.kt @@ -1,10 +1,9 @@ -package umc.com.mobile.project.ui.plan +package umc.com.mobile.project.ui.plan.adapter -import android.os.Bundle import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView -import umc.com.mobile.project.data.model.plan.semesterResult +import umc.com.mobile.project.data.model.plan.timetable.semesterResult import umc.com.mobile.project.databinding.ItemChooseSemesterBinding class PlanSemesterAdapter(semesterList: List, private val onItemClick: (semesterResult) -> Unit): RecyclerView.Adapter() { @@ -18,12 +17,12 @@ class PlanSemesterAdapter(semesterList: List, private val onIte return semesterList.size } - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlanSemesterAdapter.NonSubjectViewHolder { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NonSubjectViewHolder { val itemBinding = ItemChooseSemesterBinding.inflate(LayoutInflater.from(parent.context), parent, false) return NonSubjectViewHolder(itemBinding) } - override fun onBindViewHolder(holder: PlanSemesterAdapter.NonSubjectViewHolder, position: Int) { + override fun onBindViewHolder(holder: NonSubjectViewHolder, position: Int) { val semesterInfo = semesterList[position] if (semesterInfo != null) { holder.itemBinding.planTimeSemesterItem.text = semesterInfo.hakkiText diff --git a/app/src/main/java/umc/com/mobile/project/ui/plan/adapter/PlanTimeAdapter.kt b/app/src/main/java/umc/com/mobile/project/ui/plan/adapter/PlanTimeAdapter.kt new file mode 100644 index 00000000..32480b01 --- /dev/null +++ b/app/src/main/java/umc/com/mobile/project/ui/plan/adapter/PlanTimeAdapter.kt @@ -0,0 +1,91 @@ +package umc.com.mobile.project.ui.plan.adapter + +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.DiffUtil +import androidx.recyclerview.widget.ListAdapter +import androidx.recyclerview.widget.RecyclerView +import umc.com.mobile.project.data.model.plan.timetable.UpTimeResult +import umc.com.mobile.project.databinding.ItemPlanTimeBinding +import umc.com.mobile.project.ui.plan.viewmodel.PlanViewModel + +class PlanTimeAdapter(private val viewModel: PlanViewModel) : + ListAdapter( + UpTimeResultDiffCallback() + ) { + private var onItemLongClickListener: ((UpTimeResult) -> Unit)? = null + private var onItemClickListener: ((UpTimeResult) -> Unit)? = null + + class ViewHolder(private val binding: ItemPlanTimeBinding) : + RecyclerView.ViewHolder(binding.root) { + fun bind(item: UpTimeResult) { + binding.timeKindTitle.text = item.type + binding.timeClassTitle.text = item.name + binding.timeGradeTitle.text = item.credit.toString() + } + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + val binding = + ItemPlanTimeBinding.inflate(LayoutInflater.from(parent.context), parent, false) + return ViewHolder(binding) + } + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + val item = getItem(position) + holder.bind(item) + + holder.itemView.setOnLongClickListener { + onItemLongClickListener?.invoke(item) + val position = holder.adapterPosition + if (position != RecyclerView.NO_POSITION) { + val clickedItem = getItem(position) + viewModel.subjectId.value?.let { it1 -> + viewModel.deleteTimeTable( + viewModel.grade.value!!, + viewModel.semester.value!!, + it1 + ) + } + } + true + } + + holder.itemView.setOnClickListener { + onItemClickListener?.invoke(item) + } + } + + fun updateTimeList(addnewtime: ArrayList) { + submitList(addnewtime) + notifyDataSetChanged() + } + + /* + fun setOnItemLongClickListener(listener: (UpTimeResult) -> Unit) { + this.onItemLongClickListener = listener + } + + fun setOnItemClickListener(listener: (UpTimeResult) -> Unit) { + this.onItemClickListener = listener + } + */ + + class UpTimeResultDiffCallback : DiffUtil.ItemCallback() { + override fun areItemsTheSame( + oldItem: UpTimeResult, + newItem: UpTimeResult + ): Boolean { + // subjectId를 비교하여 동일한 아이템인지 판별 + return oldItem.name == newItem.name + } + + override fun areContentsTheSame( + oldItem: UpTimeResult, + newItem: UpTimeResult + ): Boolean { + // 내용이 동일한지 비교 + return oldItem == newItem + } + } +} diff --git a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanTrackAdapter.kt b/app/src/main/java/umc/com/mobile/project/ui/plan/adapter/PlanTrackAdapter.kt similarity index 71% rename from app/src/main/java/umc/com/mobile/project/ui/plan/PlanTrackAdapter.kt rename to app/src/main/java/umc/com/mobile/project/ui/plan/adapter/PlanTrackAdapter.kt index 36570244..06ff2f0d 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanTrackAdapter.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/plan/adapter/PlanTrackAdapter.kt @@ -1,12 +1,9 @@ -package umc.com.mobile.project.ui.plan +package umc.com.mobile.project.ui.plan.adapter import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView -import umc.com.mobile.project.data.model.plan.PlanTrackResponse -import umc.com.mobile.project.data.model.plan.TrackResult -import umc.com.mobile.project.data.model.plan.semesterResult -import umc.com.mobile.project.databinding.ItemChooseSemesterBinding +import umc.com.mobile.project.data.model.plan.timetable.TrackResult import umc.com.mobile.project.databinding.ItemChooseTrackBinding class PlanTrackAdapter(trackList: List, private val onItemClick: (TrackResult) -> Unit) : RecyclerView.Adapter() { @@ -24,12 +21,12 @@ class PlanTrackAdapter(trackList: List, private val onItemClick: ( return trackList?.size ?: 0 } - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlanTrackAdapter.NonSubjectViewHolder { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NonSubjectViewHolder { val itemBinding = ItemChooseTrackBinding.inflate(LayoutInflater.from(parent.context), parent, false) - return PlanTrackAdapter.NonSubjectViewHolder(itemBinding) + return NonSubjectViewHolder(itemBinding) } - override fun onBindViewHolder(holder: PlanTrackAdapter.NonSubjectViewHolder, position: Int) { + override fun onBindViewHolder(holder: NonSubjectViewHolder, position: Int) { val trackInfo = trackList[position] if (trackInfo != null) { diff --git a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanVPAdapter.kt b/app/src/main/java/umc/com/mobile/project/ui/plan/adapter/PlanVPAdapter.kt similarity index 93% rename from app/src/main/java/umc/com/mobile/project/ui/plan/PlanVPAdapter.kt rename to app/src/main/java/umc/com/mobile/project/ui/plan/adapter/PlanVPAdapter.kt index eda363ff..01b99652 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/plan/PlanVPAdapter.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/plan/adapter/PlanVPAdapter.kt @@ -1,4 +1,4 @@ -package umc.com.mobile.project.ui.plan +package umc.com.mobile.project.ui.plan.adapter import androidx.fragment.app.Fragment import androidx.viewpager2.adapter.FragmentStateAdapter diff --git a/app/src/main/java/umc/com/mobile/project/ui/plan/viewmodel/PlanViewModel.kt b/app/src/main/java/umc/com/mobile/project/ui/plan/viewmodel/PlanViewModel.kt new file mode 100644 index 00000000..447d6d35 --- /dev/null +++ b/app/src/main/java/umc/com/mobile/project/ui/plan/viewmodel/PlanViewModel.kt @@ -0,0 +1,617 @@ +package umc.com.mobile.project.ui.plan.viewmodel + + +import android.util.Log +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import umc.com.mobile.project.data.model.plan.license.DeleteLicense +import umc.com.mobile.project.data.model.plan.timetable.request.AddTimeRequest +import umc.com.mobile.project.data.model.plan.timetable.AddTimeResponse +import umc.com.mobile.project.data.model.plan.license.BringlicenseResponse +import umc.com.mobile.project.data.model.plan.license.CertificateLicenseRequest +import umc.com.mobile.project.data.model.plan.license.CertificateResponse +import umc.com.mobile.project.data.model.plan.freememo.EditMemoRequest +import umc.com.mobile.project.data.model.plan.freememo.PlanFreeRequest +import umc.com.mobile.project.data.model.plan.freememo.PlanFreeResponse +import umc.com.mobile.project.data.model.plan.timetable.PlanTrackResponse +import umc.com.mobile.project.data.model.plan.license.SaveInfo +import umc.com.mobile.project.data.model.plan.license.SavelicenseRequest +import umc.com.mobile.project.data.model.plan.timetable.request.SemesterDto +import umc.com.mobile.project.data.model.plan.timetable.request.SubjectDtoList + +import umc.com.mobile.project.data.model.plan.license.UPlicenseResponse +import umc.com.mobile.project.data.model.plan.timetable.DeleteTimeTableResponse +import umc.com.mobile.project.data.model.plan.timetable.SearchSemesterResponse +import umc.com.mobile.project.data.model.plan.timetable.SearchSubjectResponse +import umc.com.mobile.project.data.model.plan.timetable.TimeResult +import umc.com.mobile.project.data.model.plan.timetable.TimeTableResponse +import umc.com.mobile.project.data.model.plan.timetable.UpTimeResult +import umc.com.mobile.project.data.network.ApiClient +import umc.com.mobile.project.data.network.api.PlanApi + +class PlanViewModel : ViewModel() { + + private val planApiService = ApiClient.createService() + + private val _timeTableResponse: MutableLiveData = MutableLiveData() + val timeTableResponse: LiveData + get() = _timeTableResponse + + private val _grade: MutableLiveData = MutableLiveData() + val grade: LiveData + get() = _grade + + private val _semester: MutableLiveData = MutableLiveData() + val semester: LiveData + get() = _semester + + private val _subjectId: MutableLiveData = MutableLiveData() + val subjectId: LiveData + get() = _subjectId + + fun setGradeAndSemester(grade: Int, semester: Int) { + _grade.value = grade + _semester.value = semester + } + + private val _selectedTimeResults = MutableLiveData>() + val selectedTimeResults: LiveData> = _selectedTimeResults + + private val _searchSubjectResults = MutableLiveData>() + val searchSubjectResults: LiveData> = _searchSubjectResults + + fun setSelectedTimeResult(timeResult: TimeResult) { + val currentList = _searchSubjectResults.value ?: ArrayList() + currentList.add(timeResult) + _searchSubjectResults.value = currentList + Log.d("PlanTimetable", "setSelectedTimeResult: $timeResult") + } + + private val _planFreeInfo: MutableLiveData = MutableLiveData() + val planFreeInfo: LiveData + get() = _planFreeInfo + + private val _postMemoResult = MutableLiveData() + val postMemoResult: LiveData + get() = _postMemoResult + + private val _hakki: MutableLiveData = MutableLiveData() + val hakki: LiveData + get() = _hakki + + private val _track: MutableLiveData = MutableLiveData() + val track: LiveData + get() = _track + + + private val _planSemesterInfo: MutableLiveData = MutableLiveData() + val planSemesterInfo: LiveData + get() = _planSemesterInfo + + private val _planTrackInfo: MutableLiveData = MutableLiveData() + val planTrackInfo: LiveData + get() = _planTrackInfo + + private val _timeTableInfo = MutableLiveData() + val timeTableInfo: LiveData = _timeTableInfo + + + private val _planTimeStatus: MutableLiveData = MutableLiveData() + val planTimeStatus: LiveData + get() = _planTimeStatus + + private val _bringLicenseInfo = MutableLiveData() + + private val _listTimeInfo = MutableLiveData() + val listTimeInfo: LiveData + get() = _listTimeInfo + + val bringLicenseInfo: LiveData + get() = _bringLicenseInfo + + + private val _licenseInfo: MutableLiveData = MutableLiveData() + val licenseInfo: LiveData + get() = _licenseInfo + + + private val _error: MutableLiveData = MutableLiveData() + val error: LiveData + get() = _error + + + private val _savelicenseInfo: MutableLiveData = MutableLiveData() + val savelicenseInfo: LiveData + get() = _savelicenseInfo + + private val _certificateResponse = MutableLiveData() + val certificateResponse: LiveData + get() = _certificateResponse + + + // 기존에 있던 text LiveData + private val _text = MutableLiveData().apply { + value = "This is Plan Fragment" + } + val text: LiveData = _text + + // 새로 추가된 isFilledAllOptions LiveData + private val _isFilledAllOptions = MutableLiveData().apply { + value = false // 초기값 설정 + } + val isFilledAllOptions: LiveData = _isFilledAllOptions + + fun updateIsFilledAllOptions(isFilled: Boolean) { + _isFilledAllOptions.value = isFilled + } + + fun resetSemesterSelection() { + // 학기 정보 관련 상태 초기화 + _planSemesterInfo.postValue(null) // 학기 정보 초기화 + _hakki.postValue("") // 학기 식별자 초기화 (또는 적절한 초기 값으로 설정) + } + + fun resetTrackSelection() { + // 선택된 트랙 정보 초기화 + _track.postValue("") // 트랙 식별자 초기화 (또는 적절한 초기 값으로 설정) + } + + fun setHakki(hakki: String) { + _hakki.value = hakki + Log.d("hakki value", "setHakki 호출됨: hakki=$hakki") + } + + + fun setHakkiAndTrack(hakki: String, trackId: String) { + Log.d("hakkitrackvalue", "setHakkiAndTrack 호출됨: hakki=$hakki, trackId=$trackId") + _hakki.value = hakki + _track.value = trackId + } + + private val _addTimeResponse = MutableLiveData() + val addTimeResponse: MutableLiveData = _addTimeResponse + + /** + * 시간표 조회하기 + */ + private val _deleteTimeTableResponse = MutableLiveData() + val deleteTimeTableResponse: MutableLiveData + get() = _deleteTimeTableResponse + + private val _subjectIdList: MutableList = mutableListOf() + val subjectIdList: MutableList + get() = _subjectIdList + + fun getTimeInfo(grade: Int, semester: Int) { + planApiService.getUptime(grade, semester).enqueue(object : Callback { + override fun onResponse( + call: Call, + response: Response + ) { + if (response.isSuccessful) { + if (response.body() != null) { + val timeList = response.body()!!.result + val itemList = ArrayList() + timeList.forEach { + itemList.add( + UpTimeResult( + it.subjectId, + it.type, + it.name, + it.credit + ) + ) + } + _selectedTimeResults.value = itemList + + Log.d("PlanUpTime1", "TimeInfoResponse: $timeList") + Log.d("PlanUpTime", "${response.body()}") + } else { + Log.d("PlanUpTime", "${response.body()}") + _error.postValue("서버 응답이 올바르지 않습니다.") + } + } else { + _error.postValue("사용자 정보를 가져오지 못했습니다.") + try { + throw response.errorBody()?.string()?.let { + RuntimeException(it) + } ?: RuntimeException("Unknown error") + } catch (e: Exception) { + Log.e( + "PlanViewModel", + "Failed to get time info: ${response.errorBody()?.string()}" + ) + + } + } + } + + override fun onFailure(call: Call, t: Throwable) { + _error.postValue("네트워크 오류: ${t.message}") + Log.d("PlanUpTime12", "Network error: ${t.message}") + } + }) + } + + fun getSemesterInfo() { + planApiService.getSemesterInfo().enqueue(object : Callback { + override fun onResponse( + call: Call, + response: Response + ) { + if (response.isSuccessful) { + if (response.body() != null) { + _planSemesterInfo.postValue(response.body()) + Log.d("PlanSemester", "${response.body()}") + } else { + _error.postValue("서버 응답이 올바르지 않습니다.") + } + } else { + _error.postValue("사용자 정보를 가져오지 못했습니다.") + try { + throw response.errorBody()?.string()?.let { + RuntimeException(it) + } ?: RuntimeException("Unknown error") + } catch (e: Exception) { + Log.e("PlanInfo", "PlanResponse API 오류: ${e.message}") + } + } + } + + override fun onFailure(call: Call, t: Throwable) { + _error.postValue("네트워크 오류: ${t.message}") + Log.d("gradInfo", "completion: ${t.message}") + } + }) + } + + fun getTrackInfo(hakki: String) { + planApiService.getTrackInfo(hakki).enqueue(object : Callback { + override fun onResponse( + call: Call, + response: Response + ) { + if (response.isSuccessful) { + if (response.body() != null) { + _planTrackInfo.postValue(response.body()) + Log.d("PlanTrackInfo", "${response.body()}") + } else { + _error.postValue("서버 응답이 올바르지 않습니다.") + } + } else { + _error.postValue("사용자 정보를 가져오지 못했습니다.") + try { + throw response.errorBody()?.string()?.let { + RuntimeException(it) + } ?: RuntimeException("Unknown error") + } catch (e: Exception) { + Log.e("PlanInfo", "PlanResponse API 오류: ${e.message}") + } + } + } + + override fun onFailure(call: Call, t: Throwable) { + _error.postValue("네트워크 오류: ${t.message}") + Log.d("gradInfo", "completion: ${t.message}") + } + }) + } + + fun sendAddTimeRequest() { + val currentSelectedSubjects = _selectedTimeResults.value ?: return + val grade = _grade.value + val semester = _semester.value + val subjectId = _subjectId.value + + if (grade == null || semester == null) { + return + } else { + Log.d( + "gradesemester1", + "Sending AddTimeRequest with grade: $grade, semester: $semester" + ) + } + + val semesterDto = SemesterDto(grade = grade, semester = semester) + + val request = AddTimeRequest( + semesterDto = semesterDto, + subjectDtoList = currentSelectedSubjects.map { + SubjectDtoList( + type = it.type, + name = it.name, + credit = it.credit.toString() + ) + } + ) + + addTime(request) + } + + fun addTime(request: AddTimeRequest) { + planApiService.addTime(request).enqueue(object : Callback { + override fun onResponse( + call: Call, + response: Response + ) { + if (response.isSuccessful) { +// Log.d("TimeTableApi", "getListTimeInfo 성공: ${response.body()}") +// Log.d("gradesemester", "Sending AddTimeRequest with grade: ${request.semesterDto.grade}, semester: ${request.semesterDto.semester}") + _addTimeResponse.postValue(response.body()) + } else { + Log.e("TimeTableApi", "Error posting memo: ${response.errorBody()?.string()}") + _addTimeResponse.postValue(null) + } + } + + override fun onFailure(call: Call, t: Throwable) { + _addTimeResponse.postValue(null) + } + }) + } + + fun getListTimeInfo(hakki: String, track: String) { + Log.d("PlanViewModel", "getListTimeInfo 호출됨: hakki=$hakki, track=$track") + planApiService.getListTime(hakki, track).enqueue(object : Callback { + override fun onResponse( + call: Call, + response: Response + ) { + if (response.isSuccessful && response.body() != null) { + Log.d("PlanViewModel", "getListTimeInfo 성공: ${response.body()}") + _listTimeInfo.postValue(response.body()) + } else { + Log.e("PlanViewModel", "getListTimeInfo 실패: ${response.errorBody()?.string()}") + _error.postValue("리스트 정보를 가져오는데 실패했습니다.") + } + } + + override fun onFailure(call: Call, t: Throwable) { + Log.e("PlanViewModel", "getListTimeInfo 네트워크 오류: ${t.message}") + _error.postValue("네트워크 오류: ${t.message}") + } + }) + } + + fun deleteTimeTable(grade: Int, semester: Int, subjectId: Int) { + planApiService.deleteTimeTable(grade, semester, subjectId) + .enqueue(object : Callback { + override fun onResponse( + call: Call, + response: Response + ) { + if (response.isSuccessful) { + if (response.body() != null) { + _deleteTimeTableResponse.postValue(response.body()) + Log.d("deleteTimeTableResponse", "${response.body()}") + } else { + _error.postValue("서버 응답이 올바르지 않습니다.") + } + } else { + _error.postValue("사용자 정보를 가져오지 못했습니다.") + try { + throw response.errorBody()?.string()?.let { + RuntimeException(it) + } ?: RuntimeException("Unknown error") + } catch (e: Exception) { + Log.e("DeleteTimeTable", "DeleteTimeTable API 오류: ${e.message}") + } + } + } + + override fun onFailure(call: Call, t: Throwable) { + _error.postValue("네트워크 오류: ${t.message}") + Log.d("DeleteTimeTabl", "DeleteTimeTable: ${t.message}") + } + }) + } + + /** + * 자격증 + */ + fun getLicenseInfo() { + planApiService.getUPlicense().enqueue(object : Callback { + override fun onResponse( + call: Call, + response: Response + ) { + if (response.isSuccessful) { + if (response.body() != null) { + _licenseInfo.postValue(response.body()) + Log.d("Planlicense", "${response.body()}") + } else { + _error.postValue("서버 응답이 올바르지 않습니다.") + } + } else { + _error.postValue("사용자 정보를 가져오지 못했습니다.") + try { + throw response.errorBody()?.string()?.let { + RuntimeException(it) + } ?: RuntimeException("Unknown error") + } catch (e: Exception) { + Log.e("PlanInfo", "PlanResponse API 오류: ${e.message}") + } + } + } + + override fun onFailure(call: Call, t: Throwable) { + _error.postValue("네트워크 오류: ${t.message}") + Log.d("gradInfo", "completion: ${t.message}") + } + }) + } + + fun saveLicense(request: List) { + + planApiService.saveLicense(request).enqueue(object : Callback { + override fun onResponse( + call: Call, response: Response + ) { + if (response.isSuccessful) { + _bringLicenseInfo.postValue(response.body()) + Log.d("PlanLicenseSave", "License saved successfully: ${response.body()}") + } else { + _error.postValue("자격증 정보 저장 실패: ${response.errorBody()?.string()}") + Log.e( + "PlanLicenseSave", + "Error saving license: ${response.errorBody()?.string()}" + ) + } + } + + override fun onFailure(call: Call, t: Throwable) { + _error.postValue("네트워크 오류: ${t.message}") + Log.e("PlanViewModel", "Network error: ${t.message}") + } + }) + } + + fun deleteLicense(certificateId: Long) { + planApiService.deleteLicense(certificateId).enqueue(object : Callback { + override fun onResponse(call: Call, response: Response) { + if (response.isSuccessful) { + // 삭제 요청이 성공적으로 처리된 경우 + Log.d("DeleteLicense", "License deleted successfully") + // 여기에 필요한 처리를 추가하세요. + } else { + // 삭제 요청이 실패한 경우 + val errorMessage = response.errorBody()?.string() ?: "Unknown error" + Log.e("DeleteLicense", "Failed to delete license: $errorMessage") + // 여기에 필요한 처리를 추가하세요. + } + } + + override fun onFailure(call: Call, t: Throwable) { + // 네트워크 오류 등으로 요청이 실패한 경우 + Log.e("DeleteLicense", "Network error: ${t.message}") + // 여기에 필요한 처리를 추가하세요. + } + }) + } + + fun certificateLicense(request: List) { + planApiService.certificateLicense(request).enqueue(object : Callback { + override fun onResponse( + call: Call, + response: Response + ) { + if (response.isSuccessful) { + // 서버로부터 응답을 성공적으로 받았을 때 LiveData 업데이트 + _certificateResponse.postValue(response.body()) + Log.d("PlanViewModel", "Certificate License update success: ${response.body()}") + } else { + // 에러 처리: 실패 응답 처리 + _certificateResponse.postValue(null) + Log.e( + "PlanViewModel", + "Failed to update certificate license: ${response.errorBody()?.string()}" + ) + } + } + + override fun onFailure(call: Call, t: Throwable) { + // 네트워크 에러 처리: LiveData 업데이트로 에러 상태 전달 가능 + _certificateResponse.postValue(null) + Log.e("PlanViewModel", "Network error on certificate license update: ${t.message}") + } + }) + } + + /** + * 자유 메모 + */ + fun editMemo(memo: String) { + val editMemoRequest = EditMemoRequest(memo = memo) + planApiService.editMemo(editMemoRequest).enqueue(object : Callback { + override fun onResponse( + call: Call, + response: Response + ) { + if (response.isSuccessful) { + Log.d("PlanMemoEdit", "Memo successfully edited: ${response.body()}") + // 필요한 경우, UI 업데이트를 위한 LiveData 업데이트 로직을 여기에 추가하세요. + } else { + Log.e("PlanMemoEdit", "Failed to edit memo: ${response.errorBody()?.string()}") + } + } + + override fun onFailure(call: Call, t: Throwable) { + Log.e("PlanMemoEdit", "Network error on edit memo: ${t.message}") + } + }) + } + + fun postMemo(memoRequest: PlanFreeRequest) { + planApiService.postFreeMemo(memoRequest).enqueue(object : Callback { + override fun onResponse( + call: Call, + response: Response + ) { + if (response.isSuccessful) { + _postMemoResult.postValue(true) + } else { + Log.e("PlanViewModel", "Error posting memo: ${response.errorBody()?.string()}") + _postMemoResult.postValue(false) + } + } + + override fun onFailure(call: Call, t: Throwable) { + _postMemoResult.postValue(false) + } + }) + } + + fun getFreeInfo() { + planApiService.getFreeInfo().enqueue(object : Callback { + override fun onResponse( + call: Call, + response: Response + ) { + if (response.isSuccessful) { + if (response.body() != null) { + _planFreeInfo.postValue(response.body()) + Log.d("PlanFree", "${response.body()}") + } else { + _error.postValue("서버 응답이 올바르지 않습니다.") + } + } else { + _error.postValue("사용자 정보를 가져오지 못했습니다.") + try { + throw response.errorBody()?.string()?.let { + RuntimeException(it) + } ?: RuntimeException("Unknown error") + } catch (e: Exception) { + Log.e("PlanInfo", "PlanResponse API 오류: ${e.message}") + } + } + } + + override fun onFailure(call: Call, t: Throwable) { + _error.postValue("네트워크 오류: ${t.message}") + Log.d("gradInfo", "completion: ${t.message}") + } + }) + } +} + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_planlicense.xml b/app/src/main/res/layout/fragment_planlicense.xml index af6bdfdf..38a60f56 100644 --- a/app/src/main/res/layout/fragment_planlicense.xml +++ b/app/src/main/res/layout/fragment_planlicense.xml @@ -8,7 +8,7 @@ + type="umc.com.mobile.project.ui.plan.viewmodel.PlanViewModel" /> + type="umc.com.mobile.project.ui.plan.viewmodel.PlanViewModel" /> diff --git a/app/src/main/res/layout/plan_time_main.xml b/app/src/main/res/layout/plan_time_main.xml index 9f9a08e8..64f73248 100644 --- a/app/src/main/res/layout/plan_time_main.xml +++ b/app/src/main/res/layout/plan_time_main.xml @@ -6,7 +6,7 @@ + type="umc.com.mobile.project.ui.plan.viewmodel.PlanViewModel" /> + android:layout_height="match_parent"> + android:layout_height="match_parent" /> - + tools:listitem="@layout/item_choose_semester" /> - - - \ No newline at end of file + \ No newline at end of file