Conversation
commaengddongyeon
commented
Mar 16, 2026
- 리뷰 반영
- 하드코딩 내역 diaryId를 기반으로 감정분석 진행하게끔 변경.
dldb-chamchi
left a comment
There was a problem hiding this comment.
수고하셨슴당~~~~!!!! 지금 자려고 막 누운상태였어서... 내일 더 남길게요. 해당 PR은 모든 AI(OpenAI + whisper)까지 완성된 후 merge 해야할거 같아요.
사유 - 지금 merge하면 API 만들 때마다 다른 부가적인 설정이 너무 많아져서 검증이 힘들어짐
|
|
||
| return ResponseEntity.ok(request.diaryId() + "번 일기에 대한 감정 분석이 시작되었습니다."); | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
EOF 설정 intellij에 있으니 찾아보고 적용해주세용
| package com.memoryshade.domain.emotion.dto; | ||
|
|
||
| public record EmotionRequest( | ||
| Long diaryId // 분석 대상 일기 ID |
There was a problem hiding this comment.
제가 작성한 다른 DTO 보고 JsonProperty 설정 해주세요. 이렇게 camelCase면 모바일이 불편해용
| @@ -0,0 +1,5 @@ | |||
| package com.memoryshade.domain.emotion.dto; | |||
|
|
|||
| public record EmotionRequest( | |||
There was a problem hiding this comment.
뒤에 DTO
그건 차치해도, diaryId를 왜 dto로 받나요??
There was a problem hiding this comment.
api 명세서에 별도로 pathvariable 형태로 정의되어 있지 않아서 그렇게 진행했습니당
아니면 컨트롤러를 /api/emotions/analyze/{diaryId} 요런식으로 바꾸는 방향이 더 낫다고 보나요??
There was a problem hiding this comment.
넹 처음 명세서에 작성된 엔드포인트는 diary기준으로 할줄 모르고 초반에 작성해서 좀 차이가 있을 수 있습니다.
dto에 id를 전달하는 것은 dto 자체에 정의에 어긋난다 생각합니당
There was a problem hiding this comment.
- API 엔드포인트는 리소스와 리소스에 대해 수행하는 액션 순이기 때문에
/api/emotions/{diaryId}/analyze 이렇게 가는게 맞다고 생각합니다
| * @param emotions 전체 6가지 감정별 점수 리스트 | ||
| */ | ||
| public record EmotionResponse( | ||
| String top_emotion, |
There was a problem hiding this comment.
백엔드 코드는 camel but 모바일을 위해 snake case 적용(jsonProperty 찾아보시면 좋을거 같아요)
| @Column(name = "anger_score") | ||
| private Integer angerScore; | ||
|
|
||
| @Column(name = "anxiety_score") // 추가 |
There was a problem hiding this comment.
해당 컬럼 DB 다이어그램 V2 페이지에 반영됐나용? 혹시 까먹으셨다면 지금! 🙇
There was a problem hiding this comment.
반영했습니다!! ✅
| .sessionManagement(s -> s.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) | ||
| .authorizeHttpRequests(auth -> auth | ||
| .requestMatchers("/api/auth/**").permitAll() | ||
| .requestMatchers("/api/emotions/**").permitAll() // 임시 허용 |
There was a problem hiding this comment.
임시 허용 굳이 이유 있나요? 혹시 잘 안되나요?
There was a problem hiding this comment.
회원가입 - 로그인 - authen token 넣었는데도 저거 안 넣어주면 403 에러가 뜨더라고요,..
| } | ||
|
|
||
| /** | ||
| * Object 타입 -> Integer로 변환. |
There was a problem hiding this comment.
ai_server.py에서는 double 형태로 결과값이 넘어와서 넣었어요. 개발 많이 완료됐을 때 refactor 과정에서 손보도록 하겠습니다
There was a problem hiding this comment.
아하 그럼 double -> integr변환인가여
| * AI 서버에 분석을 요청하고 결과를 저장 | ||
| */ | ||
| @Transactional | ||
| public void analyzeAndSave(Diary diary, String text) { |
There was a problem hiding this comment.
작성된 다른 코드 보고 컨벤션 맞춰주세요. create, update, get, delete
There was a problem hiding this comment.
지금 Diary 전문 자체를 받는데 이것도 따로 Dto를 만들어야할거 같네요. 그리고 text는 무엇인가요?
|
|
||
| Map<String, ?> scores = res.emotions(); | ||
|
|
||
| EmotionAnalysis analysis = EmotionAnalysis.builder() |
There was a problem hiding this comment.
response에서 메소드 만들고 builder 안쓸수 있습니다. 그리고 지금 하드코딩 되어있는 감정표현들은 열거형으로 따로 만들어서 관리해주세용
| public record EmotionResponse( | ||
| String top_emotion, | ||
| Double confidence, | ||
| Map<String, Double> emotions |
There was a problem hiding this comment.
근데 지금 이거 구조체를 넘기는건가요...? 뭔지 설명해주실수 있나요 잘 이해를 못함... 👀
There was a problem hiding this comment.
네네 AI 모델이 확신도 점수를 담은 맵이에요, 모바일에서 각 감정별 수치를 보여주기 위해 키-값 형태 구조체로 설계했어요
There was a problem hiding this comment.
아하 굿굿~ 근데 감정은 열거형으로 정의하는게 더 좋을거 같아용
|
|
||
| void delete(EmotionAnalysis emotionAnalysis); | ||
|
|
||
| void flush(); |
There was a problem hiding this comment.
수정 과정에서 남은 코드인데 삭제하겠습니당
There was a problem hiding this comment.
밑에 있는거 같던데 그러면 안쓰는 코드인가요??
| public interface EmotionAnalysisRepository extends Repository<EmotionAnalysis, Long> { | ||
| EmotionAnalysis save(EmotionAnalysis emotionAnalysis); | ||
|
|
||
| Optional<EmotionAnalysis> findByDiary(Diary diary); |
There was a problem hiding this comment.
Diary를 통해 찾는건가요? 속성관련해서 찾는게 아닌? 어떤 메소드인가요?
| * AI 서버에 분석을 요청하고 결과를 저장 | ||
| */ | ||
| @Transactional | ||
| public void analyzeAndSave(Diary diary, String text) { |
There was a problem hiding this comment.
지금 Diary 전문 자체를 받는데 이것도 따로 Dto를 만들어야할거 같네요. 그리고 text는 무엇인가요?
| emotionAnalysisRepository.flush(); // 즉시 반영하여 중복 제약 조건 충돌 방지 | ||
| }); | ||
|
|
||
| Map<String, ?> scores = res.emotions(); |
There was a problem hiding this comment.
근데 이거 왜 와일드카드 쓰나요? double아닌가요
| EmotionResponse response = restTemplate.postForObject( | ||
| aiServerUrl, | ||
| Map.of("text", text), | ||
| EmotionResponse.class | ||
| ); |
There was a problem hiding this comment.
동작 자체가 이해가 안가는게 많아서... 이따 설명해주시면 감사하겠습니다
| public record EmotionResponse( | ||
| String top_emotion, | ||
| Double confidence, | ||
| Map<String, Double> emotions |
There was a problem hiding this comment.
아하 굿굿~ 근데 감정은 열거형으로 정의하는게 더 좋을거 같아용
|
|
||
| void delete(EmotionAnalysis emotionAnalysis); | ||
|
|
||
| void flush(); |
There was a problem hiding this comment.
밑에 있는거 같던데 그러면 안쓰는 코드인가요??