Skip to content
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

feat: Create visiting process #60

Merged
merged 1 commit into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package com.mashup.pic.event.applicationService
import com.mashup.pic.domain.event.EventService
import com.mashup.pic.domain.event.UploadService
import com.mashup.pic.event.applicationService.dto.CreateEventServiceRequest
import com.mashup.pic.event.applicationService.dto.MarkEventVisitedServiceRequest
import com.mashup.pic.event.applicationService.dto.UploadImageServiceRequest
import com.mashup.pic.event.controller.dto.CreateEventResponse
import com.mashup.pic.event.controller.dto.MarkEventVisitedResponse
import com.mashup.pic.event.controller.dto.UploadImageResponse
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
Expand Down Expand Up @@ -46,4 +48,10 @@ class EventApplicationService(

return UploadImageResponse(request.eventId)
}

@Transactional
fun markEventVisit(request: MarkEventVisitedServiceRequest): MarkEventVisitedResponse {
eventService.markVisited(request.userId, request.eventId)
return MarkEventVisitedResponse(true)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.mashup.pic.event.applicationService.dto

import com.mashup.pic.event.controller.dto.MarkEventVisitedRequest

data class MarkEventVisitedServiceRequest(
val userId: Long,
val eventId: Long
)

fun MarkEventVisitedRequest.toServiceRequest(userId: Long): MarkEventVisitedServiceRequest {
return MarkEventVisitedServiceRequest(
userId = userId,
eventId = this.eventId
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import com.mashup.pic.event.applicationService.EventApplicationService
import com.mashup.pic.event.applicationService.dto.toServiceRequest
import com.mashup.pic.event.controller.dto.CreateEventRequest
import com.mashup.pic.event.controller.dto.CreateEventResponse
import com.mashup.pic.event.controller.dto.MarkEventVisitedRequest
import com.mashup.pic.event.controller.dto.MarkEventVisitedResponse
import com.mashup.pic.event.controller.dto.UploadImageRequest
import com.mashup.pic.event.controller.dto.UploadImageResponse
import com.mashup.pic.event.controller.dto.toServiceRequest
Expand All @@ -14,6 +16,7 @@ import io.swagger.v3.oas.annotations.tags.Tag
import jakarta.validation.Valid
import org.springframework.security.core.annotation.AuthenticationPrincipal
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.PutMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
Expand Down Expand Up @@ -45,4 +48,13 @@ class EventController(
eventApplicationService.uploadImages(uploadImageRequest.toServiceRequest(user.id))
)
}

@PutMapping("/visit")
@Operation(summary = "이벀트 λ°©λ¬Έ ν‘œμ‹œ")
fun markVisited(
@AuthenticationPrincipal user: UserInfo,
@Valid @RequestBody request: MarkEventVisitedRequest
): ApiResponse<MarkEventVisitedResponse> {
return ApiResponse.success(eventApplicationService.markEventVisit(request.toServiceRequest(user.id)))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.mashup.pic.event.controller.dto

data class MarkEventVisitedRequest(
val eventId: Long
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.mashup.pic.event.controller.dto

data class MarkEventVisitedResponse(
val visited: Boolean
)
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ class EventService(
return events.map { it.toDto() }
}

@Transactional
fun markVisited(
userId: Long,
eventId: Long
) {
val eventJoin = getEventJoinByUserIdAndEventId(userId, eventId)
eventJoin.isVisited = true
}

private fun createEventJoinsByGroup(
eventId: Long,
groupId: Long
Expand Down
Loading