Skip to content

Commit 52656a0

Browse files
committed
fix: develop 브랜치 merge 및 충돌 해결
2 parents 3e9f2dc + 5b9f131 commit 52656a0

43 files changed

Lines changed: 788 additions & 19 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ dependencies {
3838
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
3939
implementation 'org.mapstruct:mapstruct:1.5.5.Final'
4040
annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.5.Final'
41+
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'
4142
}
4243

4344
tasks.named('test') {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
11
package com.ODG.ODG_back.controller;
22

3+
import com.ODG.ODG_back.dto.meeting.request.MeetingCreateRequestDto;
4+
import com.ODG.ODG_back.dto.meeting.response.MeetingCreateResponseDto;
5+
import com.ODG.ODG_back.dto.meeting.response.MeetingInfoResponseDto;
6+
import com.ODG.ODG_back.service.MeetingService;
7+
import lombok.RequiredArgsConstructor;
8+
import org.springframework.http.ResponseEntity;
9+
import org.springframework.web.bind.annotation.*;
10+
11+
@RestController
12+
@RequestMapping("/meetings")
13+
@RequiredArgsConstructor
314
public class MeetingController {
15+
private final MeetingService meetingService;
16+
17+
@PostMapping("/")
18+
public ResponseEntity<MeetingCreateResponseDto> createMeeting(@RequestBody MeetingCreateRequestDto dto) {
19+
return ResponseEntity.ok(meetingService.addMeeting(dto));
20+
}
21+
22+
@GetMapping("/{linkCode}")
23+
public ResponseEntity<MeetingInfoResponseDto> getMeeting(@PathVariable String linkCode) {
24+
return ResponseEntity.ok(meetingService.getMeeting(linkCode));
25+
}
426
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,48 @@
11
package com.ODG.ODG_back.controller;
22

3+
import com.ODG.ODG_back.dto.participant.request.ParticipantDeletionRequestDto;
4+
import com.ODG.ODG_back.dto.participant.request.ParticipantRegisterRequestDto;
5+
import com.ODG.ODG_back.dto.participant.request.ParticipantUpdateRequestDto;
6+
import com.ODG.ODG_back.dto.participant.response.ParticipantListResponseDto;
7+
import com.ODG.ODG_back.dto.participant.response.ParticipantRegisterResponseDto;
8+
import com.ODG.ODG_back.service.MeetingService;
9+
import com.ODG.ODG_back.service.ParticipantService;
10+
import lombok.RequiredArgsConstructor;
11+
import org.springframework.http.ResponseEntity;
12+
import org.springframework.web.bind.annotation.*;
13+
14+
import java.util.List;
15+
16+
17+
@RestController
18+
@RequestMapping("/meetings/{linkCode}/participants")
19+
@RequiredArgsConstructor
320
public class ParticipantController {
21+
22+
private final ParticipantService participantService;
23+
private final MeetingService meetingService;
24+
25+
@PostMapping("/register")
26+
public ResponseEntity<ParticipantRegisterResponseDto> addParticipant(@PathVariable String linkCode, @RequestBody ParticipantRegisterRequestDto participantRegisterRequestDto){
27+
ParticipantRegisterResponseDto participantRegisterResponseDto = participantService.addParticipant(linkCode, participantRegisterRequestDto);
28+
return ResponseEntity.ok(participantRegisterResponseDto);
29+
}
30+
31+
@DeleteMapping("/delete")
32+
public ResponseEntity<Void> deleteParticipant(@PathVariable String linkCode, @RequestBody ParticipantDeletionRequestDto participantDeletionRequestDto){
33+
participantService.deleteParticipant(linkCode, participantDeletionRequestDto);
34+
return ResponseEntity.ok().build();
35+
}
36+
37+
@PutMapping("/update")
38+
public ResponseEntity<Void> updateParticipant(@PathVariable String linkCode, @RequestBody ParticipantUpdateRequestDto participantUpdateRequestDto){
39+
participantService.modifyParticipant(linkCode, participantUpdateRequestDto);
40+
return ResponseEntity.ok().build();
41+
}
42+
43+
@GetMapping("/")
44+
public ResponseEntity<List<ParticipantListResponseDto>> getParticipants(@PathVariable String linkCode){
45+
List<ParticipantListResponseDto> participants = meetingService.getParticipants(linkCode);
46+
return ResponseEntity.ok(participants);
47+
}
448
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
11
package com.ODG.ODG_back.controller;
22

3+
import com.ODG.ODG_back.dto.place.response.PlaceResponseDto;
4+
import com.ODG.ODG_back.service.PlaceService;
5+
import lombok.RequiredArgsConstructor;
6+
import org.springframework.http.ResponseEntity;
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
import org.springframework.web.bind.annotation.PathVariable;
9+
import org.springframework.web.bind.annotation.RequestMapping;
10+
import org.springframework.web.bind.annotation.RestController;
11+
12+
import java.util.List;
13+
14+
@RestController
15+
@RequestMapping("/meetings/{inviteCode}")
16+
@RequiredArgsConstructor
317
public class PlaceController {
18+
19+
private final PlaceService placeService;
20+
21+
@GetMapping("/places")
22+
public ResponseEntity<List<PlaceResponseDto>> getPlacesByMidpoint(@PathVariable String inviteCode) {
23+
return ResponseEntity.ok(placeService.getPlacesByMidpoint(inviteCode));
24+
}
25+
426
}
Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,43 @@
11
package com.ODG.ODG_back.controller;
22

3+
import com.ODG.ODG_back.dto.vote.request.VoteRequestDto;
4+
import com.ODG.ODG_back.dto.vote.response.VoteResultDto;
5+
import com.ODG.ODG_back.service.VoteService;
6+
import lombok.RequiredArgsConstructor;
7+
import org.springframework.http.HttpStatus;
8+
import org.springframework.http.ResponseEntity;
9+
import org.springframework.web.bind.annotation.*;
10+
11+
import java.util.List;
12+
13+
@RestController
14+
@RequestMapping("/meetings/{inviteCode}")
15+
@RequiredArgsConstructor
316
public class VoteController {
4-
}
17+
18+
private final VoteService voteService;
19+
20+
@PostMapping("/vote")
21+
public ResponseEntity<String> vote(@PathVariable String inviteCode,
22+
@RequestBody VoteRequestDto voteRequest) {
23+
try {
24+
voteService.vote(inviteCode, voteRequest);
25+
return ResponseEntity.ok().body("OK");
26+
} catch (RuntimeException e) {
27+
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage());
28+
}
29+
30+
31+
}
32+
33+
@GetMapping("/result")
34+
public ResponseEntity<?> getVoteResults(@PathVariable String inviteCode) {
35+
try {
36+
List<VoteResultDto> voteResults = voteService.getVoteResults(inviteCode);
37+
return ResponseEntity.ok(voteResults);
38+
} catch (RuntimeException e) {
39+
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage());
40+
}
41+
}
42+
43+
}

src/main/java/com/ODG/ODG_back/domain/Meeting.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22

33
import com.ODG.ODG_back.domain.enums.MeetingType;
44
import jakarta.persistence.*;
5+
import lombok.AllArgsConstructor;
56
import lombok.Getter;
7+
import lombok.NoArgsConstructor;
68
import lombok.Setter;
79

810
import java.time.LocalDateTime;
911
import java.util.List;
1012

1113
@Entity
14+
@NoArgsConstructor
15+
@AllArgsConstructor
1216
@Getter
1317
@Setter
18+
@Table(indexes = { @Index(name = "idx_meeting_invite_code", columnList = "inviteCode") })
1419
public class Meeting {
1520

1621
@Id
@@ -22,6 +27,7 @@ public class Meeting {
2227
@Enumerated(EnumType.STRING)
2328
private MeetingType type;
2429

30+
@Column(unique = true)
2531
private String inviteCode;
2632

2733
private LocalDateTime createdAt;
@@ -36,4 +42,13 @@ public class Meeting {
3642

3743
@OneToMany(mappedBy = "meeting")
3844
private List<RecommendedMidpoint> recommendedMidpoints;
45+
46+
47+
@PrePersist
48+
private void generateInviteCode() {
49+
if (this.inviteCode == null) {
50+
this.inviteCode = java.util.Base64.getUrlEncoder().withoutPadding()
51+
.encodeToString(java.util.UUID.randomUUID().toString().getBytes());
52+
}
53+
}
3954
}

src/main/java/com/ODG/ODG_back/domain/Participant.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22

33
import com.ODG.ODG_back.domain.enums.TransportType;
44
import jakarta.persistence.*;
5-
import lombok.AllArgsConstructor;
6-
import lombok.Builder;
7-
import lombok.Getter;
8-
import lombok.NoArgsConstructor;
5+
import lombok.*;
96

107
import java.math.BigDecimal;
118
import java.time.LocalDateTime;
129

1310
@Entity
14-
@Getter
15-
@Builder
1611
@NoArgsConstructor
1712
@AllArgsConstructor
13+
@Getter
14+
@Setter
15+
@Builder
1816
public class Participant {
1917

2018
@Id
@@ -26,15 +24,14 @@ public class Participant {
2624
@Column(columnDefinition = "TEXT")
2725
private String address;
2826

29-
private BigDecimal latitude;
30-
31-
private BigDecimal longitude;
32-
3327
@Enumerated(EnumType.STRING)
34-
private TransportType transport;
28+
private TransportType transportType;
3529

3630
private LocalDateTime joinedAt;
3731

32+
private BigDecimal latitude;
33+
private BigDecimal longitude;
34+
3835
@ManyToOne
3936
private Meeting meeting;
4037
}

src/main/java/com/ODG/ODG_back/domain/Place.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
import com.ODG.ODG_back.domain.enums.PlaceCategory;
44
import jakarta.persistence.*;
5+
import lombok.Getter;
56

67
import java.math.BigDecimal;
78
import java.util.List;
89

910
@Entity
11+
@Getter
1012
public class Place {
1113

1214
@Id

src/main/java/com/ODG/ODG_back/domain/RecommendedMidpoint.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class RecommendedMidpoint {
1616
private Long id;
1717

1818
private double score;
19-
19+
@Column(name = "midpoint_rank")
2020
private int rank;
2121

2222
private LocalDateTime recommendedAt;

src/main/java/com/ODG/ODG_back/domain/Vote.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
package com.ODG.ODG_back.domain;
22

33
import jakarta.persistence.*;
4-
54
import java.time.LocalDateTime;
65

6+
@AllArgsConstructor
7+
@NoArgsConstructor
78
@Entity
9+
@Getter
810
public class Vote {
911

1012
@Id
1113
@GeneratedValue(strategy = GenerationType.IDENTITY)
1214
private Long id;
1315

16+
@Setter
1417
private Integer voteValue;
1518

1619
private LocalDateTime votedAt;
@@ -23,5 +26,16 @@ public class Vote {
2326

2427
@ManyToOne
2528
private Participant participant;
29+
30+
public Vote(Meeting meeting, Place place, Participant participant) {
31+
this.meeting = meeting;
32+
this.place = place;
33+
this.participant = participant;
34+
this.voteValue = 1; // 새 투표 시 voteValue를 1로 고정
35+
this.votedAt = LocalDateTime.now(); // 투표 생성 시간 설정
36+
}
37+
public void toggleVoteValue() {
38+
this.voteValue = (this.voteValue == 1) ? 0 : 1;
39+
}
2640
}
2741

0 commit comments

Comments
 (0)