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 @Mapper
public interface FoodDao { public interface FoodDao {
RecipeDto queryRecipe(@Param("id") Long id); RecipeDto queryRecipeById(@Param("id") Long id);
List<SummaryDto> queryRecipeByUser(@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("该美食不存在"); throw new CustomException("该美食不存在");
} }
return foodDao.queryRecipe(id); return foodDao.queryRecipeById(id);
} }
@Override @Override

View File

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