Skip to content

Commit 05bbf6b

Browse files
committed
Merge branch 'dev' of https://github.com/CommitField/commitField into Feature/89
2 parents efceb07 + 7ecfff0 commit 05bbf6b

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
@@ -184,7 +184,11 @@ public void joinRoom(Long roomId, Long userId, ChatRoomRequest chatRoomRequest)
184184
@Override
185185
@Transactional
186186
public void outRoom(Long userId, Long roomId) {
187-
ChatRoom room = getChatRoom(roomId);
187+
ChatRoom room = chatRoomRepository
188+
.findChatRoomById(roomId)
189+
.orElseThrow(() -> new CustomException(ErrorCode.NO_ROOM_FOUND));
190+
191+
188192
List<UserChatRoom> userByChatRoomId = userChatRoomRepository
189193
.findUserByChatRoomId(roomId);
190194
List<Long> userIds = new ArrayList<>();
@@ -206,21 +210,31 @@ public void outRoom(Long userId, Long roomId) {
206210
userChatRoomRepository.deleteUserChatRoomByChatRoom_Id(roomId);
207211
chatRoomRepository.deleteById(roomId);
208212

213+
// 방의 생성자와 현재 사용자가 같은지 확인
214+
boolean isCreator = Objects.equals(room.getRoomCreator(), userId);
215+
216+
// 방장 여부와 상관없이 항상 사용자-채팅방 연결만 제거
217+
// 방이 삭제되지 않고 목록에 계속 표시됨
218+
userChatRoomRepository.deleteUserChatRoomByChatRoom_IdAndUserId(roomId, userId);
209219
}
210220

221+
// 방 삭제는 별도의 메소드로 분리
211222
@Override
212223
@Transactional
213224
public void deleteRoom(Long userId, Long roomId) {
214-
ChatRoom room = getChatRoom(roomId);
225+
ChatRoom room = chatRoomRepository
226+
.findChatRoomById(roomId)
227+
.orElseThrow(() -> new CustomException(ErrorCode.NO_ROOM));
228+
215229
//방장이 아닐 경우, 삭제 불가
216230
if (!Objects.equals(room.getRoomCreator(), userId)) {
217231
throw new CustomException(ErrorCode.NOT_ROOM_CREATOR);
218232
}
233+
219234
//모든 사용자 제거 후 방 삭제
220235
chatMessageRepository.deleteChatMsgByChatRoom_Id(roomId);
221236
userChatRoomRepository.deleteUserChatRoomByChatRoom_Id(roomId);
222237
chatRoomRepository.deleteById(roomId);
223-
224238
}
225239

226240
@Override
@@ -272,7 +286,6 @@ private ChatRoom getChatRoom(Long roomId) {
272286
return chatRoomRepository
273287
.findChatRoomById(roomId)
274288
.orElseThrow(() -> new CustomException(ErrorCode.NONE_ROOM));
275-
276289
}
277290

278291
@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)