Files
SchoolFood/fp-system/src/main/resources/mapper/AccompanyMealMapper.xml
2025-07-25 10:09:40 +08:00

50 lines
2.2 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.AccompanyMealMapper">
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
am.accompany_meal_id, am.school_id, am.meal_type, am.leader_name, am.staff_name, am.address, am.cuisine_same, am.quality_normal, am.service_good, am.adverse_effective, am.feed_back, am.accompany_image as accompany_image_str , am.create_time, am.update_time, am.accompany_time
</sql>
<select id="queryAccompanyMealVO" resultType="com.zf.foodpurchase.fdsafe.vo.AccompanyMealVO">
select
<include refid="Base_Column_List"/>,
s.school_name,ed.edu_id
from accompany_meal am left join school s on am.school_id = s.school_id
left join edu ed on s.edu_id = ed.edu_id
<where>
<if test="accompanyMealId != null ">
and am.accompany_meal_id = #{accompanyMealId}
</if>
<if test="schoolId != null ">
and am.school_id = #{schoolId}
</if>
<if test="eduId != null ">
and ed.edu_id = #{eduId}
</if>
<if test="mealType != null ">
and am.meal_type = #{mealType}
</if>
<if test="leaderName != null and leaderName != ''">
and am.leader_name like CONCAT('%', #{leaderName}, '%')
</if>
<if test="staffName != null and staffName != ''">
and am.staff_name like CONCAT('%', #{staffName}, '%')
</if>
<if test="schoolName != null and schoolName != ''">
and s.school_name like CONCAT('%', #{schoolName}, '%')
</if>
<if test="beginTime != null ">
and date_format(am.create_time, '%Y-%m-%d') &gt;= date_format(#{beginTime}, '%Y-%m-%d')
</if>
<if test="endTime != null ">
and date_format(am.create_time, '%Y-%m-%d') &lt;= date_format(#{endTime}, '%Y-%m-%d')
</if>
</where>
order by am.create_time desc
</select>
</mapper>