feat:更新菜谱mysql语句

This commit is contained in:
2025-07-16 20:00:37 +08:00
parent 2c3fa19cbb
commit dcc3ca38a7
3 changed files with 17 additions and 10 deletions

View File

@@ -10,7 +10,7 @@ import java.util.List;
@Mapper
public interface FoodDao {
RecipeDto queryRecipe(@Param("id") Long id);
RecipeDto queryRecipeById(@Param("id") Long id);
List<SummaryDto> queryRecipeByUser(@Param("id") Long id);

View File

@@ -220,7 +220,7 @@ public class FoodServiceImpl implements FoodService {
throw new CustomException("该美食不存在");
}
return foodDao.queryRecipe(id);
return foodDao.queryRecipeById(id);
}
@Override

View File

@@ -47,7 +47,7 @@
<resultMap id="foodRecordResultMap" type="com.cxx.food.dto.RecordDto">
<id property="id" column="id"/>
<result property="name" column="person"/>
<result property="name" column="name"/>
<result property="category" column="category"/>
<result property="person" column="person"/>
<result property="date" column="date"/>
@@ -67,7 +67,9 @@
<result property="favouriteCount" column="favouriteCount"/>
<result property="commentCount" column="commentCount"/>
<collection property="recordList" ofType="com.cxx.food.dto.RecordDto">
<id property="id" column="workId"/>
<id property="id" column="recordId"/>
<result property="name" column="name"/>
<result property="category" column="category"/>
<result property="person" column="person"/>
<result property="date" column="date"/>
<result property="imageUrl" column="imageUrl"/>
@@ -128,11 +130,14 @@
</select>
<select id="queryRecordById" resultMap="foodRecordResultMap">
SELECT id AS id,
person AS person,
date AS date,
image_url AS imageUrl
FROM record
SELECT a.id AS id,
b.name AS name,
b.category AS category,
a.person AS person,
a.date AS date,
a.image_url AS imageUrl
FROM record AS a
LEFT JOIN recipe AS b ON a.food_id = b.id
WHERE food_id = #{id}
ORDER BY date DESC
</select>
@@ -152,7 +157,7 @@
ORDER BY date DESC
</select>
<select id="queryRecipe" resultMap="foodRecipeResultMap">
<select id="queryRecipeById" resultMap="foodRecipeResultMap">
SELECT a.id AS id,
a.name AS name,
a.category AS category,
@@ -172,9 +177,11 @@
a.name AS name,
a.category AS category,
a.recommend_rate AS recommendRate,
a.is_share AS isShare,
u.id AS userId,
u.username AS username,
u.avatar AS avatar,
b.id AS recordId,
b.person AS person,
b.date AS date,
b.image_url AS imageUrl,