-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
3f7bf61
commit ad01456
Showing
6 changed files
with
118 additions
and
5 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
5 changes: 5 additions & 0 deletions
5
...kotlin/xquare/app/xquareinfra/domain/deploy/application/port/in/MigrationDeployUseCase.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 xquare.app.xquareinfra.domain.deploy.application.port.`in` | ||
|
||
interface MigrationDeployUseCase { | ||
fun migrationDeploy() | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/xquare/app/xquareinfra/domain/deploy/application/port/out/saveDeployPort.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,7 @@ | ||
package xquare.app.xquareinfra.domain.deploy.application.port.out | ||
|
||
import xquare.app.xquareinfra.domain.deploy.domain.Deploy | ||
|
||
interface saveDeployPort { | ||
fun saveDeploy(deploy: Deploy): Deploy | ||
} |
56 changes: 56 additions & 0 deletions
56
...kotlin/xquare/app/xquareinfra/domain/deploy/application/service/MigrationDeployService.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,56 @@ | ||
package xquare.app.xquareinfra.domain.deploy.application.service | ||
|
||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
import xquare.app.xquareinfra.domain.auth.application.port.out.ReadCurrentUserPort | ||
import xquare.app.xquareinfra.domain.deploy.application.port.`in`.MigrationDeployUseCase | ||
import xquare.app.xquareinfra.domain.deploy.application.port.out.saveDeployPort | ||
import xquare.app.xquareinfra.domain.deploy.domain.Deploy | ||
import xquare.app.xquareinfra.domain.deploy.domain.DeployStatus | ||
import xquare.app.xquareinfra.domain.deploy.domain.DeployType | ||
import xquare.app.xquareinfra.domain.team.application.port.out.ExistsUserTeamPort | ||
import xquare.app.xquareinfra.domain.team.application.port.out.FindTeamPort | ||
import xquare.app.xquareinfra.infrastructure.exception.BusinessLogicException | ||
import xquare.app.xquareinfra.infrastructure.exception.XquareException | ||
import xquare.app.xquareinfra.infrastructure.feign.client.deploy.DeployClient | ||
|
||
@Transactional | ||
@Service | ||
class MigrationDeployService( | ||
private val readCurrentUserPort: ReadCurrentUserPort, | ||
private val findTeamPort: FindTeamPort, | ||
private val saveDeployPort: saveDeployPort, | ||
private val deployClient: DeployClient, | ||
private val existsUserTeamPort: ExistsUserTeamPort | ||
): MigrationDeployUseCase { | ||
override fun migrationDeploy() { | ||
val user = readCurrentUserPort.readCurrentUser() | ||
|
||
val deployList = deployClient.getAllDeploy(user.email) | ||
deployList.map { | ||
println(it.team) | ||
val team = findTeamPort.findByName(it.team) ?: throw BusinessLogicException.TEAM_NOT_FOUND | ||
|
||
if(!existsUserTeamPort.existsByTeamAndUser(team, user)) { | ||
throw XquareException.FORBIDDEN | ||
} | ||
|
||
saveDeployPort.saveDeploy( | ||
Deploy( | ||
id = null, | ||
deployName = it.nameEn, | ||
organization = it.organization, | ||
repository = it.repository.split("/")[1], | ||
projectRootDir = "/", | ||
oneLineDescription = "한줄설명을 적어주세요.", | ||
team = team, | ||
secretKey = null, | ||
deployStatus = if (it.isApproved) DeployStatus.AVAILABLE else DeployStatus.WAIT_FOR_APPROVE, | ||
deployType = if (it.type == "be") DeployType.be else DeployType.fe, | ||
useMysql = it.useMysql, | ||
useRedis = it.useRedis | ||
) | ||
) | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...pp/xquareinfra/infrastructure/feign/client/deploy/dto/request/FeignCreateDeployRequest.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 xquare.app.xquareinfra.infrastructure.feign.client.deploy.dto.request | ||
|
||
import com.fasterxml.jackson.databind.PropertyNamingStrategies | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming | ||
|
||
@JsonNaming(PropertyNamingStrategies.LowerCamelCaseStrategy::class) | ||
data class FeignCreateDeployRequest( | ||
val email: String, | ||
val nameKo: String, | ||
val nameEn: String, | ||
val team: String, | ||
val repository: String, | ||
val organization: String, | ||
val type: String, | ||
val useRedis: Boolean, | ||
val useMySQL: Boolean | ||
) |
27 changes: 27 additions & 0 deletions
27
.../xquare/app/xquareinfra/infrastructure/feign/client/deploy/dto/response/DeployResponse.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,27 @@ | ||
package xquare.app.xquareinfra.infrastructure.feign.client.deploy.dto.response | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming | ||
|
||
data class DeployResponse( | ||
@JsonProperty("nameKo") | ||
val nameKo: String, | ||
@JsonProperty("nameEn") | ||
val nameEn: String, | ||
@JsonProperty("repository") | ||
val repository: String, | ||
@JsonProperty("type") | ||
val type: String, | ||
@JsonProperty("team") | ||
val team: String, | ||
@JsonProperty("email") | ||
val email: String, | ||
@JsonProperty("organization") | ||
val organization: String, | ||
@JsonProperty("useRedis") | ||
val useRedis: Boolean, | ||
@JsonProperty("useMysql") | ||
val useMysql: Boolean, | ||
@JsonProperty("isApproved") | ||
val isApproved: Boolean | ||
) |