Files
sky-take-out/sky-server/src/main/resources/mapper/SetmealMapper.xml

71 lines
2.6 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.sky.mapper.SetmealMapper">
<select id="list" parameterType="Setmeal" resultType="Setmeal">
select * from setmeal
<where>
<if test="name != null">
and name like concat('%',#{name},'%')
</if>
<if test="categoryId != null">
and category_id = #{categoryId}
</if>
<if test="status != null">
and status = #{status}
</if>
</where>
</select>
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
insert into setmeal (category_id, name, price, description, image, create_time, update_time, create_user,
update_user)
values (#{categoryId}, #{name}, #{price}, #{description}, #{image}, #{createTime}, #{updateTime}, #{createUser},
#{updateUser})
</insert>
<select id="pageQuery" resultType="com.sky.vo.SetmealVO">
select *, c.name categoryName
from setmeal s
left join category c on s.category_id = c.id
<where>
<if test="categoryId != null">
and s.category_id = #{categoryId}
</if>
<if test="name != null">
and s.name like concat('%', #{name}, '%')
</if>
<if test="status != null">
and s.status = #{status}
</if>
</where>
order by s.create_time desc
</select>
<!-- 修改套餐 -->
<update id="update" parameterType="Setmeal">
update setmeal
<set>
<if test="name != null">name = #{name},</if>
<if test="categoryId != null">category_id = #{categoryId},</if>
<if test="price != null">price = #{price},</if>
<if test="image != null">image = #{image},</if>
<if test="description != null">description = #{description},</if>
<if test="status != null">status = #{status},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateUser != null">update_user = #{updateUser},</if>
</set>
where id = #{id}
</update>
<select id="countByMap" resultType="java.lang.Integer">
select count(id) from setmeal
<where>
<if test="status != null"> and status = #{status} </if>
<if test="categoryId != null"> and category_id = #{categoryId} </if>
</where>
</select>
</mapper>