Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.going.server.domain.history.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/history")
@RequiredArgsConstructor
public class HistoryController {
}
33 changes: 33 additions & 0 deletions src/main/java/com/going/server/domain/history/entity/History.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.going.server.domain.history.entity;

import com.going.server.domain.word.entity.Word;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name="history")
public class History {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="history_id")
private Long historyId;

@Column(name="`before`")
private String before;

@Column(name="after")
private String after;

@ManyToOne
@JoinColumn(name="word_id")
private Word word;

public static History toEntity(String before, String after, Word word){
return History.builder().before(before).after(after).word(word).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.going.server.domain.history.repository;

import com.going.server.domain.history.entity.History;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface HistoryRepository extends JpaRepository<History, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.going.server.domain.history.service;

public interface HistoryService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.going.server.domain.history.service;

import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor
public class HistoryServiceImpl {
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import com.going.server.domain.cluster.entity.Cluster;
import com.going.server.domain.cluster.repository.ClusterRepository;
import com.going.server.domain.history.entity.History;
import com.going.server.domain.history.repository.HistoryRepository;
import com.going.server.domain.history.service.HistoryServiceImpl;
import com.going.server.domain.word.dto.AddRequestDto;
import com.going.server.domain.word.dto.ModifyRequestDto;
import com.going.server.domain.word.dto.WordDto;
Expand All @@ -22,6 +25,7 @@
public class WordServiceImpl implements WordService {
private final WordRepository wordRepository;
private final ClusterRepository clusterRepository;
private final HistoryRepository historyRepository;

@Override
public WordResponseDto getWordList(Long clusterId) {
Expand All @@ -42,13 +46,22 @@ public WordResponseDto getWordList(Long clusterId) {
@Override
public void deleteWord(Long wordId) {
Word word = wordRepository.getByWord(wordId);
//변경사항 저장
History history = History.toEntity(word.getComposeWord(),"",word);
// historyRepository.save(history);
wordRepository.delete(word);
}

@Transactional
@Override
public void modifyWord(Long wordId, ModifyRequestDto dto) {
Word findWord = wordRepository.getByWord(wordId);
String modifiedWord = dto.getWord();

//변경사항 저장
History history = History.toEntity(findWord.getComposeWord(),modifiedWord,findWord);
historyRepository.save(history);

findWord.setComposeWord(dto.getWord());
wordRepository.save(findWord);
}
Expand All @@ -58,6 +71,9 @@ public void addWord(AddRequestDto dto) {
String word = dto.getWord();
Cluster cluster = clusterRepository.getByCluster(dto.getClusterId());
Word newWord = Word.toEntity(word,cluster);
//변경사항 저장
History history = History.toEntity("",word,newWord);
wordRepository.save(newWord);
historyRepository.save(history);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import com.going.server.domain.sentence.repository.SentenceRepository;
import com.going.server.domain.word.entity.Word;
import com.going.server.domain.word.repository.WordRepository;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.reactive.function.client.WebClient;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -46,6 +48,7 @@ public String callFastApi() {
/**
* FastAPI에서 클러스터링 결과 가져와 DB에 저장 (POST 요청)
*/
@PostConstruct
public void setCluster() {
// FastAPI 요청 데이터 (필요시 변경)
Map<String, Object> requestData = Map.of("input_text", "클러스터링할 데이터 예제");
Expand Down
Loading