Skip to content

Commit

Permalink
[MERGE] #163 -> develop
Browse files Browse the repository at this point in the history
[FEAT/#163] 사진생성뷰 랜덤 예시 프롬프트 API 추가
  • Loading branch information
Marchbreeze authored Oct 31, 2024
2 parents b8d9391 + 7c419b9 commit 48452e0
Show file tree
Hide file tree
Showing 25 changed files with 396 additions and 364 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ object Constants {
const val minSdk = 28
const val targetSdk = 34
const val versionCode = 15
const val versionName = "1.1.6"
const val versionName = "1.2.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import kr.genti.data.dto.BaseResponse
import kr.genti.data.dto.request.CreateRequestDto
import kr.genti.data.dto.request.KeyRequestDto
import kr.genti.data.dto.request.S3RequestDto
import kr.genti.data.dto.response.PromptExampleDto
import kr.genti.data.dto.response.S3PresignedUrlDto

interface CreateDataSource {
Expand All @@ -14,4 +15,6 @@ interface CreateDataSource {
suspend fun postToCreate(request: CreateRequestDto): BaseResponse<Boolean>

suspend fun postToVerify(request: KeyRequestDto): BaseResponse<Boolean>

suspend fun getPromptExample(): BaseResponse<List<PromptExampleDto>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ interface GenerateDataSource {
suspend fun getIsUserVerified(): BaseResponse<Boolean>

suspend fun getIsServerAvailable(): BaseResponse<ServerAvailableDto>

suspend fun patchStatusInDevelop(): BaseResponse<Boolean>
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,28 @@ import kr.genti.data.dto.BaseResponse
import kr.genti.data.dto.request.CreateRequestDto
import kr.genti.data.dto.request.KeyRequestDto
import kr.genti.data.dto.request.S3RequestDto
import kr.genti.data.dto.response.PromptExampleDto
import kr.genti.data.dto.response.S3PresignedUrlDto
import kr.genti.data.service.CreateService
import javax.inject.Inject

data class CreateDataSourceImpl
@Inject
constructor(
private val createService: CreateService,
) : CreateDataSource {
override suspend fun getSingleS3Url(request: S3RequestDto): BaseResponse<S3PresignedUrlDto> = createService.getSingleS3Url(request)
@Inject
constructor(
private val createService: CreateService,
) : CreateDataSource {
override suspend fun getSingleS3Url(request: S3RequestDto): BaseResponse<S3PresignedUrlDto> =
createService.getSingleS3Url(request)

override suspend fun getMultiS3Url(request: List<S3RequestDto>): BaseResponse<List<S3PresignedUrlDto>> =
createService.getMultiS3Url(request)
override suspend fun getMultiS3Url(request: List<S3RequestDto>): BaseResponse<List<S3PresignedUrlDto>> =
createService.getMultiS3Url(request)

override suspend fun postToCreate(request: CreateRequestDto): BaseResponse<Boolean> = createService.postToCreate(request)
override suspend fun postToCreate(request: CreateRequestDto): BaseResponse<Boolean> =
createService.postToCreate(request)

override suspend fun postToVerify(request: KeyRequestDto): BaseResponse<Boolean> = createService.postToVerify(request)
}
override suspend fun postToVerify(request: KeyRequestDto): BaseResponse<Boolean> =
createService.postToVerify(request)

override suspend fun getPromptExample(): BaseResponse<List<PromptExampleDto>> =
createService.getPromptExample()
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,44 @@ import kr.genti.data.service.GenerateService
import javax.inject.Inject

data class GenerateDataSourceImpl
@Inject
constructor(
private val generateService: GenerateService,
) : GenerateDataSource {
override suspend fun getGenerateStatus(): BaseResponse<GenerateStatusDto> = generateService.getGenerateStatus()

override suspend fun getGeneratedPictureList(
page: Int,
size: Int,
sortBy: String?,
direction: String?,
): BaseResponse<PicturePagedListDto> = generateService.getGeneratedPictureList(page, size, sortBy, direction)

override suspend fun postGenerateReport(request: ReportRequestDto): BaseResponse<Boolean> =
generateService.postGenerateReport(request)

override suspend fun postGenerateRate(
responseId: Int,
star: Int,
): BaseResponse<Boolean> = generateService.postGenerateRate(responseId, star)

override suspend fun postVerifyGenerateState(responseId: Int): BaseResponse<Boolean> =
generateService.postVerifyGenerateState(responseId)

override suspend fun getCanceledToReset(requestId: String): BaseResponse<Boolean> = generateService.getCanceledToReset(requestId)

override suspend fun getOpenchatData(): BaseResponse<OpenchatDto> = generateService.getOpenchatData()

override suspend fun getIsUserVerified(): BaseResponse<Boolean> = generateService.getIsUserVerified()

override suspend fun getIsServerAvailable(): BaseResponse<ServerAvailableDto> = generateService.getIsServerAvailable()
}
@Inject
constructor(
private val generateService: GenerateService,
) : GenerateDataSource {
override suspend fun getGenerateStatus(): BaseResponse<GenerateStatusDto> =
generateService.getGenerateStatus()

override suspend fun getGeneratedPictureList(
page: Int,
size: Int,
sortBy: String?,
direction: String?,
): BaseResponse<PicturePagedListDto> =
generateService.getGeneratedPictureList(page, size, sortBy, direction)

override suspend fun postGenerateReport(request: ReportRequestDto): BaseResponse<Boolean> =
generateService.postGenerateReport(request)

override suspend fun postGenerateRate(
responseId: Int,
star: Int,
): BaseResponse<Boolean> = generateService.postGenerateRate(responseId, star)

override suspend fun postVerifyGenerateState(responseId: Int): BaseResponse<Boolean> =
generateService.postVerifyGenerateState(responseId)

override suspend fun getCanceledToReset(requestId: String): BaseResponse<Boolean> =
generateService.getCanceledToReset(requestId)

override suspend fun getOpenchatData(): BaseResponse<OpenchatDto> =
generateService.getOpenchatData()

override suspend fun getIsUserVerified(): BaseResponse<Boolean> =
generateService.getIsUserVerified()

override suspend fun getIsServerAvailable(): BaseResponse<ServerAvailableDto> =
generateService.getIsServerAvailable()

override suspend fun patchStatusInDevelop(): BaseResponse<Boolean> =
generateService.patchStatusInDevelop()
}
15 changes: 15 additions & 0 deletions data/src/main/java/kr/genti/data/dto/response/PromptExampleDto.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package kr.genti.data.dto.response

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kr.genti.domain.entity.response.PromptExampleModel

@Serializable
data class PromptExampleDto(
@SerialName("url")
val url: String,
@SerialName("prompt")
val prompt: String,
) {
fun toModel() = PromptExampleModel(url, prompt)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,38 @@ import kr.genti.data.dto.request.S3RequestDto.Companion.toDto
import kr.genti.domain.entity.request.CreateRequestModel
import kr.genti.domain.entity.request.KeyRequestModel
import kr.genti.domain.entity.request.S3RequestModel
import kr.genti.domain.entity.response.PromptExampleModel
import kr.genti.domain.entity.response.S3PresignedUrlModel
import kr.genti.domain.repository.CreateRepository
import javax.inject.Inject

class CreateRepositoryImpl
@Inject
constructor(
private val createDataSource: CreateDataSource,
) : CreateRepository {
override suspend fun getS3SingleUrl(request: S3RequestModel): Result<S3PresignedUrlModel> =
runCatching {
createDataSource.getSingleS3Url(request.toDto()).response.toModel()
}
@Inject
constructor(
private val createDataSource: CreateDataSource,
) : CreateRepository {
override suspend fun getS3SingleUrl(request: S3RequestModel): Result<S3PresignedUrlModel> =
runCatching {
createDataSource.getSingleS3Url(request.toDto()).response.toModel()
}

override suspend fun getS3MultiUrl(request: List<S3RequestModel>): Result<List<S3PresignedUrlModel>> =
runCatching {
createDataSource.getMultiS3Url(request.map { it.toDto() }).response.map { it.toModel() }
}
override suspend fun getS3MultiUrl(request: List<S3RequestModel>): Result<List<S3PresignedUrlModel>> =
runCatching {
createDataSource.getMultiS3Url(request.map { it.toDto() }).response.map { it.toModel() }
}

override suspend fun postToCreate(request: CreateRequestModel): Result<Boolean> =
runCatching {
createDataSource.postToCreate(request.toDto()).response
}
override suspend fun postToCreate(request: CreateRequestModel): Result<Boolean> =
runCatching {
createDataSource.postToCreate(request.toDto()).response
}

override suspend fun postToVerify(request: KeyRequestModel): Result<Boolean> =
runCatching {
createDataSource.postToVerify(request.toDto()).response
}
}
override suspend fun postToVerify(request: KeyRequestModel): Result<Boolean> =
runCatching {
createDataSource.postToVerify(request.toDto()).response
}

override suspend fun getPromptExample(): Result<List<PromptExampleModel>> =
runCatching {
createDataSource.getPromptExample().response.map { it.toModel() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,67 +11,72 @@ import kr.genti.domain.repository.GenerateRepository
import javax.inject.Inject

class GenerateRepositoryImpl
@Inject
constructor(
private val generateDataSource: GenerateDataSource,
) : GenerateRepository {
override suspend fun getGenerateStatus(): Result<GenerateStatusModel> =
runCatching {
generateDataSource.getGenerateStatus().response.toModel()
}
@Inject
constructor(
private val generateDataSource: GenerateDataSource,
) : GenerateRepository {
override suspend fun getGenerateStatus(): Result<GenerateStatusModel> =
runCatching {
generateDataSource.getGenerateStatus().response.toModel()
}

override suspend fun getGeneratedPictureList(
page: Int,
size: Int,
sortBy: String?,
direction: String?,
): Result<PicturePagedListModel> =
runCatching {
generateDataSource
.getGeneratedPictureList(
page,
size,
sortBy,
direction,
).response
.toModel()
}
override suspend fun getGeneratedPictureList(
page: Int,
size: Int,
sortBy: String?,
direction: String?,
): Result<PicturePagedListModel> =
runCatching {
generateDataSource
.getGeneratedPictureList(
page,
size,
sortBy,
direction,
).response
.toModel()
}

override suspend fun postGenerateReport(request: ReportRequestModel): Result<Boolean> =
runCatching {
generateDataSource.postGenerateReport(request.toDto()).response
}
override suspend fun postGenerateReport(request: ReportRequestModel): Result<Boolean> =
runCatching {
generateDataSource.postGenerateReport(request.toDto()).response
}

override suspend fun postGenerateRate(
responseId: Int,
star: Int,
): Result<Boolean> =
runCatching {
generateDataSource.postGenerateRate(responseId, star).response
}
override suspend fun postGenerateRate(
responseId: Int,
star: Int,
): Result<Boolean> =
runCatching {
generateDataSource.postGenerateRate(responseId, star).response
}

override suspend fun postVerifyGenerateState(responseId: Int): Result<Boolean> =
runCatching {
generateDataSource.postVerifyGenerateState(responseId).response
}
override suspend fun postVerifyGenerateState(responseId: Int): Result<Boolean> =
runCatching {
generateDataSource.postVerifyGenerateState(responseId).response
}

override suspend fun getCanceledToReset(requestId: String): Result<Boolean> =
runCatching {
generateDataSource.getCanceledToReset(requestId).response
}
override suspend fun getCanceledToReset(requestId: String): Result<Boolean> =
runCatching {
generateDataSource.getCanceledToReset(requestId).response
}

override suspend fun getOpenchatData(): Result<OpenchatModel> =
runCatching {
generateDataSource.getOpenchatData().response.toModel()
}
override suspend fun getOpenchatData(): Result<OpenchatModel> =
runCatching {
generateDataSource.getOpenchatData().response.toModel()
}

override suspend fun getIsUserVerified(): Result<Boolean> =
runCatching {
generateDataSource.getIsUserVerified().response
}
override suspend fun getIsUserVerified(): Result<Boolean> =
runCatching {
generateDataSource.getIsUserVerified().response
}

override suspend fun getIsServerAvailable(): Result<ServerAvailableModel> =
runCatching {
generateDataSource.getIsServerAvailable().response.toModel()
}
}
override suspend fun getIsServerAvailable(): Result<ServerAvailableModel> =
runCatching {
generateDataSource.getIsServerAvailable().response.toModel()
}

override suspend fun patchStatusInDevelop(): Result<Boolean> =
runCatching {
generateDataSource.patchStatusInDevelop().response
}
}
5 changes: 5 additions & 0 deletions data/src/main/java/kr/genti/data/service/CreateService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import kr.genti.data.dto.BaseResponse
import kr.genti.data.dto.request.CreateRequestDto
import kr.genti.data.dto.request.KeyRequestDto
import kr.genti.data.dto.request.S3RequestDto
import kr.genti.data.dto.response.PromptExampleDto
import kr.genti.data.dto.response.S3PresignedUrlDto
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST

interface CreateService {
Expand All @@ -28,4 +30,7 @@ interface CreateService {
suspend fun postToVerify(
@Body request: KeyRequestDto,
): BaseResponse<Boolean>

@GET("api/v1/users/examples/with-picture-square")
suspend fun getPromptExample(): BaseResponse<List<PromptExampleDto>>
}
3 changes: 3 additions & 0 deletions data/src/main/java/kr/genti/data/service/GenerateService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,7 @@ interface GenerateService {

@GET("api/v1/maintenance")
suspend fun getIsServerAvailable(): BaseResponse<ServerAvailableDto>

@POST("api/v1/frontend/picture-generate-responses")
suspend fun patchStatusInDevelop(): BaseResponse<Boolean>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package kr.genti.domain.entity.response

data class PromptExampleModel(
val url: String,
val prompt: String,
)
Loading

0 comments on commit 48452e0

Please sign in to comment.