Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/module #5

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions high-api-server/src/main/resources/application.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package wiki.hi.hiwikiserver.core.user.domain

enum class Authority {
USER, MANAGER, ADMIN
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package wiki.hi.hiwikiserver.core.user.domain

class Email(
email: String
) {
companion object {
fun of(email: String): Email{
if (email.endsWith("hs.kr"))
return Email(email)

else
throw IllegalArgumentException("email의 형식이 올바르지 않습니다.")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package wiki.hi.hiwikiserver.core.user.domain

data class User (
val id: Long,
val email: Email,
val nickName: String,
val authority: Authority,
val schoolId: Long,
val contributeId: ArrayList<Long>,
val thumbsUpsId: ArrayList<Long>
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ plugins {

dependencies {
// impl project
implementation(project(":high-persistence"))
implementation(project(":high-core"))
runtimeOnly(project(":high-internal-api-server"))

// web
implementation(Dependencies.SPRING_WEB)
implementation(project(":high-presentation"))

// validation
implementation(Dependencies.SPRING_VALIDATION)
Expand All @@ -33,9 +31,15 @@ dependencies {

// aop
implementation(Dependencies.AOP)
}

kapt {
arguments {
arg("mapstruct.defaultComponentModel", "spring")
arg("mapstruct.unmappedTargetPolicy", "ignore")
}
}

tasks.getByName<Jar>("bootJar") {
tasks.getByName<Jar>("jar") {
enabled = false
}
6 changes: 6 additions & 0 deletions high-infrastructure/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
spring:
config:
import:
- core.yml
- presentation.yml
- persistence.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package wiki.hi.hiwikiserver

import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest

@SpringBootTest
class HiwikiServerApplicationTests {

@Test
fun contextLoads() {
}
// @Test
// fun contextLoads() {
// }

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {

dependencies {
// impl project
compileOnly(project(":high-core"))
implementation(project(":high-core"))

// database
implementation(Dependencies.SPRING_DATA_JPA)
Expand All @@ -16,6 +16,7 @@ dependencies {
// querydsl
implementation(Dependencies.QUERYDSL)
kapt(Dependencies.QUERYDSL_PROCESSOR)

}

allOpen {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package wiki.hi.hiwikiserver.persistence

interface GenericMapper<D, E> {
fun toDomain(entity: E): D

fun toEntity(domain: D): E
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package wiki.hi.hiwikiserver.persistence.user.entity

import wiki.hi.hiwikiserver.core.user.domain.Authority
import wiki.hi.hiwikiserver.core.user.domain.Email
import javax.persistence.*

@Entity
@Table(name = "USER")
class UserJpaEntity (
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
val id: Long?,
@Embedded
val email: Email,
val nickName: String,
val authority: Authority,
val schoolId: Long
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package wiki.hi.hiwikiserver.persistence.user.mapper

import wiki.hi.hiwikiserver.core.user.domain.User
import wiki.hi.hiwikiserver.persistence.GenericMapper
import wiki.hi.hiwikiserver.persistence.user.entity.UserJpaEntity

class UserMapper : GenericMapper<User, UserJpaEntity> {
override fun toDomain(entity: UserJpaEntity): User {
TODO("ThumbsUpsId과 contributeId 때문에 추후에 개발")
}

override fun toEntity(domain: User): UserJpaEntity {

return UserJpaEntity(
id = domain.id,
email = domain.email,
nickName = domain.nickName,
authority = domain.authority,
schoolId = domain.schoolId
)
}

}
20 changes: 20 additions & 0 deletions high-persistence/src/main/resources/persistence.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: ${DB_URL}
username: ${DB_USERNAME}
password: ${DB_PASSWORD}

logging:
level:
org:
hibernate:
SQL: debug

jpa:
database: mysql

database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
generate-ddl: true
hibernate:
ddl-auto: update
20 changes: 20 additions & 0 deletions high-presentation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
plugins {
id("org.springframework.boot") version PluginVersions.SPRING_BOOT_VERSION
id("io.spring.dependency-management") version PluginVersions.DEPENDENCY_MANAGER_VERSION
kotlin("plugin.spring") version PluginVersions.SPRING_PLUGIN_VERSION
}

dependencies {
// impl project
implementation(project(":high-core"))

// web
implementation(Dependencies.SPRING_WEB)

// validation
implementation(Dependencies.SPRING_VALIDATION)
}

tasks.getByName<Jar>("bootJar") {
enabled = false
}
Empty file.
5 changes: 3 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
rootProject.name = "hiwiki-server"

include("high-core")
include("high-internal-api-server")
include("high-api-server")
include("high-presentation")
include("high-persistence")
include("high-infrastructure")