-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
54 changed files
with
1,664 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,3 +175,5 @@ gradle-app.setting | |
*.hprof | ||
|
||
redis/ | ||
|
||
.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/com/mjucow/eatda/common/config/S3Config.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.mjucow.eatda.common.config | ||
|
||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.context.annotation.Profile | ||
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials | ||
import software.amazon.awssdk.regions.Region | ||
import software.amazon.awssdk.services.s3.presigner.S3Presigner | ||
|
||
@Configuration | ||
@Profile("prod") | ||
class S3Config( | ||
@Value("\${aws.s3.credentials.access-key}") | ||
private val accessKey: String, | ||
@Value("\${aws.s3.credentials.secret-key}") | ||
private val secretKey: String, | ||
) { | ||
|
||
@Bean | ||
fun s3Presigner(): S3Presigner { | ||
val credential = AwsBasicCredentials.create(accessKey, secretKey) | ||
|
||
return S3Presigner.builder() | ||
.region(Region.AP_NORTHEAST_2) | ||
.credentialsProvider { credential } | ||
.build() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.mjucow.eatda.common.vo | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
|
||
@JvmInline | ||
value class Latitude( | ||
@JsonProperty(value = "latitude") | ||
val value: Double, | ||
) { | ||
init { | ||
if (LATITUDE_MIN > value || LATITUDE_MAX < value) { | ||
throw IllegalArgumentException() | ||
} | ||
} | ||
|
||
companion object { | ||
const val LATITUDE_MIN = 33.0 | ||
const val LATITUDE_MAX = 43.0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.mjucow.eatda.common.vo | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
|
||
@JvmInline | ||
value class Longitude( | ||
@JsonProperty(value = "longitude") | ||
val value: Double, | ||
) { | ||
init { | ||
if (LONGITUDE_MIN > value || LONGITUDE_MAX < value) { | ||
throw IllegalArgumentException() | ||
} | ||
} | ||
|
||
companion object { | ||
const val LONGITUDE_MIN = 124.0 | ||
const val LONGITUDE_MAX = 132.0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/main/kotlin/com/mjucow/eatda/domain/curation/entity/Curation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.mjucow.eatda.domain.curation.entity | ||
|
||
import com.mjucow.eatda.domain.common.BaseEntity | ||
import com.mjucow.eatda.domain.store.entity.Store | ||
import jakarta.persistence.CascadeType | ||
import jakarta.persistence.Column | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.FetchType | ||
import jakarta.persistence.JoinColumn | ||
import jakarta.persistence.JoinTable | ||
import jakarta.persistence.ManyToMany | ||
import jakarta.persistence.Table | ||
|
||
@Entity | ||
@Table(name = "curation") | ||
class Curation() : BaseEntity() { | ||
constructor( | ||
title: String, | ||
description: String, | ||
imageAddress: String, | ||
) : this() { | ||
this.title = title | ||
this.description = description | ||
this.imageAddress = imageAddress | ||
} | ||
|
||
@Column(nullable = false) | ||
var title: String = "" | ||
set(value) { | ||
validateTitle(value) | ||
field = value | ||
} | ||
|
||
@Column(nullable = false) | ||
var description: String = "" | ||
set(value) { | ||
validateDescription(value) | ||
field = value | ||
} | ||
|
||
@Column(nullable = false) | ||
var imageAddress: String = "" | ||
|
||
@ManyToMany(fetch = FetchType.LAZY, cascade = [CascadeType.PERSIST, CascadeType.MERGE]) | ||
@JoinTable( | ||
name = "curation_store", | ||
joinColumns = [JoinColumn(name = "curation_id")], | ||
inverseJoinColumns = [JoinColumn(name = "store_id")] | ||
) | ||
val mutableStores: MutableSet<Store> = mutableSetOf() | ||
|
||
fun getStores(): Set<Store> = mutableStores.toSet() | ||
|
||
fun addStore(store: Store) { | ||
mutableStores.add(store) | ||
} | ||
|
||
private fun validateTitle(title: String) { | ||
require(title.isNotBlank() && title.length <= MAX_TITLE_LENGTH) | ||
} | ||
|
||
private fun validateDescription(description: String) { | ||
require(description.isNotBlank() && description.length <= MAX_DESCRIPTION_LENGTH) | ||
} | ||
|
||
companion object { | ||
const val MAX_TITLE_LENGTH = 255 | ||
const val MAX_DESCRIPTION_LENGTH = 255 | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/kotlin/com/mjucow/eatda/domain/curation/service/command/CurationCommandService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.mjucow.eatda.domain.curation.service.command | ||
|
||
import com.mjucow.eatda.domain.curation.entity.Curation | ||
import com.mjucow.eatda.domain.curation.service.command.dto.AddStoreCommand | ||
import com.mjucow.eatda.domain.curation.service.command.dto.CreateCurationCommand | ||
import com.mjucow.eatda.domain.curation.service.command.dto.UpdateCurationCommand | ||
import com.mjucow.eatda.persistence.curation.CurationRepository | ||
import com.mjucow.eatda.persistence.store.StoreRepository | ||
import org.springframework.data.repository.findByIdOrNull | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Service | ||
@Transactional | ||
class CurationCommandService( | ||
private val repository: CurationRepository, | ||
private val storeRepository: StoreRepository, | ||
|
||
) { | ||
fun create(command: CreateCurationCommand): Long { | ||
return repository.save(Curation(command.title, command.description, command.imageAddress)).id | ||
} | ||
|
||
fun update(id: Long, command: UpdateCurationCommand) { | ||
val (newTitle, newDescription, newImageAddress) = command | ||
val updatedCuration = repository.getReferenceById(id).apply { | ||
title = newTitle | ||
description = newDescription | ||
imageAddress = newImageAddress | ||
} | ||
|
||
repository.save(updatedCuration) | ||
} | ||
|
||
fun delete(id: Long) { | ||
val curation = repository.findByIdOrNull(id) ?: return | ||
|
||
repository.delete(curation) | ||
} | ||
|
||
fun addStore(id: Long, command: AddStoreCommand): Long { | ||
val (storeId) = command | ||
val curation = repository.getReferenceById(id) | ||
val store = storeRepository.getReferenceById(storeId) | ||
|
||
curation.addStore(store) | ||
|
||
return repository.save(curation).id | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/com/mjucow/eatda/domain/curation/service/command/dto/AddStoreCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.mjucow.eatda.domain.curation.service.command.dto | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class AddStoreCommand( | ||
@Schema(name = "storeId", example = "1") | ||
val storeId: Long, | ||
) |
12 changes: 12 additions & 0 deletions
12
...main/kotlin/com/mjucow/eatda/domain/curation/service/command/dto/CreateCurationCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.mjucow.eatda.domain.curation.service.command.dto | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class CreateCurationCommand( | ||
@Schema(name = "title", example = "큐레이션 제목") | ||
val title: String, | ||
@Schema(name = "description", example = "큐레이션 설명") | ||
val description: String, | ||
@Schema(name = "imageAddress", example = "store/232D8241-C6A9-4AD9-B0EA-56F6DD24BADF.png") | ||
val imageAddress: String, | ||
) |
12 changes: 12 additions & 0 deletions
12
...main/kotlin/com/mjucow/eatda/domain/curation/service/command/dto/UpdateCurationCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.mjucow.eatda.domain.curation.service.command.dto | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class UpdateCurationCommand( | ||
@Schema(name = "title", example = "수정할 큐레이션 제목") | ||
val title: String, | ||
@Schema(name = "description", example = "수정할 큐레이션 설명") | ||
val description: String, | ||
@Schema(name = "imageAddress", example = "store/232D8241-C6A9-4AD9-B0EA-56F6DD24BADF.png") | ||
val imageAddress: String, | ||
) |
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/com/mjucow/eatda/domain/curation/service/query/CurationQueryService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.mjucow.eatda.domain.curation.service.query | ||
|
||
import com.mjucow.eatda.domain.curation.service.query.dto.CurationDto | ||
import com.mjucow.eatda.domain.curation.service.query.dto.Curations | ||
import com.mjucow.eatda.persistence.curation.CurationRepository | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Service | ||
@Transactional(readOnly = true) | ||
class CurationQueryService( | ||
private val repository: CurationRepository, | ||
) { | ||
fun findAll(): Curations { | ||
return Curations(repository.findAll().map(CurationDto::from)) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/com/mjucow/eatda/domain/curation/service/query/dto/CurationDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.mjucow.eatda.domain.curation.service.query.dto | ||
|
||
import com.fasterxml.jackson.annotation.JsonUnwrapped | ||
import com.mjucow.eatda.domain.curation.entity.Curation | ||
import com.mjucow.eatda.domain.store.service.query.dto.StoreDto | ||
import com.mjucow.eatda.domain.store.service.query.dto.Stores | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class CurationDto( | ||
@Schema(name = "id", example = "1") | ||
val id: Long, | ||
@Schema(name = "title", example = "명지대 점심 특선") | ||
val title: String, | ||
@Schema(name = "description", example = "점심 특선 메뉴를 판매하는 음식점들이에요.") | ||
val description: String, | ||
@Schema(name = "imageAddress", example = "store/232D8241-C6A9-4AD9-B0EA-56F6DD24BADF.png") | ||
val imageAddress: String, | ||
@JsonUnwrapped val stores: Stores? = null, | ||
) { | ||
|
||
companion object { | ||
fun from(domain: Curation): CurationDto { | ||
return CurationDto( | ||
id = domain.id, | ||
title = domain.title, | ||
description = domain.description, | ||
imageAddress = domain.imageAddress, | ||
stores = Stores(domain.getStores().map(StoreDto::from)) | ||
) | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/com/mjucow/eatda/domain/curation/service/query/dto/Curations.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.mjucow.eatda.domain.curation.service.query.dto | ||
|
||
data class Curations( | ||
val curationList: List<CurationDto>, | ||
) : ArrayList<CurationDto>(curationList) |
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/com/mjucow/eatda/domain/s3/dto/PresignedUrlDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.mjucow.eatda.domain.s3.dto | ||
|
||
import java.net.URL | ||
|
||
data class PresignedUrlDto( | ||
val url: URL, | ||
) { | ||
|
||
companion object { | ||
fun from(url: URL): PresignedUrlDto { | ||
return PresignedUrlDto(url) | ||
} | ||
} | ||
} |
Oops, something went wrong.