Skip to content

Commit afcd1a5

Browse files
authored
Merge pull request #24 from Nexters/fix/change-domain
2 parents f663d0b + 14a1153 commit afcd1a5

File tree

12 files changed

+114
-104
lines changed

12 files changed

+114
-104
lines changed

docker/init.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ CREATE TABLE IF NOT EXISTS gathering_member
4848
INDEX idx_deleted_at (deleted_at)
4949
);
5050

51-
CREATE TABLE IF NOT EXISTS invitation
51+
CREATE TABLE IF NOT EXISTS proposal
5252
(
5353
id BIGINT AUTO_INCREMENT PRIMARY KEY,
5454
gathering_id BIGINT NOT NULL,
@@ -58,8 +58,8 @@ CREATE TABLE IF NOT EXISTS invitation
5858
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
5959
deleted_at TIMESTAMP NULL,
6060

61-
CONSTRAINT fk_invitation_gathering_id FOREIGN KEY (gathering_id) REFERENCES gathering (id),
62-
CONSTRAINT fk_invitation_member_id FOREIGN KEY (member_id) REFERENCES member (id),
61+
CONSTRAINT fk_proposal_gathering_id FOREIGN KEY (gathering_id) REFERENCES gathering (id),
62+
CONSTRAINT fk_proposal_member_id FOREIGN KEY (member_id) REFERENCES member (id),
6363
INDEX idx_gathering_member (gathering_id, member_id),
6464
INDEX idx_deleted_at (deleted_at)
6565
);

tuk-api/src/main/kotlin/nexters/tuk/application/gathering/GatheringQueryService.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package nexters.tuk.application.gathering
33
import nexters.tuk.application.gathering.dto.request.GatheringQuery
44
import nexters.tuk.application.gathering.dto.response.GatheringResponse
55
import nexters.tuk.application.gathering.vo.RelativeTime
6-
import nexters.tuk.application.invitation.InvitationService
6+
import nexters.tuk.application.proposal.ProposalService
77
import nexters.tuk.application.member.MemberService
88
import nexters.tuk.domain.gathering.GatheringRepository
99
import nexters.tuk.domain.gathering.findByIdOrThrow
@@ -15,7 +15,7 @@ import org.springframework.transaction.annotation.Transactional
1515
class GatheringQueryService(
1616
private val gatheringRepository: GatheringRepository,
1717
private val gatheringMemberService: GatheringMemberService,
18-
private val invitationService: InvitationService,
18+
private val proposalService: ProposalService,
1919
private val memberService: MemberService,
2020
) {
2121
@Transactional(readOnly = true)
@@ -35,7 +35,7 @@ class GatheringQueryService(
3535
fun getGatheringDetail(query: GatheringQuery.GatheringDetail): GatheringResponse.GatheringDetail {
3636
gatheringMemberService.verifyGatheringAccess(query.gatheringId, query.memberId)
3737

38-
val invitationStat = invitationService.getGatheringInvitationStat(query.gatheringId, query.memberId)
38+
val proposalStat = proposalService.getGatheringProposalStat(query.gatheringId, query.memberId)
3939

4040
val gatheringMemberIds = gatheringMemberService.getGatheringMemberIds(query.gatheringId)
4141
val members = memberService.getMemberOverviews(gatheringMemberIds).map {
@@ -48,8 +48,8 @@ class GatheringQueryService(
4848
gatheringId = gatheringDetail.id,
4949
gatheringName = gatheringDetail.name,
5050
lastNotificationRelativeTime = RelativeTime.fromDays(0),
51-
sentInvitationCount = invitationStat.sentCount,
52-
receivedInvitationCount = invitationStat.receivedCount,
51+
sentProposalCount = proposalStat.sentCount,
52+
receivedProposalCount = proposalStat.receivedCount,
5353
members = members
5454
)
5555
}

tuk-api/src/main/kotlin/nexters/tuk/application/gathering/dto/response/GatheringResponse.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ class GatheringResponse {
3535
val gatheringName: String,
3636
@Schema(description = "상대 시간 타입 - \"오늘\", \"n일 전\", \"n주 전\", \"n개월 전\", \"n년 전\" ")
3737
val lastNotificationRelativeTime: RelativeTime,
38-
@Schema(description = "보낸 초대장")
39-
val sentInvitationCount: Int,
40-
@Schema(description = "받은 초대장")
41-
val receivedInvitationCount: Int,
38+
@Schema(description = "보낸 제안")
39+
val sentProposalCount: Int,
40+
@Schema(description = "받은 제안")
41+
val receivedProposalCount: Int,
4242
@Schema(description = "모임원")
4343
val members: List<MemberOverview>
4444
) {

tuk-api/src/main/kotlin/nexters/tuk/application/invitation/InvitationService.kt

Lines changed: 0 additions & 25 deletions
This file was deleted.

tuk-api/src/main/kotlin/nexters/tuk/application/invitation/dto/response/InvitationResponse.kt

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package nexters.tuk.application.proposal
2+
3+
import nexters.tuk.application.proposal.dto.response.ProposalResponse
4+
import nexters.tuk.domain.gathering.GatheringRepository
5+
import nexters.tuk.domain.gathering.findByIdOrThrow
6+
import nexters.tuk.domain.proposal.ProposalRepository
7+
import org.springframework.stereotype.Service
8+
import org.springframework.transaction.annotation.Transactional
9+
10+
@Service
11+
class ProposalService(
12+
private val proposalRepository: ProposalRepository,
13+
private val gatheringRepository: GatheringRepository,
14+
) {
15+
@Transactional(readOnly = true)
16+
fun getGatheringProposalStat(gatheringId: Long, memberId: Long): ProposalResponse.ProposalStat {
17+
val gathering = gatheringRepository.findByIdOrThrow(gatheringId)
18+
val proposals = proposalRepository.findByGathering(gathering).toList()
19+
20+
val sentCount = proposals.count { it.proposerId == memberId }
21+
val receivedCount = proposals.size - sentCount
22+
23+
return ProposalResponse.ProposalStat(sentCount, receivedCount)
24+
}
25+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package nexters.tuk.application.proposal.dto.response
2+
3+
import io.swagger.v3.oas.annotations.media.Schema
4+
5+
class ProposalResponse {
6+
data class ProposalStat(
7+
@Schema(description = "보낸 제안 수")
8+
val sentCount: Int,
9+
@Schema(description = "받은 제안 수")
10+
val receivedCount: Int,
11+
)
12+
}

tuk-api/src/main/kotlin/nexters/tuk/domain/invitation/Invitation.kt

Lines changed: 0 additions & 22 deletions
This file was deleted.

tuk-api/src/main/kotlin/nexters/tuk/domain/invitation/InvitationRepository.kt

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package nexters.tuk.domain.proposal
2+
3+
import jakarta.persistence.*
4+
import nexters.tuk.domain.BaseEntity
5+
import nexters.tuk.domain.gathering.Gathering
6+
import org.hibernate.annotations.SQLRestriction
7+
8+
// FIXME: 모임 생성을 위한 임시 제안 엔티티
9+
@SQLRestriction("deleted_at is NULL")
10+
@Table(name = "proposal")
11+
@Entity
12+
class Proposal(
13+
@Column(name = "member_id", nullable = false)
14+
val proposerId: Long,
15+
16+
@ManyToOne(fetch = FetchType.LAZY)
17+
@JoinColumn(name = "gathering_id", nullable = false)
18+
val gathering: Gathering,
19+
20+
@Column(nullable = false)
21+
val purpose: String,
22+
) : BaseEntity() {
23+
companion object {
24+
fun publish(gathering: Gathering, proposerId: Long, purpose: String): Proposal {
25+
return Proposal(
26+
proposerId = proposerId,
27+
gathering = gathering,
28+
purpose = purpose
29+
)
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)