<?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.ruoyi.model.mapper.AppFeedingFoodTypeMapper">
    
    <resultMap type="AppFeedingFoodType" id="AppFeedingFoodTypeResult">
        <result property="feedingFoodTypeId"    column="feeding_food_type_id"    />
        <result property="feedingFoodTypeName"    column="feeding_food_type_name"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectAppFeedingFoodTypeVo">
        select feeding_food_type_id, feeding_food_type_name, create_by, create_time, update_by, update_time, del_flag from app_feeding_food_type
    </sql>

    <select id="selectAppFeedingFoodTypeList" parameterType="AppFeedingFoodType" resultMap="AppFeedingFoodTypeResult">
        <include refid="selectAppFeedingFoodTypeVo"/>
        <where>  
            <if test="feedingFoodTypeName != null  and feedingFoodTypeName != ''"> and feeding_food_type_name like concat('%', #{feedingFoodTypeName}, '%')</if>
        </where>
    </select>
    
    <select id="selectAppFeedingFoodTypeByFeedingFoodTypeId" parameterType="Long" resultMap="AppFeedingFoodTypeResult">
        <include refid="selectAppFeedingFoodTypeVo"/>
        where feeding_food_type_id = #{feedingFoodTypeId}
    </select>
    <select id="getAppFeedingFoodTypeList" resultType="com.ruoyi.model.domain.AppFeedingFoodType">
        <include refid="selectAppFeedingFoodTypeVo"/>
    </select>

    <insert id="insertAppFeedingFoodType" parameterType="AppFeedingFoodType">
        insert into app_feeding_food_type
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="feedingFoodTypeId != null">feeding_food_type_id,</if>
            <if test="feedingFoodTypeName != null">feeding_food_type_name,</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>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="feedingFoodTypeId != null">#{feedingFoodTypeId},</if>
            <if test="feedingFoodTypeName != null">#{feedingFoodTypeName},</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>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateAppFeedingFoodType" parameterType="AppFeedingFoodType">
        update app_feeding_food_type
        <trim prefix="SET" suffixOverrides=",">
            <if test="feedingFoodTypeName != null">feeding_food_type_name = #{feedingFoodTypeName},</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>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where feeding_food_type_id = #{feedingFoodTypeId}
    </update>

    <delete id="deleteAppFeedingFoodTypeByFeedingFoodTypeId" parameterType="Long">
        delete from app_feeding_food_type where feeding_food_type_id = #{feedingFoodTypeId}
    </delete>

    <delete id="deleteAppFeedingFoodTypeByFeedingFoodTypeIds" parameterType="String">
        delete from app_feeding_food_type where feeding_food_type_id in 
        <foreach item="feedingFoodTypeId" collection="array" open="(" separator="," close=")">
            #{feedingFoodTypeId}
        </foreach>
    </delete>
</mapper>