Skip to content

Commit 1070eb3

Browse files
authored
Merge pull request #32 from studio-recoding/feat-main-api
[🚀feat] chat 반환시 case 분류도 같이 반환
2 parents 57b3bc2 + 9121639 commit 1070eb3

File tree

5 files changed

+53
-52
lines changed

5 files changed

+53
-52
lines changed

src/main/java/Ness/Backend/domain/chat/ChatService.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public GetChatListDto getOneWeekUserChat(Long id){
3737
.id(chat.getId())
3838
.createdDate(chat.getCreatedDate().toString())
3939
.text(chat.getText())
40+
.caseNumber(chat.getCaseNumber())
4041
.chatType(chat.getChatType().toString())
4142
.build())
4243
.toList();
@@ -51,20 +52,22 @@ public GetChatListDto postNewUserChat(Long id, PostUserChatDto postUserChatDto){
5152
.atZone(ZoneId.of("Asia/Seoul")))
5253
.text(postUserChatDto.getText())
5354
.chatType(postUserChatDto.getChatType())
55+
.caseNumber(0) //유저는 디폴트로 case
5456
.member(memberEntity)
5557
.build();
5658

5759
chatRepository.save(newUserChat);
5860

59-
String answer = postNewAiChat(id, postUserChatDto.getText());
60-
String parsedAnswer = parseAiChat(answer);
61+
PostFastApiAiChatDto AiDto = postNewAiChat(id, postUserChatDto.getText());
62+
String parsedAnswer = parseAiChat(AiDto.getAnswer());
6163

6264
//AI 챗 답변 저장
6365
Chat newAiChat = Chat.builder()
6466
.createdDate(LocalDateTime.now(ZoneId.of("Asia/Seoul"))
6567
.atZone(ZoneId.of("Asia/Seoul")))
6668
.text(parsedAnswer)
6769
.chatType(ChatType.AI)
70+
.caseNumber(AiDto.getCaseNumber()) //AI는 받아온 값으로 저장
6871
.member(memberEntity)
6972
.build();
7073

@@ -77,7 +80,7 @@ public String parseAiChat(String text){
7780
return text.replace("\"", "");
7881
}
7982

80-
public String postNewAiChat(Long id, String text){
83+
public PostFastApiAiChatDto postNewAiChat(Long id, String text){
8184

8285
PostFastApiUserChatDto userDto = PostFastApiUserChatDto.builder()
8386
.message(text)
@@ -86,6 +89,6 @@ public String postNewAiChat(Long id, String text){
8689
//Fast API에 전송하기
8790
PostFastApiAiChatDto AiDto = fastApiChatApi.creatFastApiChat(userDto);
8891

89-
return AiDto.getAnswer();
92+
return AiDto;
9093
}
9194
}

src/main/java/Ness/Backend/domain/chat/dto/response/GetChatDto.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package Ness.Backend.domain.chat.dto.response;
22

3+
import com.fasterxml.jackson.annotation.JsonProperty;
34
import io.swagger.v3.oas.annotations.media.Schema;
45
import lombok.Builder;
56
import lombok.Data;
@@ -20,11 +21,15 @@ public class GetChatDto {
2021
@Schema(description = "발화자 구분", example = "AI")
2122
private String chatType;
2223

24+
@JsonProperty("case")
25+
private int caseNumber;
26+
2327
@Builder
24-
public GetChatDto(Long id, String createdDate, String text, String chatType){
28+
public GetChatDto(Long id, String createdDate, String text, String chatType, int caseNumber){
2529
this.id = id;
2630
this.createdDate = createdDate;
2731
this.text = text;
2832
this.chatType = chatType;
33+
this.caseNumber = caseNumber;
2934
}
3035
}

src/main/java/Ness/Backend/domain/chat/dto/response/PostFastApiAiChatDto.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@
1313
public class PostFastApiAiChatDto {
1414
@JsonProperty("ness")
1515
private String answer;
16+
17+
@JsonProperty("case")
18+
private int caseNumber;
1619
}

src/main/java/Ness/Backend/domain/chat/entity/Chat.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public class Chat {
2222

2323
private String text;
2424

25+
private int caseNumber;
26+
2527
//AI 발화인지, USER 발화인지 구분해주는 타입 값
2628
@Enumerated(EnumType.STRING)
2729
private ChatType chatType;
@@ -34,11 +36,13 @@ public class Chat {
3436
private Member member;
3537

3638
@Builder
37-
public Chat(Long id, ZonedDateTime createdDate, String text, ChatType chatType, Schedule schedule, Member member) {
39+
public Chat(Long id, ZonedDateTime createdDate, String text, ChatType chatType,
40+
int caseNumber, Schedule schedule, Member member) {
3841
this.id = id;
3942
this.createdDate = createdDate;
4043
this.text = text;
4144
this.chatType = chatType;
45+
this.caseNumber = caseNumber;
4246
this.schedule = schedule;
4347
this.member = member;
4448
}

src/main/resources/data.sql

Lines changed: 32 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,32 @@
11
/*한 달 단위 업데이트*/
22
INSERT INTO report_tag (created_date, tag_title, tag_desc, member_id)
3-
VALUES ("2024-03-24 00:00:00.000000", "공부 매니아", "이번 달에 공부를 많이 하셨네요. 공부에 열정이 넘치는 당신은 공부 매니아!", 1),
4-
("2024-03-24 00:00:00.000000", "홈 프로텍터", "집을 지키기 위해 최선을 다하는 당신, 최고의 홈 프로텍터네요.", 1),
5-
("2024-03-24 00:00:00.000000", "노는 게 제일 좋아", "이번 달에는 외부 약속이 별로 없으셨네요. 역시 노는 게 최고죠?", 1),
6-
("2024-03-24 00:00:00.000000", "프로 운동선수", "이번 달에는 운동을 정말 많이 하셨네요. 전문 운동선수이신가요?", 1),
7-
("2024-03-24 00:00:00.000000", "주니어 개발자", "개발에 열정을 불태우는 당신, 주니어 개발자입니다.", 1),
8-
("2024-03-24 00:00:00.000000", "시니어 개발자", "하루 24시간 개발만 하시는 건 아니죠? 시니어 개발자이시네요!", 1),
9-
("2024-04-14 00:00:00.000000", "공부 매니아", "이번 달에 공부를 많이 하셨네요. 공부에 열정이 넘치는 당신은 공부 매니아!", 1),
10-
("2024-04-14 00:00:00.000000", "홈 프로텍터", "집을 지키기 위해 최선을 다하는 당신, 최고의 홈 프로텍터네요.", 1),
11-
("2024-04-14 00:00:00.000000", "노는 게 제일 좋아", "이번 달에는 외부 약속이 별로 없으셨네요. 역시 노는 게 최고죠?", 1),
12-
("2024-04-14 00:00:00.000000", "프로 운동선수", "이번 달에는 운동을 정말 많이 하셨네요. 전문 운동선수이신가요?", 1),
13-
("2024-04-14 00:00:00.000000", "주니어 개발자", "개발에 열정을 불태우는 당신, 주니어 개발자입니다.", 1),
14-
("2024-04-14 00:00:00.000000", "시니어 개발자", "하루 24시간 개발만 하시는 건 아니죠? 시니어 개발자이시네요!", 1);
3+
VALUES ("2024-04-06 00:00:00.000000", "공부 매니아", "이번 달에 공부를 많이 하셨네요. 공부에 열정이 넘치는 당신은 공부 매니아!", 1),
4+
("2024-04-06 00:00:00.000000", "홈 프로텍터", "집을 지키기 위해 최선을 다하는 당신, 최고의 홈 프로텍터네요.", 1),
5+
("2024-04-06 00:00:00.000000", "노는 게 제일 좋아", "이번 달에는 외부 약속이 별로 없으셨네요. 역시 노는 게 최고죠?", 1),
6+
("2024-04-06 00:00:00.000000", "프로 운동선수", "이번 달에는 운동을 정말 많이 하셨네요. 전문 운동선수이신가요?", 1),
7+
("2024-04-06 00:00:00.000000", "주니어 개발자", "개발에 열정을 불태우는 당신, 주니어 개발자입니다.", 1),
8+
("2024-04-06 00:00:00.000000", "시니어 개발자", "하루 24시간 개발만 하시는 건 아니죠? 시니어 개발자이시네요!", 1);
159

1610
INSERT INTO report_tag (created_date, tag_title, tag_desc, member_id)
17-
VALUES ("2024-04-14 00:00:00.000000", "공부 매니아", "이번 달에 공부를 많이 하셨네요. 공부에 열정이 넘치는 당신은 공부 매니아!", 1),
18-
("2024-04-14 00:00:00.000000", "홈 프로텍터", "집을 지키기 위해 최선을 다하는 당신, 최고의 홈 프로텍터네요.", 1),
19-
("2024-04-14 00:00:00.000000", "노는 게 제일 좋아", "이번 달에는 외부 약속이 별로 없으셨네요. 역시 노는 게 최고죠?", 1),
20-
("2024-04-14 00:00:00.000000", "프로 운동선수", "이번 달에는 운동을 정말 많이 하셨네요. 전문 운동선수이신가요?", 1),
21-
("2024-04-14 00:00:00.000000", "주니어 개발자", "개발에 열정을 불태우는 당신, 주니어 개발자입니다.", 1),
22-
("2024-04-14 00:00:00.000000", "시니어 개발자", "하루 24시간 개발만 하시는 건 아니죠? 시니어 개발자이시네요!", 1);
11+
VALUES ("2024-04-15 00:00:00.000000", "공부 매니아", "이번 달에 공부를 많이 하셨네요. 공부에 열정이 넘치는 당신은 공부 매니아!", 1),
12+
("2024-04-15 00:00:00.000000", "홈 프로텍터", "집을 지키기 위해 최선을 다하는 당신, 최고의 홈 프로텍터네요.", 1),
13+
("2024-04-15 00:00:00.000000", "노는 게 제일 좋아", "이번 달에는 외부 약속이 별로 없으셨네요. 역시 노는 게 최고죠?", 1),
14+
("2024-04-15 00:00:00.000000", "프로 운동선수", "이번 달에는 운동을 정말 많이 하셨네요. 전문 운동선수이신가요?", 1),
15+
("2024-04-15 00:00:00.000000", "주니어 개발자", "개발에 열정을 불태우는 당신, 주니어 개발자입니다.", 1),
16+
("2024-04-15 00:00:00.000000", "시니어 개발자", "하루 24시간 개발만 하시는 건 아니죠? 시니어 개발자이시네요!", 1);
2317

2418
/* 일주일 단위 업데이트 */
25-
INSERT INTO chat (chat_type, created_date, text, member_id)
26-
VALUES ("USER", "2024-03-20 00:00:00.000000", "나 지난 6개월동안 얼마나 운동했어?", 1),
27-
("AI", "2024-03-21 06:00:00.000000", "축구는 지난 6개월동안 12번, 스케이트 보드는 24번 하셨습니다. 활발한 프로 운동러이시네요!", 1),
28-
("USER", "2024-03-22 00:00:00.000000", "최근 들어서 내가 예전보다 운동을 많이 한 편인가?", 1),
29-
("AI", "2024-03-23 06:00:00.000000", "아쉽게도 그렇지 않네요 🥹 최근 바쁜 공부 일정때문에 이전과는 달리 거의 운동을 하지 못했어요. 가벼운 스트레칭이라도 해보시는 것 어떨까요?", 1);
19+
INSERT INTO chat (chat_type, created_date, text, member_id, case_number)
20+
VALUES ("USER", "2024-04-06 00:00:00.000000", "나 지난 6개월동안 얼마나 운동했어?", 1, 0),
21+
("AI", "2024-04-06 06:00:00.000000", "축구와 스케이트 보드를 열심히 하셨어요. 활발한 프로 운동러이시네요!", 1, 3),
22+
("USER", "2024-04-06 00:00:00.000000", "최근 들어서 내가 예전보다 운동을 많이 한 편인가?", 1, 0),
23+
("AI", "2024-04-06 06:00:00.000000", "아쉽게도 그렇지 않네요 🥹 최근 바쁜 공부 일정때문에 이전과는 달리 거의 운동을 하지 못했어요. 가벼운 스트레칭이라도 해보시는 것 어떨까요?", 1, 3);
3024

31-
INSERT INTO chat (chat_type, created_date, text, member_id)
32-
VALUES ("USER", "2024-03-24 00:00:00.000000", "나 지난 6개월동안 얼마나 운동했어?", 1),
33-
("AI", "2024-03-25 06:00:00.000000", "축구는 지난 6개월동안 12번, 스케이트 보드는 24번 하셨습니다. 활발한 프로 운동러이시네요!", 1),
34-
("USER", "2024-03-26 00:00:00.000000", "최근 들어서 내가 예전보다 운동을 많이 한 편인가?", 1),
35-
("AI", "2024-03-27 06:00:00.000000", "아쉽게도 그렇지 않네요 🥹 최근 바쁜 공부 일정때문에 이전과는 달리 거의 운동을 하지 못했어요. 가벼운 스트레칭이라도 해보시는 것 어떨까요?", 1);
36-
37-
INSERT INTO chat (chat_type, created_date, text, member_id)
38-
VALUES ("USER", "2024-04-01 00:00:00.000000", "나 지난 6개월동안 얼마나 운동했어?", 1),
39-
("AI", "2024-04-02 06:00:00.000000", "축구는 지난 6개월동안 12번, 스케이트 보드는 24번 하셨습니다. 활발한 프로 운동러이시네요!", 1),
40-
("USER", "2024-04-03 00:00:00.000000", "최근 들어서 내가 예전보다 운동을 많이 한 편인가?", 1),
41-
("AI", "2024-04-04 06:00:00.000000", "아쉽게도 그렇지 않네요 🥹 최근 바쁜 공부 일정때문에 이전과는 달리 거의 운동을 하지 못했어요. 가벼운 스트레칭이라도 해보시는 것 어떨까요?", 1);
42-
43-
INSERT INTO chat (chat_type, created_date, text, member_id)
44-
VALUES ("USER", "2024-04-08 00:00:00.000000", "나 지난 6개월동안 얼마나 운동했어?", 1),
45-
("AI", "2024-04-09 06:00:00.000000", "축구는 지난 6개월동안 12번, 스케이트 보드는 24번 하셨습니다. 활발한 프로 운동러이시네요!", 1),
46-
("USER", "2024-04-10 00:00:00.000000", "최근 들어서 내가 예전보다 운동을 많이 한 편인가?", 1),
47-
("AI", "2024-04-11 06:00:00.000000", "아쉽게도 그렇지 않네요 🥹 최근 바쁜 공부 일정때문에 이전과는 달리 거의 운동을 하지 못했어요. 가벼운 스트레칭이라도 해보시는 것 어떨까요?", 1);
25+
INSERT INTO chat (chat_type, created_date, text, member_id, case_number)
26+
VALUES ("USER", "2024-04-16 00:00:00.000000", "나 지난 6개월동안 얼마나 운동했어?", 1, 0),
27+
("AI", "2024-04-16 06:00:00.000000", "축구와 스케이트 보드를 열심히 하셨어요. 활발한 프로 운동러이시네요!", 1, 3),
28+
("USER", "2024-04-16 00:00:00.000000", "최근 들어서 내가 예전보다 운동을 많이 한 편인가?", 1, 0),
29+
("AI", "2024-04-16 06:00:00.000000", "아쉽게도 그렇지 않네요 🥹 최근 바쁜 공부 일정때문에 이전과는 달리 거의 운동을 하지 못했어요. 가벼운 스트레칭이라도 해보시는 것 어떨까요?", 1, 3);
4830

4931
INSERT INTO category (name)
5032
VALUES ("💰 인턴"),
@@ -54,9 +36,13 @@ VALUES ("💰 인턴"),
5436
("👩‍💻 개발");
5537

5638
INSERT INTO schedule (start_time, end_time, info, location, person, member_id, category_id)
57-
VALUES ("2024-04-20 00:00:00.000000", null, "랩실에서 인공지능 모델 돌리기", null, "혜승", 1, 1),
58-
("2024-04-20 00:00:00.000000", null, "NEST.JS 공부하기", null, "민주", 1, 1),
59-
("2024-04-20 00:00:00.000000", null, "정확도 계산하기", null, "채원", 1, 1),
60-
("2024-04-20 00:00:00.000000", null, "백엔드 공부하기", "학교", null, 1, 2),
61-
("2024-04-20 18:00:00.000000", "2024-04-20 20:00:00.000000", "토익 기출문제 풀기", "학원", null, 1, 2),
62-
("2024-04-20 00:00:00.000000", null, "기타 연습하기", null, null, 1, 3);
39+
VALUES ("2024-04-04 00:00:00.000000", null, "한강 놀러가기", "한강", "혜승", 1, 3),
40+
("2024-04-15 00:00:00.000000", "2024-04-17 00:00:00.000000", "졸업 프로젝트 개발하기", null, null, 1, 5),
41+
("2024-04-19 00:00:00.000000", null, "랩실에서 인공지능 모델 돌리기", "연구실", "혜승", 1, 1),
42+
("2024-04-19 00:00:00.000000", null, "NEST.JS 공부하기", null, "민주", 1, 1),
43+
("2024-04-19 00:00:00.000000", null, "정확도 계산하기", null, "채원", 1, 1),
44+
("2024-04-19 00:00:00.000000", null, "백엔드 공부하기", "학교", null, 1, 2),
45+
("2024-04-19 18:00:00.000000", "2024-04-19 20:00:00.000000", "토익 기출문제 풀기", "학원", null, 1, 2),
46+
("2024-04-19 00:00:00.000000", null, "기타 연습하기", null, null, 1, 3),
47+
("2024-04-23 00:00:00.000000", null, "연극 보러가기", null, "민주", 1, 3),
48+
("2024-04-30 00:00:00.000000", null, "술 마시러 가기", null, "GDSC 맴버", 1, 3);

0 commit comments

Comments
 (0)