-
Notifications
You must be signed in to change notification settings - Fork 1
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
21 changed files
with
268 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# 리뷰 생성 | ||
|
||
리뷰를 생성합니다. | ||
|
||
## Request | ||
|
||
### HTTP METHOD : `POST` | ||
|
||
### url : `https://api.misik.me/reviews` | ||
### Http Headers | ||
- device-id: 식별할 수 있는 값 | ||
`미래에도 변하지 않아야함 앱을 삭제했다 다시 깔아도 안변하는 값으로 줄 수 있는지` | ||
|
||
### RequestBody | ||
|
||
```json | ||
{ | ||
"ocrText": "", | ||
"hashTag": ["특별한 메뉴가 있어요", "뷰가 좋아요", ..., "종류가 다양해요"], | ||
"reviewStyle": "딱딱한 미식가" | ||
} | ||
``` | ||
|
||
### Response | ||
|
||
#### `Response Status 200 OK` | ||
|
||
```json | ||
{ | ||
"id": "123456789", | ||
"review": "카야토스는 숨겨져 있는 카야잼과 버터가 확실히 가득합니다. 또한, 가게의 분위기는 아늑하고 편안하고 바깥쪽에 있고 사랑하는 시간을 보낼 수 있는 공간입니다. 무엇보다 가격에 비해 음식의 품질이 정말 훌륭해서, 마음에 들었습니다." | ||
} | ||
``` |
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,23 @@ | ||
# 리뷰 재생성 | ||
|
||
리뷰를 재생성합니다. | ||
|
||
## Request | ||
|
||
### HTTP METHOD : `POST` | ||
|
||
### url : `https://api.misik.me/reviews/{id}/re-create` | ||
### Http Headers | ||
- device-id: 식별할 수 있는 값 | ||
`미래에도 변하지 않아야함 앱을 삭제했다 다시 깔아도 안변하는 값으로 줄 수 있는지` | ||
|
||
### Response | ||
|
||
#### `Response Status 200 OK` | ||
|
||
```json | ||
{ | ||
"id": "123456789", | ||
"review": "가득합니다....." | ||
} | ||
``` |
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,25 @@ | ||
# 가능한 어조 조회 | ||
|
||
선택 가능한 어조를 조회합니다. | ||
|
||
## Request | ||
|
||
### HTTP METHOD : `GET` | ||
|
||
### url : `https://api.misik.me/reviews/styles` | ||
|
||
### Response | ||
|
||
#### `Response Status 200 OK` | ||
|
||
```json | ||
{ | ||
"reviewStyles": [ | ||
{ | ||
"icon": "https://static.misik.me/", | ||
"style": "딱딱한 미식가" | ||
}, | ||
... | ||
] | ||
} | ||
``` |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
dependencies { | ||
implementation "mysql:mysql-connector-java:${mysqlConnectorVersion}" | ||
implementation "com.github.f4b6a3:tsid-creator:${snowflakeVersion}" | ||
|
||
testRuntimeOnly "com.h2database:h2:${h2Version}" | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/kotlin/com/misik/api/Application.kt → src/main/kotlin/me/misik/api/Application.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
Empty file.
Empty file.
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 me.misik.api.core | ||
|
||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class AggregateRoot |
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 me.misik.api.core | ||
|
||
import java.time.Clock | ||
import java.time.Instant | ||
import java.time.ZoneId | ||
import java.time.ZonedDateTime | ||
|
||
object Clock { | ||
|
||
var clock: Clock = Clock.systemUTC() | ||
|
||
fun instant() = Instant.now(clock) | ||
|
||
fun Instant.toZonedDateTime() = ZonedDateTime.ofInstant(this, clock.zone) | ||
|
||
fun Instant.toZonedDateTime(zoneId: ZoneId) = ZonedDateTime.ofInstant(this, zoneId) | ||
|
||
fun Instant.toKr() = ZonedDateTime.ofInstant(this, ZoneId.of("Asia/Seoul")) | ||
|
||
} |
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,10 @@ | ||
package me.misik.api.core | ||
|
||
import com.github.f4b6a3.tsid.TsidFactory | ||
|
||
object IdGenerator { | ||
|
||
private val tsidFactory = TsidFactory.newInstance256() | ||
|
||
fun generate(): Long = tsidFactory.create().toLong() | ||
} |
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 me.misik.api.domain | ||
|
||
import jakarta.persistence.Column | ||
import jakarta.persistence.EntityListeners | ||
import jakarta.persistence.MappedSuperclass | ||
import jakarta.persistence.PrePersist | ||
import org.springframework.data.annotation.CreatedDate | ||
import org.springframework.data.annotation.LastModifiedDate | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener | ||
import java.time.Instant | ||
|
||
@MappedSuperclass | ||
@EntityListeners(AuditingEntityListener::class) | ||
abstract class AbstractTime( | ||
@CreatedDate | ||
@Column(name = "created_at") | ||
var createdAt: Instant = Instant.now(), | ||
|
||
@LastModifiedDate | ||
@Column(name = "modified_at") | ||
var modifiedAt: Instant? = null, | ||
) { | ||
|
||
@PrePersist | ||
fun prePersist() { | ||
modifiedAt = when (modifiedAt == null) { | ||
true -> createdAt | ||
false -> return | ||
} | ||
} | ||
} | ||
|
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 me.misik.api.domain | ||
|
||
import jakarta.persistence.* | ||
import me.misik.api.domain.converter.ListToStringConverter | ||
|
||
@Embeddable | ||
class RequestPrompt( | ||
@Enumerated(EnumType.STRING) | ||
@Column(name = "style", nullable = false, columnDefinition = "VARCHAR(20)") | ||
val style: ReviewStyle, | ||
|
||
@Column(name = "text", columnDefinition = "TEXT", nullable = false) | ||
val text: String, | ||
|
||
@Column(name = "hash_tags", columnDefinition = "TEXT", nullable = false) | ||
@Convert(converter = ListToStringConverter::class) | ||
val hashTags: List<String>, | ||
) { | ||
|
||
} |
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,30 @@ | ||
package me.misik.api.domain | ||
|
||
import jakarta.persistence.Column | ||
import jakarta.persistence.Embedded | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import jakarta.persistence.Table | ||
import me.misik.api.core.AggregateRoot | ||
|
||
|
||
@Entity(name = "review") | ||
@Table(name = "review") | ||
@AggregateRoot | ||
class Review( | ||
@Id | ||
@Column(name = "id") | ||
val id: Long, | ||
|
||
@Column(name = "text", length = 300, columnDefinition = "VARCHAR(300)", nullable = false) | ||
val text: String, | ||
|
||
@Column(name = "device_id", nullable = false, columnDefinition = "VARCHAR(100)") | ||
val deviceId: String, | ||
|
||
@Embedded | ||
val requestPrompt: RequestPrompt, | ||
): AbstractTime() { | ||
|
||
|
||
} |
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 me.misik.api.domain | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository | ||
|
||
interface ReviewRepository : JpaRepository<Review, Long> |
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,11 @@ | ||
package me.misik.api.domain | ||
|
||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Service | ||
@Transactional(readOnly = true) | ||
class ReviewService( | ||
private val reviewRepository: ReviewRepository, | ||
) { | ||
} |
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 me.misik.api.domain | ||
|
||
enum class ReviewStyle { | ||
DUMMY, | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/kotlin/me/misik/api/domain/converter/ListToStringConverter.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,23 @@ | ||
package me.misik.api.domain.converter | ||
|
||
import jakarta.persistence.AttributeConverter | ||
import jakarta.persistence.Converter | ||
|
||
@Converter | ||
class ListToStringConverter : AttributeConverter<List<String>, String> { | ||
|
||
override fun convertToDatabaseColumn(attribute: List<String>): String { | ||
val seperatorDeletedAttribute = attribute.map { it.replace(SEPERATOR, "") } | ||
|
||
return seperatorDeletedAttribute.joinToString(SEPERATOR) | ||
} | ||
|
||
override fun convertToEntityAttribute(dbData: String?): List<String> { | ||
return dbData?.split(SEPERATOR) ?: emptyList() | ||
} | ||
|
||
private companion object { | ||
private const val SEPERATOR = "|" | ||
} | ||
} | ||
|
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,19 @@ | ||
package me.misik.api.domain.query | ||
|
||
import jakarta.persistence.* | ||
import me.misik.api.domain.AbstractTime | ||
import me.misik.api.domain.ReviewStyle | ||
|
||
@Entity | ||
class Prompt( | ||
@Id | ||
@Column(name = "id") | ||
val id: Long, | ||
|
||
@Column(name = "style", columnDefinition = "VARCHAR(20)", nullable = false) | ||
@Enumerated(EnumType.STRING) | ||
val style: ReviewStyle, | ||
|
||
@Column(name = "text", columnDefinition = "TEXT", nullable = false) | ||
val text: String, | ||
) : AbstractTime() |
Empty file.