Skip to content

Commit 7ecfff0

Browse files
authored
Merge pull request #100 from CommitField/fix-chat
Fix: ChatMessage, ChatRoom
2 parents cddfb81 + 5603080 commit 7ecfff0

File tree

9 files changed

+86
-15
lines changed

9 files changed

+86
-15
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package cmf.commitField.domain.Timer.controller;
2+
3+
import org.springframework.web.bind.annotation.RestController;
4+
5+
@RestController
6+
public class TimerController {
7+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package cmf.commitField.domain.Timer.dto;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
6+
import java.time.LocalDateTime;
7+
8+
@Getter
9+
@Setter
10+
public class TimerDto {
11+
private LocalDateTime startTime;
12+
private LocalDateTime endTime;
13+
private String totalTime;
14+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package cmf.commitField.domain.Timer.entity;
2+
3+
import cmf.commitField.domain.user.entity.User;
4+
import jakarta.persistence.GeneratedValue;
5+
import jakarta.persistence.GenerationType;
6+
import jakarta.persistence.Id;
7+
import lombok.AllArgsConstructor;
8+
import lombok.Getter;
9+
import lombok.NoArgsConstructor;
10+
import lombok.Setter;
11+
12+
import java.time.LocalDateTime;
13+
14+
@Getter
15+
@Setter
16+
@NoArgsConstructor
17+
@AllArgsConstructor
18+
public class Timer {
19+
@Id
20+
@GeneratedValue(strategy = GenerationType.IDENTITY)
21+
private Long id;
22+
23+
private User user;
24+
private LocalDateTime startTime;
25+
private LocalDateTime endTime;
26+
private String totalTime;
27+
28+
// ํƒ€์ด๋จธ ์ข…๋ฃŒ ๋ฉ”์„œ๋“œ
29+
public void stop(LocalDateTime endTime, String totalTime) {
30+
this.endTime = endTime;
31+
this.totalTime = totalTime;
32+
}
33+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package cmf.commitField.domain.Timer.service;
2+
3+
import org.springframework.stereotype.Service;
4+
5+
@Service
6+
public class TimerService {
7+
8+
}

โ€Žsrc/main/java/cmf/commitField/domain/chat/chatMessage/service/ChatMessageServiceImpl.javaโ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class ChatMessageServiceImpl implements ChatMessageService {
3434
private final UserChatRoomRepository userChatRoomRepository;
3535

3636
@Override
37+
@Transactional
3738
public ChatMsgResponse sendMessage(ChatMsgRequest message, Long userId, Long roomId) {
3839
User findUser = userRepository.findById(userId)
3940
.orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND_USER));

โ€Žsrc/main/java/cmf/commitField/domain/chat/chatRoom/service/ChatRoomServiceImpl.javaโ€Ž

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,11 @@ public void joinRoom(Long roomId, Long userId, ChatRoomRequest chatRoomRequest)
183183
@Override
184184
@Transactional
185185
public void outRoom(Long userId, Long roomId) {
186-
ChatRoom room = getChatRoom(roomId);
186+
ChatRoom room = chatRoomRepository
187+
.findChatRoomById(roomId)
188+
.orElseThrow(() -> new CustomException(ErrorCode.NO_ROOM_FOUND));
189+
190+
187191
List<UserChatRoom> userByChatRoomId = userChatRoomRepository
188192
.findUserByChatRoomId(roomId);
189193
List<Long> userIds = new ArrayList<>();
@@ -205,21 +209,31 @@ public void outRoom(Long userId, Long roomId) {
205209
userChatRoomRepository.deleteUserChatRoomByChatRoom_Id(roomId);
206210
chatRoomRepository.deleteById(roomId);
207211

212+
// ๋ฐฉ์˜ ์ƒ์„ฑ์ž์™€ ํ˜„์žฌ ์‚ฌ์šฉ์ž๊ฐ€ ๊ฐ™์€์ง€ ํ™•์ธ
213+
boolean isCreator = Objects.equals(room.getRoomCreator(), userId);
214+
215+
// ๋ฐฉ์žฅ ์—ฌ๋ถ€์™€ ์ƒ๊ด€์—†์ด ํ•ญ์ƒ ์‚ฌ์šฉ์ž-์ฑ„ํŒ…๋ฐฉ ์—ฐ๊ฒฐ๋งŒ ์ œ๊ฑฐ
216+
// ๋ฐฉ์ด ์‚ญ์ œ๋˜์ง€ ์•Š๊ณ  ๋ชฉ๋ก์— ๊ณ„์† ํ‘œ์‹œ๋จ
217+
userChatRoomRepository.deleteUserChatRoomByChatRoom_IdAndUserId(roomId, userId);
208218
}
209219

220+
// ๋ฐฉ ์‚ญ์ œ๋Š” ๋ณ„๋„์˜ ๋ฉ”์†Œ๋“œ๋กœ ๋ถ„๋ฆฌ
210221
@Override
211222
@Transactional
212223
public void deleteRoom(Long userId, Long roomId) {
213-
ChatRoom room = getChatRoom(roomId);
224+
ChatRoom room = chatRoomRepository
225+
.findChatRoomById(roomId)
226+
.orElseThrow(() -> new CustomException(ErrorCode.NO_ROOM));
227+
214228
//๋ฐฉ์žฅ์ด ์•„๋‹ ๊ฒฝ์šฐ, ์‚ญ์ œ ๋ถˆ๊ฐ€
215229
if (!Objects.equals(room.getRoomCreator(), userId)) {
216230
throw new CustomException(ErrorCode.NOT_ROOM_CREATOR);
217231
}
232+
218233
//๋ชจ๋“  ์‚ฌ์šฉ์ž ์ œ๊ฑฐ ํ›„ ๋ฐฉ ์‚ญ์ œ
219234
chatMessageRepository.deleteChatMsgByChatRoom_Id(roomId);
220235
userChatRoomRepository.deleteUserChatRoomByChatRoom_Id(roomId);
221236
chatRoomRepository.deleteById(roomId);
222-
223237
}
224238

225239
@Override
@@ -246,7 +260,6 @@ private ChatRoom getChatRoom(Long roomId) {
246260
return chatRoomRepository
247261
.findChatRoomById(roomId)
248262
.orElseThrow(() -> new CustomException(ErrorCode.NONE_ROOM));
249-
250263
}
251264

252265
@Override

โ€Žsrc/main/java/cmf/commitField/domain/commit/sinceCommit/service/SinceCommitService.javaโ€Ž

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
@Service
2323
public class SinceCommitService {
2424
private static final String BASE_URL = "https://api.github.com";
25-
// ?since=2024-01-01T00:00:00Z&until=2025-02-1T23:59:59Z
2625

2726
@Value("${github.token}")
2827
private String PAT;
@@ -53,7 +52,6 @@ public List<SinceCommitResponseDto> getSinceCommits(String owner, String repo, L
5352

5453
// ์—ฐ์† ์ปค๋ฐ‹ ์ˆ˜ ๊ณ„์‚ฐ
5554

56-
// ์ƒˆ๋กœ์šด ๋ถ„์„ ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
5755
public CommitAnalysisResponseDto getCommitAnalysis(String owner, String repo, LocalDateTime since, LocalDateTime until) {
5856
List<SinceCommitResponseDto> commits = getSinceCommits(owner, repo, since, until);
5957
StreakResult streakResult = calculateStreaks(commits);

โ€Žsrc/main/java/cmf/commitField/domain/commit/totalCommit/controller/TotalCommitController.javaโ€Ž

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import lombok.RequiredArgsConstructor;
77
import org.springframework.security.core.annotation.AuthenticationPrincipal;
88
import org.springframework.web.bind.annotation.GetMapping;
9+
import org.springframework.web.bind.annotation.PathVariable;
910
import org.springframework.web.bind.annotation.RestController;
1011

1112
import java.time.LocalDateTime;
@@ -16,10 +17,11 @@
1617
public class TotalCommitController {
1718
private final TotalCommitService totalCommitService;
1819

19-
// @GetMapping("/api/commits/{username}")
20-
// public TotalCommitResponseDto getTotalCommits(@PathVariable String username) {
21-
// return totalCommitService.getTotalCommitCount(username);
22-
// }
20+
// Postman ํ…Œ์ŠคํŠธ์šฉ
21+
@GetMapping("/api/commits/{username}")
22+
public TotalCommitResponseDto getTotalCommits(@PathVariable String username) {
23+
return totalCommitService.getTotalCommitCount(username);
24+
}
2325

2426
// ๋กœ๊ทธ์ธํ•œ ์‚ฌ์šฉ์ž์˜ username ์ด์šฉ
2527
@GetMapping("/api/commits")

โ€Žsrc/main/java/cmf/commitField/domain/commit/totalCommit/dto/TotalCommitResponseDto.javaโ€Ž

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,4 @@ public TotalCommitResponseDto(long totalCommitContributions, long restrictedCont
1818
this.currentStreakDays = currentStreakDays;
1919
this.maxStreakDays = maxStreakDays;
2020
}
21-
22-
public TotalCommitResponseDto(long totalCommitContributions, long restrictedContributionsCount) {
23-
this.totalCommitContributions = totalCommitContributions;
24-
this.restrictedContributionsCount = restrictedContributionsCount;
25-
}
2621
}

0 commit comments

Comments
ย (0)