Skip to content

Commit d6bd1f2

Browse files
committed
Merge branch 'dev' of https://github.com/CommitField/commitField into feat/#97
2 parents 1c15c2d + 7ecfff0 commit d6bd1f2

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)