diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0aaefbca..1af9e093 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/kotlin/com/damaba/damaba/application/photographer/Command.kt b/src/main/kotlin/com/damaba/damaba/application/photographer/Command.kt index 02e9c210..d6dd3613 100644 --- a/src/main/kotlin/com/damaba/damaba/application/photographer/Command.kt +++ b/src/main/kotlin/com/damaba/damaba/application/photographer/Command.kt @@ -1,10 +1,12 @@ package com.damaba.damaba.application.photographer +import com.damaba.damaba.application.term.TermItem import com.damaba.damaba.domain.common.Address import com.damaba.damaba.domain.common.constant.PhotographyType import com.damaba.damaba.domain.file.Image import com.damaba.damaba.domain.photographer.PhotographerValidator import com.damaba.damaba.domain.region.Region +import com.damaba.damaba.domain.term.TermValidator import com.damaba.damaba.domain.user.UserValidator import com.damaba.damaba.domain.user.constant.Gender @@ -16,12 +18,14 @@ data class RegisterPhotographerCommand( val profileImage: Image, val mainPhotographyTypes: Set, val activeRegions: Set, + val terms: List, ) { init { PhotographerValidator.validateNickname(nickname) if (instagramId != null) UserValidator.validateInstagramId(instagramId) PhotographerValidator.validateMainPhotographyTypes(mainPhotographyTypes) PhotographerValidator.validateActiveRegions(activeRegions) + TermValidator.validatePhotographerRequired(terms) } } diff --git a/src/main/kotlin/com/damaba/damaba/application/photographer/PhotographerService.kt b/src/main/kotlin/com/damaba/damaba/application/photographer/PhotographerService.kt index 5d9bf516..23fc4d75 100644 --- a/src/main/kotlin/com/damaba/damaba/application/photographer/PhotographerService.kt +++ b/src/main/kotlin/com/damaba/damaba/application/photographer/PhotographerService.kt @@ -1,11 +1,13 @@ package com.damaba.damaba.application.photographer +import com.damaba.damaba.application.term.TermItem import com.damaba.damaba.domain.common.Pagination import com.damaba.damaba.domain.photographer.Photographer import com.damaba.damaba.domain.photographer.PhotographerListItem import com.damaba.damaba.domain.photographer.PhotographerSave import com.damaba.damaba.domain.photographer.exception.AlreadyPhotographerSaveException import com.damaba.damaba.domain.photographer.exception.PhotographerSaveNotFoundException +import com.damaba.damaba.domain.term.Term import com.damaba.damaba.domain.user.User import com.damaba.damaba.domain.user.exception.NicknameAlreadyExistsException import com.damaba.damaba.domain.user.exception.UserAlreadyRegisteredException @@ -13,6 +15,7 @@ import com.damaba.damaba.infrastructure.photographer.PhotographerRepository import com.damaba.damaba.infrastructure.photographer.PhotographerSaveRepository import com.damaba.damaba.infrastructure.promotion.PromotionRepository import com.damaba.damaba.infrastructure.promotion.PromotionSaveRepository +import com.damaba.damaba.infrastructure.term.TermRepository import com.damaba.damaba.infrastructure.user.UserRepository import com.damaba.damaba.mapper.PhotographerMapper import org.springframework.stereotype.Service @@ -25,6 +28,7 @@ class PhotographerService( private val photographerSaveRepo: PhotographerSaveRepository, private val promotionRepo: PromotionRepository, private val promotionSaveRepo: PromotionSaveRepository, + private val termRepo: TermRepository, ) { @Transactional fun register(command: RegisterPhotographerCommand): Photographer { @@ -46,7 +50,21 @@ class PhotographerService( mainPhotographyTypes = command.mainPhotographyTypes, activeRegions = command.activeRegions, ) - return photographerRepo.createIfUserExists(photographer) + val saved = photographerRepo.createIfUserExists(photographer) + + if (command.terms.isNotEmpty()) { + val termList: List = command.terms.map { item: TermItem -> + Term( + id = null, + userId = saved.id, + type = item.type, + agreed = item.agreed, + ) + } + termRepo.saveAll(termList) + } + + return saved } @Transactional diff --git a/src/main/kotlin/com/damaba/damaba/application/term/Command.kt b/src/main/kotlin/com/damaba/damaba/application/term/Command.kt new file mode 100644 index 00000000..fbe18008 --- /dev/null +++ b/src/main/kotlin/com/damaba/damaba/application/term/Command.kt @@ -0,0 +1,29 @@ +package com.damaba.damaba.application.term + +import com.damaba.damaba.domain.term.TermType +import com.damaba.damaba.domain.term.TermValidator + +data class TermItem( + val type: TermType, + val agreed: Boolean, +) + +data class AcceptUserTermsCommand( + val userId: Long, + val terms: List, +) { + init { + // TermValidator 에서 필수 약관 체크 + TermValidator.validateUserRequired(terms) + } +} + +data class AcceptPhotographerTermsCommand( + val userId: Long, + val terms: List, +) { + init { + // TermValidator 에서 유저+작가 필수 약관 체크 + TermValidator.validatePhotographerRequired(terms) + } +} diff --git a/src/main/kotlin/com/damaba/damaba/application/term/TermService.kt b/src/main/kotlin/com/damaba/damaba/application/term/TermService.kt new file mode 100644 index 00000000..db54076b --- /dev/null +++ b/src/main/kotlin/com/damaba/damaba/application/term/TermService.kt @@ -0,0 +1,39 @@ +package com.damaba.damaba.application.term + +import com.damaba.damaba.domain.term.Term +import com.damaba.damaba.infrastructure.term.TermRepository +import jakarta.transaction.Transactional +import org.springframework.stereotype.Service + +@Service +class TermService( + private val termRepo: TermRepository, +) { + // 일반 유저용 약관 동의 내역 저장 + @Transactional + fun acceptUserTerms(command: AcceptUserTermsCommand) { + val userTerms = command.terms.map { item -> + Term( + id = 0L, + userId = command.userId, + type = item.type, + agreed = item.agreed, + ) + } + termRepo.saveAll(userTerms) + } + + // 사진 작가용 약관 동의 내역 저장 + @Transactional + fun acceptPhotographerTerms(command: AcceptPhotographerTermsCommand) { + val photoTerm = command.terms.map { item -> + Term( + id = 0L, + userId = command.userId, + type = item.type, + agreed = item.agreed, + ) + } + termRepo.saveAll(photoTerm) + } +} diff --git a/src/main/kotlin/com/damaba/damaba/application/user/Command.kt b/src/main/kotlin/com/damaba/damaba/application/user/Command.kt index 274f3eb4..6361b072 100644 --- a/src/main/kotlin/com/damaba/damaba/application/user/Command.kt +++ b/src/main/kotlin/com/damaba/damaba/application/user/Command.kt @@ -1,6 +1,8 @@ package com.damaba.damaba.application.user +import com.damaba.damaba.application.term.TermItem import com.damaba.damaba.domain.file.Image +import com.damaba.damaba.domain.term.TermValidator import com.damaba.damaba.domain.user.UserValidator import com.damaba.damaba.domain.user.constant.Gender @@ -9,10 +11,12 @@ data class RegisterUserCommand( val nickname: String, val gender: Gender, val instagramId: String?, + val terms: List, ) { init { UserValidator.validateNickname(nickname) if (instagramId != null) UserValidator.validateInstagramId(instagramId) + TermValidator.validateUserRequired(terms) } } diff --git a/src/main/kotlin/com/damaba/damaba/application/user/UserService.kt b/src/main/kotlin/com/damaba/damaba/application/user/UserService.kt index b3d952b5..6c6bd436 100644 --- a/src/main/kotlin/com/damaba/damaba/application/user/UserService.kt +++ b/src/main/kotlin/com/damaba/damaba/application/user/UserService.kt @@ -1,11 +1,14 @@ package com.damaba.damaba.application.user +import com.damaba.damaba.application.term.TermItem +import com.damaba.damaba.domain.term.Term import com.damaba.damaba.domain.user.User import com.damaba.damaba.domain.user.exception.NicknameAlreadyExistsException import com.damaba.damaba.domain.user.exception.UserAlreadyRegisteredException import com.damaba.damaba.domain.user.exception.UserNotFoundException import com.damaba.damaba.infrastructure.photographer.PhotographerSaveRepository import com.damaba.damaba.infrastructure.promotion.PromotionSaveRepository +import com.damaba.damaba.infrastructure.term.TermRepository import com.damaba.damaba.infrastructure.user.UserRepository import com.damaba.damaba.mapper.UserMapper import org.springframework.stereotype.Service @@ -16,6 +19,7 @@ class UserService( private val userRepo: UserRepository, private val photographerSaveRepo: PhotographerSaveRepository, private val promotionSaveRepo: PromotionSaveRepository, + private val termRepo: TermRepository, ) { @Transactional(readOnly = true) fun getUser(userId: Long): User = userRepo.getById(userId) @@ -49,7 +53,20 @@ class UserService( gender = command.gender, instagramId = command.instagramId, ) - return userRepo.update(user) + val saved = userRepo.update(user) + + if (command.terms.isNotEmpty()) { + val termList: List = command.terms.map { item: TermItem -> + Term( + id = 0L, + userId = saved.id, + type = item.type, + agreed = item.agreed, + ) + } + termRepo.saveAll(termList) + } + return saved } @Transactional diff --git a/src/main/kotlin/com/damaba/damaba/controller/photographer/Request.kt b/src/main/kotlin/com/damaba/damaba/controller/photographer/Request.kt index fe63f8be..50bf15e1 100644 --- a/src/main/kotlin/com/damaba/damaba/controller/photographer/Request.kt +++ b/src/main/kotlin/com/damaba/damaba/controller/photographer/Request.kt @@ -3,10 +3,13 @@ package com.damaba.damaba.controller.photographer import com.damaba.damaba.application.photographer.RegisterPhotographerCommand import com.damaba.damaba.application.photographer.UpdatePhotographerPageCommand import com.damaba.damaba.application.photographer.UpdatePhotographerProfileCommand +import com.damaba.damaba.application.term.TermItem import com.damaba.damaba.controller.common.AddressRequest import com.damaba.damaba.controller.common.ImageRequest import com.damaba.damaba.controller.region.RegionRequest +import com.damaba.damaba.controller.term.AgreementRequestItem import com.damaba.damaba.domain.common.constant.PhotographyType +import com.damaba.damaba.domain.term.TermType import com.damaba.damaba.domain.user.constant.Gender import com.damaba.damaba.mapper.AddressMapper import com.damaba.damaba.mapper.ImageMapper @@ -20,6 +23,7 @@ data class RegisterPhotographerRequest( val profileImage: ImageRequest, val mainPhotographyTypes: Set, val activeRegions: Set, + val agreements: List, ) { fun toCommand(requesterId: Long) = RegisterPhotographerCommand( userId = requesterId, @@ -29,6 +33,7 @@ data class RegisterPhotographerRequest( profileImage = ImageMapper.INSTANCE.toImage(profileImage), mainPhotographyTypes = mainPhotographyTypes, activeRegions = activeRegions.map { regionRequest -> RegionMapper.INSTANCE.toRegion(regionRequest) }.toSet(), + terms = agreements.map { TermItem(it.type, it.agreed) }, ) } @@ -69,4 +74,12 @@ data class UpdateMyPhotographerProfileRequest( mainPhotographyTypes = this.mainPhotographyTypes, activeRegions = this.activeRegions.map { RegionMapper.INSTANCE.toRegion(it) }.toSet(), ) + + data class AgreementRequestItem( + @Schema(description = "약관 종류", example = "SERVICE_TERMS") + val type: TermType, + + @Schema(description = "사용자 동의 여부", example = "ture") + val agreed: Boolean, + ) } diff --git a/src/main/kotlin/com/damaba/damaba/controller/term/Request.kt b/src/main/kotlin/com/damaba/damaba/controller/term/Request.kt new file mode 100644 index 00000000..b50510db --- /dev/null +++ b/src/main/kotlin/com/damaba/damaba/controller/term/Request.kt @@ -0,0 +1,14 @@ +@file:Suppress("ktlint:standard:filename") + +package com.damaba.damaba.controller.term + +import com.damaba.damaba.domain.term.TermType +import io.swagger.v3.oas.annotations.media.Schema + +data class AgreementRequestItem( + @Schema(description = "약관 항목", example = "SERVICE_TERMS") + val type: TermType, + + @Schema(description = "사용자의 동의 여부") + val agreed: Boolean, +) diff --git a/src/main/kotlin/com/damaba/damaba/controller/term/Response.kt b/src/main/kotlin/com/damaba/damaba/controller/term/Response.kt new file mode 100644 index 00000000..b446ab3b --- /dev/null +++ b/src/main/kotlin/com/damaba/damaba/controller/term/Response.kt @@ -0,0 +1,14 @@ +@file:Suppress("ktlint:standard:filename") + +package com.damaba.damaba.controller.term + +import com.damaba.damaba.domain.term.TermType +import io.swagger.v3.oas.annotations.media.Schema + +data class TermMetadataResponse( + @Schema(description = "약관 항목", example = "SERVICE_TERMS") + val type: TermType, + + @Schema(description = "필수 약관 여부", example = "true") + val required: Boolean, +) diff --git a/src/main/kotlin/com/damaba/damaba/controller/term/TermController.kt b/src/main/kotlin/com/damaba/damaba/controller/term/TermController.kt new file mode 100644 index 00000000..0832c538 --- /dev/null +++ b/src/main/kotlin/com/damaba/damaba/controller/term/TermController.kt @@ -0,0 +1,54 @@ +package com.damaba.damaba.controller.term + +import com.damaba.damaba.application.term.TermService +import com.damaba.damaba.domain.term.TermType +import io.swagger.v3.oas.annotations.Operation +import io.swagger.v3.oas.annotations.responses.ApiResponse +import io.swagger.v3.oas.annotations.responses.ApiResponses +import io.swagger.v3.oas.annotations.tags.Tag +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@Tag(name = "서비스 약관 동의 관련 API") +@RestController +@RequestMapping("/api/v1/terms") +class TermController( + private val termService: TermService, +) { + /** + * 일반 유저의 서비스 약관 동의 목록 조회 (type, required) + */ + @Operation( + summary = "회원용 약관 목록 조회", + description = "가입 시 일반 유저가 동의해야 하는 약관 동의 목록 조회", + ) + @ApiResponses( + ApiResponse(responseCode = "200"), + ) + @GetMapping("/user") + fun getUserTerms(): ResponseEntity> { + val userTerms = TermType.values() + .filter { it != TermType.PHOTOGRAPHER_TERMS } + .map { TermMetadataResponse(type = it, required = it.required) } + return ResponseEntity.ok(userTerms) + } + + /** + * 사진 작가의 서비스 약관 동의 목록 조회 (type, required) + */ + @Operation( + summary = "작가용 약관 목록 조회", + description = "가입 시 작가가 동의해야 하는 약관 동의 목록 조회", + ) + @ApiResponses( + ApiResponse(responseCode = "200"), + ) + @GetMapping("/photographer") + fun getPhotographerTerms(): ResponseEntity> { + val photographerTerms = TermType.values() + .map { TermMetadataResponse(type = it, required = it.required) } + return ResponseEntity.ok(photographerTerms) + } +} diff --git a/src/main/kotlin/com/damaba/damaba/controller/user/Request.kt b/src/main/kotlin/com/damaba/damaba/controller/user/Request.kt index 3846d988..87ca2a85 100644 --- a/src/main/kotlin/com/damaba/damaba/controller/user/Request.kt +++ b/src/main/kotlin/com/damaba/damaba/controller/user/Request.kt @@ -1,8 +1,10 @@ package com.damaba.damaba.controller.user +import com.damaba.damaba.application.term.TermItem import com.damaba.damaba.application.user.RegisterUserCommand import com.damaba.damaba.application.user.UpdateUserProfileCommand import com.damaba.damaba.controller.common.ImageRequest +import com.damaba.damaba.controller.term.AgreementRequestItem import com.damaba.damaba.domain.user.constant.Gender import com.damaba.damaba.mapper.ImageMapper import io.swagger.v3.oas.annotations.media.Schema @@ -16,12 +18,25 @@ data class RegisterUserRequest( @Schema(description = "인스타 아이디", example = "damaba.unofficial") val instagramId: String?, + + @Schema( + description = "동의한 약관 목록", + example = """ + [ + { "type": "AGE_CONFIRMATION", "agreed": true }, + { "type": "SERVICE_TERMS", "agreed": true }, + { "type": "PRIVACY_TERMS", "agreed": true } + ] + """, + ) + val agreements: List, ) { fun toCommand(requestUserId: Long) = RegisterUserCommand( userId = requestUserId, nickname = nickname, gender = gender, instagramId = instagramId, + terms = agreements.map { TermItem(it.type, it.agreed) }, ) } @@ -42,3 +57,11 @@ data class UpdateMyProfileRequest( profileImage = profileImage?.let { ImageMapper.INSTANCE.toImage(it) }, ) } + +data class AgreementRequestItem( + @Schema(description = "약관 종류", example = "SERVICE_TERMS") + val type: String, + + @Schema(description = "사용자 동의 여부", example = "true") + val agreed: Boolean, +) diff --git a/src/main/kotlin/com/damaba/damaba/domain/term/Term.kt b/src/main/kotlin/com/damaba/damaba/domain/term/Term.kt new file mode 100644 index 00000000..6855e691 --- /dev/null +++ b/src/main/kotlin/com/damaba/damaba/domain/term/Term.kt @@ -0,0 +1,11 @@ +package com.damaba.damaba.domain.term + +class Term( + val id: Long, + val userId: Long, + val type: TermType, + agreed: Boolean, +) { + var agreed: Boolean = agreed + private set +} diff --git a/src/main/kotlin/com/damaba/damaba/domain/term/TermType.kt b/src/main/kotlin/com/damaba/damaba/domain/term/TermType.kt new file mode 100644 index 00000000..b9ab1e3b --- /dev/null +++ b/src/main/kotlin/com/damaba/damaba/domain/term/TermType.kt @@ -0,0 +1,10 @@ +package com.damaba.damaba.domain.term + +enum class TermType( + val required: Boolean, +) { + AGE_CONFIRMATION(required = true), + SERVICE_TERMS(required = true), + PRIVACY_TERMS(required = true), + PHOTOGRAPHER_TERMS(required = true), +} diff --git a/src/main/kotlin/com/damaba/damaba/domain/term/TermValidator.kt b/src/main/kotlin/com/damaba/damaba/domain/term/TermValidator.kt new file mode 100644 index 00000000..8353554b --- /dev/null +++ b/src/main/kotlin/com/damaba/damaba/domain/term/TermValidator.kt @@ -0,0 +1,26 @@ +package com.damaba.damaba.domain.term + +import com.damaba.damaba.application.term.TermItem + +object TermValidator { + private val userRequired = setOf( + TermType.AGE_CONFIRMATION, + TermType.PRIVACY_TERMS, + TermType.SERVICE_TERMS, + ) + private val photographerRequired = userRequired + TermType.PHOTOGRAPHER_TERMS + + fun validateUserRequired(items: List) { + val agreedSet = items.filter { it.agreed }.map { it.type }.toSet() + if (!agreedSet.containsAll(userRequired)) { + throw IllegalArgumentException("(유저) 필수 약관에 모두 동의해야 합니다.") + } + } + + fun validatePhotographerRequired(items: List) { + val agreedSet = items.filter { it.agreed }.map { it.type }.toSet() + if (!agreedSet.containsAll(photographerRequired)) { + throw IllegalArgumentException("(작가) 필수 약관에 모두 동의해야 합니다.") + } + } +} diff --git a/src/main/kotlin/com/damaba/damaba/infrastructure/term/TermCoreRepository.kt b/src/main/kotlin/com/damaba/damaba/infrastructure/term/TermCoreRepository.kt new file mode 100644 index 00000000..81c1ccd0 --- /dev/null +++ b/src/main/kotlin/com/damaba/damaba/infrastructure/term/TermCoreRepository.kt @@ -0,0 +1,15 @@ +package com.damaba.damaba.infrastructure.term + +import com.damaba.damaba.domain.term.Term +import org.springframework.stereotype.Repository + +@Repository +class TermCoreRepository( + private val jpaRepository: TermJpaRepository, +) : TermRepository { + + override fun saveAll(terms: List): List { + val entities = terms.map { TermJpaEntity.fromTerm(it) } + return jpaRepository.saveAll(entities).map { it.toTerm() } + } +} diff --git a/src/main/kotlin/com/damaba/damaba/infrastructure/term/TermJpaEntity.kt b/src/main/kotlin/com/damaba/damaba/infrastructure/term/TermJpaEntity.kt new file mode 100644 index 00000000..7f746226 --- /dev/null +++ b/src/main/kotlin/com/damaba/damaba/infrastructure/term/TermJpaEntity.kt @@ -0,0 +1,50 @@ +package com.damaba.damaba.infrastructure.term + +import com.damaba.damaba.domain.term.Term +import com.damaba.damaba.domain.term.TermType +import com.damaba.damaba.infrastructure.common.TimeTrackedJpaEntity +import jakarta.persistence.Column +import jakarta.persistence.Entity +import jakarta.persistence.EnumType +import jakarta.persistence.Enumerated +import jakarta.persistence.GeneratedValue +import jakarta.persistence.GenerationType +import jakarta.persistence.Id +import jakarta.persistence.Table + +@Entity +@Table(name = "term") +class TermJpaEntity( + @Column(name = "user_id", nullable = false) + val userId: Long, + + @Enumerated(EnumType.STRING) + @Column(name = "type", nullable = false) + val type: TermType, + + agreed: Boolean, +) : TimeTrackedJpaEntity() { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + val id: Long = 0 + + @Column(name = "agreed", nullable = false) + var agreed: Boolean = agreed + private set + + fun toTerm(): Term = Term( + id = this.id, + userId = this.userId, + type = this.type, + agreed = this.agreed, + ) + + companion object { + fun fromTerm(term: Term): TermJpaEntity = TermJpaEntity( + userId = term.userId, + type = term.type, + agreed = term.agreed, + ) + } +} diff --git a/src/main/kotlin/com/damaba/damaba/infrastructure/term/TermJpaRepository.kt b/src/main/kotlin/com/damaba/damaba/infrastructure/term/TermJpaRepository.kt new file mode 100644 index 00000000..b87428d0 --- /dev/null +++ b/src/main/kotlin/com/damaba/damaba/infrastructure/term/TermJpaRepository.kt @@ -0,0 +1,5 @@ +package com.damaba.damaba.infrastructure.term + +import org.springframework.data.jpa.repository.JpaRepository + +interface TermJpaRepository : JpaRepository diff --git a/src/main/kotlin/com/damaba/damaba/infrastructure/term/TermRepository.kt b/src/main/kotlin/com/damaba/damaba/infrastructure/term/TermRepository.kt new file mode 100644 index 00000000..00f7fd13 --- /dev/null +++ b/src/main/kotlin/com/damaba/damaba/infrastructure/term/TermRepository.kt @@ -0,0 +1,7 @@ +package com.damaba.damaba.infrastructure.term + +import com.damaba.damaba.domain.term.Term + +interface TermRepository { + fun saveAll(terms: List): List +} diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index fd3c642b..6b51674e 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -4,6 +4,7 @@ spring: jpa: properties: hibernate: + ddl-auto: update format_sql: true defer-datasource-initialization: false diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 48cbf451..26de4259 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -36,7 +36,7 @@ spring: jpa: hibernate: - ddl-auto: validate + ddl-auto: update open-in-view: false properties: hibernate: diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index bd2c9883..de043b9f 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -11,6 +11,7 @@ DROP TABLE IF EXISTS promotion_image; DROP TABLE IF EXISTS promotion_active_region; DROP TABLE IF EXISTS promotion_hashtag; DROP TABLE IF EXISTS promotion_save; +DROP TABLE IF EXISTS term; CREATE TABLE `user` ( @@ -185,5 +186,15 @@ CREATE TABLE promotion_save updated_at TIMESTAMP NOT NULL, PRIMARY KEY (id) ); +CREATE TABLE term +( + id BIGINT NOT NULL AUTO_INCREMENT, + user_id BIGINT NOT NULL COMMENT '(FK) id of user', + type VARCHAR(255) NOT NULL, + agreed BOOLEAN NOT NULL, + created_at TIMESTAMP NOT NULL , + updated_at TIMESTAMP NOT NULL, + PRIMARY KEY (id) +); CREATE INDEX fk_idx__promotion_save__user_id ON promotion_save (user_id); CREATE INDEX fk_idx__promotion_save__promotion_id ON promotion_save (promotion_id);