Skip to content

Commit

Permalink
Feat[#2]: User 엔티티 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobhboy committed Jun 27, 2023
1 parent 5c6d19d commit e59840b
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 3 deletions.
2 changes: 1 addition & 1 deletion high-api-server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ spring:
config:
import:
- core.yml
- persistence.yml
- infrastructure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ data class User (
val authority: Authority,
val schoolId: Long,
val contributeId: ArrayList<Long>,
val thumbsUpId: ArrayList<Long>
val thumbsUpsId: ArrayList<Long>
)
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-internal-api-server/src/main/resources/infrastructure.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

This file was deleted.

0 comments on commit e59840b

Please sign in to comment.