Skip to content

Commit 3b90362

Browse files
authored
Merge pull request #8 from ktb3-team4/feature/clay/db
feat: chatStyle, Relationship 조회 api 생성
2 parents ac80253 + ea0fca6 commit 3b90362

8 files changed

Lines changed: 172 additions & 10 deletions

File tree

src/main/java/com/example/team4backend/common/runner/ChatStyleDataRunner.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@ public void run(String... args) {
2525

2626
List<ChatStyle> styles = Arrays.asList(
2727
new ChatStyle("편한 반말", "일상적이고 거리감 없는 말투"),
28-
new ChatStyle("기본 존댓말", "무난하고 예의 중심의 말투"),
29-
new ChatStyle("부드러운 존댓말", "말끝을 완화해 정중함을 강조한 말투"),
28+
new ChatStyle("존댓말", "무난하고 예의 중심의 말투"),
3029
new ChatStyle("애교 섞인 말투", "감정 표현이 많고 친근함을 강조"),
31-
new ChatStyle("차분한 설명형 말투", "또박또박 설명하듯 말하는 스타일"),
32-
new ChatStyle("걱정·배려 중심 말투", "상대 상태를 먼저 살피는 말투"),
33-
new ChatStyle("보고·전달형 말투", "사실 위주로 간단히 전달하는 스타일"),
34-
new ChatStyle("감사·존중 강조 말투", "고마움과 존중 표현이 자주 들어가는 말투"),
35-
new ChatStyle("농담 섞인 편안한 말투", "가벼운 웃음 포인트가 있는 스타일"),
36-
new ChatStyle("조심스러운 요청형 말투", "부탁이나 제안을 할 때 사용하는 말투")
30+
new ChatStyle("걱정·배려 중심 말투", "상대 상태를 먼저 살피는 말투")
31+
// new ChatStyle("농담 섞인 편안한 말투", "가벼운 웃음 포인트가 있는 스타일"),
32+
// new ChatStyle("부드러운 존댓말", "말끝을 완화해 정중함을 강조한 말투"),
33+
// new ChatStyle("차분한 설명형 말투", "또박또박 설명하듯 말하는 스타일"),
34+
// new ChatStyle("농담 섞인 편안한 말투", "가벼운 웃음 포인트가 있는 스타일"),
35+
// new ChatStyle("부드러운 존댓말", "말끝을 완화해 정중함을 강조한 말투"),
36+
// new ChatStyle("차분한 설명형 말투", "또박또박 설명하듯 말하는 스타일"),
37+
// new ChatStyle("보고·전달형 말투", "사실 위주로 간단히 전달하는 스타일"),
38+
// new ChatStyle("감사·존중 강조 말투", "고마움과 존중 표현이 자주 들어가는 말투"),
39+
// new ChatStyle("조심스러운 요청형 말투", "부탁이나 제안을 할 때 사용하는 말투")
3740
);
3841

3942
chatStyleRepository.saveAll(styles);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.example.team4backend.controller;
2+
3+
import com.example.team4backend.common.response.ApiResult;
4+
import com.example.team4backend.dto.ChatStyleResponse;
5+
import com.example.team4backend.service.ChatStyleService;
6+
import io.swagger.v3.oas.annotations.Operation;
7+
import io.swagger.v3.oas.annotations.tags.Tag;
8+
import lombok.RequiredArgsConstructor;
9+
import org.springframework.http.ResponseEntity;
10+
import org.springframework.web.bind.annotation.GetMapping;
11+
import org.springframework.web.bind.annotation.RequestMapping;
12+
import org.springframework.web.bind.annotation.RestController;
13+
14+
import java.util.List;
15+
16+
@Tag(name = "ChatStyle", description = "채팅 스타일 관리 API")
17+
@RestController
18+
@RequestMapping("/chat-styles")
19+
@RequiredArgsConstructor
20+
public class ChatStyleController {
21+
22+
private final ChatStyleService chatStyleService;
23+
24+
@Operation(summary = "채팅 스타일 목록 조회", description = "시스템에 등록된 모든 채팅 스타일을 조회합니다.")
25+
@GetMapping
26+
public ResponseEntity<ApiResult<List<ChatStyleResponse>>> getAllChatStyles() {
27+
List<ChatStyleResponse> chatStyles = chatStyleService.getAllChatStyles();
28+
return ResponseEntity.ok(ApiResult.ok(chatStyles));
29+
}
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.example.team4backend.controller;
2+
3+
import com.example.team4backend.common.response.ApiResult;
4+
import com.example.team4backend.dto.RelationshipResponse;
5+
import com.example.team4backend.service.RelationshipService;
6+
import io.swagger.v3.oas.annotations.Operation;
7+
import io.swagger.v3.oas.annotations.tags.Tag;
8+
import lombok.RequiredArgsConstructor;
9+
import org.springframework.http.ResponseEntity;
10+
import org.springframework.web.bind.annotation.GetMapping;
11+
import org.springframework.web.bind.annotation.RequestMapping;
12+
import org.springframework.web.bind.annotation.RestController;
13+
14+
import java.util.List;
15+
16+
@Tag(name = "Relationship", description = "관계 관리 API")
17+
@RestController
18+
@RequestMapping("/relationships")
19+
@RequiredArgsConstructor
20+
public class RelationshipController {
21+
22+
private final RelationshipService relationshipService;
23+
24+
@Operation(summary = "관계 목록 조회", description = "시스템에 등록된 모든 관계 유형을 조회합니다.")
25+
@GetMapping
26+
public ResponseEntity<ApiResult<List<RelationshipResponse>>> getAllRelationships() {
27+
List<RelationshipResponse> relationships = relationshipService.getAllRelationships();
28+
return ResponseEntity.ok(ApiResult.ok(relationships));
29+
}
30+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.example.team4backend.dto;
2+
3+
import com.example.team4backend.domain.ChatStyle;
4+
import io.swagger.v3.oas.annotations.media.Schema;
5+
6+
@Schema(description = "채팅 스타일 정보 응답")
7+
public record ChatStyleResponse(
8+
@Schema(description = "채팅 스타일 ID", example = "1")
9+
Long id,
10+
11+
@Schema(description = "스타일 이름", example = "편한 반말")
12+
String styleName,
13+
14+
@Schema(description = "스타일 설명", example = "친근하고 편안한 반말 스타일")
15+
String description
16+
) {
17+
public static ChatStyleResponse from(ChatStyle chatStyle) {
18+
return new ChatStyleResponse(
19+
chatStyle.getId(),
20+
chatStyle.getStyleName(),
21+
chatStyle.getDescription()
22+
);
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.example.team4backend.dto;
2+
3+
import com.example.team4backend.domain.Relationship;
4+
import io.swagger.v3.oas.annotations.media.Schema;
5+
6+
@Schema(description = "관계 정보 응답")
7+
public record RelationshipResponse(
8+
@Schema(description = "관계 ID", example = "1")
9+
Long id,
10+
11+
@Schema(description = "관계 코드", example = "FRIEND")
12+
String code,
13+
14+
@Schema(description = "관계 설명", example = "친구")
15+
String description
16+
) {
17+
public static RelationshipResponse from(Relationship relationship) {
18+
return new RelationshipResponse(
19+
relationship.getId(),
20+
relationship.getCode(),
21+
relationship.getDescription()
22+
);
23+
}
24+
}

src/main/java/com/example/team4backend/security/SecurityPaths.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ private SecurityPaths() {}
99
"/auth/login",
1010
"/auth/kakao/login",
1111
"/auth/refresh",
12-
"/prompts"
12+
"/prompts",
13+
"/relationships",
14+
"/chat-styles"
1315
};
1416

1517
public static final String[] CSRF_IGNORED = {
@@ -23,7 +25,8 @@ private SecurityPaths() {}
2325
"/swagger-ui.html",
2426
"/prompts",
2527
"/users",
26-
"/targets"
28+
"/targets",
29+
"/relationships"
2730
};
2831

2932
public static final String[] PUBLIC_DOCS = {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.example.team4backend.service;
2+
3+
import com.example.team4backend.dto.ChatStyleResponse;
4+
import com.example.team4backend.repository.ChatStyleRepository;
5+
import lombok.RequiredArgsConstructor;
6+
import org.springframework.stereotype.Service;
7+
import org.springframework.transaction.annotation.Transactional;
8+
9+
import java.util.List;
10+
11+
@Service
12+
@RequiredArgsConstructor
13+
public class ChatStyleService {
14+
15+
private final ChatStyleRepository chatStyleRepository;
16+
17+
@Transactional(readOnly = true)
18+
public List<ChatStyleResponse> getAllChatStyles() {
19+
return chatStyleRepository.findAll()
20+
.stream()
21+
.map(ChatStyleResponse::from)
22+
.toList();
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.example.team4backend.service;
2+
3+
import com.example.team4backend.dto.RelationshipResponse;
4+
import com.example.team4backend.repository.RelationshipRepository;
5+
import lombok.RequiredArgsConstructor;
6+
import org.springframework.stereotype.Service;
7+
import org.springframework.transaction.annotation.Transactional;
8+
9+
import java.util.List;
10+
11+
@Service
12+
@RequiredArgsConstructor
13+
public class RelationshipService {
14+
15+
private final RelationshipRepository relationshipRepository;
16+
17+
@Transactional(readOnly = true)
18+
public List<RelationshipResponse> getAllRelationships() {
19+
return relationshipRepository.findAll()
20+
.stream()
21+
.map(RelationshipResponse::from)
22+
.toList();
23+
}
24+
}

0 commit comments

Comments
 (0)