51 lines
2.1 KiB
XML
51 lines
2.1 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.DishMapper">
|
|
|
|
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
|
|
insert into dish (name, category_id, price, image, description, status, create_time, update_time, create_user,
|
|
update_user)
|
|
values (#{name}, #{categoryId}, #{price}, #{image}, #{description}, #{status}, #{createTime}, #{updateTime},
|
|
#{createUser}, #{updateUser})
|
|
</insert>
|
|
<update id="update">
|
|
update dish
|
|
<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>
|
|
<delete id="deleteByIds">
|
|
delete from dish where id in
|
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
<select id="pageQuery" resultType="com.sky.vo.DishVO">
|
|
select dish.*, category.name as categoryName
|
|
from dish
|
|
left outer join category
|
|
on dish.category_id = category.id
|
|
<where>
|
|
<if test="name != null">
|
|
and dish.name like concat('%',#{name},'%')
|
|
</if>
|
|
<if test="categoryId != null">
|
|
and dish.category_id = #{categoryId}
|
|
</if>
|
|
<if test="status != null">
|
|
and dish.status = #{status}
|
|
</if>
|
|
</where>
|
|
order by dish.create_time desc
|
|
</select>
|
|
</mapper> |