-
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.
Merge pull request #50 from mash-up-kr/feature/group-domain
feat: Implement domain logics of group view
- Loading branch information
Showing
11 changed files
with
101 additions
and
30 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
18 changes: 15 additions & 3 deletions
18
pic-domain/src/main/kotlin/com/mashup/pic/domain/event/UploadService.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 |
---|---|---|
@@ -1,16 +1,28 @@ | ||
package com.mashup.pic.domain.event | ||
|
||
import com.mashup.pic.common.exception.PicException | ||
import com.mashup.pic.common.exception.PicExceptionType | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Service | ||
@Transactional(readOnly = true) | ||
class UploadService { | ||
class UploadService( | ||
private val eventJoinRepository: EventJoinRepository, | ||
private val eventImageOptionRepository: EventImageOptionRepository | ||
) { | ||
fun hasUserUploaded( | ||
userId: Long, | ||
eventId: Long | ||
): Boolean { | ||
// TODO: 올린 이미지 있는지 확인하기 | ||
return true | ||
val eventJoin = getEventJoinByUserIdAndEventId(userId, eventId) | ||
return eventImageOptionRepository.existsByEventJoinId(eventJoin.id) | ||
} | ||
|
||
private fun getEventJoinByUserIdAndEventId( | ||
userId: Long, | ||
eventId: Long | ||
): EventJoin { | ||
return eventJoinRepository.findByUserIdAndEventId(userId, eventId) ?: throw PicException.of(PicExceptionType.NOT_EXIST) | ||
} | ||
} |
16 changes: 0 additions & 16 deletions
16
pic-domain/src/main/kotlin/com/mashup/pic/domain/event/VoteService.kt
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...otlin/com/mashup/pic/domain/event/Vote.kt → ...kotlin/com/mashup/pic/domain/vote/Vote.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
7 changes: 7 additions & 0 deletions
7
pic-domain/src/main/kotlin/com/mashup/pic/domain/vote/VoteRepository.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 com.mashup.pic.domain.vote | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository | ||
|
||
interface VoteRepository : JpaRepository<Vote, Long> { | ||
fun existsByEventJoinId(id: Long): Boolean | ||
} |
32 changes: 32 additions & 0 deletions
32
pic-domain/src/main/kotlin/com/mashup/pic/domain/vote/VoteService.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,32 @@ | ||
package com.mashup.pic.domain.vote | ||
|
||
import com.mashup.pic.common.exception.PicException | ||
import com.mashup.pic.common.exception.PicExceptionType | ||
import com.mashup.pic.domain.event.EventImageOptionRepository | ||
import com.mashup.pic.domain.event.EventJoin | ||
import com.mashup.pic.domain.event.EventJoinRepository | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Service | ||
@Transactional(readOnly = true) | ||
class VoteService( | ||
private val voteRepository: VoteRepository, | ||
private val eventJoinRepository: EventJoinRepository, | ||
private val eventImageOptionRepository: EventImageOptionRepository | ||
) { | ||
fun hasUserVoted( | ||
userId: Long, | ||
eventId: Long | ||
): Boolean { | ||
val eventJoin = getEventJoinByUserIdAndEventId(userId, eventId) | ||
return voteRepository.existsByEventJoinId(eventJoin.id) | ||
} | ||
|
||
private fun getEventJoinByUserIdAndEventId( | ||
userId: Long, | ||
eventId: Long | ||
): EventJoin { | ||
return eventJoinRepository.findByUserIdAndEventId(userId, eventId) ?: throw PicException.of(PicExceptionType.NOT_EXIST) | ||
} | ||
} |