feat:增加查询用户菜谱接口
This commit is contained in:
@@ -39,10 +39,16 @@ public class FoodController {
|
||||
return foodService.deleteRecipe(id);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询用户美食菜谱")
|
||||
@GetMapping("/recipe/user/{id}")
|
||||
public List<SummaryDto> queryRecipeByUser(@PathVariable("id") long id) {
|
||||
return foodService.queryRecipeByUser(id);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询美食菜谱")
|
||||
@GetMapping("/recipe")
|
||||
public List<SummaryDto> querySummary(FoodQueryVo foodQueryVo) {
|
||||
return foodService.querySummary(foodQueryVo);
|
||||
public List<SummaryDto> queryRecipeSummary(FoodQueryVo foodQueryVo) {
|
||||
return foodService.queryRecipeSummary(foodQueryVo);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询美食菜谱")
|
||||
@@ -53,10 +59,10 @@ public class FoodController {
|
||||
return foodService.querySummaryByPage(currentPage, pageSize, foodQueryVo);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询美食")
|
||||
@Operation(summary = "根据id查询美食")
|
||||
@GetMapping("/recipe/{id}")
|
||||
public @JsonView(ReadView.class) RecipeDto queryRecipe(@PathVariable("id") long id) {
|
||||
return foodService.queryRecipe(id);
|
||||
public @JsonView(ReadView.class) RecipeDto queryRecipeById(@PathVariable("id") long id) {
|
||||
return foodService.queryRecipeById(id);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询所有美食名称")
|
||||
|
||||
@@ -12,10 +12,12 @@ import java.util.List;
|
||||
public interface FoodDao {
|
||||
RecipeDto queryRecipe(@Param("id") Long id);
|
||||
|
||||
List<SummaryDto> queryRecipeByUser(@Param("id") Long id);
|
||||
|
||||
IPage<SummaryDto> querySummaryByPage(IPage<SummaryDto> page,
|
||||
@Param("query") FoodQueryVo foodQueryVo);
|
||||
|
||||
List<SummaryDto> querySummary(@Param("query") FoodQueryVo foodQueryVo,
|
||||
List<SummaryDto> queryRecipeSummary(@Param("query") FoodQueryVo foodQueryVo,
|
||||
@Param("user") String user);
|
||||
|
||||
List<RecordDto> queryRecordById(@Param("id") Long id);
|
||||
|
||||
@@ -26,9 +26,11 @@ public interface FoodService {
|
||||
|
||||
Boolean deleteLike(Long recipeId);
|
||||
|
||||
RecipeDto queryRecipe(Long id);
|
||||
RecipeDto queryRecipeById(Long id);
|
||||
|
||||
List<SummaryDto> querySummary(FoodQueryVo foodQueryVo);
|
||||
List<SummaryDto> queryRecipeByUser(Long id);
|
||||
|
||||
List<SummaryDto> queryRecipeSummary(FoodQueryVo foodQueryVo);
|
||||
|
||||
IPage<SummaryDto> querySummaryByPage(Integer currentPage, Integer pageSize, FoodQueryVo foodQueryVo);
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ public class FoodServiceImpl implements FoodService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeDto queryRecipe(Long id) {
|
||||
public RecipeDto queryRecipeById(Long id) {
|
||||
if (recipeMapper.selectById(id) == null) {
|
||||
throw new CustomException("该美食不存在");
|
||||
}
|
||||
@@ -204,8 +204,13 @@ public class FoodServiceImpl implements FoodService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SummaryDto> querySummary(FoodQueryVo foodQueryVo) {
|
||||
return foodDao.querySummary(foodQueryVo, StpUtil.getLoginIdAsString());
|
||||
public List<SummaryDto> queryRecipeByUser(Long id) {
|
||||
return foodDao.queryRecipeByUser(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SummaryDto> queryRecipeSummary(FoodQueryVo foodQueryVo) {
|
||||
return foodDao.queryRecipeSummary(foodQueryVo, StpUtil.getLoginIdAsString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -143,6 +143,30 @@
|
||||
WHERE a.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="queryRecipeByUser" resultMap="foodSummaryResultMap">
|
||||
SELECT a.id AS id,
|
||||
a.name AS name,
|
||||
a.category AS category,
|
||||
a.recommend_rate AS recommendRate,
|
||||
b.person AS person,
|
||||
b.date AS date,
|
||||
b.image_url AS imageUrl,
|
||||
COALESCE(c.like_count, 0) AS likeCount,
|
||||
COALESCE(d.comment_count, 0) AS commentCount
|
||||
FROM recipe a
|
||||
LEFT JOIN record b ON a.id = b.food_id
|
||||
LEFT JOIN (SELECT subject_id, COUNT(id) AS like_count
|
||||
FROM like_record
|
||||
WHERE type = 'recipe'
|
||||
GROUP BY subject_id) c ON a.id = c.subject_id
|
||||
LEFT JOIN (SELECT subject_id, COUNT(id) AS comment_count
|
||||
FROM comment_record
|
||||
WHERE type = 'recipe'
|
||||
GROUP BY subject_id) d ON a.id = d.subject_id
|
||||
WHERE a.create_by = #{id}
|
||||
ORDER BY a.update_time DESC
|
||||
</select>
|
||||
|
||||
<select id="querySummaryByPage" resultMap="foodSummaryResultMap">
|
||||
SELECT a.id AS id,
|
||||
a.name AS name,
|
||||
@@ -156,7 +180,7 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="querySummary" resultMap="foodSummaryResultMap">
|
||||
<select id="queryRecipeSummary" resultMap="foodSummaryResultMap">
|
||||
SELECT a.id AS id,
|
||||
a.name AS name,
|
||||
a.category AS category,
|
||||
|
||||
Reference in New Issue
Block a user