Skip to content

Commit

Permalink
Fix: 온보딩 API 구현
Browse files Browse the repository at this point in the history
관심사 interestCode로 저장안되는 현상 수정

Resolves: #17
  • Loading branch information
haeyonghahn committed Aug 23, 2023
1 parent 3bc748e commit 4e69f78
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public class FeedController {
@GetMapping(value = "/{userId}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Page<FeedResponse>> feed(
@PathVariable Long userId,
@RequestParam(name = "interests") List<String> interests,
@RequestParam(name = "interestCodes") List<String> interestCodes,
@Parameter(hidden = true) Pageable pageable) {
return ResponseEntity
.ok()
.body(feedService.findByRecordIsNotUserId(userId, pageable));
.body(feedService.findByRecordByInterestCodeAndIsNotUserId(userId, interestCodes, pageable));
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.dnd.gooding.domain.feed.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import com.dnd.gooding.domain.record.model.Record;

public interface FeedRepositoryCustom {

Page<Record> findByRecordIsNotUserId(Long userId, Pageable pageable);
Page<Record> findByRecordByInterestCodeAndIsNotUserId(Long userId, List<String> interestCodes, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import static com.dnd.gooding.domain.record.model.QRecord.*;
import static com.dnd.gooding.domain.user.model.QUser.*;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

Expand All @@ -19,7 +21,7 @@ public FeedRepositoryImpl() {
}

@Override
public Page<Record> findByRecordIsNotUserId(Long userId, Pageable pageable) {
public Page<Record> findByRecordByInterestCodeAndIsNotUserId(Long userId, List<String> interestCodes, Pageable pageable) {
return applyPagination(pageable, contentQuery -> contentQuery
.select(record).distinct()
.from(record)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.dnd.gooding.domain.feed.service;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import com.dnd.gooding.domain.feed.dto.response.FeedResponse;

public interface FeedService {

Page<FeedResponse> findByRecordIsNotUserId(Long userId, Pageable pageable);
Page<FeedResponse> findByRecordByInterestCodeAndIsNotUserId(Long userId, List<String> interestCodes, Pageable pageable);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dnd.gooding.domain.feed.service;

import java.util.List;
import java.util.stream.Collectors;

import org.springframework.data.domain.Page;
Expand All @@ -22,9 +23,9 @@ public class FeedServiceImpl implements FeedService {
private final FeedRepository feedRepository;

@Override
public Page<FeedResponse> findByRecordIsNotUserId(Long userId, Pageable pageable) {
Page<Record> records = feedRepository.findByRecordIsNotUserId(userId, pageable);
return new PageImpl<FeedResponse>(records.stream()
public Page<FeedResponse> findByRecordByInterestCodeAndIsNotUserId(Long userId, List<String> interestCodes, Pageable pageable) {
Page<Record> records = feedRepository.findByRecordByInterestCodeAndIsNotUserId(userId, interestCodes, pageable);
return new PageImpl<>(records.stream()
.map(FeedResponse::new)
.collect(Collectors.toList()),
pageable, records.getTotalElements());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class Onboarding extends BaseEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Enumerated
@Column(name = "interest_type")
@Convert(converter = InterestConverter.class)
private InterestType interestType;
Expand Down

0 comments on commit 4e69f78

Please sign in to comment.