Skip to content

Commit 880a58b

Browse files
authored
Merge pull request #13 from CarToi/dev
[feat/consume] 데이터 소비 로직 1차 배포
2 parents 92cb431 + 6d385b9 commit 880a58b

File tree

85 files changed

+593
-243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+593
-243
lines changed

src/jmh/java/org/jun/saemangeum/benchmark/process/ContentCollectServiceBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.jun.saemangeum.benchmark.process;
22

3-
import org.jun.saemangeum.process.application.service.ContentCollectService;
3+
import org.jun.saemangeum.pipeline.application.service.ContentCollectService;
44
import org.openjdk.jmh.annotations.*;
55
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
66
import org.springframework.context.annotation.ComponentScan;

src/jmh/java/org/jun/saemangeum/benchmark/process/MockContentCollectServiceBenchmark.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import org.jun.saemangeum.global.domain.Content;
44
import org.jun.saemangeum.global.repository.ContentRepository;
5-
import org.jun.saemangeum.process.application.collect.base.Refiner;
6-
import org.jun.saemangeum.process.application.service.ContentCollectService;
5+
import org.jun.saemangeum.pipeline.application.collect.base.Refiner;
6+
import org.jun.saemangeum.pipeline.application.service.ContentCollectService;
77
import org.jun.saemangeum.global.service.ContentService;
88
import org.mockito.Mockito;
99
import org.openjdk.jmh.annotations.*;

src/main/java/org/jun/saemangeum/SaemangeumApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.scheduling.annotation.EnableScheduling;
56

7+
@EnableScheduling
68
@SpringBootApplication
79
public class SaemangeumApplication {
810

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.jun.saemangeum.consume.controller;
2+
3+
import lombok.RequiredArgsConstructor;
4+
import org.jun.saemangeum.consume.domain.dto.AverageRequest;
5+
import org.jun.saemangeum.consume.domain.dto.RecommendationResponse;
6+
import org.jun.saemangeum.consume.domain.dto.SurveyCreateRequest;
7+
import org.jun.saemangeum.consume.domain.dto.SurveyUpdateRequest;
8+
import org.jun.saemangeum.consume.service.SurveyRecommendationService;
9+
import org.springframework.web.bind.annotation.*;
10+
11+
import java.util.List;
12+
13+
@RestController
14+
@RequestMapping("/api/survey")
15+
@RequiredArgsConstructor
16+
public class SurveyController {
17+
18+
private final SurveyRecommendationService surveyRecommendationService;
19+
20+
/**
21+
* 사용자 설문 결과 추천 응답 데이터 리스트 반환
22+
*/
23+
@PostMapping("/recommendation")
24+
public List<RecommendationResponse> createSurvey(@RequestBody SurveyCreateRequest request) {
25+
return surveyRecommendationService.createRecommendationsBySurvey(request);
26+
}
27+
28+
/**
29+
* 사용자 설문 결과 만족도 반영 요청
30+
*/
31+
@PatchMapping("/update")
32+
public void updateSurvey(@RequestBody SurveyUpdateRequest request) {
33+
surveyRecommendationService.updateSurvey(request);
34+
}
35+
36+
/**
37+
* 평균 사용자 설문 응답 확인 응답 데이터 리스트 반환
38+
*/
39+
@GetMapping("/average")
40+
public List<RecommendationResponse> readAverageSurvey(@RequestBody AverageRequest request) {
41+
return surveyRecommendationService.calculateAverageSurvey(request);
42+
}
43+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package org.jun.saemangeum.consume.domain.dto;
2+
3+
public record AverageRequest(
4+
int age, // 연령대
5+
String gender, // 성별
6+
String city, // 거주의향 지역
7+
String want, // 여유 선호
8+
String mood // 분위기 선호
9+
) {
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.jun.saemangeum.consume.domain.dto;
2+
3+
import org.jun.saemangeum.global.domain.Category;
4+
5+
public record RecommendationResponse(
6+
String title, // 추천 컨텐츠명
7+
String position, // 위치 (주소 혹은 추상적인 지리적 위치)
8+
Category category, // 컨텐츠 분류 (FESTIVAL, EVENT, TOUR, CULTURE)
9+
String image, // 이미지 소스 url (null 가능성 존재)
10+
String url // 컨텐츠 데이터 출처
11+
) {
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.jun.saemangeum.consume.domain.dto;
2+
3+
public record SurveyCreateRequest(
4+
String clientId, // UUID 문자열 처리
5+
int age, // 연령대
6+
String gender, // 성별
7+
String resident, // 실거주지
8+
String city, // 거주의향 지역
9+
String want, // 여유 선호
10+
String mood // 분위기 선호
11+
) {
12+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.jun.saemangeum.consume.domain.dto;
2+
3+
import java.util.List;
4+
5+
public record SurveyUpdateRequest(
6+
String clientId,
7+
List<Integer> satisfactions
8+
) {
9+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.jun.saemangeum.consume.domain.entity;
2+
3+
import jakarta.persistence.*;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Builder;
6+
import lombok.Getter;
7+
import lombok.NoArgsConstructor;
8+
import org.jun.saemangeum.global.domain.Content;
9+
10+
@Entity
11+
@Builder
12+
@Table(name = "recommendation_logs")
13+
@Getter
14+
@NoArgsConstructor
15+
@AllArgsConstructor
16+
public class RecommendationLog {
17+
@Id
18+
@GeneratedValue(strategy = GenerationType.IDENTITY)
19+
private Long id;
20+
21+
@Column(name = "content_id")
22+
private Long contentId;
23+
24+
@Column(name = "survey_id")
25+
private Long surveyId;
26+
27+
public RecommendationLog(Content content, Survey survey) {
28+
this.contentId = content.getId();
29+
this.surveyId = survey.getId();
30+
}
31+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package org.jun.saemangeum.consume.domain.entity;
2+
3+
import jakarta.persistence.*;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Builder;
6+
import lombok.Getter;
7+
import lombok.NoArgsConstructor;
8+
import org.jun.saemangeum.consume.domain.dto.SurveyCreateRequest;
9+
10+
// 엔티티 필드를 어떻게 잡아야 평균값 산출이 쉬우려나...
11+
@Entity
12+
@Builder
13+
@Table(name = "surveys")
14+
@Getter
15+
@NoArgsConstructor
16+
@AllArgsConstructor
17+
public class Survey {
18+
@Id
19+
@GeneratedValue(strategy = GenerationType.IDENTITY)
20+
private Long id;
21+
22+
@Column(name = "client_id")
23+
private String clientId; // UUID 클라이언트 id
24+
25+
// 설문 응답
26+
private int age; // 연령대
27+
private String gender; // 성별
28+
private String resident; // 실거주지
29+
private String city; // 거주의향 지역
30+
private String want; // 여유 선호
31+
private String mood; // 분위기 선호
32+
33+
// 후속 평가
34+
private int help; // 도움 정도(1, 2, 3, 4, 5)
35+
private int preference; // 선호도 정도(1, 2, 3, 4, 5)
36+
private int intention; // 의향 변화 정도(1, 2, 3, 4, 5)
37+
38+
public static Survey create(SurveyCreateRequest request) {
39+
return Survey.builder()
40+
.clientId(request.clientId())
41+
.age(request.age())
42+
.gender(request.gender())
43+
.resident(request.resident())
44+
.city(request.city())
45+
.want(request.want())
46+
.mood(request.mood())
47+
.help(3) // 기본값 3
48+
.preference(3)
49+
.intention(3)
50+
.build();
51+
}
52+
53+
public void updateEvaluation(int help, int preference, int intention) {
54+
this.help = help;
55+
this.preference = preference;
56+
this.intention = intention;
57+
}
58+
}

0 commit comments

Comments
 (0)