Skip to content

Commit

Permalink
Merge pull request #97 from DaITssu/chore/mysql
Browse files Browse the repository at this point in the history
Chore/mysql
  • Loading branch information
HwanGonJang authored Nov 27, 2023
2 parents 49df633 + 73622d6 commit e2ad107
Show file tree
Hide file tree
Showing 48 changed files with 291 additions and 299 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
FROM openjdk:17
COPY build/libs/daitssu-api.jar /

ENTRYPOINT ["java", "-Dspring.profiles.active=dev", "-jar","/daitssu-api.jar"]
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ dependencies {
implementation("org.springframework.boot", "spring-boot-starter-web")
implementation("org.springframework.boot", "spring-boot-configuration-processor")

implementation("org.postgresql", "postgresql", "42.6.0")
implementation("com.mysql", "mysql-connector-j")

implementation("org.springframework.cloud", "spring-cloud-starter-aws", "2.2.6.RELEASE")
implementation("org.springframework.cloud:spring-cloud-starter-aws-messaging:2.2.1.RELEASE")
Expand Down Expand Up @@ -93,7 +93,7 @@ dependencies {
developmentOnly("org.springframework.boot", "spring-boot-devtools")
annotationProcessor("org.springframework.boot", "spring-boot-configuration-processor")

testRuntimeOnly("com.h2database", "h2")
// testRuntimeOnly("com.h2database", "h2")
testRuntimeOnly("org.jetbrains.kotlinx", "kotlinx-coroutines-core", "1.6.4")
testRuntimeOnly("org.jetbrains.kotlinx", "kotlinx-coroutines-test", "1.6.4")
testImplementation("org.springframework.boot", "spring-boot-starter-test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import java.time.LocalDateTime
@EntityListeners(AuditingEntityListener::class)
abstract class BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Long = 0L

@CreatedDate
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.example.daitssuapi.common.converter

import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import jakarta.persistence.AttributeConverter
import jakarta.persistence.Converter

@Converter
class JsonParsingConverter: AttributeConverter<List<String>, String> {
override fun convertToDatabaseColumn(attribute: List<String>): String =
"""{"url" : [${attribute.joinToString(", ")}]}"""

override fun convertToEntityAttribute(dbData: String): List<String> =
jacksonObjectMapper().readTree(dbData).findValuesAsText("url")
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ package com.example.daitssuapi.common.enums

enum class CalendarType {
ASSIGNMENT,
VIDEO
VIDEO,
OFFLINE_LECTURE,
QUIZ
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ enum class NoticeCategory(val categoryCode: String) {
UNDERGRADUATE("학부");


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class JwtVerifier(
private val tokenAlgorithm: Algorithm,
@Value("\${spring.profiles.active}") private val profile: String
) {
private val alwaysAllowProfiles = listOf("dev", "local")
private val alwaysAllowProfiles = listOf("dev", "local", "test")

val tokenVerifier: JWTVerifier = JWT
.require(tokenAlgorithm)
Expand All @@ -36,8 +36,9 @@ class JwtVerifier(
}

fun verifyToken(bearerToken: String): TokenDto {
// TODO: 실제 토큰을 넣어도 무시해버림 수정 필요
if (profile in alwaysAllowProfiles) {
return TokenDto(userId = 0, userRole = "STUDENT")
return TokenDto(userId = 2, userRole = "STUDENT")
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ class AuthService(
student_id = studentId,
password = password,
)
)
).replace("\"", "")
} catch (e: Exception) {
throw DefaultException(ErrorCode.PASSWORD_INCORRECT, HttpStatus.BAD_REQUEST)
}
print("------")
print(user.id)

val accessToken = tokenProvider.createAccessToken(user.id)
val refreshToken = tokenProvider.createRefreshToken(user.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import com.example.daitssuapi.domain.course.dto.request.AssignmentRequest
import com.example.daitssuapi.domain.course.dto.request.CalendarRequest
import com.example.daitssuapi.domain.course.dto.request.CourseRequest
import com.example.daitssuapi.domain.course.dto.request.VideoRequest
import com.example.daitssuapi.domain.course.dto.response.*
import com.example.daitssuapi.domain.course.dto.response.AssignmentResponse
import com.example.daitssuapi.domain.course.dto.response.CalendarResponse
import com.example.daitssuapi.domain.course.dto.response.CourseResponse
import com.example.daitssuapi.domain.course.dto.response.TodayCalendarResponse
import com.example.daitssuapi.domain.course.dto.response.UserCourseResponse
import com.example.daitssuapi.domain.course.dto.response.VideoResponse
import com.example.daitssuapi.domain.course.service.CourseService
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.responses.ApiResponse
Expand Down Expand Up @@ -49,7 +54,7 @@ class CourseController(
ApiResponse(responseCode = "200", description = "OK")
]
)
@GetMapping("/calendar/{date}")
@GetMapping("/calendar/{date}") // TODO : calendar에 저장된 course로 group by, 실제 강의와 연결 불가
fun getCalendar(
@PathVariable("date") date: String
): Response<Map<String, List<CalendarResponse>>> =
Expand All @@ -61,7 +66,7 @@ class CourseController(
ApiResponse(responseCode = "200", description = "OK")
]
)
@PostMapping("/calendar")
@PostMapping("/calendar") // TODO : course를 String으로 박는데, 실제 강의와 연결을 못 시키고 있음. courseId 등으로 대체 필요
fun postCreateCalendar(
@RequestBody calendarRequest: CalendarRequest
): Response<CalendarResponse> =
Expand All @@ -73,7 +78,7 @@ class CourseController(
ApiResponse(responseCode = "200", description = "OK")
]
)
@PostMapping("/video")
@PostMapping("/video") // TODO : due가 강제로 7일 이후로 처리되는거 수정
fun postCreateVideo(
@RequestBody videoRequest: VideoRequest
): Response<VideoResponse> =
Expand All @@ -97,7 +102,7 @@ class CourseController(
ApiResponse(responseCode = "200", description = "OK")
]
)
@PostMapping("/course")
@PostMapping
fun postCreateCourse(
@RequestBody courseRequest: CourseRequest
): Response<CourseResponse> =
Expand All @@ -122,11 +127,11 @@ class CourseController(
ApiResponse(responseCode = "200", description = "OK")
]
)
@PutMapping("/calendar/{calendarId}")
@PutMapping("/calendar/{calendarId}") // TODO : 이거도 동일하게 강의와 Mapping 불가
fun updateCalendar(
@RequestBody calendarRequest: CalendarRequest,
@PathVariable calendarId: Long
) : Response<CalendarResponse> =
): Response<CalendarResponse> =
Response(data = courseService.updateCalendar(calendarRequest = calendarRequest, calendarId = calendarId))

@Operation(
Expand All @@ -136,7 +141,7 @@ class CourseController(
]
)
@GetMapping("/calendar/today")
fun getTodayCalendar() : Response<TodayCalendarResponse> =
fun getTodayCalendar(): Response<TodayCalendarResponse> =
Response(data = courseService.getTodayDueAtCalendars())

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ data class CourseRequest(
val name: String,

@NotNull
val term: Int
)
val term: Int,

@NotNull
val courseCode: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package com.example.daitssuapi.domain.course.dto.response
data class CourseResponse(
val id: Long,
val name: String,
val term: Int,
val courseCode: String,
val videos: List<VideoResponse> = emptyList(),
val assignments: List<AssignmentResponse> = emptyList(),
val term: Int
)
val assignments: List<AssignmentResponse> = emptyList()
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import jakarta.persistence.Entity
import jakarta.persistence.FetchType
import jakarta.persistence.JoinColumn
import jakarta.persistence.ManyToOne
import jakarta.persistence.Table
import java.time.LocalDateTime

@Entity
@Table(schema = "course")
class Assignment(
val dueAt: LocalDateTime,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import com.example.daitssuapi.domain.course.dto.request.CalendarRequest
import jakarta.persistence.Entity
import jakarta.persistence.EnumType
import jakarta.persistence.Enumerated
import jakarta.persistence.Table
import java.time.LocalDateTime

@Entity
@Table(schema = "course")
class Calendar(
@Enumerated(EnumType.STRING)
var type: CalendarType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package com.example.daitssuapi.domain.course.model.entity
import com.example.daitssuapi.common.audit.BaseEntity
import jakarta.persistence.Entity
import jakarta.persistence.OneToMany
import jakarta.persistence.Table

@Entity
@Table(schema = "course")
class Course(
val name: String,

val term: Int,

val courseCode: String,

@OneToMany(mappedBy = "course")
val videos: MutableList<Video> = mutableListOf(),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.example.daitssuapi.domain.main.model.entity.User
import jakarta.persistence.*

@Entity
@Table(schema = "course")
class UserCourseRelation(
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.example.daitssuapi.domain.course.model.entity

import com.example.daitssuapi.common.audit.BaseEntity
import jakarta.persistence.*
import jakarta.persistence.Entity
import jakarta.persistence.FetchType
import jakarta.persistence.JoinColumn
import jakarta.persistence.ManyToOne
import java.time.LocalDateTime


@Entity
@Table(schema = "course")
class Video(
var dueAt: LocalDateTime,

Expand Down
Loading

0 comments on commit e2ad107

Please sign in to comment.