-
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.
Merge pull request #144 from DSM-PICK/develop
add :: bug message api
- Loading branch information
Showing
34 changed files
with
373 additions
and
65 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
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
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,42 @@ | ||
package dsm.pick2024.domain.bug | ||
|
||
import dsm.pick2024.domain.bug.presentation.dto.request.BugRequest | ||
import dsm.pick2024.domain.user.facade.UserFacade | ||
import dsm.pick2024.infrastructure.feign.client.dto.request.DiscordMessageRequest | ||
import dsm.pick2024.infrastructure.feign.client.DiscordBugClient | ||
import dsm.pick2024.infrastructure.s3.FileUtil | ||
import dsm.pick2024.infrastructure.s3.PathList | ||
import org.springframework.scheduling.annotation.Async | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class AddBugService( | ||
private val fileUtil: FileUtil, | ||
private val discordBugClient: DiscordBugClient, | ||
private val userFacade: UserFacade | ||
) { | ||
@Async | ||
fun bugAlarm(request: BugRequest) { | ||
val message = DiscordMessageRequest( | ||
content = "# 🚨 버그 제보", | ||
embeds = listOf( | ||
DiscordMessageRequest.Embed( | ||
title = "ℹ️ 버그 정보", | ||
description = """ | ||
### 🕖 버그 제목 | ||
${request.title} | ||
### 🔗 버그 내용 | ||
${request.content} | ||
### 📄 이미지 | ||
``` | ||
${request.fileName?.let { fileUtil.generateObjectUrl(request.fileName, PathList.BUG) }} | ||
``` | ||
### 🧑🏻💻 버그 제보자 | ||
${userFacade.currentUser().name} | ||
""".trimIndent() | ||
) | ||
) | ||
) | ||
discordBugClient.sendMessage(message) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/dsm/pick2024/domain/bug/UploadBugImageService.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 dsm.pick2024.domain.bug | ||
|
||
import dsm.pick2024.infrastructure.s3.ImageService | ||
import dsm.pick2024.infrastructure.s3.PathList | ||
import org.springframework.stereotype.Service | ||
import org.springframework.web.multipart.MultipartFile | ||
|
||
@Service | ||
class UploadBugImageService( | ||
private val imageService: ImageService | ||
) { | ||
fun uploadBugImage(file: MultipartFile) = | ||
imageService.uploadImage(file, PathList.BUG) | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/kotlin/dsm/pick2024/domain/bug/presentation/BugController.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,40 @@ | ||
package dsm.pick2024.domain.bug.presentation | ||
|
||
import dsm.pick2024.domain.bug.AddBugService | ||
import dsm.pick2024.domain.bug.UploadBugImageService | ||
import dsm.pick2024.domain.bug.presentation.dto.request.BugRequest | ||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.tags.Tag | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RequestPart | ||
import org.springframework.web.bind.annotation.ResponseStatus | ||
import org.springframework.web.bind.annotation.RestController | ||
import org.springframework.web.multipart.MultipartFile | ||
|
||
@Tag(name = "버그제보 api") | ||
@RestController | ||
@RequestMapping("/bug") | ||
class BugController( | ||
private val uploadBugImageService: UploadBugImageService, | ||
private val addBugService: AddBugService | ||
) { | ||
|
||
@Operation(summary = "버그제보 이미지 업로드 API") | ||
@ResponseStatus(value = HttpStatus.OK) | ||
@PostMapping("/upload") | ||
fun uploadBugImage( | ||
@RequestPart(name = "file") file: MultipartFile | ||
) = | ||
uploadBugImageService.uploadBugImage(file) | ||
|
||
@Operation(summary = "버그제부 문자 전송 API") | ||
@ResponseStatus(value = HttpStatus.CREATED) | ||
@PostMapping("/message") | ||
fun sendBugMessage( | ||
@RequestBody bugRequest: BugRequest | ||
) = | ||
addBugService.bugAlarm(bugRequest) | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/dsm/pick2024/domain/bug/presentation/dto/request/BugRequest.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 dsm.pick2024.domain.bug.presentation.dto.request | ||
|
||
data class BugRequest( | ||
val title: String, | ||
val content: String, | ||
val fileName: String? | ||
) |
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/dsm/pick2024/global/config/aws/AwsConfig.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 dsm.pick2024.global.config.aws | ||
|
||
import com.amazonaws.auth.AWSCredentials | ||
import com.amazonaws.auth.AWSStaticCredentialsProvider | ||
import com.amazonaws.auth.BasicAWSCredentials | ||
import com.amazonaws.services.s3.AmazonS3 | ||
import com.amazonaws.services.s3.AmazonS3ClientBuilder | ||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
|
||
@Configuration | ||
class AwsConfig( | ||
@Value("\${cloud.aws.credentials.accessKey}") | ||
private val accessKey: String, | ||
@Value("\${cloud.aws.credentials.secretKey}") | ||
private val secretKey: String, | ||
@Value("\${cloud.aws.region.static}") | ||
private val region: String | ||
) { | ||
@Bean | ||
fun amazonS3(): AmazonS3 { | ||
val awsCredentials: AWSCredentials = BasicAWSCredentials(accessKey, secretKey) | ||
return AmazonS3ClientBuilder.standard() | ||
.withRegion(region) | ||
.withCredentials(AWSStaticCredentialsProvider(awsCredentials)) | ||
.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
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
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
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/dsm/pick2024/infrastructure/feign/client/DiscordBugClient.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 dsm.pick2024.infrastructure.feign.client | ||
|
||
import dsm.pick2024.infrastructure.feign.client.dto.request.DiscordMessageRequest | ||
import org.springframework.cloud.openfeign.FeignClient | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
|
||
@FeignClient(name = "discord-bug-message-client", url = "\${discord.webhook.message}") | ||
interface DiscordBugClient { | ||
@PostMapping | ||
fun sendMessage( | ||
@RequestBody message: DiscordMessageRequest | ||
) | ||
} |
15 changes: 0 additions & 15 deletions
15
src/main/kotlin/dsm/pick2024/infrastructure/feign/client/DiscordClient.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.