Bonus-Cloud-JYY-Smart-Canteen/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookDishesMaterialMapper.xml

86 lines
4.4 KiB
XML
Raw Normal View History

2025-05-25 19:57:10 +08:00
<?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.bonus.canteen.core.cook.mapper.CookDishesMaterialMapper">
<resultMap type="com.bonus.canteen.core.cook.domain.CookDishesMaterial" id="CookDishesMaterialResult">
<result property="id" column="id" />
<result property="dishesId" column="dishes_id" />
<result property="materialId" column="material_id" />
<result property="weight" column="weight" />
<result property="materialType" column="material_type" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectCookDishesMaterialVo">
select id, dishes_id, material_id, weight, material_type, create_by, create_time, update_by, update_time from cook_dishes_material
</sql>
<select id="selectCookDishesMaterialList" parameterType="com.bonus.canteen.core.cook.domain.CookDishesMaterial" resultMap="CookDishesMaterialResult">
<include refid="selectCookDishesMaterialVo"/>
<where>
<if test="dishesId != null "> and dishes_id = #{dishesId}</if>
<if test="materialId != null "> and material_id = #{materialId}</if>
<if test="weight != null "> and weight = #{weight}</if>
<if test="materialType != null "> and material_type = #{materialType}</if>
</where>
</select>
<select id="selectCookDishesMaterialById" parameterType="Long" resultMap="CookDishesMaterialResult">
<include refid="selectCookDishesMaterialVo"/>
where id = #{id}
</select>
<insert id="insertCookDishesMaterial" parameterType="com.bonus.canteen.core.cook.domain.CookDishesMaterial" useGeneratedKeys="true" keyProperty="id">
insert into cook_dishes_material
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="dishesId != null">dishes_id,</if>
<if test="materialId != null">material_id,</if>
<if test="weight != null">weight,</if>
<if test="materialType != null">material_type,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="dishesId != null">#{dishesId},</if>
<if test="materialId != null">#{materialId},</if>
<if test="weight != null">#{weight},</if>
<if test="materialType != null">#{materialType},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateCookDishesMaterial" parameterType="com.bonus.canteen.core.cook.domain.CookDishesMaterial">
update cook_dishes_material
<trim prefix="SET" suffixOverrides=",">
<if test="dishesId != null">dishes_id = #{dishesId},</if>
<if test="materialId != null">material_id = #{materialId},</if>
<if test="weight != null">weight = #{weight},</if>
<if test="materialType != null">material_type = #{materialType},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteCookDishesMaterialById" parameterType="Long">
delete from cook_dishes_material where id = #{id}
</delete>
<delete id="deleteCookDishesMaterialByIds" parameterType="String">
delete from cook_dishes_material where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>