Skip to content
This repository was archived by the owner on Jul 7, 2025. It is now read-only.

Commit c8df9d0

Browse files
committed
ASAP-451 비회원 편지 생성 api 추가
1 parent cf5837f commit c8df9d0

5 files changed

Lines changed: 113 additions & 14 deletions

File tree

Bootstrap-Module/src/main/kotlin/com/asap/bootstrap/web/letter/api/LetterApi.kt

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,7 @@ package com.asap.bootstrap.web.letter.api
22

33
import com.asap.bootstrap.common.exception.ExceptionResponse
44
import com.asap.bootstrap.common.security.annotation.AccessUser
5-
import com.asap.bootstrap.web.letter.dto.AddPhysicalLetterRequest
6-
import com.asap.bootstrap.web.letter.dto.AddVerifiedLetterRequest
7-
import com.asap.bootstrap.web.letter.dto.AllLetterCountResponse
8-
import com.asap.bootstrap.web.letter.dto.DeleteSendLettersRequest
9-
import com.asap.bootstrap.web.letter.dto.GetIndependentLetterDetailResponse
10-
import com.asap.bootstrap.web.letter.dto.GetIndependentLetterSimpleInfo
11-
import com.asap.bootstrap.web.letter.dto.LetterVerifyRequest
12-
import com.asap.bootstrap.web.letter.dto.LetterVerifyResponse
13-
import com.asap.bootstrap.web.letter.dto.ModifyLetterRequest
14-
import com.asap.bootstrap.web.letter.dto.SendLetterDetailResponse
15-
import com.asap.bootstrap.web.letter.dto.SendLetterHistoryResponse
16-
import com.asap.bootstrap.web.letter.dto.SendLetterRequest
17-
import com.asap.bootstrap.web.letter.dto.SendLetterResponse
18-
import com.asap.bootstrap.web.letter.dto.VerifiedLetterInfoResponse
5+
import com.asap.bootstrap.web.letter.dto.*
196
import com.asap.common.page.ListResponse
207
import com.asap.common.page.SliceResponse
218
import io.swagger.v3.oas.annotations.Operation
@@ -317,4 +304,28 @@ interface LetterApi {
317304
@RequestBody request: DeleteSendLettersRequest,
318305
@AccessUser userId: String,
319306
)
307+
308+
@Operation(summary = "비회원 편지 쓰기")
309+
@PostMapping("/anonymous/send")
310+
@ApiResponses(
311+
value = [
312+
ApiResponse(
313+
responseCode = "200",
314+
description = "비회원 편지 전송 성공",
315+
content = [
316+
Content(
317+
mediaType = "application/json",
318+
schema = Schema(implementation = SendLetterResponse::class),
319+
),
320+
],
321+
),
322+
ApiResponse(
323+
responseCode = "4XX",
324+
description = "비회원 편지 전송 실패",
325+
),
326+
],
327+
)
328+
fun sendAnonymousLetter(
329+
@RequestBody request: AnonymousSendLetterRequest,
330+
): SendLetterResponse
320331
}

Bootstrap-Module/src/main/kotlin/com/asap/bootstrap/web/letter/controller/LetterController.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,4 +265,19 @@ class LetterController(
265265
),
266266
)
267267
}
268+
269+
override fun sendAnonymousLetter(request: AnonymousSendLetterRequest): SendLetterResponse {
270+
val response =
271+
sendLetterUsecase.sendAnonymous(
272+
SendLetterUsecase.AnonymousCommand(
273+
receiverName = request.receiverName,
274+
content = request.content,
275+
images = request.images,
276+
templateType = request.templateType,
277+
),
278+
)
279+
return SendLetterResponse(
280+
letterCode = response.letterCode,
281+
)
282+
}
268283
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.asap.bootstrap.web.letter.dto
2+
3+
data class AnonymousSendLetterRequest(
4+
val receiverName: String,
5+
val content: String,
6+
val images: List<String>,
7+
val templateType: Int,
8+
)

Bootstrap-Module/src/test/kotlin/com/asap/bootstrap/acceptance/letter/controller/LetterControllerTest.kt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,4 +589,41 @@ class LetterControllerTest : LetterAcceptanceSupporter() {
589589
}
590590
}
591591
}
592+
@Test
593+
fun sendAnonymousLetter() {
594+
// given
595+
val request =
596+
AnonymousSendLetterRequest(
597+
receiverName = "receiverName",
598+
content = "content",
599+
images = listOf("images"),
600+
templateType = 1,
601+
)
602+
BDDMockito
603+
.given(
604+
sendLetterUsecase.sendAnonymous(
605+
SendLetterUsecase.AnonymousCommand(
606+
receiverName = request.receiverName,
607+
content = request.content,
608+
images = request.images,
609+
templateType = request.templateType,
610+
),
611+
),
612+
).willReturn(SendLetterUsecase.Response("letterCode"))
613+
// when
614+
val response =
615+
mockMvc.post("/api/v1/letters/anonymous/send") {
616+
contentType = MediaType.APPLICATION_JSON
617+
content = objectMapper.writeValueAsString(request)
618+
}
619+
// then
620+
response.andExpect {
621+
status { isOk() }
622+
jsonPath("$.letterCode") {
623+
exists()
624+
isString()
625+
isNotEmpty()
626+
}
627+
}
628+
}
592629
}

Bootstrap-Module/src/test/kotlin/com/asap/bootstrap/integration/letter/LetterApiIntegrationTest.kt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,4 +1081,32 @@ class LetterApiIntegrationTest : IntegrationSupporter() {
10811081
}
10821082
}
10831083
}
1084+
1085+
@Test
1086+
@DisplayName("비회원 편지 쓰기")
1087+
fun sendAnonymousLetter() {
1088+
// given
1089+
val request =
1090+
AnonymousSendLetterRequest(
1091+
receiverName = "receiverName",
1092+
content = "content",
1093+
images = listOf("images"),
1094+
templateType = 1,
1095+
)
1096+
// when
1097+
val response =
1098+
mockMvc.post("/api/v1/letters/anonymous/send") {
1099+
contentType = MediaType.APPLICATION_JSON
1100+
content = objectMapper.writeValueAsString(request)
1101+
}
1102+
// then
1103+
response.andExpect {
1104+
status { isOk() }
1105+
jsonPath("$.letterCode") {
1106+
exists()
1107+
isString()
1108+
isNotEmpty()
1109+
}
1110+
}
1111+
}
10841112
}

0 commit comments

Comments
 (0)