Skip to content

Commit 5b93c82

Browse files
committed
Merge branch 'feat/#150' of https://github.com/CommitField/commitField into feat/#150
2 parents 0c75093 + 1633f7a commit 5b93c82

Some content is hidden

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

44 files changed

+695
-156
lines changed

.DS_Store

-6 KB
Binary file not shown.
+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Gemini Code Review
2+
3+
on:
4+
push:
5+
branches: [ feat/gemini ]
6+
paths:
7+
- 'backend/**'
8+
pull_request:
9+
types: [opened, synchronize]
10+
11+
jobs:
12+
code-review:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
pull-requests: write
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Set up Node
24+
uses: actions/setup-node@v3
25+
26+
- name: Install GoogleGenerativeAI
27+
run: |
28+
npm install @google/generative-ai
29+
30+
# PR 이벤트에서의 변경사항 처리
31+
- name: Get git diff for PR
32+
if: github.event_name == 'pull_request'
33+
run: |
34+
git fetch origin "${{ github.event.pull_request.base.ref }}"
35+
git fetch origin "${{ github.event.pull_request.head.ref }}"
36+
git diff --unified=0 "origin/${{ github.event.pull_request.base.ref }}" > "diff.txt"
37+
echo "EVENT_TYPE=pull_request" >> $GITHUB_ENV
38+
39+
# Push 이벤트에서의 변경사항 처리
40+
- name: Get git diff for Push
41+
if: github.event_name == 'push'
42+
run: |
43+
git diff --unified=0 HEAD^ HEAD > "diff.txt"
44+
echo "EVENT_TYPE=push" >> $GITHUB_ENV
45+
46+
# Gemini를 사용한 코드 분석
47+
- name: Run Gemini-1.5-flash
48+
id: gemini_review
49+
uses: actions/github-script@v7
50+
with:
51+
script: |
52+
const fs = require("fs");
53+
const diff_output = fs.readFileSync("diff.txt",'utf8');
54+
55+
const { GoogleGenerativeAI } = require("@google/generative-ai");
56+
const genAI = new GoogleGenerativeAI("${{ secrets.GEMINI_API_KEY }}");
57+
const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash"});
58+
59+
// PR과 Push에 따라 다른 프롬프트 사용
60+
let prompt;
61+
if (process.env.EVENT_TYPE === 'pull_request') {
62+
prompt = `Explain in korean. You are a senior software engineer and need to perform a code review based on the results of a given git diff. Review the changed code from different perspectives and let us know if there are any changes that need to be made. If you see any code that needs to be fixed in the result of the git diff, you need to calculate the exact line number by referring to the "@@ -0,0 +0,0 @@" part. The output format is \[{"path":"{ filepath }", "line": { line }, "text": { review comment }, "side": "RIGHT"}\] format must be respected.\n<git diff>${diff_output}</git diff>`;
63+
} else {
64+
prompt = `Explain in korean. You are a senior software engineer and need to perform a code review based on the results of a given git diff. Provide a detailed review of the code changes, focusing on code quality, readability, performance, and security. Format your response in Markdown with clear headings for each file reviewed.\n<git diff>${diff_output}</git diff>`;
65+
}
66+
67+
const result = await model.generateContent(prompt);
68+
const response = await result.response;
69+
const text = response.text();
70+
71+
fs.writeFileSync('review_result.txt', text);
72+
console.log('Review results saved!');
73+
74+
# PR 이벤트: 라인별 리뷰 코멘트 추가
75+
- name: Format and add PR review comments
76+
if: env.EVENT_TYPE == 'pull_request'
77+
id: store
78+
run: |
79+
COMMENT=$(sed '/^```/d' review_result.txt | jq -c .)
80+
echo "comment=$COMMENT" >> $GITHUB_OUTPUT
81+
82+
- name: Add Pull Request Review Comment
83+
if: env.EVENT_TYPE == 'pull_request'
84+
uses: nbaztec/[email protected]
85+
with:
86+
comments: ${{ steps.store.outputs.comment }}
87+
repo-token: ${{ secrets.GITHUB_TOKEN }}
88+
repo-token-user-login: 'github-actions[bot]'
89+
allow-repeats: false
90+
91+
# Push 이벤트: 액션 로그에 리뷰 결과 출력 및 아티팩트 업로드
92+
- name: Display review results in workflow log
93+
if: env.EVENT_TYPE == 'push'
94+
run: |
95+
echo "===== Gemini Code Review Results ====="
96+
cat review_result.txt
97+
echo "======================================"
98+
99+
- name: Upload review results as artifact
100+
if: env.EVENT_TYPE == 'push'
101+
uses: actions/upload-artifact@v4
102+
with:
103+
name: gemini-code-review
104+
path: review_result.txt

README.md

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# 🌱 CommitField_BE
2+
> 커밋필드 (사용자의 깃허브 기록을 활용해 펫 육성 및 업적 달성을 지원하며, 채팅 등 지속적인 동기 부여를 돕는 서비스)
3+
4+
총 개발기간 : `2025.2.18` ~ `2025.03.13` (22일)
5+
</br>
6+
개발인원: 5명
7+
8+
</br>
9+
<img width="1629" alt="스크린샷 2025-02-13 오후 5 17 27" src="https://github.com/user-attachments/assets/5b9be8f8-f524-4bd6-bee5-99dbd2d4f591" />
10+
11+
# 🌴 팀원 소개
12+
<table>
13+
<tr>
14+
<td><img src="https://avatars.githubusercontent.com/u/15629036?v=4" width="200" height="200"></td>
15+
<td><img src="https://avatars.githubusercontent.com/u/181931584?v=4" width="200" height="200"></td>
16+
<td><img src="https://avatars.githubusercontent.com/u/93702730?v=4" width="200" height="200"></td>
17+
<td><img src="https://avatars.githubusercontent.com/u/82190411?v=4" width="200" height="200"></td>
18+
<td><img src="https://avatars.githubusercontent.com/u/55117130?v=4" width="200" height="200"></td>
19+
</tr>
20+
<tr>
21+
<td><a href="https://github.com/whale22">김소영</a></td>
22+
<td><a href="https://github.com/skyeong42">성수경</a></td>
23+
<td><a href="https://github.com/seoyeonson">손서연</a></td>
24+
<td><a href="https://github.com/ces0135-hub">백성현</a></td>
25+
<td><a href="https://github.com/ces0135-hub">윤현승</a></td>
26+
</tr>
27+
</table>
28+
29+
## 💐 기술 스택
30+
31+
<img width="1046" alt="스크린샷 2025-03-14 오후 1 18 14" src="https://github.com/user-attachments/assets/48a7e53b-08c6-41bb-8fae-88fc9be322d3" />
32+
</br>
33+
34+
## 🌼 시스템 아키텍쳐
35+
36+
<img width="1545" alt="스크린샷 2025-02-13 오후 1 18 55" src="https://github.com/user-attachments/assets/cc121c13-be01-47fd-a44a-64bf3a6433c7" />
37+
</br>
38+
39+
## 🌳 ERD
40+
41+
<img width="1502" alt="스크린샷 2025-03-14 오후 1 19 59" src="https://github.com/user-attachments/assets/4c50079c-240c-47d3-9c87-e09e13f4d9b5" />
42+
</br>
43+
44+
45+
# 🍀 페이지 별 기능
46+
47+
## 🌺 메인 페이지
48+
49+
<img width="1600" alt="메인 페이지" src="https://github.com/user-attachments/assets/824e6caa-6a15-4b1b-a747-a5da09d29892" />
50+
</br>
51+
52+
### 🍃 기능
53+
#### 🔹 펫/랭킹
54+
- 계절 별 랭킹 설계로 총 커밋 수와 계절 별 커밋 수.
55+
- 현재 시즌에 맞는 커밋 수에 따라 랭킹을 부여.
56+
#### 🔹 커밋 개수 자동 갱신
57+
- 유저 커밋 수 주기적 갱신.
58+
- 스프링 이벤트를 통한 데이터 일괄 갱신.
59+
#### 🔹 실시간 알림
60+
- 시즌 알림
61+
- 랭킹 알림
62+
- 연속 커밋 축하 알림
63+
- 커밋 부재 알림
64+
65+
## 🌹 펫
66+
67+
<img width="1600" alt="" src="https://github.com/user-attachments/assets/766fc5cf-11a4-43ad-bd58-1aa7f8908efa" />
68+
</br>
69+
70+
### 🍃 기능
71+
#### 🔹 펫
72+
- 사용자 별 펫 확인 가능.
73+
74+
## 🌻 로그인
75+
76+
<img width="1600" alt="로그인" src="https://github.com/user-attachments/assets/a3842c23-023c-4eda-965f-4767768cb5cf" />
77+
</br>
78+
79+
### 🍃 기능
80+
#### 🔹 로그인
81+
- Github API를 이용한 로그인 구현.
82+
- 세션 방식 사용.
83+
84+
85+
## 🌷 채팅
86+
<img width="1600" alt="로그인" src="https://github.com/user-attachments/assets/f29670ac-4dbe-4af0-87d5-3e9360a9246e" />
87+
</br>
88+
<img width="1600" alt="로그인" src="https://github.com/user-attachments/assets/a09a257f-9ebf-43ec-89f3-7399678e17b2" />
89+
</br>
90+
91+
92+
### 🍃 기능
93+
#### 🔹 채팅 방 관리
94+
- 반장이 채팅 방을 생성 및 삭제 가능.
95+
- 마지막 사용자가 나가면 채팅 방 자동 삭제.
96+
- 채팅 방 목록 조회 (전체, 내가 생성한 방, 참여 중인 방, 좋아요 순, 내가 좋아요한 방).
97+
- 중복 참여 불가.
98+
- 키워드 기반 채팅 방 검색.
99+
- 반장만 채팅 방 이름 수정 가능.
100+
- 비밀번호 설정 가능.
101+
102+
#### 🔹 채팅 기능
103+
- 실시간 양방향 통신 사용자 메시지 전송.
104+
- 채팅 방 내 메시지 조회 (사용자가 들어온 시점부터 확인 가능).
105+
106+
#### 🔹 사용자 관리
107+
- 온라인/오프라인 상태 확인 (로그인, 로그아웃).
108+
- 채팅 방 참여자 목록 조회 가능.
109+
- 채팅 방 좋아요 기능 제공 (좋아요 순 정렬 가능).
110+
111+
112+
113+

src/.DS_Store

-6 KB
Binary file not shown.

src/main/.DS_Store

-6 KB
Binary file not shown.

src/main/java/.DS_Store

-6 KB
Binary file not shown.

src/main/java/cmf/.DS_Store

-6 KB
Binary file not shown.
-6 KB
Binary file not shown.
Binary file not shown.

src/main/java/cmf/commitField/domain/admin/controller/ApiV1PetImgController.java renamed to src/main/java/cmf/commitField/domain/admin/admin/controller/ApiV1PetImgController.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package cmf.commitField.domain.admin.controller;
1+
package cmf.commitField.domain.admin.admin.controller;
22

33
import cmf.commitField.global.aws.s3.S3Service;
44
import lombok.RequiredArgsConstructor;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package cmf.commitField.domain.admin.notice.entity;
2+
3+
4+
import cmf.commitField.global.jpa.BaseEntity;
5+
import jakarta.persistence.Entity;
6+
import lombok.*;
7+
import lombok.experimental.SuperBuilder;
8+
9+
@Entity
10+
@SuperBuilder
11+
@Getter
12+
@Setter
13+
@NoArgsConstructor(access = AccessLevel.PROTECTED)
14+
@AllArgsConstructor(access = AccessLevel.PROTECTED)
15+
public class Notice extends BaseEntity {
16+
// 관리자 공지사항
17+
private String title;
18+
private String content;
19+
}

src/main/java/cmf/commitField/domain/chat/chatMessage/controller/response/ChatMsgResponse.java

+4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
public class ChatMsgResponse {
1313
//채팅방 ID
1414
private Long roomId;
15+
//chatMsgId
16+
private Long id;
1517
//사용자(user)
18+
private Long userId;
1619
private String from;
1720
private String message;
1821
private LocalDateTime sendAt;
22+
private String avatarUrl; // 아바타 URL 필드 추가
1923
}

src/main/java/cmf/commitField/domain/chat/chatMessage/dto/ChatMsgDto.java

+1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ public class ChatMsgDto {
1515
private String nickname;
1616
private String message;
1717
private LocalDateTime sendAt;
18+
private String avatarUrl; // avatarUrl 필드 추가
1819
}

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

+11-10
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,30 @@ public ChatMsgResponse sendMessage(ChatMsgRequest message, Long userId, Long roo
4343

4444
ChatRoom chatRoom = chatRoomRepository.findChatRoomById(roomId)
4545
.orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND_ROOM));
46-
// 채팅 메시지 생성
46+
4747
ChatMsg chatMsg = ChatMsg.builder()
4848
.message(message.getMessage())
4949
.createdAt(LocalDateTime.now())
5050
.user(findUser)
5151
.chatRoom(chatRoom)
5252
.build();
5353

54-
// Response message
55-
// 응답 값으로 변환
56-
57-
ChatMsgResponse response = ChatMsgResponse.builder()
54+
chatMessageRepository.save(chatMsg);
5855

56+
// Response message
57+
// 응답값 변환
58+
return ChatMsgResponse.builder()
59+
.id(chatMsg.getId()) // chatMsgId 추가
5960
.roomId(roomId)
60-
.from(findUser.getNickname())
61+
.userId(userId) // userId 추가
62+
.from(findUser.getUsername())
6163
.message(message.getMessage())
6264
.sendAt(chatMsg.getCreatedAt())
65+
.avatarUrl(findUser.getAvatarUrl()) // 아바타 URL 추가
6366
.build();
64-
chatMessageRepository.save(chatMsg);
65-
return response;
6667

6768
}
6869

69-
7070
@Transactional(readOnly = true)
7171
@Override
7272
public List<ChatMsgDto> getRoomChatMsgList(Long roomId, Long userId, Long lastId) {
@@ -83,10 +83,11 @@ public List<ChatMsgDto> getRoomChatMsgList(Long roomId, Long userId, Long lastId
8383
for (ChatMsg chatMsg : chatMsgsList) {
8484
ChatMsgDto build = ChatMsgDto.builder()
8585
.chatMsgId(chatMsg.getId())
86-
.nickname(chatMsg.getUser().getNickname())
86+
.nickname(chatMsg.getUser().getUsername()) // nickname 대신 username 사용
8787
.sendAt(chatMsg.getCreatedAt())
8888
.message(chatMsg.getMessage())
8989
.userId(chatMsg.getUser().getId())
90+
.avatarUrl(chatMsg.getUser().getAvatarUrl()) // avatarUrl 추가
9091
.build();
9192
if (build.getSendAt().isAfter(joinDt)) {
9293
chatMsgDtos.add(build);
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//package cmf.commitField.domain.chat.chatRoom.controller.response;
2-
//
3-
//public class ChatRoomResponse {
4-
//}
1+
package cmf.commitField.domain.chat.chatRoom.controller.response;
2+
3+
public class ChatRoomResponse {
4+
}

src/main/java/cmf/commitField/domain/chat/chatRoom/dto/ChatRoomUserDto.java

+2
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@
1010
public class ChatRoomUserDto {
1111
private String nickname;
1212
private Boolean status;
13+
// 사용자 github image
14+
private String imageUrl;
1315
}

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ public List<ChatRoomDto> searchRoomByTitle(String roomName, Long userId, Pageabl
271271
.heartCount(chatRoom.getHearts().size())
272272
.currentUserCount((long) chatRoom.getUserChatRooms().size())
273273
.userCountMax(chatRoom.getUserCountMax())
274+
.imageUrl(chatRoom.getImageUrl())
274275
.build();
275276
chatRoomDtos.add(build);
276277
}
@@ -312,8 +313,9 @@ public List<ChatRoomUserDto> getRoomUsers(Long roomId, Long userId) {
312313
List<ChatRoomUserDto> chatRoomUserDtos = new ArrayList<>();
313314
for (UserChatRoom userChatRoom : userIds) {
314315
ChatRoomUserDto build = ChatRoomUserDto.builder()
315-
.nickname(userChatRoom.getUser().getNickname())
316+
.nickname(userChatRoom.getUser().getUsername())
316317
.status(userChatRoom.getUser().getStatus())
318+
.imageUrl(userChatRoom.getUser().getAvatarUrl())
317319
.build();
318320
chatRoomUserDtos.add(build);
319321
}
@@ -334,6 +336,7 @@ public List<ChatRoomDto> getRoomHeartSortList(Pageable pageable) {
334336
.userCountMax(chatRoom.getUserCountMax())
335337
.currentUserCount((long) chatRoom.getUserChatRooms().size())
336338
.heartCount(chatRoom.getHearts().size())
339+
.imageUrl(chatRoom.getImageUrl())
337340
.build();
338341
chatRoomDtos.add(build);
339342
}
@@ -363,6 +366,7 @@ public List<ChatRoomDto> myHeartRoomList(Long userId, Pageable pageable) {
363366
.heartCount(chatRoom.getHearts().size())
364367
.currentUserCount((long) chatRoom.getUserChatRooms().size())
365368
.userCountMax(chatRoom.getUserCountMax())
369+
.imageUrl(chatRoom.getImageUrl())
366370
.build();
367371
chatRoomDtos.add(build);
368372
}

0 commit comments

Comments
 (0)