Files
SchoolFood/fp-system/src/main/resources/mapper/FoodMapper.xml
2025-05-21 08:59:12 +08:00

40 lines
1.5 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zf.foodpurchase.fdsafe.mapper.FoodMapper">
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
fd.food_id, fd.food_name, fd.type_id, fd.unit_id, fd.limit_price, fd.edu_id, fd.del_flag, fd.create_time, fd.update_time
</sql>
<select id="queryFoodVO" resultType="com.zf.foodpurchase.fdsafe.vo.FoodVO"
parameterType="com.zf.foodpurchase.fdsafe.vo.FoodVO">
select <include refid="Base_Column_List"></include>,
ty.type_label,
un.unit_label,
ed.edu_name
from food fd
left join food_type ty on fd.type_id = ty.type_id
left join food_unit un on fd.unit_id = un.unit_id
left join edu ed on ed.edu_id = fd.edu_id
<where>
<if test="foodId != null">
and fd.food_id = #{foodId}
</if>
<if test="foodName != null and foodName != ''">
and fd.food_name like concat('%',#{foodName},'%')
</if>
<if test="typeId != null">
and fd.type_id = #{typeId}
</if>
<if test="eduId!=null">
and fd.edu_id = #{eduId}
</if>
<if test="delFlag!=null">
and fd.del_flag = #{delFlag}
</if>
</where>
order by fd.create_time desc
</select>
</mapper>