diff --git a/.gitignore b/.gitignore index 2bff8a4..dad507a 100644 --- a/.gitignore +++ b/.gitignore @@ -36,4 +36,6 @@ out/ ### VS Code ### .vscode/ -.DS_Store \ No newline at end of file +.DS_Store + +uploads/ \ No newline at end of file diff --git a/README.md b/README.md index 25729ea..d4db378 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ ### Language and Framework -- Spring Boot: 2.7.4 -- Kotlin: 1.7.20 -- Gradle: 7.5 +- Spring Boot: 3.0.0 +- Kotlin: 1.7.22 +- Gradle: 7.5.1 # Modules diff --git a/api/build.gradle.kts b/api/build.gradle.kts index 8737e8e..3b2a381 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -8,8 +8,8 @@ plugins { kotlin("plugin.jpa") } -val kotlinVersion = "1.7.20" -val springBootVersion = "2.7.4" +val kotlinVersion = "1.7.22" +val springBootVersion = "3.0.0" // find the last commit fun getGitHashLastCommit(): String { @@ -25,9 +25,9 @@ fun getGitHashLastCommit(): String { springBoot { buildInfo { properties { - additional["commitId"] = getGitHashLastCommit() - additional["springBootVersion"] = springBootVersion - additional["kotlinVersion"] = kotlinVersion + this.additional.put("commitId", getGitHashLastCommit()) + this.additional.put("springBootVersion", springBootVersion) + this.additional.put("kotlinVersion", kotlinVersion) } } } @@ -36,9 +36,10 @@ dependencies { // Spring Data JPA (Required for Database Layer) implementation("org.springframework.boot:spring-boot-starter-data-jpa") implementation("org.springframework.boot:spring-boot-starter-data-redis") + implementation("org.springframework.boot:spring-boot-starter-validation") - // Migrating from SpringFox - implementation("org.springdoc:springdoc-openapi-ui:1.6.13") + // Migrating from SpringDoc API (Swagger) for Support Spring Boot 3.x + implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.0") // SPRING FRAMEWORK AND CORE implementation("org.springframework.boot:spring-boot-starter-web") diff --git a/api/src/main/kotlin/com/cubetiqs/web/config/OpenApiDocConfig.kt b/api/src/main/kotlin/com/cubetiqs/web/config/OpenApiDocConfig.kt index 523f701..a67cb74 100644 --- a/api/src/main/kotlin/com/cubetiqs/web/config/OpenApiDocConfig.kt +++ b/api/src/main/kotlin/com/cubetiqs/web/config/OpenApiDocConfig.kt @@ -6,12 +6,12 @@ import io.swagger.v3.oas.annotations.security.SecurityScheme import io.swagger.v3.oas.models.OpenAPI import io.swagger.v3.oas.models.info.Info import io.swagger.v3.oas.models.info.License -import org.springdoc.core.GroupedOpenApi import org.springframework.beans.factory.annotation.Autowired import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import io.swagger.v3.oas.annotations.OpenAPIDefinition import io.swagger.v3.oas.annotations.servers.Server +import org.springdoc.core.models.GroupedOpenApi import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty //import org.springdoc.core.SpringDocUtils diff --git a/api/src/main/kotlin/com/cubetiqs/web/controller/ApiDoc.kt b/api/src/main/kotlin/com/cubetiqs/web/controller/ApiDoc.kt index a5a7918..96ac1bf 100644 --- a/api/src/main/kotlin/com/cubetiqs/web/controller/ApiDoc.kt +++ b/api/src/main/kotlin/com/cubetiqs/web/controller/ApiDoc.kt @@ -10,6 +10,6 @@ import org.springframework.web.servlet.view.RedirectView class ApiDoc { @GetMapping(value = [ "/api-doc", "/api-docs"]) fun redirect(): RedirectView { - return RedirectView("/swagger-ui/") + return RedirectView("/swagger-ui/index.html") } } \ No newline at end of file diff --git a/api/src/main/kotlin/com/cubetiqs/web/modules/uploader/UploaderController.kt b/api/src/main/kotlin/com/cubetiqs/web/modules/uploader/UploaderController.kt index 21ef781..219c11c 100644 --- a/api/src/main/kotlin/com/cubetiqs/web/modules/uploader/UploaderController.kt +++ b/api/src/main/kotlin/com/cubetiqs/web/modules/uploader/UploaderController.kt @@ -14,7 +14,7 @@ import org.springframework.util.FileCopyUtils import org.springframework.web.bind.annotation.* import org.springframework.web.multipart.MultipartFile import java.util.* -import javax.servlet.http.HttpServletResponse +import jakarta.servlet.http.HttpServletResponse @UploaderModule @Tag(name = "Uploader Controller") diff --git a/api/src/main/kotlin/com/cubetiqs/web/modules/uploader/UploaderEntity.kt b/api/src/main/kotlin/com/cubetiqs/web/modules/uploader/UploaderEntity.kt index e8de856..a2f7a13 100644 --- a/api/src/main/kotlin/com/cubetiqs/web/modules/uploader/UploaderEntity.kt +++ b/api/src/main/kotlin/com/cubetiqs/web/modules/uploader/UploaderEntity.kt @@ -12,40 +12,47 @@ import java.io.InputStream import java.io.Serializable import java.nio.file.Files import java.util.* -import javax.persistence.* +import jakarta.persistence.* +import org.hibernate.annotations.GenericGenerator @UploaderModule @Entity -@Table(name = "uploader") +@Table(name = "`uploader`") @EntityListeners(AuditingEntityListener::class) open class UploaderEntity( @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(generator = "custom-uuid") + @GenericGenerator( + name = "custom-uuid", + strategy = "org.hibernate.id.UUIDGenerator", + parameters = [org.hibernate.annotations.Parameter(name = "uuid_gen_strategy_class", value = "org.hibernate.id.uuid.CustomVersionOneStrategy")] + ) + @Column(columnDefinition = "BINARY(16)") open var id: UUID? = null, - @Column(name = "filename") + @Column(name = "`filename`") open var filename: String? = null, - @Column(name = "content_type") + @Column(name = "`content_type`") open var contentType: String? = null, - @Column(name = "content_length") + @Column(name = "`content_length`") open var contentLength: Long? = null, - @Column(name = "path", length = 300) + @Column(name = "`path`", length = 300) open var path: String? = null, @Temporal(TemporalType.TIMESTAMP) - @Column(name = "created_at") + @Column(name = "`created_at`") @CreatedDate open var createdAt: Date? = null, @Temporal(TemporalType.TIMESTAMP) - @Column(name = "updated_at") + @Column(name = "`updated_at`") @LastModifiedDate open var updatedAt: Date? = null, - @Column(length = 30) + @Column(length = 30, name = "`provider_type`") open var providerType: String? = null, ) : Serializable { @Transient diff --git a/api/src/main/kotlin/com/cubetiqs/web/modules/user/UserEntity.kt b/api/src/main/kotlin/com/cubetiqs/web/modules/user/UserEntity.kt index 61c4817..c27f772 100644 --- a/api/src/main/kotlin/com/cubetiqs/web/modules/user/UserEntity.kt +++ b/api/src/main/kotlin/com/cubetiqs/web/modules/user/UserEntity.kt @@ -3,20 +3,27 @@ package com.cubetiqs.web.modules.user import org.hibernate.Hibernate import java.io.Serializable import java.util.* -import javax.persistence.* +import jakarta.persistence.* +import org.hibernate.annotations.GenericGenerator @UserModule @Entity -@Table(name = "user") +@Table(name = "`user`") open class UserEntity( @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(generator = "custom-uuid") + @GenericGenerator( + name = "custom-uuid", + strategy = "org.hibernate.id.UUIDGenerator", + parameters = [org.hibernate.annotations.Parameter(name = "uuid_gen_strategy_class", value = "org.hibernate.id.uuid.CustomVersionOneStrategy")] + ) + @Column(columnDefinition = "BINARY(16)") open var id: UUID? = null, - @Column(name = "name", length = 50) + @Column(name = "`name`", length = 50) open var name: String? = null, - @Column(name = "username", length = 50, unique = true) + @Column(name = "`username`", length = 50, unique = true) open var username: String? = null, ) : Serializable { override fun equals(other: Any?): Boolean { diff --git a/api/src/main/resources/application.yml b/api/src/main/resources/application.yml index 9cf6b43..d09e7ea 100644 --- a/api/src/main/resources/application.yml +++ b/api/src/main/resources/application.yml @@ -27,8 +27,9 @@ spring: password: ${DATASOURCE_PASSWORD:password} jpa: hibernate: - ddl-auto: ${JPA_HIBERNATE_DDL_AUTO:update} + ddl-auto: ${JPA_HIBERNATE_DDL_AUTO:create-drop} open-in-view: ${JPA_OPEN_IN_VIEW:false} + database-platform: ${JPA_DATABASE_PLATFORM:org.hibernate.dialect.H2Dialect} data: redis: repositories: @@ -55,5 +56,3 @@ logging: springdoc: api-docs: enabled: ${API_DOCS_ENABLED:true} - swagger-ui: - path: /swagger-ui diff --git a/build.gradle.kts b/build.gradle.kts index fb79a9a..c4ae243 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,9 +3,9 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id("org.springframework.boot") version "3.0.0" apply false id("io.spring.dependency-management") version "1.1.0" apply false - kotlin("jvm") version "1.7.21" apply false + kotlin("jvm") version "1.7.22" apply false kotlin("plugin.spring") version "1.7.22" apply false - kotlin("plugin.jpa") version "1.7.21" apply false + kotlin("plugin.jpa") version "1.7.22" apply false } allprojects { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8049c68..ae04661 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists