Skip to content

Commit

Permalink
feat: 카테고리 랜덤 추천기능, enhance 예정(#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
acceptor-gyu committed Jun 14, 2023
1 parent 311a97f commit 55cb32e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.secondhand.category.dto.CategoriesDto;
import com.secondhand.category.dto.CategoryInterestsDto;
import com.secondhand.category.dto.PostTitleDto;
import com.secondhand.category.dto.RecommendedCategoriesDto;
import com.secondhand.post.repository.InterestRepository;
import com.secondhand.util.CustomResponse;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -46,17 +45,15 @@ public ResponseEntity<CustomResponse<CategoryInterestsDto>> getInterestCategoryL
}

@GetMapping("/recommend")
public ResponseEntity<CustomResponse<RecommendedCategoriesDto>> findRecommendedCategories(@RequestBody PostTitleDto postTitleDto) {


public ResponseEntity<CustomResponse<CategoriesDto>> findRecommendedCategories(@RequestBody PostTitleDto postTitleDto) {

return ResponseEntity
.ok()
.body(new CustomResponse<>(
"success",
200,
"관심 카테고리 목록 조회 성공",
null)
);
categoryService.getRecommendedCategories(postTitleDto.getTitle())
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public CategoriesDto getCategoryList() {
return categoryRepository.findAllCategories();
}

public CategoriesDto getRecommendedCategories() {
public CategoriesDto getRecommendedCategories(String postTitle) {

return recommendCategories(categoryRepository.findAllCategories().getCategories());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@

import lombok.Getter;

import java.util.List;

@Getter
public class RecommendedCategoriesDto {

private int id;
private String name;

public RecommendedCategoriesDto(int id, String name) {
this.id = id;
this.name = name;
}
private List<RecommendedCategoryDto> categories;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.secondhand.category.dto;

import com.querydsl.core.annotations.QueryProjection;

public class RecommendedCategoryDto {

private int id;
private String name;

@QueryProjection
public RecommendedCategoryDto(CategoryDto categoryDto) {
this.id = categoryDto.getId();
this.name = categoryDto.getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
public interface CategoryRepositoryCustom {

CategoriesDto findAllCategories();

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.querydsl.jpa.impl.JPAQueryFactory;
import com.secondhand.category.dto.CategoriesDto;
import com.secondhand.category.dto.QCategoryDto;
import com.secondhand.post.repository.CategoryRepositoryCustom;
import com.secondhand.category.dto.RecommendedCategoriesDto;

import javax.persistence.EntityManager;

Expand All @@ -29,4 +29,5 @@ public CategoriesDto findAllCategories() {
.from(category)
.fetch());
}

}

0 comments on commit 55cb32e

Please sign in to comment.