-
Notifications
You must be signed in to change notification settings - Fork 2
Event 구조 및 생성 기능 #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RbertKo
wants to merge
12
commits into
develop
Choose a base branch
from
feat/create-event
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Event 구조 및 생성 기능 #38
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
47690db
feat: add event.late-diff-minute, event.absent-diff-minute properties
RbertKo fd59e9c
feat: edit Event.kt entity
RbertKo 935ed70
feat: add entity method for converting
RbertKo 93c7f1b
feat: add createEvent method
RbertKo 863d180
feat: add createUser method to EventAPI interface
RbertKo 048e788
feat: edit startAt
RbertKo 77272d9
feat: add createEvent Ctrl
RbertKo 8d891b3
feat: add createEvent Svc
RbertKo 7e92ae8
feat: edit security for event
RbertKo 4bcc44d
refactor: change roles visibility public to private
RbertKo 861b35c
feat: remove POST /event
RbertKo f8b8b1e
feat: add annotation about authroize
RbertKo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
13 changes: 12 additions & 1 deletion
13
src/main/kotlin/com/example/attendanceapimono/adapter/present/EventController.kt
This file contains hidden or 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,8 +1,19 @@ | ||
package com.example.attendanceapimono.adapter.present | ||
|
||
import com.example.attendanceapimono.adapter.present.api.EventAPI | ||
import com.example.attendanceapimono.application.EventService | ||
import com.example.attendanceapimono.application.dto.event.CreateEventRequest | ||
import com.example.attendanceapimono.application.dto.event.CreateEventResponse | ||
import com.example.attendanceapimono.application.exception.handleValidationCatch | ||
import kotlinx.coroutines.reactor.awaitSingle | ||
import org.springframework.web.bind.annotation.RestController | ||
import reactor.core.publisher.Mono | ||
|
||
@RestController | ||
class EventController: EventAPI { | ||
class EventController (private val eventService: EventService): EventAPI { | ||
override suspend fun createEvent(body: Mono<CreateEventRequest>): CreateEventResponse { | ||
return body.handleValidationCatch() | ||
.map(eventService::createEvent) | ||
.awaitSingle() | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/kotlin/com/example/attendanceapimono/adapter/present/api/EventAPI.kt
This file contains hidden or 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,7 +1,44 @@ | ||
package com.example.attendanceapimono.adapter.present.api | ||
|
||
import com.example.attendanceapimono.application.dto.event.CreateEventRequest | ||
import com.example.attendanceapimono.application.dto.event.CreateEventResponse | ||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.media.Content | ||
import io.swagger.v3.oas.annotations.media.ExampleObject | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse | ||
import io.swagger.v3.oas.annotations.tags.Tag | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.http.MediaType | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.ResponseStatus | ||
import reactor.core.publisher.Mono | ||
import javax.validation.Valid | ||
|
||
@Tag(name = "Event 관련 API") | ||
interface EventAPI { | ||
@Operation( | ||
summary = "이벤트 생성", | ||
requestBody = io.swagger.v3.oas.annotations.parameters.RequestBody( | ||
content = [ | ||
Content( | ||
mediaType = MediaType.APPLICATION_JSON_VALUE, | ||
schema = Schema(implementation = CreateEventRequest::class), | ||
) | ||
] | ||
) | ||
) | ||
@ApiResponse( | ||
responseCode = "201", | ||
description = "이벤트 생성", | ||
content = [Content( | ||
mediaType = MediaType.APPLICATION_JSON_VALUE, | ||
schema = Schema(implementation = CreateEventResponse::class), | ||
examples = [ExampleObject(CreateEventResponse.Example)] | ||
)], | ||
) | ||
@ResponseStatus(HttpStatus.CREATED) | ||
@PostMapping("/event") | ||
suspend fun createEvent(@Valid @RequestBody body: Mono<CreateEventRequest>): CreateEventResponse | ||
} |
17 changes: 15 additions & 2 deletions
17
src/main/kotlin/com/example/attendanceapimono/application/EventService.kt
This file contains hidden or 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,10 +1,23 @@ | ||
package com.example.attendanceapimono.application | ||
|
||
import com.example.attendanceapimono.application.dto.event.CreateEventRequest | ||
import com.example.attendanceapimono.application.dto.event.CreateEventResponse | ||
import com.example.attendanceapimono.domain.event.EventRepository | ||
import kotlinx.coroutines.async | ||
import kotlinx.coroutines.runBlocking | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Service | ||
class EventService { | ||
fun createEvent() { | ||
class EventService ( | ||
private val eventRepository: EventRepository | ||
) { | ||
@Transactional | ||
fun createEvent(dto: CreateEventRequest): CreateEventResponse = runBlocking { | ||
val event = dto.entity() | ||
|
||
eventRepository.save(event) | ||
|
||
CreateEventResponse(eventId = event.id) | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
외부에서 접근 하면 안되는 함수이므로 좋지 않습니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RebirthLee 따로 멘션이나 알람이 없어서 지금봤네요 ㅜㅜ 관련해서 반영하겠습니다 👍🏼