Skip to content

Commit

Permalink
🔀 FIX. 충돌 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
frombunny committed Sep 13, 2024
2 parents 8e34256 + b63641a commit dc7e7ab
Show file tree
Hide file tree
Showing 21 changed files with 758 additions and 3 deletions.
10 changes: 10 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'

<<<<<<< HEAD
=======
// gpt
implementation 'io.github.flashvayne:chatgpt-spring-boot-starter:1.0.5'

>>>>>>> b63641a0ca3b6bfba9938ee558bf8e5a7bf49013
// security
implementation 'org.springframework.boot:spring-boot-starter-security'

Expand All @@ -36,6 +42,10 @@ dependencies {
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'

<<<<<<< HEAD
=======

>>>>>>> b63641a0ca3b6bfba9938ee558bf8e5a7bf49013
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void deleteBreathing() {
}

// 플라스크 서버 엔드포인트
String flaskUrl = "http://localhost:5001/analyze";
String flaskUrl = "http://15.165.141.134:5001/analyze";

// Flask 서버로 POST 요청을 보내서 PEF 값을 받아옴
ResponseEntity<Map> response = restTemplate.postForEntity(flaskUrl, breathingFlaskRequestDto, Map.class);
Expand All @@ -166,7 +166,7 @@ public void deleteBreathing() {
.third(pefValues.get("pef_3"))
.build();

// 최대 수치 서렂ㅇ
// 최대 수치 설정
Double maxPef = Math.max(breathingPefDto.getFirst(),
Math.max(breathingPefDto.getSecond(), breathingPefDto.getThird()));

Expand All @@ -185,6 +185,11 @@ public void deleteBreathing() {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "통신 중 서버 오류가 발생했습니다.");
}

// 응답 본문이 비어 있는 경우 예외 처리
if (response.getBody() == null) {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "서버로부터 올바른 응답을 받지 못했습니다.");
}

return newBreathing;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public CustomAPIResponse<Map<String, Object>> calculateBreathingResult(Breathing
Map<String, Object> responseData = new LinkedHashMap<>();
responseData.put("status", state.getDescription()); // 한국어 설명으로 반환
responseData.put("breathingRate", maxBreathingRate);
responseData.put("rateDifference", rateDifferencePercent + "% " + rateChangeDirection);
responseData.put("variance", rateDifferencePercent + "%"); // 증감률
responseData.put("rateChangeDirection", rateChangeDirection);
responseData.put("first", todayBreathing.getFirst());
responseData.put("second", todayBreathing.getSecond());
responseData.put("third", todayBreathing.getThird());
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/com/hsu/shimpyoo/domain/chatbot/entity/Chat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.hsu.shimpyoo.domain.chatbot.entity;

import com.hsu.shimpyoo.domain.user.entity.User;
import com.hsu.shimpyoo.global.entity.BaseEntity;
import com.hsu.shimpyoo.global.enums.TFStatus;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Table(name="CHAT")
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Chat extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "chat_id")
private Long chatId;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", nullable = false)
private User userId; // 사용자 기본키

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="chatting_room_id", nullable = false)
private ChatRoom chatRoomId; // 채팅방 기본키

@Enumerated(EnumType.STRING)
@Column(name="is_send")
private TFStatus isSend; // 수신 여부 (true -> 받은 메시지, false -> 보낸 메시지)

@Column(name="content", columnDefinition = "TEXT")
private String content; // 메시지의 내용

}
28 changes: 28 additions & 0 deletions src/main/java/com/hsu/shimpyoo/domain/chatbot/entity/ChatRoom.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.hsu.shimpyoo.domain.chatbot.entity;

import com.hsu.shimpyoo.domain.user.entity.User;
import com.hsu.shimpyoo.global.entity.BaseEntity;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Table(name="CHAT_ROOM")
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ChatRoom extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "chat_room_id")
private Long chatRoomId;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", nullable = false)
private User userId; // 사용자 기본키

@Column(name="chat_title")
private String chatTitle; // 채팅방 제목

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.hsu.shimpyoo.domain.chatbot.repository;

import com.hsu.shimpyoo.domain.chatbot.entity.Chat;
import com.hsu.shimpyoo.domain.chatbot.entity.ChatRoom;
import com.hsu.shimpyoo.domain.user.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface ChatRepository extends JpaRepository<Chat, Long> {
// 사용자 기본키와 채팅방 기본키로 검색하여 가장 최근의 메시지 반환
Optional<Chat> findTopByUserIdAndChatRoomIdOrderByCreatedAtDesc(User user, ChatRoom chatRoom);

// 채팅방에서 채팅 상세 조회
List<Chat> findChatByUserIdAndChatRoomId(User user, ChatRoom chatRoom);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.hsu.shimpyoo.domain.chatbot.repository;

import com.hsu.shimpyoo.domain.chatbot.entity.ChatRoom;
import com.hsu.shimpyoo.domain.user.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface ChatRoomRepository extends JpaRepository<ChatRoom, Long> {
// 사용자의 모든 채팅방 조회
List<ChatRoom> findChatRoomByUserId(User user);

// 채팅방 기본키로 채팅방 조회
Optional<ChatRoom> findChatRoomByChatRoomId(Long id);

// 채팅방 제목에 키워드가 포함된 채팅방 조회
List<ChatRoom> findChatRoomByChatTitleContainingAndUserId(String keyword, User user);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.hsu.shimpyoo.domain.chatbot.service;

import com.hsu.shimpyoo.domain.chatbot.web.dto.ModifyChatRoomTitleDto;
import com.hsu.shimpyoo.global.response.CustomAPIResponse;
import org.springframework.http.ResponseEntity;

public interface ChatRoomService {
// 채팅방 생성
ResponseEntity<CustomAPIResponse<?>> makeChatRoom();

// 채팅방 제목 수정
ResponseEntity<CustomAPIResponse<?>> modifyChatRoomTitle(ModifyChatRoomTitleDto requestDto);

// 채팅방 목록 조회
ResponseEntity<CustomAPIResponse<?>> getAllChatRooms();

// 채팅방 대화 내역 조회
ResponseEntity<CustomAPIResponse<?>> getChat(Long chatRoomId);

// 채팅방 제목으로 검색
ResponseEntity<CustomAPIResponse<?>> getChatRoomByKeyword(String keyword);
}
Loading

0 comments on commit dc7e7ab

Please sign in to comment.